diff --git a/install/INSTALL.sh b/install/INSTALL.sh index 5ad719e..406fe6e 100755 --- a/install/INSTALL.sh +++ b/install/INSTALL.sh @@ -41,6 +41,11 @@ mv $SRC_DIR/hooks $CONFDIR/glacier mv $SRC_DIR/post-hooks $CONFDIR/glacier mv $SRC_DIR/hooks.sh $CONFDIR/glacier mv $SRC_DIR/make.conf $CONFDIR +mv $SRC_DIR/glacier-integrity-check $PREFIX/bin + if [ "$?" != "0" ]; then + mv $SRC_DIR/glacier-integrity-check $PREFIX + printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead\n" + fi printf "finished installation\n" exit 0 diff --git a/src/glacier b/src/glacier index 54ba83e..0634526 100755 --- a/src/glacier +++ b/src/glacier @@ -17,21 +17,22 @@ get_pkg() { 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 } -# implementing this later because this whole section is a clusterfuck -#int_check () { -# printf "$blue[ i ]$reset Checking package integrity...\n" -# LOCAL_CHECKSUM=$(cat $2.checksum) -# hsh $2.tar.gz $LOCAL_CHECKSUM -# if [ "$?" != "0" ]; then -# printf "$red[ $error ]$reset Integrity check failed.\n" -# exit 1 -# else -# printf "$green[ $check ]$reset Integrity check passed.\n" -# exit 0 -# fi -#} +int_check() { + 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" +} unpack_pkg() { printf "$blue[ i ]$reset Unpacking $2.tar.gz...\n" @@ -108,7 +109,7 @@ clear_cache() { } debug_info() { - printf "$blue>> Glacier v3.0.1$reset\n" + printf "$blue>> Glacier v3.1.0$reset\n" printf ">> Checking for valid download backend...\n" whereis wget whereis curl @@ -196,7 +197,7 @@ case $1 in exit 0 ;; -v|--version) - printf "$blue Glacier v3.0.1$reset\n" + printf "$blue Glacier v3.1.0$reset\n" exit 0 ;; -f|-install) @@ -204,14 +205,14 @@ case $1 in printf "$red[ $error ]$reset Please run Glacier as root.\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" get_pkg "$@" - #int_check # Will implement this later on + int_check # Will implement this later on unpack_pkg "$@" installpkg "$@" post_hooks "$@" @@ -232,7 +233,7 @@ case $1 in cd /opt/glacier/workspace printf "\n" get_pkg "$@" - #int_check + int_check unpack_pkg "$@" updatepkg "$@" post_hooks "$@" @@ -253,7 +254,7 @@ case $1 in cd /opt/glacier/workspace printf "\n" get_pkg "$@" - #int_check + int_check unpack_pkg "$@" removepkg "$@" post_hooks "$@" @@ -278,6 +279,7 @@ case $1 in cd /var/cache/glacier printf "\n" get_pkg "$@" + int_check printf "$green[ $check ]$reset Operation completed.\n" exit 0 fi diff --git a/src/glacier-integrity-check b/src/glacier-integrity-check new file mode 100755 index 0000000..34dc42f --- /dev/null +++ b/src/glacier-integrity-check @@ -0,0 +1,17 @@ +#!/usr/bin/python3 + +import sys +import os + +LOCAL_SUM=os.system("cat *.checksum") +PKG_SUM=os.system("sha256sum *.tar.gz") + +if LOCAL_SUM == PKG_SUM: + print("checksums match\n") + sys.exit(0) +elif LOCAL_SUM != PKG_SUM: + print("checksums do not match\n") + sys.exit(1) +else: + print("an error occured\n") + sys.exit(1) diff --git a/src/post-hooks b/src/post-hooks old mode 100644 new mode 100755