From 8b38129b5ea7c240d48cdc0f5216c2ec7b6a6c24 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 20 Jun 2018 09:20:01 +0200 Subject: lib/common-functions: remove_old_package_versions(): "sed w" does not append - we need to do it with a single sed invocation --- lib/common-functions | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'lib/common-functions') diff --git a/lib/common-functions b/lib/common-functions index 0585917..984f76c 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -175,25 +175,30 @@ remove_old_package_versions() { expand_version 3 | \ sort -k3V,3 -k2r,2 | \ shrink_version 3 | \ - sed -n ' - /^'"${bpir_id}"' /q - s/^\([0-9]\+ \)\(\S\+ \)\{2\}/\1/ - h - /^[0-9]\+ 0 / { - s/^\(\S\+ \)\{2\}// - s/ \S\+$// - w'"${tmp_dir}"'/repo-removes - g - } - s/^\(\S\+ \)\{5\}// - w'"${tmp_dir}"'/sftp-removes - s/$/.sig/ - w'"${tmp_dir}"'/sftp-removes - g - s/ .*$// - w'"${tmp_dir}"'/db-removes + sed ' + s/^/'"${bpir_id}"' / + $ a ' - done + done | \ + sed -n ' + /^\([0-9]\+\) \1 /,/^$/ d + /^$/ d + s/^[0-9]\+ \([0-9]\+ \)\(\S\+ \)\{2\}/\1/ + h + /^[0-9]\+ 0 / { + s/^\(\S\+ \)\{2\}// + s/ \S\+$// + w'"${tmp_dir}"'/repo-removes + g + } + s/^\(\S\+ \)\{5\}// + w'"${tmp_dir}"'/sftp-removes + s/$/.sig/ + w'"${tmp_dir}"'/sftp-removes + g + s/ .*$// + w'"${tmp_dir}"'/db-removes + ' for file in 'repo-removes' 'sftp-remove' 'db-removes'; do if [ -s "${tmp_dir}/${file}" ]; then -- cgit v1.2.3-70-g09d2