From 07de651e7222691c5eabef6ac156ab0f33fc3314 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 9 Mar 2018 11:04:24 +0100 Subject: bin/db-update: repo-copy and repo-remove packages in bunches --- bin/db-update | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'bin/db-update') diff --git a/bin/db-update b/bin/db-update index a1622ec..ca52688 100755 --- a/bin/db-update +++ b/bin/db-update @@ -195,21 +195,38 @@ for source_stability in 'testing' 'staging'; do done # remove to-be-deleted packages - while read -r pkgname repo; do - cd "${tmp_dir}/dbs/${repo}" - repo-remove -q "${repo}.db.tar.gz" "${pkgname%-*-*-*}" - done < \ - "${tmp_dir}/rm" - - # delete and add moved packages - while read -r pkgname from_repo to_repo; do - repo-copy \ - "${tmp_dir}/dbs/${from_repo}/${from_repo}.db.tar.gz" \ - "${tmp_dir}/dbs/${to_repo}/${to_repo}.db.tar.gz" \ - "${pkgname%-*}" - repo-remove -q "${tmp_dir}/dbs/${from_repo}/${from_repo}.db.tar.gz" "${pkgname%-*-*-*}" - done < \ - "${tmp_dir}/mv" + # shellcheck disable=SC2094 + cut -d' ' -f2 < \ + "${tmp_dir}/rm" | \ + sort -u | \ + while read -r repo; do + grep " $(str_to_regex "${repo}")\$" "${tmp_dir}/rm" | \ + sed ' + s/\(-[^-]\+\)\{3\} \S\+$// + ' | \ + xargs -r repo-remove -q "${tmp_dir}/dbs/${repo}/${repo}.db.tar.gz" + done + + # copy and delete moved packages + # shellcheck disable=SC2094 + cut -d' ' -f2,3 < \ + "${tmp_dir}/mv" | \ + sort -u | \ + while read -r from_repo to_repo; do + grep " $(str_to_regex "${from_repo}") $(str_to_regex "${to_repo}")\$" "${tmp_dir}/mv" | \ + sed ' + s/-[^-]\+ \S\+ \S\+$// + ' | \ + xargs -r repo-copy \ + "${tmp_dir}/dbs/${from_repo}/${from_repo}.db.tar.gz" \ + "${tmp_dir}/dbs/${to_repo}/${to_repo}.db.tar.gz" + grep " $(str_to_regex "${from_repo}") $(str_to_regex "${to_repo}")\$" "${tmp_dir}/mv" | \ + sed ' + s/\(-[^-]\+\)\{3\} \S\+ \S\+$// + ' | \ + xargs -r repo-remove -q \ + "${tmp_dir}/dbs/${from_repo}/${from_repo}.db.tar.gz" + done # move the packages remotely via sftp { -- cgit v1.2.3-70-g09d2