Glacier v3.2.1 - Toggle integrity checking

This commit is contained in:
lw-everestlinux 2022-12-08 09:07:57 -05:00
parent 346b351ad0
commit a2b3ad34d4
5 changed files with 549 additions and 63 deletions

View File

@ -25,13 +25,17 @@ get_pkg() {
} }
int_check() { int_check() {
printf "$blue[ i ]$reset Checking package integrity...\n" if [ "$GLACIER_DO_INT_CHECK" = "true" ]; then
/usr/bin/glacier-integrity-check printf "$blue[ i ]$reset Checking package integrity...\n"
if [ "$?" != "0" ]; then /usr/bin/glacier-integrity-check
printf "$red[ $error ]$reset Integrity check failed.\n" if [ "$?" != "0" ]; then
exit 1 printf "$red[ $error ]$reset Integrity check failed.\n"
fi exit 1
fi
printf "$green[ $check ]$reset Integrity check passed.\n" printf "$green[ $check ]$reset Integrity check passed.\n"
else
printf "$yellow[ ! ]$reset Skipping integrity check...\n"
fi
} }
unpack_pkg() { unpack_pkg() {
@ -113,7 +117,7 @@ clear_cache() {
# #
debug_info() { debug_info() {
printf "$blue>> Glacier v3.2.0$reset\n" printf "$blue>> Glacier v3.2.1$reset\n"
printf ">> Checking for valid download backend...\n" printf ">> Checking for valid download backend...\n"
whereis wget whereis wget
whereis curl whereis curl
@ -236,7 +240,7 @@ case $1 in
exit 0 exit 0
;; ;;
-v|--version) -v|--version)
printf "${blue}Glacier v3.2.0${reset}\n" printf "${blue}Glacier v3.2.1${reset}\n"
exit 0 exit 0
;; ;;
-f|install) -f|install)

View File

@ -1,50 +1,107 @@
#!/bin/sh #!/bin/sh
# Tool for creating Everest Linux images
mkskel() { get_toolchain() {
printf ">> Creating build directory at /mnt/everest\n" printf ">> Downloading toolchain sources...\n"
mkdir -v /mnt/everest git clone https://git.everestlinux.org/EverestLinux/toolchain
printf ">> Creating toolchain directories at /opt/everest\n" if [ "$?" != "0" ]; then
mkdir -v /opt/everest printf ">> Failed to get toolchain.\n"
mkdir -v /opt/everest/toolchain exit 1
mkdir -v /opt/everest/sources fi
printf ">> Creating filesystem skeleton at /mnt/everest\n" printf ">> Temporarily adding toolchain to PATH...\n"
mkdir -pv /mnt/everest/{bin,boot,dev,etc,home,lib/{firmware,modules}} PATH=$PATH:$(pwd)/toolchain/bin
mkdir -pv /mnt/everest/{mnt,opt,proc,sbin,srv,sys} printf ">> Finished.\n"
mkdir -pv /mnt/everest/var/{cache,lib,local,lock,log,opt,run,spool} exit 0
install -dv -m 0750 /mnt/everest/root
install -dv -m 1777 /mnt/everest/{var/,}tmp
mkdir -pv /mnt/everest/usr/{,local/}{bin,include,lib,sbin,share,src}
printf "=============== SUMMARY ===============\n"
printf "Target directory: /mnt/everest\n"
printf "Toolchain directory: /opt/everest/toolchain\n"
printf "Sources directory: /opt/everest/sources\n"
sleep 2
} }
get_sources() { get_skel() {
printf ">> Downloading the following packages:\n" printf ">> Creating directory layout in /opt/everest...\n"
printf "- GNU Binutils\n" cd /opt/everest
printf "- GNU GCC\n" if [ "$?" != "0" ]; then
printf "- GNU GMP\n" printf ">> Error while changing directory to /opt/everest.\n"
printf "- GNU MPC\n" exit 1
printf "- GNU MPFR\n" fi
printf "- musl\n" git clone https://git.everestlinux.org/EverestLinux/skel
printf "- Busybox\n" if [ "$?" != "0" ]; then
printf "- iana-etc\n" printf ">> Failed to clone filesystem skeleton.\n"
printf "- everest-bootscripts\n" exit 1
printf "- everest-distfiles\n" fi
printf "- GNU make\n" printf ">> WARNING: directory symlinks may be broken!!!\n"
printf "- Python\n" printf ">> Once chrooted into the new installation, run the following commands:\n"
printf "- glacier\n" printf ">> ln -sv /usr/bin /bin\n"
sleep 2 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"
rm -rf skel/.git
if [ "$?" != "0" ]; then
printf ">> Failed to remove .git.\n"
exit 1
fi
printf ">> Finished.\n"
exit 0
}
printf ">> Downloading packages...\n" install_busybox() {
cd /opt/everest/sources printf ">> Installing busybox...\n"
wget -i sources-list mv $(pwd)/pkg/busybox-base.tar.gz /var/cache/glacier
glacier -ci busybox-base
if [ "$?" != "0" ]; then
printf ">> Failed to install busybox-base.\n"
exit 1
fi
printf ">> Finished.\n"
exit 0
}
printf ">> Finished downloading packages.\n" install_musl() {
sleep 2 printf ">> Installing musl...\n"
mv $(pwd)/pkg/musl-base.tar.gz /var/cache/glacier
glacier -ci musl-base
if [ "$?" != "0" ]; then
printf ">> Failed to install musl-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: tcc-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"
#
#
# WRITE THIS SECTION LATER
#
#
printf ">> Glacier installed.\n"
}
warn_about_cache() {
printf ">> WARNING: The cache was used for installing packages to the target.\n"
printf ">> It is recommended to run the following command to clean the cache:\n"
printf ">> glacier -cc\n"
exit 0
} }

View File

@ -29,17 +29,6 @@
#[multiverse-testing] #[multiverse-testing]
#export GREPO8=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse-testing #export GREPO8=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse-testing
# Checksum locations
export WORLD_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/world/"
export GALAXY_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/galaxy/"
export UNIEVRSE_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/universe/"
export MULTIVERSE_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse"
export WORLD_TESTING_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/world-testing"
export GALAXY_TESTING_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/galaxy-testing"
export UNIVERSE_TESTING_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/universe-testing"
export MULTIVERSE_TESTING_SUM="https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse-testing"
# Define colors and unicode symbols to be used # Define colors and unicode symbols to be used
export red="\033[1;31m" export red="\033[1;31m"
export green="\033[1;32m" export green="\033[1;32m"
@ -57,6 +46,12 @@
#export GLACIER_DOWNLOAD_BACKEND="curl --output $2.tar.gz" #export GLACIER_DOWNLOAD_BACKEND="curl --output $2.tar.gz"
#export GLACIER_DOWNLOAD_BACKEND="aria2c" #export GLACIER_DOWNLOAD_BACKEND="aria2c"
# Enable/disable package integrity checking
# This option requires Python to be installed
# WARNING: Keeping this enabled is strongly recommended.
export GLACIER_DO_INT_CHECK="true"
# #
# end /etc/glacier.conf # end /etc/glacier.conf
# #

430
src/glacier.test Executable file
View File

@ -0,0 +1,430 @@
#!/bin/sh
# Glacier - manage installed packages on a Linux system
# This program is free software - you can distribute it
# under the terms of the GNU General Public License v3.0,
# or at your option, any later version.
# A copy of the GNU General Public License should have been
# recieved along with this program. If not, see
# <https://www.gnu.org/licenses>
source $(pwd)/glacier.conf
get_pkg() {
printf "$blue[ i ]$reset Downloading archive for package '$2'...\n"
$GLACIER_DOWNLOAD_BACKEND $GREPO1/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$2.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$2.tar.gz
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Package '$2' not found.\n"
exit 1
fi
$GLACIER_DOWNLOAD_BACKEND $GREPO1/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$2.checksum || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$2.tar.gz
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Package checksum not found.\n"
exit 1
fi
}
int_check() {
if [ "$GLACIER_DO_INT_CHECK" = "true" ]; then
printf "$blue[ i ]$reset Checking package integrity...\n"
/usr/bin/glacier-integrity-check
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Integrity check failed.\n"
exit 1
fi
printf "$green[ $check ]$reset Integrity check passed.\n"
else
printf "$yellow[ ! ]$reset Skipping integrity check...\n"
fi
}
unpack_pkg() {
printf "$blue[ i ]$reset Unpacking $2.tar.gz...\n"
mkdir $2 && mv $2.tar.gz $2 && cd $2
tar -xf $2.tar.gz
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Could not unpack $2.tar.gz.\n"
cd .. && rm -rf $2
exit 1
fi
}
installpkg() {
printf "$blue[ i ]$reset Installing $2...\n"
sleep 1
chmod +x *
./INSTALL.sh
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Failed to update $2.\n"
cd .. && rm -rf $2
exit 1
fi
./$2.ts.sh
mv $2-pkginfo.json /etc/glacier/pkginfo
}
updatepkg() {
printf "$blue[ i ]$reset Updating $2...\n"
sleep 1
chmod +x *
./UPDATE.sh
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Failed to update $2.\n"
cd .. && rm -rf $2
exit 1
fi
./$2.ts.sh
}
removepkg() {
printf "$blue[ i ]$reset Removing $2...\n"
sleep 1
chmod +x *
/etc/glacier/pkginfo/$2.remove
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Failed to remove $2.\n"
cd .. && rm -rf $2
exit 1
fi
rm /var/log/glacier/$2.timestamp
rm /etc/glacier/pkginfo/$2-pkginfo.json
}
installpkg_from_cache() {
printf "$blue[ i ]$reset Installing $2 from cache...\n"
sleep 1
cd /var/cache/glacier && cp $2.tar.gz /tmp && cd /tmp
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Package does not exist in cache.\n"
exit 1
fi
unpack_pkg
install_pkg
}
clear_cache() {
printf "$blue[ i ]$reset Clearing cache...\n"
sleep 1
cd /var/cache/glacier && rm -rvf *
if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Some items could not be cleared.\n"
exit 1
fi
}
#
# Show Glacier debugging info
#
debug_info() {
printf "$blue>> Glacier v3.2.0$reset\n"
printf ">> Checking for valid download backend...\n"
whereis wget
whereis curl
whereis aria2c
printf ">> Checking which download backend is in use...\n"
echo $GLACIER_DOWNLOAD_BACKEND
printf ">> Checking if all Glacier files are present...\n"
whereis glacier glacier.conf make.conf
ls /var/log | grep glacier
ls /var/cache | grep glacier
printf ">> If any files are missing, Glacier will not behave properly.\n"
printf ">> Checking if terminal can output unicode symbols...\n"
printf "$check\n"
printf "$error\n"
printf "$warning\n"
printf "$question\n"
printf "$red Red.$reset\n"
printf "$green Green.$reset\n"
printf "$yellow Yellow.$reset\n"
printf "$blue Blue.$reset\n"
printf "NOTE: If you use a custom colorscheme, colors will not match.\n"
printf ">> Checking if repositories are valid...\n"
echo $GREPO1
echo $GREPO2
echo $GREPO3
echo $GREPO4
echo $GREPO5
echo $GREPO6
echo $GREPO7
echo $GREPO8
printf ">> Checking which shell is in use...\n"
which $SHELL
printf "NOTE: If you use zsh, a percentage symbol may appear after some lines.\n"
printf ">> Gathered debug information.\n"
printf ">> To save this information to a file, run:\n"
printf ">> $ glacier --debuginfo > glacier.debug\n"
}
#
# Parses JSON from pkginfo files and outputs it
#
query() {
printf "$blue[ i ]$reset Showing information for package '$2'.\n"
printf "$blue>> Package name:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .package_name
printf "$blue>> Package version:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .package_version
printf "$blue>> Package description:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .package_description
printf "$blue>> Source tree size:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .src_tree_size
printf "$blue>> Size of installed files:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .exec_size
printf "$blue>> License:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .license
printf "$blue>> Installation date:$reset " && cat /var/log/glacier/$2.timestamp
}
#
# Will either keep removal script, update it with a new one, or delete it alltogether
#
cleanup_keep_rm () {
printf "$blue[ i ]$reset Cleaning up...\n"
mv REMOVE.sh /etc/glacier/pkginfo/$2.remove
cd .. && rm -rf *.checksum *.tar.* $2
}
cleanup_update_rm () {
printf "$blue[ i ]$reset Cleaning up...\n"
rm /etc/glacier/pkginfo/$2.remove
mv REMOVE.sh /etc/glacier/pkginfo/$2.remove
cd .. && rm -rf *.checksum *.tar.* $2
}
cleanup_del_rm () {
printf "$blue[ i ]$reset Cleaning up...\n"
rm /etc/glacier/pkginfo/$2.remove
cd .. && rm -rf *.checksum *.tar.* $2
}
#
# Execute pre and posr hooks from files
#
pre_hooks() {
source /etc/glacier/hooks
}
pre_op_hooks() {
printf "$blue[ i ]$reset Executing pre-operation hooks...\n"
/etc/glacier/pre-hooks
}
post_hooks () {
printf "$blue[ i ]$reset Executing post-operation hooks...\n"
/etc/glacier/post-hooks
}
case $1 in
-h|--help)
printf "$blue[ * ] Glacier - Manage installed packages on the system$reset\n"
printf "usage: glacier [-f] [-u] [-x] [-q] [-c] [-ci] [-cc] [--debuginfo]\n"
printf "\n"
printf "$blue=== Information ===$reset\n"
printf "glacier {-h/--help} - Show this message and exit\n"
printf "glacier {-v/--version} - Show the version and exit\n"
printf "\n"
printf "$blue=== Operations ===$reset\n"
printf "glacier {-f/install} - Install a new package\n"
printf "glacier {-u/update} - Update an installed package\n"
printf "glacier {-x/remove} - Remove an installed package\n"
printf "glacier {-q/query} - Query an installed package\n"
printf "glacier {-c/cache} - Download a package to the cache\n"
printf "glacier {-ci/cache-install} - Install a package from the cache\n"
printf "glacier {-cc/cache-clear} - Clear the cache\n"
printf "\n"
printf "$blue=== Debugging ===$reset\n"
printf "glacier {--debuginfo} - Show debugging information\n"
printf "\n"
printf "$blue=== Licensing ===$reset\n"
printf "This program is free software: you can redistribute it and/or modify it\n"
printf "under the terms of the GNU General Public License as published by the\n"
printf "Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n"
exit 0
;;
-v|--version)
printf "${blue}Glacier v3.2.0${reset}\n"
exit 0
;;
-f|install)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
printf "$blue[ i ]$reset Installing package '$2'.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /opt/glacier/workspace
printf "\n"
pre_hooks "$@"
get_pkg "$@"
int_check "$@"
unpack_pkg "$@"
pre_op_hooks "$@"
installpkg "$@"
post_hooks "$@"
cleanup_keep_rm "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
printf "\n"
printf "${red}[ $error ]${reset} Aborting.\n"
exit 1
fi
;;
-u|update)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
printf "$blue[ i ]$reset Updating package '$2'.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /opt/glacier/workspace
printf "\n"
pre_hooks "$@"
get_pkg "$@"
int_check "$@"
unpack_pkg "$@"
pre_op_hooks "$@"
updatepkg "$@"
post_hooks "$@"
cleanup_update_rm "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
printf "\n"
printf "${red}[ $error ]${reset} Aborting.\n"
exit 1
fi
;;
-x|remove)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
printf "$blue[ i ]$reset Removing package '$2'.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /opt/glacier/workspace
printf "\n"
pre_hooks "$@"
removepkg "$@"
post_hooks "$@"
cleanup_del_rm "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
printf "\n"
printf "${red}[ $error ]${reset} Aborting.\n"
exit 1
fi
;;
-q|query)
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
query "$@"
exit 0
;;
-c|cache)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
printf "$blue[ i ]$reset Caching package '$2'.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /var/cache/glacier
printf "\n"
get_pkg "$@"
int_check "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
printf "\n"
printf "${red}[ $error ]${reset} Aborting.\n"
exit 1
fi
;;
-ci|cache-install)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
printf "$blue[ i ]$reset Installing package '$2' from cache.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cd /var/cache/glacier
mv $2.tar.gz /opt/glacier/workspace
cd /opt/glacier/workspace
printf "\n"
pre_hooks "$@"
unpack_pkg "$@"
pre_op_hooks "$@"
installpkg "$@"
post_hooks "$@"
cleanup_keep_rm "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
printf "\n"
printf "${red}[ $error ]${reset} Aborting.\n"
exit 1
fi
;;
-cc|cache-clear)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n"
exit 1
fi
clear_cache "$@"
printf "$green[ $check ]$reset Operation completed.\n"
exit 0
;;
--debuginfo)
debug_info "$@"
exit 0
;;
-*|--*)
printf "$red[ $error ]$reset Unknown option, see 'glacier -h' for usage.\n"
exit 1
;;
*)
printf "$red[ $error ]$reset Unknown option, see 'glacier -h' for usage.\n"
exit 1
;;
esac
printf "$red[ $error ]$reset Unknown option, see 'glacier -h' for usage.\n"
exit 1