diff options
author | Erich Eckner <git@eckner.net> | 2017-07-20 20:59:57 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-07-20 20:59:57 +0200 |
commit | e2d038d4aaa8f0ce171ff5050b5a709813283a6b (patch) | |
tree | cb768f4bc0c31ee28f12438bd0a27c3e3606dc05 | |
parent | 002d036064354d9e7b4412f703ddbb8a92b87804 (diff) | |
download | builder-e2d038d4aaa8f0ce171ff5050b5a709813283a6b.tar.xz |
bin/common-functions: accelerate delete_old_metadata
-rwxr-xr-x | bin/common-functions | 19 |
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='' |