Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-07-04 11:55:18 +0200
committerErich Eckner <git@eckner.net>2017-07-04 11:55:18 +0200
commit7238c1d5b6c23e3227ebf4e10ba99eff46775fe9 (patch)
tree016b5e3855eb4a1e361546543c167696e4dfbc6b /bin/common-functions
parent4d83e12fdcea0957cdaecf766d33186d62b9e9ed (diff)
bin/get-assignment, bin/get-package-updates: adding "break_loops" order enhanced and extracted to a function
Diffstat (limited to 'bin/common-functions')
-rwxr-xr-xbin/common-functions36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 3146572..25c592f 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -424,3 +424,39 @@ recursively_umount_and_rm() {
-exec 'sudo' 'umount' '-l' '{}' ';'
rm -rf --one-file-system "${dir}"
}
+
+# insert_break_loops_orders $file
+# inserts the correct number of 'break_loops' order into $file
+
+insert_break_loops_orders() {
+ local file="$1"
+ local looped_packages
+ local line
+
+ looped_packages="$(
+ ls "${work_dir}/build-list.loops" | \
+ grep '^loop_[0-9]\+$' | \
+ sed "s|^|${work_dir}/build-list.loops/|" | \
+ xargs -r cat | \
+ sort -u | \
+ wc -l
+ )"
+
+ (
+ while read -r line; do
+ if [ "${line}" = 'break_loops' ]; then
+ if [ ${looped_packages} -eq 0 ]; then
+ continue
+ fi
+ looped_packages=$((${looped_packages}-1))
+ fi
+ printf '%s\n' "${line}"
+ done < \
+ "${file}"
+ while [ ${looped_packages} -gt 0 ]; do
+ looped_packages=$((${looped_packages}-1))
+ echo 'break_loops'
+ done
+ ) | \
+ sponge "${file}"
+}