Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/db-update
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-12 09:45:15 +0100
committerErich Eckner <git@eckner.net>2018-03-12 09:45:15 +0100
commitecc8af9665697dd8b2b074cab4fc14ea780c5915 (patch)
tree519b9809d8dd84ec0e86a800c24389c2f8843393 /bin/db-update
parentb8f92b3a98ef521d15140fa4c28327e85f73d71e (diff)
bin/db-update: only delete/move parts of state files to avoid unnecessary insanities
Diffstat (limited to 'bin/db-update')
-rwxr-xr-xbin/db-update47
1 files changed, 41 insertions, 6 deletions
diff --git a/bin/db-update b/bin/db-update
index 001f030..01a38ad 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -277,24 +277,59 @@ for source_stability in 'testing' 'staging'; do
} | \
mysql_run_query
- # TODO: this may delete too much, but these files will be obsolete soon anyway ...
+ sed_apply_rm=$(
+ while read -r pkg _ _; do
+ printf '/^%s$/d\n' "$(str_to_regex "${pkg}")"
+ done < \
+ "${tmp_dir}/rm"
+ )
+
+ sed_apply_remove_part_of_mv=$(
+ while read -r pkg _ _; do
+ printf '/^%s$/d\n' "$(str_to_regex "${pkg}")"
+ done < \
+ "${tmp_dir}/mv"
+ )
+
+ sed_apply_move_part_of_mv=$(
+ while read -r pkg _ _; do
+ printf '/^%s$/{\n' "$(str_to_regex "${pkg}")"
+ printf 'w %%s\n'
+ printf 'd\n'
+ printf '}\n'
+ done < \
+ "${tmp_dir}/mv"
+ )
+
find "${work_dir}/package-states/" \
\( \
-name '*.done' -o \
-name '*.testing' -o \
-name '*.tested' \
\) \
- -exec grep -qxF "$(cut -d' ' -f1 < "${tmp_dir}/rm")" '{}' \; \
- -delete
+ -exec sed -i "${sed_apply_rm}" '{}' \;
find "${work_dir}/package-states/" \
-name '*.tested' \
- -exec grep -qxF "$(cut -d' ' -f1 < "${tmp_dir}/mv")" '{}' \; \
- -delete
+ -exec sed -i "${sed_apply_remove_part_of_mv}" '{}' \;
find "${work_dir}/package-states/" \
-name '*.done' \
-exec grep -qxF "$(cut -d' ' -f1 < "${tmp_dir}/mv")" '{}' \; \
-printf '%p\n' | \
while read -r sf; do
- mv "${sf}" "${sf%.done}.testing"
+ sed -i "$(
+ printf '%s\n' "${sed_apply_move_part_of_mv}" | \
+ sed '
+ s,%s,'"${sf%.done}.testing"',g
+ '
+ )" "${sf}"
done
+ find "${work_dir}/package-states/" \
+ \( \
+ -name '*.done' -o \
+ -name '*.testing' -o \
+ -name '*.tested' \
+ \) \
+ -type f \
+ -not -exec test -s '{}' \; \
+ -delete
done