diff options
author | midipix <writeonce@midipix.org> | 2021-11-03 01:41:31 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-11-12 19:10:00 +0000 |
commit | e06f87944efabb35a183813b9a74f44167f04053 (patch) | |
tree | d926b5e1b9541bc1d2abd183b0d0612f3196a5a4 /once | |
parent | 3f01df052ca14b084abe8bfd7d4b82f984c913b9 (diff) | |
download | mpackage-e06f87944efabb35a183813b9a74f44167f04053.tar.bz2 mpackage-e06f87944efabb35a183813b9a74f44167f04053.tar.xz |
once/update.sh: only keep n packages as configured in /etc/vendor.cfg.
Diffstat (limited to 'once')
-rwxr-xr-x | once/update.sh | 28 |
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 |