summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-11-03 01:41:31 +0000
committermidipix <writeonce@midipix.org>2021-11-12 19:10:00 +0000
commite06f87944efabb35a183813b9a74f44167f04053 (patch)
treed926b5e1b9541bc1d2abd183b0d0612f3196a5a4
parent3f01df052ca14b084abe8bfd7d4b82f984c913b9 (diff)
downloadmpackage-e06f87944efabb35a183813b9a74f44167f04053.tar.bz2
mpackage-e06f87944efabb35a183813b9a74f44167f04053.tar.xz
once/update.sh: only keep n packages as configured in /etc/vendor.cfg.
-rwxr-xr-xonce/update.sh28
1 files 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