2021-06-29 22:35:23 +03:00
|
|
|
#!/bin/sh
|
2021-06-30 23:57:44 +03:00
|
|
|
source="https://git.hippoz.xyz/duck/repo/raw/branch/master"
|
2021-06-30 01:26:20 +03:00
|
|
|
tmpdir="/tmp"
|
2021-06-29 22:35:23 +03:00
|
|
|
setup() {
|
2021-06-30 23:38:15 +03:00
|
|
|
prefix=$1
|
2021-07-01 19:06:28 +03:00
|
|
|
mkdir "${prefix}"/bin
|
2021-07-01 19:38:43 +03:00
|
|
|
cp ./spkg "${prefix}"/bin/spkg
|
|
|
|
chmod +x "${prefix}"/bin/spkg
|
2021-06-30 23:38:15 +03:00
|
|
|
mkdir "${prefix}"/etc/
|
|
|
|
mv os-release "${prefix}"/etc/
|
2021-07-01 20:21:30 +03:00
|
|
|
mkdir "${prefix}"/usr/
|
|
|
|
mkdir "${prefix}"/usr/share
|
|
|
|
mkdir "${prefix}"/usr/share/man
|
|
|
|
mkdir "${prefix}"/usr/share/man/man1 "${prefix}"/usr/share/man/man2 "${prefix}"/usr/share/man/man3 "${prefix}"/usr/share/man/man4 "${prefix}"/usr/share/man/man5 "${prefix}"/usr/share/man/man6 "${prefix}"/usr/share/man/man7 "${prefix}"/usr/share/man/man8 "${prefix}"/usr/share/man/man9
|
|
|
|
install -Dm644 ./man /usr/share/man1/spkg.1
|
2021-06-29 22:35:23 +03:00
|
|
|
}
|
|
|
|
removepkg() {
|
|
|
|
pkgname=$1
|
2021-07-01 00:16:01 +03:00
|
|
|
prefix=$2
|
2021-06-29 22:35:23 +03:00
|
|
|
cd /usr/src/"${pkgname}" || exit 2
|
2021-07-01 18:18:02 +03:00
|
|
|
{
|
|
|
|
source ./PACKAGE
|
|
|
|
"pkg_uninstall" "${prefix}"
|
|
|
|
}
|
2021-07-01 00:16:01 +03:00
|
|
|
sed "s/${pkgname} $(${pkgname} --version)//" "${prefix}"/var/cache/spkg.cache
|
2021-06-29 22:35:23 +03:00
|
|
|
}
|
|
|
|
instpkg() {
|
|
|
|
pkgname=$1
|
|
|
|
prefix=$2
|
2021-06-30 01:26:20 +03:00
|
|
|
mkdir -p "${tmpdir}"/spkg/work/"${1}"-work/
|
|
|
|
cd "${tmpdir}"/spkg/work/"${1}"-work/ || exit 2
|
2021-06-29 22:35:23 +03:00
|
|
|
mkdir -p "${prefix}"/usr/src/"${pkgname}"
|
2021-07-01 18:18:02 +03:00
|
|
|
wget "${prefix}"/usr/src/"${pkgname}" "${source}"/"${pkgname}"/PACKAGE
|
2021-06-29 22:35:23 +03:00
|
|
|
cd "${prefix}"/usr/src/"${pkgname}" || exit 2
|
|
|
|
export PREFIX="${prefix}"
|
|
|
|
export PKGNAME="${pkgname}"
|
2021-07-01 18:18:02 +03:00
|
|
|
{
|
|
|
|
source ./PACKAGE
|
|
|
|
"pkg_install" "${prefix}"
|
|
|
|
}
|
2021-07-01 00:16:01 +03:00
|
|
|
sed a\ "${pkgname} $(${pkgname} --version)" "${prefix}"/var/cache/spkg.cache > "${prefix}"/var/cache/spkg.cache
|
2021-06-29 22:35:23 +03:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|
2021-06-30 03:18:42 +03:00
|
|
|
dblist() {
|
|
|
|
cat /var/cache/spkg.cache
|
|
|
|
}
|
2021-06-29 22:35:23 +03:00
|
|
|
usage() {
|
2021-07-01 20:21:30 +03:00
|
|
|
echo ' How to use: install to install, update to update, list to list, remove to remove. '
|
2021-06-29 22:35:23 +03:00
|
|
|
}
|
|
|
|
version() {
|
2021-07-01 20:21:30 +03:00
|
|
|
echo "spkg 21.07.01.2a.nr"
|
2021-06-29 22:35:23 +03:00
|
|
|
}
|
|
|
|
case "${1}" in
|
|
|
|
setup)
|
2021-06-30 23:38:15 +03:00
|
|
|
case "${2}" in
|
|
|
|
--root-dir) setup "${3}" ;;
|
|
|
|
*) setup "/" ;;
|
|
|
|
esac ;;
|
2021-07-01 00:16:01 +03:00
|
|
|
remove)
|
|
|
|
case "${2}" in
|
|
|
|
--root-dir) removepkg "${3}" "${4}" ;;
|
|
|
|
*) removepkg "${3}" "/" ;;
|
2021-07-01 02:22:09 +03:00
|
|
|
esac ;;
|
2021-06-29 22:35:23 +03:00
|
|
|
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}" ;;
|
2021-06-30 03:25:18 +03:00
|
|
|
esac;;
|
2021-06-29 22:35:23 +03:00
|
|
|
esac ;;
|
|
|
|
esac ;;
|
2021-06-30 03:25:18 +03:00
|
|
|
list)
|
|
|
|
dblist ;;
|
2021-06-29 22:35:23 +03:00
|
|
|
update)
|
|
|
|
update "${2}" ;;
|
|
|
|
--help)
|
|
|
|
usage ;;
|
|
|
|
--version)
|
|
|
|
version ;;
|
2021-04-04 18:38:38 +03:00
|
|
|
esac
|