From 15df206ebadec042300c1283841552d0e4d994c6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 30 Jan 2020 14:39:44 +0100 Subject: bin/return-assignment: use intentions-queue --- bin/return-assignment | 151 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 107 insertions(+), 44 deletions(-) (limited to 'bin') diff --git a/bin/return-assignment b/bin/return-assignment index 6517be2..f403519 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -17,12 +17,8 @@ # 4: package error (e.g. wrong packages sent) # 5: wrong number of arguments -# TODO: sign database - # TODO: remove hard-coded package suffixes -# TODO: use the intention-queue - # shellcheck disable=SC2119,SC2120 # shellcheck source=../lib/load-configuration @@ -938,59 +934,117 @@ cut -d' ' -f4,5 "${tmp_dir}/repository-ids" | \ sort -u | \ while read -r arch repo; do - mkdir -p "${arch}/${repo}" - failsafe_rsync \ - "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.db."* \ - "${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.files."* \ - "${arch}/${repo}/" + { + printf 'cd "%s"\n' \ + "${tmp_dir}" + printf 'mkdir -p "%s/%s"\n' \ + "${arch}" \ + "${repo}" + + printf 'failsafe_rsync' + for suffix in 'db' 'files'; do + printf ' "%s/%s/%s/%s.%s."*' \ + "${master_mirror_rsync_directory}" \ + "${arch}" \ + "${repo}" \ + "${repo}" \ + "${suffix}" + done + printf ' "%s/%s/"\n' \ + "${arch}" \ + "${repo}" + +# TODO: sign database - grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" | \ - cut -d' ' -f2 | \ - xargs -r repo-add "${arch}/${repo}/${repo}.db.tar.gz" - # xargs -r repo-add -v -s -k "${repo_key}" "${destination}.db.tar.gz" + # repo-add -v -s -k "${repo_key}" "${destination}.db.tar.gz" + printf 'repo-add "%s/%s/%s.db.tar.gz"' \ + "${arch}" \ + "${repo}" \ + "${repo}" + grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" \ + | cut -d' ' -f2 \ + | tr '\n' ' ' + printf '\n' + } \ + | intent_something done # upload the packages into /pool -failsafe_rsync -c --copy-dest=/.transfer \ - ./*".pkg.tar.zst" \ - ./*".pkg.tar.zst.sig" \ - "${master_mirror_rsync_directory}/pool/" +{ + printf 'cd "%s"\n' \ + "${tmp_dir}" + printf 'failsafe_rsync -c --copy-dest=/.transfer' + printf ' ./*".pkg.tar.zst%s"' \ + '' '.sig' + printf ' "%s/pool/"' \ + "${master_mirror_rsync_directory}" +} \ +| intent_something # create symlinks -find . \( -name '*.pkg.tar.zst' -o -name '*.pkg.tar.zst.sig' \) -printf '%f\n' | \ - while read -r file; do - rm "${file}" - ln -s "../../pool/${file}" "${file}" - done +{ + find . \( -name '*.pkg.tar.zst' -o -name '*.pkg.tar.zst.sig' \) -printf '%f\n' | \ + while read -r file; do + printf 'rm "%s"\n' \ + "${file}" + printf 'ln -s "../../pool/%s" "%s/%s"\n' \ + "${file}" \ + "${tmp_dir}" \ + "${file}" + done +} \ +| intent_something # upload the database and the symlinks into /$arch/$repo cut -d' ' -f4,5 "${tmp_dir}/repository-ids" | \ sort -u | \ while read -r arch repo; do - recompress_gz \ - "${tmp_dir}" \ - "${arch}/${repo}/${repo}."*".tar.gz" \ - "${arch}/${repo}/${repo}."*".tar.gz.old" - # shellcheck disable=SC2046 - failsafe_rsync \ - "${arch}/${repo}/${repo}.db."* \ - "${arch}/${repo}/${repo}.files."* \ - $( - grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" | \ - cut -d' ' -f2 | \ - sed ' - s,^,./, - p - s/$/.sig/ - ' - ) \ - "${master_mirror_rsync_directory}/${arch}/${repo}/" + { + printf 'recompress_gz "%s"' \ + "${tmp_dir}" + for suffix in '' '.old'; do + printf ' "%s/%s/%s."*".tar.gz%s"' \ + "${arch}" \ + "${repo}" \ + "${repo}" \ + "${suffix}" + done + printf '\n' + + printf 'failsafe_rsync ' + for suffix in 'db' 'files'; do + printf '"%s/%s/%s/%s."* ' \ + "${arch}" \ + "${repo}" \ + "${repo}" \ + "${suffix}" + done + grep " $(str_to_regex "${arch} ${repo}")\$" "${tmp_dir}/repository-ids" \ + | cut -d' ' -f2 \ + | sed ' + s,^,./, + p + s/$/.sig/ + ' \ + | tr '\n' ' ' + printf '"%s/%s/%s/"\n' \ + "${master_mirror_rsync_directory}" \ + "${arch}" \ + "${repo}" + } \ + | intent_something done # shellcheck disable=SC2016 { + printf '{\n' + printf ' mysql_run_query |' + printf ' sort -u |' + printf ' remove_old_package_versions\n' + printf '} <