Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-08-31 16:08:11 +0200
committerErich Eckner <git@eckner.net>2017-08-31 16:08:11 +0200
commit906480fae444bfc44070836963ca613e438f5abe (patch)
treec74f1903f1a2decd61782f62797fc801c4907123 /bin
parent71e420d29b063dec02fd1c8a85fd5237ba3cefb2 (diff)
bin/common-functions: remove_old_package_versions: remove older packages in not-newer repositories and not-older packages in newer repositories
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common-functions60
1 files changed, 43 insertions, 17 deletions
diff --git a/bin/common-functions b/bin/common-functions
index b1fb9f0..fda2288 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -393,8 +393,8 @@ ls_master_mirror() {
}
# remove_old_package_versions $arch $repository $package_file
-# removes all older versions of $package_file for architecture $arch in all
-# repositories not-older than $repository
+# removes all older (not-newer) versions of $package_file for architecture
+# $arch in all repositories not-older (newer) than $repository
remove_old_package_versions() {
@@ -402,32 +402,47 @@ remove_old_package_versions() {
local repository="$2"
local package="$3"
- local delete_repositories
- local repo
+ # repositories in which older packages should be deleted
+ local delete_older_repositories
+ # repositories in which not-newer packages should be deleted
+ local delete_not_newer_repositories
if echo "${standalone_package_repositories}" | \
- tr ' ' '\n' | \
grep -qxF "${repository}"; then
- delete_repositories="${repository}"
+ delete_older_repositories="${repository}"
+ delete_not_newer_repositories=''
elif echo "${staging_package_repositories}" | \
- tr ' ' '\n' | \
grep -qxF "${repository}"; then
- delete_repositories="${staging_package_repositories}"
+ delete_older_repositories="${repository}"
+ delete_not_newer_repositories=$(
+ echo "${staging_package_repositories}" | \
+ grep -vxF "${repository}"
+ ) || true
elif echo "${testing_package_repositories}" | \
- tr ' ' '\n' | \
grep -qxF "${repository}"; then
- delete_repositories="${staging_package_repositories} ${testing_package_repositories}"
+ delete_older_repositories=$(
+ printf '%s\n' "${staging_package_repositories}" "${repository}"
+ )
+ delete_not_newer_repositories=$(
+ echo "${testing_package_repositories}" | \
+ grep -vxF "${repository}"
+ ) || true
elif echo "${stable_package_repositories}" | \
- tr ' ' '\n' | \
grep -qxF "${repository}"; then
- delete_repositories="${staging_package_repositories} ${testing_package_repositories} ${stable_package_repositories}"
+ delete_older_repositories=$(
+ printf '%s\n' "${staging_package_repositories}" "${testing_package_repositories}" "${repository}"
+ )
+ delete_not_newer_repositories=$(
+ echo "${stable_package_repositories}" | \
+ grep -vxF "${repository}"
+ ) || true
else
@@ -441,22 +456,33 @@ remove_old_package_versions() {
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
{
- for repo in ${delete_repositories}; do
+ for repo in ${delete_older_repositories}; do
+ echo "do: '${repo}'" >&2
+ ls_master_mirror "${arch}/${repo}" | \
+ sed '
+ /\.pkg\.tar\.xz$/!d
+ s|-\([^-]\+-[^-]\+\)-\([^-]\+\)$| \1 \2|
+ /^'"$(str_to_regex "${package%-*-*-*}")"' /!d
+ s|^|2 '"${arch} ${repo}"' |
+ '
+ done
+ for repo in ${delete_not_newer_repositories}; do
+ echo "dnn: '${repo}'" >&2
ls_master_mirror "${arch}/${repo}" | \
sed '
/\.pkg\.tar\.xz$/!d
s|-\([^-]\+-[^-]\+\)-\([^-]\+\)$| \1 \2|
/^'"$(str_to_regex "${package%-*-*-*}")"' /!d
- s|^|1 '"${arch} ${repo}"' |
+ s|^|0 '"${arch} ${repo}"' |
'
done
echo "${package%-*}" | \
- sed 's|^.*-\([^-]\+-[^-]\+\)$|0 %cut% %it% %here% \1|'
+ sed 's|^.*-\([^-]\+-[^-]\+\)$|1 %cut% %it% %here% \1|'
} | \
sort -k5V,5 -k1n,1 | \
sed -n '
- /^0 %cut% %it% %here% /q
- s/^1 //
+ /^1 %cut% %it% %here% /q
+ s/^[02] //
s/ \(\S\+\)$/-\1/
p
' > \