caching works properly now

This commit is contained in:
Ohio2 2021-06-29 16:08:44 +02:00
parent 0015593109
commit 6c96f158fc

8
spkg
View file

@ -7,16 +7,16 @@ case ${1} in
#remove, just well, uninstalls and removes from cache.
remove) for fname in $@
do
pushd && cd /usr/src/${2} && make uninstall && cd .. && rm -rf ${2} && sed "s/${2}//" && popd && done ;;
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
#and saves to cache.
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 && cat ${3} > ${4}/var/cache/spkg.cache && ${3} --version && popd && done || echo 'Invalid package.' && popd ;;
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 ;;
*) 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 && cat ${3} > /var/cache/spkg.cache && popd && done || echo 'Invalid package.' && popd ;;
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
@ -39,7 +39,7 @@ case ${1} in
#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 && cat ${2} > /var/cache/spkg.cache && ${2} --version > /var/cache/spkg.cache && popd && done ;;
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 ;;
--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.