From e06f87944efabb35a183813b9a74f44167f04053 Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 3 Nov 2021 01:41:31 +0000 Subject: once/update.sh: only keep n packages as configured in /etc/vendor.cfg. --- once/update.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/once/update.sh b/once/update.sh index 6962973..d93a461 100755 --- a/once/update.sh +++ b/once/update.sh @@ -21,6 +21,10 @@ if [ "$tarballs" = '/updates/*.tar.gz' ]; then exit 0 fi +if [ -f /etc/vendor.cfg ]; then + . /etc/vendor.cfg +fi + for tarball in $tarballs; do tarball="${tarball##*/}" @@ -38,9 +42,27 @@ for tarball in $tarballs; do pkgdir=/tarballs/archive/${tarball%%.tar.gz}/ mkdir -p $pkgdir printf '%s\n' "$pkgsig" >> ${pkgdir}/pkgsigs.log - pkgdir=$pkgdir/$pkgsig/ - mkdir -p $pkgdir - mv /tarballs/$tarball $pkgdir + mkdir -p $pkgdir/$pkgsig/ + mv /tarballs/$tarball $pkgdir/$pkgsig/ + + case ${keep:-'-1'} in + -1 ) + ;; + + * ) + tail -n ${keep} ${pkgdir}/pkgsigs.log > ${pkgdir}/pkgsigs.keep + + for pkgsigdir in ${pkgdir}/*; do + if [ -d $pkgsigdir ]; then + if ! grep ${pkgsigdir##*/} ${pkgdir}/pkgsigs.keep; then + rm $pkgsigdir/$tarball + rmdir $pkgsigdir + fi + fi + done + + ;; + esac fi echo caching the current $tarball -- cgit v1.2.3