This commit is contained in:
Liam Waldron 2023-02-01 16:33:21 -05:00
parent 66611d0b70
commit 87b85db1ce

View File

@ -34,20 +34,30 @@
get_pkg() { get_pkg() {
printf "$blue[ i ]$reset Downloading archive for package '$2'...\n" printf "$blue[ i ]$reset Downloading archive for package '$2'...\n"
<<<<<<< HEAD
for r in ${ALLOWED_REPOS[@]}; do for r in ${ALLOWED_REPOS[@]}; do
$GLACIER_DOWNLOAD_BACKEND $GREPO/${r}/$2.tar.gz $GLACIER_DOWNLOAD_BACKEND $GREPO/${r}/$2.tar.gz
done done
find $2.tar.gz find $2.tar.gz
=======
# Extremely ugly but does what it needs to do
$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
>>>>>>> main
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Package '$2' not found.\n" printf "$red[ $error ]$reset Package '$2' not found.\n"
exit 1 exit 1
fi fi
<<<<<<< HEAD
printf "$blue[ i ]$reset Downloading checksum for package '$2'...\n" printf "$blue[ i ]$reset Downloading checksum for package '$2'...\n"
for r in ${ALLOWED_REPOS[@]}; do for r in ${ALLOWED_REPOS[@]}; do
$GLACIER_DOWNLOAD_BACKEND $GREPO/${r}/$2.checksum $GLACIER_DOWNLOAD_BACKEND $GREPO/${r}/$2.checksum
done done
find $2.checksum find $2.checksum
=======
# same goes for this
$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
>>>>>>> main
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
printf "$red[ $error ]$reset Package checksum not found.\n" printf "$red[ $error ]$reset Package checksum not found.\n"
exit 1 exit 1
@ -148,7 +158,11 @@ clear_cache() {
# #
debug_info() { debug_info() {
<<<<<<< HEAD
printf "$blue>> Glacier v3.3.0$reset\n" printf "$blue>> Glacier v3.3.0$reset\n"
=======
printf "$blue>> Glacier v3.2.2$reset\n"
>>>>>>> main
printf ">> Checking for valid download backend...\n" printf ">> Checking for valid download backend...\n"
whereis wget whereis wget
whereis curl whereis curl
@ -238,15 +252,24 @@ pre_op_hooks() {
/etc/glacier/pre-hooks /etc/glacier/pre-hooks
} }
post_hooks () { post_hooks() {
printf "$blue[ i ]$reset Executing post-operation hooks...\n" printf "$blue[ i ]$reset Executing post-operation hooks...\n"
/etc/glacier/post-hooks /etc/glacier/post-hooks
} }
search_for_local_pkg() {
printf "$blue[ i ]$reset Searching working directory for package $2...\n"
find $2.tar.gz
if [ "$?" != 0 ]; then
printf "$red[ $error ]$reset Package $2 not found.\n"
exit 1
fi
}
case $1 in case $1 in
-h|--help) -h|--help)
printf "$blue[ * ] Glacier - Manage installed packages on the system$reset\n" printf "$blue[ * ] Glacier - Manage installed packages on the system$reset\n"
printf "usage: glacier [-f] [-u] [-x] [-q] [-c] [-ci] [-cc] [--debuginfo]\n" printf "usage: glacier [-f] [-u] [-x] [-q] [-c] [-ci] [-cc] [-li] [--debuginfo]\n"
printf "\n" printf "\n"
printf "$blue=== Information ===$reset\n" printf "$blue=== Information ===$reset\n"
printf "glacier {-h/--help} - Show this message and exit\n" printf "glacier {-h/--help} - Show this message and exit\n"
@ -260,6 +283,7 @@ case $1 in
printf "glacier {-c/cache} - Download a package to the cache\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 {-ci/cache-install} - Install a package from the cache\n"
printf "glacier {-cc/cache-clear} - Clear the cache\n" printf "glacier {-cc/cache-clear} - Clear the cache\n"
printf "glacier {-li/local-install} - Install a package from a local directory\n"
printf "\n" printf "\n"
printf "$blue=== Debugging ===$reset\n" printf "$blue=== Debugging ===$reset\n"
printf "glacier {--debuginfo} - Show debugging information\n" printf "glacier {--debuginfo} - Show debugging information\n"
@ -271,12 +295,16 @@ case $1 in
exit 0 exit 0
;; ;;
-v|--version) -v|--version)
<<<<<<< HEAD
printf "${blue}Glacier v3.3.0${reset}\n" printf "${blue}Glacier v3.3.0${reset}\n"
=======
printf "${blue}Glacier v3.2.2${reset}\n"
>>>>>>> main
exit 0 exit 0
;; ;;
-f|install) -f|install)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -308,7 +336,7 @@ case $1 in
;; ;;
-u|update) -u|update)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -340,7 +368,7 @@ case $1 in
;; ;;
-x|remove) -x|remove)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -377,7 +405,7 @@ case $1 in
;; ;;
-c|cache) -c|cache)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -403,7 +431,7 @@ case $1 in
;; ;;
-ci|cache-install) -ci|cache-install)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -435,7 +463,7 @@ case $1 in
;; ;;
-cc|cache-clear) -cc|cache-clear)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Please run Glacier as root.\n" printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1 exit 1
fi fi
@ -443,6 +471,40 @@ case $1 in
printf "$green[ $check ]$reset Operation completed.\n" printf "$green[ $check ]$reset Operation completed.\n"
exit 0 exit 0
;; ;;
-li|local-install)
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "$red[ $error ]$reset Failed to commit to transaction - permission denied. Are you root?\n"
exit 1
fi
if [ "$2" == "" ]; then
printf "$red[ $error ]$reset No package name was supplied.\n"
exit 1
fi
search_for_local_pkg "$@"
printf "$blue[ i ]$reset Installing package '$2' from local file.\n"
read -p "$(printf "$blue[ ? ]$reset Proceed with this operation? (y/n) ")" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
cp $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
;;
--debuginfo) --debuginfo)
debug_info "$@" debug_info "$@"
exit 0 exit 0