glacier-mkimg 0.0.1-rc2

This commit is contained in:
Liam Waldron 2023-01-10 10:35:49 -05:00
parent 9381aecd34
commit 8a9641be67
2 changed files with 80 additions and 140 deletions

View File

@ -16,161 +16,78 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Glacier. If not, see <https://www.gnu.org/licenses/>. # 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() { info() {
printf ">> Building root filesystem image with the following settings:\n" printf ">> Building root filesystem image with the following settings:\n"
printf "Image build location: /opt/everest\n" printf "Image build location: /opt/everest\n"
printf "Packages to be installed:\n" printf "Packages to be installed:\n"
printf " - musl\n" printf " - system-toolchain-bin\n"
printf " - lacc\n" printf " - busybox-base-bin\n"
printf " - binutils\n" printf " - glacier-base-bin\n"
printf " - busybox\n" printf " - make-base-bin\n"
printf " - make\n"
printf " - runit\n"
printf " - glacier\n"
printf " - gpc\n"
printf " - emk\n"
} }
init-env() { init-env() {
mkdir -v /opt/everest mkdir -v /opt/everest
mkdir -v /opt/everest/{sources,toolchain} mkdir -v /opt/everest/{sources,toolchain,targetfs}
cd /opt/everest 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() { get_skel() {
printf ">> Creating directory layout in /opt/everest...\n" printf ">> Creating directory layout in /opt/everest...\n"
cd /opt/everest ROOT=/opt/everest/targetfs
if [ "$?" != "0" ]; then
printf ">> Error while changing directory to /opt/everest.\n" mkdir -v $ROOT/{boot,dev,etc,home,mnt,opt,proc,root,srv,sys,tmp,var}
exit 1 mkdir -v $ROOT/usr
fi mkdir -v $ROOT/usr/{bin,sbin,include,lib,lib64,libexec,local,sbin,share,src}
git clone https://git.everestlinux.org/EverestLinux/skel mkdir -v $ROOT/var/{cache,lib,local,lock,log,opt,run,spool,tmp,www}
if [ "$?" != "0" ]; then mkdir -v $ROOT/var/cache/glacier
printf ">> Failed to clone filesystem skeleton.\n" mkdir -v $ROOT/var/log/glacier
exit 1 mkdir -v $ROOT/etc/glacier
fi mkdir -v $ROOT/etc/glacier/pkginfo
printf ">> WARNING: directory symlinks may be broken!!!\n" ln -sv $ROOT/usr/bin $ROOT/bin
printf ">> Once chrooted into the new installation, run the following commands:\n" ln -sv $ROOT/usr/lib $ROOT/lib
printf ">> ln -sv /usr/bin /bin\n" lv -sv $ROOT/usr/sbin $ROOT/sbin
printf ">> ln -sv /usr/sbin /sbin\n" ln -sv $ROOT/usr/lib64 $ROOT/lib64
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
printf ">> Finished.\n" printf ">> Finished.\n"
exit 0 exit 0
} }
prepare_for_pkg() { prepare_for_pkg() {
printf ">> Preparing for package installation...\n" printf ">> Preparing for package installation...\n"
mkdir -v /opt/everest/pkg glacier -c system-toolchain-bin
glacier -c busybox-base glacier -c busybox-base-bin
glacier -c musl-base glacier -c glacier-base-bin
glacier -c binutils-base glacier -c make-base-bin
glacier -c glacier-base
glacier -c runit-base
glacier -c tar-base
glacier -c make-base
glacier -c lacc-base
printf ">> Done.\n" printf ">> Done.\n"
exit 0 exit 0
} }
install_busybox() { install_pkg() {
printf ">> Installing busybox...\n" printf ">> Installing packages...\n"
mv $(pwd)/pkg/busybox-base.tar.gz /var/cache/glacier glacier -ci system-toolchain-bin
glacier -ci busybox-base
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
printf ">> Failed to install busybox-base.\n"
exit 1 exit 1
fi fi
printf ">> Finished.\n" glacier -ci busybox-base-bin
exit 0
}
install_musl() {
printf ">> Installing musl...\n"
mv $(pwd)/pkg/musl-base.tar.gz /var/cache/glacier
glacier -ci musl-base
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
printf ">> Failed to install musl-base.\n"
exit 1 exit 1
fi fi
printf ">> Finished.\n" glacier -ci glacier-base-bin
exit 0
}
install_binutils() {
printf ">> Installing binutils...\n"
mv $(pwd)/pkg/binutils-base.tar.gz /var/cache/glacier
glacier -ci binutils-base
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
printf ">> Failed to install binutils-base.\n"
exit 1 exit 1
fi fi
printf ">> Finished.\n" glacier -ci make-base-bin
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 if [ "$?" != "0" ]; then
printf ">> Failed to install tar-base.\n"
exit 1 exit 1
fi 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() { warn_about_cache() {
@ -191,18 +108,23 @@ create_img() {
printf ">> Creating filesystem image...\n" printf ">> Creating filesystem image...\n"
install -dv /opt/everest/build install -dv /opt/everest/build
cd /opt/everest/targetfs cd /opt/everest/targetfs
tar -cvf /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar * tar -cvf /opt/everest/build/everestlinux-RELEASE-img.tar *
zstd /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar zstd /opt/everest/build/everestlinux-RELEASE-img.tar
rm /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar rm /opt/everest/build/everestlinux-${EVEREST_RELEASE}-img.tar
printf ">> Done.\n" 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() { showhelp_big() {
printf "glacier-mkimg - easily compile an Everest Linux image\n" 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 "\n"
printf "glacier-mkimg {init} initialize the environment\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 {-s} only download filesystem skeleton\n"
printf "glacier-mkimg {-p} only install packages to /opt/everest\n" printf "glacier-mkimg {-p} only install packages to /opt/everest\n"
printf "glacier-mkimg {-o} only change ownership of /opt/everest\n" printf "glacier-mkimg {-o} only change ownership of /opt/everest\n"
@ -221,16 +143,43 @@ case $1 in
showhelp_big showhelp_big
;; ;;
init) init)
am_i_root "$@"
init_env "$@" init_env "$@"
;; exit 0
-t)
get_toolchain "$@"
;; ;;
-s) -s)
get_skel "$@" get_skel "$@"
exit 0
;; ;;
-p) -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 esac
printf "usage: glacier-mkimg [-h] [init] [-s] [-p] [-o] [-i]\n"
exit 1

View File

@ -1,9 +0,0 @@
#
# img.conf
#
GLACIER_RELEASE="1.0.0"
#
# end img.conf
#