From d11295933f2feaa4fdfac3dcab65ab84befc80f3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 30 Jan 2020 13:53:03 +0100 Subject: bin/delete-packages: use intentions-queue --- bin/delete-packages | 109 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 36 deletions(-) (limited to 'bin/delete-packages') diff --git a/bin/delete-packages b/bin/delete-packages index 2377f75..dddd5fa 100755 --- a/bin/delete-packages +++ b/bin/delete-packages @@ -11,8 +11,6 @@ # shellcheck disable=SC2039,SC2119,SC2120 -# TODO: use the intention-queue - # shellcheck source=../lib/load-configuration . "${0%/*}/../lib/load-configuration" @@ -360,42 +358,68 @@ fi mkdir "${tmp_dir}/repos" -while read -r arch repo; do - mkdir -p "${tmp_dir}/repos/${arch}" - failsafe_rsync \ - "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.db.tar.gz" \ - "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.files.tar.gz" \ - "${tmp_dir}/repos/${arch}" - - # shellcheck disable=SC2046 - repo-remove "${tmp_dir}/repos/${arch}/${repo}.db.tar.gz" \ - $( - grep "^$(str_to_regex "${arch} ${repo}") " "${tmp_dir}/packages" | \ - cut -d' ' -f3 - ) - if ! ${no_action}; then - recompress_gz \ - "${tmp_dir}" \ - "${tmp_dir}/repos/${arch}/${repo}."*".tar.gz" \ - "${tmp_dir}/repos/${arch}/${repo}."*".tar.gz.old" - failsafe_rsync \ - "${tmp_dir}/repos/${arch}/${repo}.db."* \ - "${tmp_dir}/repos/${arch}/${repo}.files."* \ - "${master_mirror_rsync_directory}/${arch}/${repo}/" - fi -done < \ - "${tmp_dir}/repositories" - if ${no_action}; then - printf 'Now, I would remove the packages from the database and delete the following files from the master mirror:\n' + printf 'I would delete the following files from the master mirror:\n' sed ' s,^, , ' "${tmp_dir}/package-files" exit fi +while read -r arch repo; do + { + printf 'mkdir -p "%s/repos/%s"\n' "${tmp_dir}" "${arch}" + printf 'failsafe_rsync' + for suffix in 'db' 'files'; do + printf ' "%s/%s/%s/%s.%s.tar.gz"' \ + "${master_mirror_rsync_directory}" \ + "${arch}" \ + "${repo}" \ + "${repo}" \ + "${suffix}" + done + printf ' "%s/repos/%s"\n' "${tmp_dir}" "${arch}" + } \ + | intent_something + { + printf 'repo-remove "%s/repos/%s/%s.db.tar.gz" ' \ + "${tmp_dir}" \ + "${arch}" \ + "${repo}" + grep "^$(str_to_regex "${arch} ${repo}") " "${tmp_dir}/packages" \ + | cut -d' ' -f3 \ + | tr '\n' ' ' + printf '\n' + printf 'recompress_gz "%s"' \ + "${tmp_dir}" + for suffix in '' '.old'; do + printf ' "%s/repos/%s/%s."*".tar.gz%s"' \ + "${tmp_dir}" "${arch}" "${repo}" "${suffix}" + done + printf '\n' + } \ + | intent_something + { + printf 'failsafe_rsync' + for suffix in 'db' 'files'; do + printf ' "%s/repos/%s/%s.%s."*' \ + "${tmp_dir}" \ + "${arch}" \ + "${repo}" \ + "${suffix}" + done + printf ' "%s/%s/%s/"\n' \ + "${master_mirror_rsync_directory}" \ + "${arch}" \ + "${repo}" + } \ + | intent_something +done \ +<"${tmp_dir}/repositories" + # shellcheck disable=SC2016 { + printf 'mysql_run_query <