diff --git a/src/glacier-pkg-check/gpc b/src/glacier-pkg-check/gpc new file mode 100755 index 0000000..ef4ef27 --- /dev/null +++ b/src/glacier-pkg-check/gpc @@ -0,0 +1,71 @@ +#!/bin/sh +# Glacier package checker + +/etc/gpc.conf +source $(pwd)/gpc.conf #remove before release + +INSCRIPT=INSTALL.sh +UPSCRIPT=UPDATE.sh +RMSCRIPT=REMOVE.sh + +PKGINFO=*-pkginfo.json + +TIMESTAMP=*.ts.sh + +case $1 in + check) + printf " Searching for package directory...\n" + if [ -d "$2" ]; then + printf "$green $2 exists.$reset\n" + else + printf "$red $2 does not exist.$reset\n" + exit 1 + fi + + cd $2 + printf " Searching for instruction scripts in package directory...\n" + if [ -f $INSCRIPT -a -f $UPSCRIPT -a -f $RMSCRIPT ]; then + printf "$green Instruction scripts exist.$reset\n" + else + printf "$red Instruction scripts do not exist.$reset\n" + exit 1 + fi + + printf " Searching for miscellaneous files...\n" + if [ -f $PKGINFO -a -f $TIMESTAMP ]; then + printf "$green $2.pkginfo and $2.ts.sh exist.$reset\n" + else + printf "$red $2.pkginfo and $2.ts.sh do not exist.$reset\n" + exit 1 + fi + ;; + mkpkg) + printf "$blue Making package...$reset\n" + cd $2 + tar -czvf $2.tar.gz * + printf "$blue Creating timestamp...$reset\n" + sha256sum $2.tar.gz >> $2.checksum + if [ "$?" != "0" ]; then + printf "$red Failed to make package.$reset\n" + exit 1 + fi + printf "$green Finished making package$reset\n" + exit 0 + ;; + -h|--help) + printf "gpc - test and create Glacier packages\n" + printf "\n" + printf "gpc {-h|--help} show this message and exit\n" + printf "gpc {-v|--version} show the version and exit\n" + printf "gpc {check} check a package for errors\n" + printf "gpc {mkpkg} create a package from a directory\n" + printf "\n" + printf "This program is licensed under the GNU GPL v3.0\n" + printf "You should have recieved a copy along with this program.\n" + printf "If not, see \n" + exit 0 + ;; + -v|--version) + printf "gpc v1.0.0\n" + exit 0 +esac diff --git a/src/glacier-pkg-check/gpc.conf b/src/glacier-pkg-check/gpc.conf new file mode 100755 index 0000000..cf28ec0 --- /dev/null +++ b/src/glacier-pkg-check/gpc.conf @@ -0,0 +1,7 @@ +# /etc/gpc.conf + +# Colors and unicode symbols to be used + export red="\033[1;31m" + export green="\033[1;32m" + export blue="\033[1;34m" + export reset="\033[m"