glacier-mkimg 0.0.1-rc2
This commit is contained in:
parent
9381aecd34
commit
8a9641be67
@ -16,161 +16,78 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Glacier. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
am_i_root() {
|
||||
printf ">> Checking if user is root...\n"
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf ">> glacier-mkimg must be run as root.\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
info() {
|
||||
printf ">> Building root filesystem image with the following settings:\n"
|
||||
printf "Image build location: /opt/everest\n"
|
||||
printf "Packages to be installed:\n"
|
||||
printf " - musl\n"
|
||||
printf " - lacc\n"
|
||||
printf " - binutils\n"
|
||||
printf " - busybox\n"
|
||||
printf " - make\n"
|
||||
printf " - runit\n"
|
||||
printf " - glacier\n"
|
||||
printf " - gpc\n"
|
||||
printf " - emk\n"
|
||||
printf " - system-toolchain-bin\n"
|
||||
printf " - busybox-base-bin\n"
|
||||
printf " - glacier-base-bin\n"
|
||||
printf " - make-base-bin\n"
|
||||
}
|
||||
|
||||
init-env() {
|
||||
mkdir -v /opt/everest
|
||||
mkdir -v /opt/everest/{sources,toolchain}
|
||||
mkdir -v /opt/everest/{sources,toolchain,targetfs}
|
||||
cd /opt/everest
|
||||
}
|
||||
|
||||
get_toolchain() {
|
||||
cd /opt/everest/toolchain
|
||||
printf ">> Downloading toolchain sources...\n"
|
||||
git clone https://git.everestlinux.org/EverestLinux/toolchain
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to get toolchain.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Temporarily adding toolchain to PATH...\n"
|
||||
PATH=$PATH:/opt/everest/toolchain/bin
|
||||
printf ">> Finished.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
get_skel() {
|
||||
printf ">> Creating directory layout in /opt/everest...\n"
|
||||
cd /opt/everest
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Error while changing directory to /opt/everest.\n"
|
||||
exit 1
|
||||
fi
|
||||
git clone https://git.everestlinux.org/EverestLinux/skel
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to clone filesystem skeleton.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> WARNING: directory symlinks may be broken!!!\n"
|
||||
printf ">> Once chrooted into the new installation, run the following commands:\n"
|
||||
printf ">> ln -sv /usr/bin /bin\n"
|
||||
printf ">> ln -sv /usr/sbin /sbin\n"
|
||||
printf ">> ln -sv /usr/lib /lib\n"
|
||||
printf ">> ln -sv /usr/lib64 /lib64\n"
|
||||
printf ">> Removing .git...\n"
|
||||
mv skel targetfs
|
||||
rm -rf skel/.git
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to remove .git.\n"
|
||||
exit 1
|
||||
fi
|
||||
ROOT=/opt/everest/targetfs
|
||||
|
||||
mkdir -v $ROOT/{boot,dev,etc,home,mnt,opt,proc,root,srv,sys,tmp,var}
|
||||
mkdir -v $ROOT/usr
|
||||
mkdir -v $ROOT/usr/{bin,sbin,include,lib,lib64,libexec,local,sbin,share,src}
|
||||
mkdir -v $ROOT/var/{cache,lib,local,lock,log,opt,run,spool,tmp,www}
|
||||
mkdir -v $ROOT/var/cache/glacier
|
||||
mkdir -v $ROOT/var/log/glacier
|
||||
mkdir -v $ROOT/etc/glacier
|
||||
mkdir -v $ROOT/etc/glacier/pkginfo
|
||||
ln -sv $ROOT/usr/bin $ROOT/bin
|
||||
ln -sv $ROOT/usr/lib $ROOT/lib
|
||||
lv -sv $ROOT/usr/sbin $ROOT/sbin
|
||||
ln -sv $ROOT/usr/lib64 $ROOT/lib64
|
||||
printf ">> Finished.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
prepare_for_pkg() {
|
||||
printf ">> Preparing for package installation...\n"
|
||||
mkdir -v /opt/everest/pkg
|
||||
glacier -c busybox-base
|
||||
glacier -c musl-base
|
||||
glacier -c binutils-base
|
||||
glacier -c glacier-base
|
||||
glacier -c runit-base
|
||||
glacier -c tar-base
|
||||
glacier -c make-base
|
||||
glacier -c lacc-base
|
||||
glacier -c system-toolchain-bin
|
||||
glacier -c busybox-base-bin
|
||||
glacier -c glacier-base-bin
|
||||
glacier -c make-base-bin
|
||||
printf ">> Done.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_busybox() {
|
||||
printf ">> Installing busybox...\n"
|
||||
mv $(pwd)/pkg/busybox-base.tar.gz /var/cache/glacier
|
||||
glacier -ci busybox-base
|
||||
install_pkg() {
|
||||
printf ">> Installing packages...\n"
|
||||
glacier -ci system-toolchain-bin
|
||||
if [ "$?" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
glacier -ci busybox-base-bin
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install busybox-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Finished.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_musl() {
|
||||
printf ">> Installing musl...\n"
|
||||
mv $(pwd)/pkg/musl-base.tar.gz /var/cache/glacier
|
||||
glacier -ci musl-base
|
||||
glacier -ci glacier-base-bin
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install musl-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Finished.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_binutils() {
|
||||
printf ">> Installing binutils...\n"
|
||||
mv $(pwd)/pkg/binutils-base.tar.gz /var/cache/glacier
|
||||
glacier -ci binutils-base
|
||||
glacier -ci make-base-bin
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install binutils-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Finished.\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_glacier() {
|
||||
printf ">> Installing Glacier to target...\n"
|
||||
printf ">> Dependency 1: tar-base\n"
|
||||
mv $(pwd)/pkg/tar-base.tar.gz /var/cache/glacier
|
||||
glacier -ci tar-base
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install tar-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Dependency 2: make-base\n"
|
||||
mv $(pwd)/pkg/make-base.tar.gz /var/cache/glacier
|
||||
glacier -ci make-base
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install make-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Dependency 3: lacc-base\n"
|
||||
mv $(pwd)/pkg/tcc-base.tar.gz /var/cache/glacier
|
||||
glacier -ci tcc-base
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install tcc-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> All dependencies installed, installing Glacier...\n"
|
||||
git clone https://git.everestlinux.org/EverestLinux/glacier
|
||||
cd glacier/install
|
||||
chmod +x ../src/*
|
||||
./bootstrap-on-target.sh
|
||||
printf ">> Glacier installed.\n"
|
||||
}
|
||||
|
||||
install_runit() {
|
||||
printf ">> Installing runit...\n"
|
||||
mv $(pwd)/pkg/runit-base.tar.gz /var/cache/glacier
|
||||
glacier -ci runit-base
|
||||
if [ "$?" != "0" ]; then
|
||||
printf ">> Failed to install runit-base.\n"
|
||||
exit 1
|
||||
fi
|
||||
printf ">> Finished.\n"
|
||||
}
|
||||
|
||||
warn_about_cache() {
|
||||
@ -191,18 +108,23 @@ create_img() {
|
||||
printf ">> Creating filesystem image...\n"
|
||||
install -dv /opt/everest/build
|
||||
cd /opt/everest/targetfs
|
||||
tar -cvf /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar *
|
||||
zstd /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar
|
||||
tar -cvf /opt/everest/build/everestlinux-RELEASE-img.tar *
|
||||
zstd /opt/everest/build/everestlinux-RELEASE-img.tar
|
||||
rm /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar
|
||||
printf ">> Done.\n"
|
||||
}
|
||||
|
||||
finish() {
|
||||
printf ">> Build has finished.\n"
|
||||
printf ">> Filesystem image is located in the following directory:\n"
|
||||
printf ">> /opt/everest/build\n"
|
||||
}
|
||||
|
||||
showhelp_big() {
|
||||
printf "glacier-mkimg - easily compile an Everest Linux image\n"
|
||||
printf "usage - glacier-mkimg [-h] [-t] [-s] [-p] [-o] [-i]\n"
|
||||
printf "usage - glacier-mkimg [-h] [init] [-t] [-s] [-p] [-o] [-i]\n"
|
||||
printf "\n"
|
||||
printf "glacier-mkimg {init} initialize the environment\n"
|
||||
printf "glacier-mkimg {-t} only download toolchain\n"
|
||||
printf "glacier-mkimg {-s} only download filesystem skeleton\n"
|
||||
printf "glacier-mkimg {-p} only install packages to /opt/everest\n"
|
||||
printf "glacier-mkimg {-o} only change ownership of /opt/everest\n"
|
||||
@ -221,16 +143,43 @@ case $1 in
|
||||
showhelp_big
|
||||
;;
|
||||
init)
|
||||
am_i_root "$@"
|
||||
init_env "$@"
|
||||
;;
|
||||
-t)
|
||||
get_toolchain "$@"
|
||||
exit 0
|
||||
;;
|
||||
-s)
|
||||
get_skel "$@"
|
||||
exit 0
|
||||
;;
|
||||
-p)
|
||||
printf "not implemented\n"
|
||||
prepare_for_pkg "$@"
|
||||
install_pkg "$@"
|
||||
warn_about_cache "$@"
|
||||
exit 0
|
||||
;;
|
||||
-o)
|
||||
change_ownership "$@"
|
||||
exit 0
|
||||
;;
|
||||
-i)
|
||||
create_img "$@"
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
printf "usage: glacier-mkimg [-h] [init] [-s] [-p] [-o] [-i]\n"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
get_skel "$@"
|
||||
prepare_for_pkg "$@"
|
||||
install_pkg "$@"
|
||||
warn_about_cache "$@"
|
||||
change_ownership "$@"
|
||||
create_img "$@"
|
||||
finish
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "usage: glacier-mkimg [-h] [init] [-s] [-p] [-o] [-i]\n"
|
||||
exit 1
|
||||
|
@ -1,9 +0,0 @@
|
||||
#
|
||||
# img.conf
|
||||
#
|
||||
|
||||
GLACIER_RELEASE="1.0.0"
|
||||
|
||||
#
|
||||
# end img.conf
|
||||
#
|
Loading…
Reference in New Issue
Block a user