This commit is contained in:
Ohio2 2021-06-29 21:51:11 +02:00
parent b477c096ae
commit b0d9b00fc3

9
spkg
View file

@ -13,10 +13,10 @@ case ${1} in
install) case ${2} in
--root-dir=) for fname in $@
do
pushd && mkdir ${4}/usr/src/${3} 2>/dev/null && wget $source/${3}/Makefile ${4}/usr/src/${3}/Makefile && cd ${4}/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=${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 $@
do
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=/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 ;;
esac ;;
cache) case ${2} in
#cache clean rm and save are easy thus won't wase time for them
@ -33,13 +33,14 @@ case ${1} in
lookup) case ${4} in
local) grep $@ /var/cache/spkg.cache ;;
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;;
esac ;;
list) cat /var/cache/spkg.cache
esac ;;
esac ;;
esac ;;
#update is really complicated. you must know that it compares local and repo version of the package
update) for fname in $@
do
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\ "${3} $(${3} --version)" /var/cache/spkg.cache > /var/cache/spkg.cache && popd && done ;;
$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.
to install, just type in sudo spkg install.
to update, just type in sudo spkg update.