summaryrefslogtreecommitdiff
path: root/bin/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-07-20 20:59:57 +0200
committerErich Eckner <git@eckner.net>2017-07-20 20:59:57 +0200
commite2d038d4aaa8f0ce171ff5050b5a709813283a6b (patch)
treecb768f4bc0c31ee28f12438bd0a27c3e3606dc05 /bin/common-functions
parent002d036064354d9e7b4412f703ddbb8a92b87804 (diff)
downloadbuilder-e2d038d4aaa8f0ce171ff5050b5a709813283a6b.tar.xz
bin/common-functions: accelerate delete_old_metadata
Diffstat (limited to 'bin/common-functions')
-rwxr-xr-xbin/common-functions19
1 files changed, 14 insertions, 5 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 2037853..08e73f2 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -226,12 +226,12 @@ delete_old_metadata() {
cut -d' ' -f1,2,3 "${work_dir}/build-list" | \
sed 'p'
- current_metadata_file="$(mktemp)"
- trap 'rm -f "${current_metadata_file}"' EXIT
+ tmp_dir="$(mktemp -d)"
+ trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT
echo "${current_metadata}" | \
sort -k1,1 > \
- "${current_metadata_file}"
+ "${tmp_dir}/current-metadata"
# the newest of the following should stay:
(
@@ -248,8 +248,17 @@ delete_old_metadata() {
done
) | \
sort -u | \
- join -j 1 -o 2.2,2.3,2.1 - "${current_metadata_file}" | \
- sort -k3,3 | \
+ join -j 1 -o 2.2,2.3,2.1 - "${tmp_dir}/current-metadata" | \
+ sort -k3,3 > \
+ "${tmp_dir}/find-newest-revisions"
+
+ uniq -uf2 < \
+ "${tmp_dir}/find-newest-revisions" | \
+ awk '{print $3 " " $1 " " $2}' | \
+ sed 'p'
+
+ uniq -Df2 < \
+ "${tmp_dir}/find-newest-revisions" | \
uniq --group=append -f2 | \
(
revs=''