generated from EverestLinux/glacier-old
Initial commit
This commit is contained in:
251
scripts/glacier
Normal file
251
scripts/glacier
Normal file
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
# Glacier - A source based package manager written in POSIX sh
|
||||
# (C) 2022 Everest Developers
|
||||
# This program is free software: see the GNU GPL v3.0 for details.
|
||||
|
||||
# Preloading
|
||||
|
||||
source /etc/glacier/hooks.sh
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
printf "$blue [ * ] Glacier - A source based package manager written in POSIX sh [ * ] $reset\n"
|
||||
printf "$ glacier {-h --help} show this message and exit\n"
|
||||
printf "$ glacier {--version} display the current Glacier version and exit\n"
|
||||
printf "# glacier {install -f} install a package\n"
|
||||
printf "# glacier {update -u} update a package\n"
|
||||
printf "# glacier {remove -x} remove a package\n"
|
||||
printf "$ glacier {query -q} query a package\n"
|
||||
printf "# glacier {cache -c} cache a package\n"
|
||||
printf "# glacier {cache-install -ci} install a cached package\n"
|
||||
printf "# glacier {cache-clear -cc} clear the package cache\n"
|
||||
printf "\n"
|
||||
printf "This program is free software: see the GNU GPL v3.0 for details.\n"
|
||||
exit 0
|
||||
;;
|
||||
--version)
|
||||
printf "$blue Glacier v2.2 $reset\n"
|
||||
exit 0
|
||||
;;
|
||||
install|-f)
|
||||
# Require the script to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "\033[1;31m [ \xE2\x9C\x95 ] \033[m Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Get package name and download package archive
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
printf "\033[1;34m [ i ] \033[m Installing $input.tar.gz...\n"
|
||||
printf "\033[1;34m [ i ] \033[m Checking databases... " && $GLACIER_DOWNLOAD_BACKEND $GREPO1/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ \xE2\x9C\x95 ] \033[m Package not found.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# Unpack Tarball
|
||||
printf "\033[1;34m [ i ] \033[m Unpacking $input.tar.gz...\n"
|
||||
mkdir $input && mv $input.tar.gz $input && cd $input
|
||||
printf "$blue [ i ]$reset Verifying integrity of package...\n"
|
||||
sha256sum $input.tar.gz
|
||||
tar -xf $input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ \xE2\x9C\x95 ] \033[m Could not unpack $input.tar.gz.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# Run installation hooks
|
||||
chmod +x INSTALL.sh
|
||||
chmod +x $input.ts.sh
|
||||
printf "$blue [ i ]$reset The following instruction set will be executed:\n"
|
||||
cat INSTALL.sh
|
||||
printf "\033[1;34m [ i ] \033[m Executing installation instructions...\n"
|
||||
./INSTALL.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red [ $error ]$reset Instructions were either unable to execute, or encountered an error while executing.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
./$input.ts.sh
|
||||
# Clean up
|
||||
printf "\033[1;34m [ i ] \033[m Cleaning up...\n"
|
||||
mv $input-pkginfo.json /etc/glacier/pkginfo
|
||||
cd ..
|
||||
rm -rf $input
|
||||
printf "\033[1;32m [ \xE2\x9C\x93 ] \033[m Operation completed.\n"
|
||||
exit 0
|
||||
;;
|
||||
update|-u)
|
||||
# Require Glacier to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
printf "\033[1;34m [ i ] \033[m Installing $input.tar.gz...\n"
|
||||
printf "\033[1;34m [ i ] \033[m Checking databases... " && $GLACIER_DOWNLOAD_BACKEND $GREPO1/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Package not found.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[1;34m [ i ] \033[m Unpacking $input.tar.gz...\n"
|
||||
mkdir $input && mv $input.tar.gz $input && cd $input
|
||||
printf "$blue [ i ]$reset Verifying integrity of package...\n"
|
||||
sha256sum $input.tar.gz
|
||||
tar -xf $input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Could not unpack $input.tar.gz.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
rm /var/log/glacier/$input.timestamp
|
||||
chmod +x UPDATE.sh
|
||||
chmod +x $input.ts.sh
|
||||
printf "$blue [ i ]$reset The following instruction set will be executed:\n"
|
||||
cat UPDATE.sh
|
||||
printf "\033[1;34m [ i ] \033[m Executing update instructions...\n"
|
||||
./UPDATE.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red [ $error ]$reset Instructions were either unable to execute, or encountered an error while executing.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
./$input.ts.sh
|
||||
printf "\033[1;34m [ i ] \033[m Cleaning up...\n"
|
||||
mv $input-pkginfo.json /etc/glacier/pkginfo
|
||||
cd ..
|
||||
rm -rf $input
|
||||
printf "\033[1;32m [ $check ] \033[m Operation completed.\n"
|
||||
exit 0
|
||||
;;
|
||||
remove|-x)
|
||||
# Require the script to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
printf "\033[1;34m [ i ] \033[m Removing $input.tar.gz...\n"
|
||||
printf "\033[1;34m [ i ] \033[m Checking databases... " && $GLACIER_DOWNLOAD_BACKEND $GREPO1/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Package not found.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[1;34m [ i ] \033[m Unpacking $input.tar.gz...\n"
|
||||
mkdir $input && mv $input.tar.gz $input && cd $input
|
||||
printf "$blue [ i ]$reset Verifying integrity of package...\n"
|
||||
sha256sum $input.tar.gz
|
||||
tar -xf $input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Could not unpack $input.tar.gz.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
chmod +x REMOVE.sh
|
||||
printf "$blue [ i ] $reset The following instruction set will be executed:\n"
|
||||
cat REMOVE.sh
|
||||
printf "$blue [ i ] $reset Executing removal instructions...\n"
|
||||
./REMOVE.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red [ $error ]$reset Instructions were either unable to execute, or encountered an error while executing.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
rm /var/log/glacier/$input.timestamp
|
||||
printf "\033[1;34m [ i ] \033[m Cleaning up... \n" # Status message
|
||||
cd ..
|
||||
rm -rf $input
|
||||
rm /etc/glacier/pkginfo/$input-pkginfo.json
|
||||
printf "\033[1;32m [ $check ] \033[m Operation completed.\n"
|
||||
exit 0
|
||||
;;
|
||||
query|-q)
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
cat /etc/glacier/pkginfo/$input-pkginfo.json
|
||||
cat /var/log/glacier/$input.timestamp
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Package not found.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
cache|-c)
|
||||
# Require the script to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
printf "\033[1;34m [ i ] \033[m Caching $input.tar.gz...\n"
|
||||
printf "\033[1;34m [ i ] \033[m Checking databases... " && $GLACIER_DOWNLOAD_BACKEND $GREPO1/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Package not found.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
printf "$blue [ i ]$reset Verifying integrity of package...\n"
|
||||
sha256sum $input.tar.gz
|
||||
mv $input.tar.gz /var/cache/glacier
|
||||
printf "\033[1;32m [ $check ] \033[m Operation completed.\n"
|
||||
exit 0
|
||||
;;
|
||||
cache-install|-ci)
|
||||
# Require the script to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
echo "$red[ $error ]$reset Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "\033[1;34m [ ? ] \033[m Enter package name: " && read input
|
||||
printf "\033[1;34m [ i ] \033[m Checking cache for $input.tar.gz...\n"
|
||||
cd /var/cache/glacier && cp $input.tar.gz /tmp && cd /tmp
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Could not fetch package from cache.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[1;34m [ i ] \033[m Unpacking $input.tar.gz...\n"
|
||||
mkdir $input && mv $input.tar.gz $input && cd $input
|
||||
tar -xf $input.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Could not unpack $input.tar.gz.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
chmod +x INSTALL.sh
|
||||
chmod +x $input.ts.sh
|
||||
./INSTALL.sh # Actually executes installation script
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red [ $error ]$reset Instructions were either unable to execute, or encountered an error while executing.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
./$input.ts.sh
|
||||
printf "\033[1;34m [ i ] \033[m Cleaning up...\n" # Status message
|
||||
mv -v $input-pkginfo.json /etc/glacier/pkginfo
|
||||
cd ..
|
||||
rm -rvf $input
|
||||
printf "\033[1;32m [ $check ] \033[m Operation completed.\n"
|
||||
exit 0
|
||||
;;
|
||||
cache-clear|-cc)
|
||||
# Require the script to be run as root
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Please run Glacier as root.\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "\033[1;34m [ i ] \033[m Clearing cache...\n"
|
||||
cd /var/cache/glacier && rm -rf *
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "\033[1;31m [ $error ] \033[m Some items could not be cleared.\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[1;32m [ $check ] \033[m Cache cleared.\n"
|
||||
exit 0
|
||||
;;
|
||||
-*|--*)
|
||||
printf "$red [ $error ]$reset Unknown option, use 'glacier -h' to see usage.\n"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
printf "$red [ $error ]$reset Unknown option, use 'glacier -h' to see usage.\n"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
printf "$red [ $error ]$reset Unknown option, use 'glacier -h' to see usage.\n"
|
||||
36
scripts/glacier.conf
Normal file
36
scripts/glacier.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# /etc/glacier.conf
|
||||
# The settings stored in this file will be loaded when Glacier is called
|
||||
# For more information on each of these options, see https://git.everest
|
||||
#
|
||||
|
||||
# Repositories Glacier will use
|
||||
GREPO1=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/world # System Software
|
||||
GREPO2=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/galaxy # GPL Only Software
|
||||
GREPO3=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/universe # All Open Source Software
|
||||
#GREPO4=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse # Proprietary Software
|
||||
#GREPO5=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/world-testing
|
||||
#GREPO6=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/galaxy-testing
|
||||
#GREPO7=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/universe-testing
|
||||
#GREPO8=https://git.everestlinux.org/EverestLinux/glacier-pkgs/raw/branch/main/multiverse-testing
|
||||
|
||||
# Define colors and unicode symbols to be used
|
||||
export red="\033[1;31m"
|
||||
export green="\033[1;32m"
|
||||
export yellow="\033[1;33m"
|
||||
export blue="\033[1;34m"
|
||||
export reset="\033[m"
|
||||
export check="\xE2\x9C\x93"
|
||||
export error="\xE2\x9C\x95"
|
||||
export warning="\x21"
|
||||
export question="\x3F"
|
||||
|
||||
# Which backend Glacier will use to download files
|
||||
# Selecting more than one backend will cause breakage
|
||||
GLACIER_DOWNLOAD_BACKEND="wget --quiet --show-progress"
|
||||
#GLACIER_DOWNLOAD_BACKEND="curl --output $input.tar.gz"
|
||||
#GLACIER_DOWNLOAD_BACKEND="aria2c"
|
||||
|
||||
#
|
||||
# end /etc/glacier.conf
|
||||
#
|
||||
9
scripts/hooks.sh
Normal file
9
scripts/hooks.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# /etc/glacier/hooks.sh
|
||||
# Hooks that will be run while calling Glacier
|
||||
# DO NOT DELETE THE 2 HOOKS BELOW
|
||||
|
||||
source /etc/glacier.conf
|
||||
source /etc/make.conf
|
||||
|
||||
# Custom hooks can be put below
|
||||
Reference in New Issue
Block a user