From 25da9bfd6828868cf0d300bc45cbdff069d751c0 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 14 Jun 2017 13:12:57 +0200 Subject: bin/return-assignment: removing of old package versions encapulated in external function, now --- bin/common-functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin/common-functions') diff --git a/bin/common-functions b/bin/common-functions index cd115fd..00da63c 100755 --- a/bin/common-functions +++ b/bin/common-functions @@ -275,3 +275,18 @@ official_or_community() { ;; esac } + +# remove_old_package_versions $package_file +# removes all other versions of $package_file in the current directory + +remove_old_package_versions() { + + local package="$1" + local pkgname="${package%-*-*-*.pkg.tar.xz}" + + ls | \ + grep "^${pkgname//./\\.}\(-[^-]\+\)\{3\}\.pkg\.tar\.xz\(\.sig\)\?\$" | \ + grep -v "^${package//./\\.}\(\.sig\)\?\$" | \ + xargs -rn1 rm + +} -- cgit v1.2.3-54-g00ecf