115 lines
2.5 KiB
Bash
Executable file
115 lines
2.5 KiB
Bash
Executable file
#!/bin/sh
|
|
source="https://git.hippoz.xyz/duck/repo/raw/branch/master"
|
|
tmpdir="/tmp"
|
|
setup() {
|
|
prefix=$1
|
|
cp ./spkg "${prefix}"/usr/bin/spkg
|
|
chmod +x "${perfix}"/usr/bin/spkg
|
|
mkdir "${prefix}"/etc/
|
|
mv os-release "${prefix}"/etc/
|
|
}
|
|
removepkg() {
|
|
pkgname=$1
|
|
prefix=$2
|
|
cd /usr/src/"${pkgname}" || exit 2
|
|
{
|
|
source ./PACKAGE
|
|
"pkg_uninstall" "${prefix}"
|
|
}
|
|
sed "s/${pkgname} $(${pkgname} --version)//" "${prefix}"/var/cache/spkg.cache
|
|
}
|
|
instpkg() {
|
|
pkgname=$1
|
|
prefix=$2
|
|
mkdir -p "${tmpdir}"/spkg/work/"${1}"-work/
|
|
cd "${tmpdir}"/spkg/work/"${1}"-work/ || exit 2
|
|
mkdir -p "${prefix}"/usr/src/"${pkgname}"
|
|
wget "${prefix}"/usr/src/"${pkgname}" "${source}"/"${pkgname}"/PACKAGE
|
|
cd "${prefix}"/usr/src/"${pkgname}" || exit 2
|
|
export PREFIX="${prefix}"
|
|
export PKGNAME="${pkgname}"
|
|
{
|
|
source ./PACKAGE
|
|
"pkg_install" "${prefix}"
|
|
}
|
|
sed a\ "${pkgname} $(${pkgname} --version)" "${prefix}"/var/cache/spkg.cache > "${prefix}"/var/cache/spkg.cache
|
|
}
|
|
update() {
|
|
pkgname=$1
|
|
prefix=$2
|
|
version1=$(grep "${pkgname}" /var/cache/spkg.cache)
|
|
version2=$(wget "${source}"/spkg.cache /tmp/spkg/web.spkg.cache && grep "${pkgname}" /tmp/spkg/web.spkg.cache )
|
|
if [ "$version1" = "${version2}" ]; then
|
|
echo 'Up to date.'
|
|
else
|
|
instpkg "${pkgname}" "${prefix}"
|
|
fi
|
|
}
|
|
dbquery() {
|
|
pkgname=$1
|
|
wget "${source}"/spkg.cache /tmp/spkg/web.spkg.cache
|
|
grep "${pkgname}" /tmp/spkg/web.spkg.cache
|
|
rm /tmp/spkg/cache || mkdir 2>/dev/null /tmp/spkg
|
|
}
|
|
dblocal() {
|
|
pkgname=$1
|
|
grep "${pkgname}" /var/cache/spkg.cache
|
|
}
|
|
dblist() {
|
|
cat /var/cache/spkg.cache
|
|
}
|
|
usage() {
|
|
echo 'sPKG via WGET, to cache, just type in sudo spkg cache save.
|
|
to install, just type in sudo spkg install.
|
|
to update, just type in sudo spkg update.
|
|
to setup (IMPORTANT!!!), just type in sudo spkg setup'
|
|
}
|
|
version() {
|
|
echo "spkg 21.06.30.1b"
|
|
}
|
|
case "${1}" in
|
|
setup)
|
|
case "${2}" in
|
|
--root-dir) setup "${3}" ;;
|
|
*) setup "/" ;;
|
|
esac ;;
|
|
remove)
|
|
case "${2}" in
|
|
--root-dir) removepkg "${3}" "${4}" ;;
|
|
*) removepkg "${3}" "/" ;;
|
|
esac ;;
|
|
install)
|
|
case "${2}" in
|
|
--root-dir) instpkg "${4}" "${3}" ;;
|
|
*) instpkg "${3}" "/" ;;
|
|
esac ;;
|
|
cache)
|
|
case "${2}" in
|
|
clean)
|
|
rm -rf /usr/src/* ;;
|
|
rm)
|
|
rm -rf /usr/src/"${3}" ;;
|
|
save)
|
|
case ${3} in
|
|
to) cp -rv /usr/src/* "${4}"/ ;;
|
|
esac ;;
|
|
database)
|
|
case "${3}" in
|
|
lookup)
|
|
case "${4}" in
|
|
local)
|
|
dblocal "${5}" ;;
|
|
query)
|
|
dbquery "${5}" ;;
|
|
esac;;
|
|
esac ;;
|
|
esac ;;
|
|
list)
|
|
dblist ;;
|
|
update)
|
|
update "${2}" ;;
|
|
--help)
|
|
usage ;;
|
|
--version)
|
|
version ;;
|
|
esac
|