This commit is contained in:
Ohio2 2021-06-29 23:19:51 +02:00
commit 4ce26f75e6
2 changed files with 102 additions and 49 deletions

View file

@ -3,7 +3,7 @@ PRETTY_NAME="Duck Linux Beta"
ID=dlb ID=dlb
BUILD_ID=rolling BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209" ANSI_COLOR="38;2;23;147;209"
HOME_URL="" HOME_URL="https://git.hippoz.xyz/duck"
DOCUMENTATION_URL="" DOCUMENTATION_URL=""
SUPPORT_URL="" SUPPORT_URL=""
BUG_REPORT_URL="" BUG_REPORT_URL=""

145
spkg
View file

@ -1,49 +1,102 @@
#!/usr/bin/env sh #!/bin/sh
# NOTE: sPKG via wget CAN'T RUN WITHOUT MAKE!!!
source=git.hippoz.xyz/spkg/repos source="https://git.hippoz.xyz/spkg/repo"
case ${1} in
#setup does the important shit like, copy spkg and chmod it, install osrel to etc. setup() {
setup) cp ./spkg /usr/bin/spkg && chmod +x /usr/bin/spkg && mkdir /etc/ && mv os-release /etc/ ;; cp ./spkg /usr/bin/spkg
#remove, just well, uninstalls and removes from cache. chmod +x /usr/bin/spkg
remove) for fname in $@ mkdir /etc/
do mv os-release /etc/
pushd && cd /usr/src/${2} && sed "s/${2} $(${2} --version)//" && make uninstall && cd .. && rm -rf ${2} && popd && done ;; }
#install is complicated, root dir just changes the root dir, first install gets the make file that's requested, prepares, makes, installs removepkg() {
#and saves to cache. pkgname=$1
install) case ${2} in
--root-dir=) for fname in $@ cd /usr/src/"${pkgname}" || exit 2
do make uninstall
$prefix=${4} && export $prefix && pushd && mkdir $prefix/usr/src/${3} 2>/dev/null && wget $source/${3}/Makefile $prefix/usr/src/${3}/Makefile && cd $prefix/usr/src/${3} && make prepare && make && make install && sed a\ "${3} $(${3} --version)" /var/cache/spkg.cache > /var/cache/spkg.cache && popd && done || echo 'Invalid package.' && popd ;; }
*) for fname in $@ instpkg() {
do pkgname=$1
$prefix=/usr && export $prefix && pushd && mkdir /usr/src/${3} 2>/dev/null && wget $source/${3}/Makefile /usr/src/${3}/Makefile && cd /usr/src/${3} && make prepare && make && make install && sed a\ "${3} $(${3} --version)" /var/cache/spkg.cache > /var/cache/spkg.cache && popd && done || echo 'Invalid package.' && popd ;; prefix=$2
esac ;;
cache) case ${2} in mkdir -p "${prefix}"/usr/src/"${pkgname}"
#cache clean rm and save are easy thus won't wase time for them wget "${source}"/"${pkgname}"/Makefile "${prefix}"/usr/src/"${pkgname}"/Makefile
clean) rm -rf /usr/src/* ;; cd "${prefix}"/usr/src/"${pkgname}" || exit 2
rm) rm -rf /usr/src/${3} ;; export PREFIX="${prefix}"
save) case ${3} in export PKGNAME="${pkgname}"
to) cp /usr/src/ ${4} ;; make prepare
*) cp /usr/src/ /etc/spkg/cache || mkdir /etc/spkg 2>/dev/null && mkdir /etc/spkg/cache 2>/dev/null && cp /usr/src/ /etc/spkg/cache ;; make
esac ;; make install
#database lookup local just greps cache cat "${pkgname}" > "${prefix}"/var/cache/spkg.cache
# on the other hand, query is complicated, does the same thing though. "${pkgname}" --version > "${prefix}"/var/cache/spkg.cache
#but for online cache. }
database) case ${3} in update() {
lookup) case ${4} in pkgname=$1
local) grep $@ /var/cache/spkg.cache ;; prefix=$2
query) wget $source/spkg.cache /tmp/spkg/web.spkg.cache && grep ${5} /tmp/spkg/web.spkg.cache && rm /tmp/spkg/cache || mkdir 2>/dev/null /tmp/spkg && wget $source/spkg.cache /tmp/spkg/ && grep ${5} /tmp/spkg/web.spkg.cache && rm /tmp/spkg/cache;;
list) cat /var/cache/spkg.cache version1=$(grep "${pkgname}" /var/cache/spkg.cache)
esac ;; version2=$(wget "${source}"/spkg.cache /tmp/spkg/web.spkg.cache && grep "${pkgname}" /tmp/spkg/web.spkg.cache )
esac ;; if [ "$version1" = "${version2}" ]; then
esac ;; echo 'Up to date.'
#update is really complicated. you must know that it compares local and repo version of the package else
update) for fname in $@ instpkg "${pkgname}" "${prefix}"
do fi
$prefix=/usr && export $prefix && version1=$(grep ${2} /var/cache/spkg.cache) && version2=$(wget $source/spkg.cache /tmp/spkg/web.spkg.cache && grep ${2} /tmp/spkg/web.spkg.cache ) && [ version1 = version2] && echo 'Up to date.' || pushd && mkdir /usr/src/${2} 2>/dev/null && wget $source/${2}/Makefile /usr/src/${2}/Makefile && cd /usr/src/${2} && make prepare && make && make install && sed "s/${2} $({$2} --version)//" && sed a\ "${2} $(${2} --version)" /var/cache/spkg.cache > /var/cache/spkg.cache && popd && done ;; }
--help) echo 'sPKG via WGET, to cache, just type in sudo spkg cache save. 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
}
usage() {
echo 'sPKG via WGET, to cache, just type in sudo spkg cache save.
to install, just type in sudo spkg install. to install, just type in sudo spkg install.
to update, just type in sudo spkg update. to update, just type in sudo spkg update.
to setup (IMPORTANT!!!), just type in sudo spkg setup' ;; to setup (IMPORTANT!!!), just type in sudo spkg setup'
--version) echo 'beta 21.06.29.2b' ;; }
version() {
echo "beta 21.06.29.1a"
}
case "${1}" in
setup)
setup ;;
remove)
removepkg "${2}" ;;
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 ;;
update)
update "${2}" ;;
--help)
usage ;;
--version)
version ;;
esac esac