Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/return-assignment
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-01-30 14:39:44 +0100
committerErich Eckner <git@eckner.net>2020-01-30 14:39:44 +0100
commit15df206ebadec042300c1283841552d0e4d994c6 (patch)
treebd6eaabf1ee650d5c0436235832a60a336e40998 /bin/return-assignment
parent25d948f14c5f69fe44ef97097528ae6a4d1e94f9 (diff)
bin/return-assignment: use intentions-queue
Diffstat (limited to 'bin/return-assignment')
-rwxr-xr-xbin/return-assignment151
1 files changed, 107 insertions, 44 deletions
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 '} <<END_OF_MYSQL_QUERY\n'
+
# insert checksums into database
printf 'CREATE TEMPORARY TABLE `pkg_hashes` (`pkgid` BIGINT, `sha512sum` VARCHAR(128));\n'
printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `pkg_hashes`;\n' \
@@ -1249,9 +1303,18 @@ cut -d' ' -f4,5 "${tmp_dir}/repository-ids" | \
printf ' WHERE `loops_to_delete`.`loop`=`build_dependency_loops`.`loop`'
printf ');\n'
printf 'DROP TEMPORARY TABLE `loops_to_delete`;\n'
-} | \
- mysql_run_query | \
- sort -u | \
- remove_old_package_versions
+
+ printf 'END_OF_MYSQL_QUERY\n'
+} \
+| sed 's/`/\\`/g' \
+| intent_something
+
+# handle cleanup in intentions-queue
+printf 'rm -rf --one-file-system "%s"\n' \
+ "${tmp_dir}" \
+| intent_something
+trap - EXIT
+
+execute_all_intentions
trigger_mirror_refreshs