Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-01-31 09:34:56 +0100
committerErich Eckner <git@eckner.net>2020-01-31 09:44:57 +0100
commitb2554880deb779f50aa82e73b247edf3a63b8837 (patch)
tree05003f4f29c58d03e92af987444f9280291e78ce
parent8048b29f90d956a295349d03ab91dcbd23106d34 (diff)
lib/intentions-queue: make intentions_left() work similar to flock and verbose_flock()
-rwxr-xr-xbin/bootstrap-mysql2
-rwxr-xr-xbin/copy-to-build-support13
-rwxr-xr-xbin/create-build-support-package6
-rwxr-xr-xbin/db-update2
-rwxr-xr-xbin/delete-packages2
-rwxr-xr-xbin/modify-package-state2
-rwxr-xr-xlib/intentions-queue11
7 files changed, 19 insertions, 19 deletions
diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql
index cf055f7..711f3d1 100755
--- a/bin/bootstrap-mysql
+++ b/bin/bootstrap-mysql
@@ -20,7 +20,7 @@ if ! verbose_flock -s -n 7; then
>&2 echo 'Cannot get package-database lock.'
exit 1
fi
-if intentions_left; then
+if intentions_left -n; then
>&2 echo 'There are still intentions in the queue.'
exit 1
fi
diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support
index bb7e421..0dcc298 100755
--- a/bin/copy-to-build-support
+++ b/bin/copy-to-build-support
@@ -77,16 +77,9 @@ verbose_flock -s ${wait_for_lock} 9
exec 8> "${package_database_lock_file}"
verbose_flock ${wait_for_lock} 8
-if [ -z "${wait_for_lock}" ]; then
- while intentions_left; do
- >&2 echo 'There are still intentions in the queue.'
- sleep 1
- done
-else
- if intentions_left; then
- >&2 echo 'come back (shortly) later - There are still intentions in the queue.'
- exit 1
- fi
+if intentions_left ${wait_for_lock}; then
+ >&2 echo 'come back (shortly) later - There are still intentions in the queue.'
+ exit 1
fi
tmp_dir=$(mktemp -d "${work_dir}/tmp.copy-to-build-support.0.XXXXXXXXXX")
diff --git a/bin/create-build-support-package b/bin/create-build-support-package
index dd8ddc3..fd4d456 100755
--- a/bin/create-build-support-package
+++ b/bin/create-build-support-package
@@ -256,10 +256,10 @@ elif [ -n "${shim_package}" ]; then
exec 8> "${package_database_lock_file}"
verbose_flock ${wait_for_lock} 8
- while intentions_left; do
+ if intentions_left ${wait_for_lock}; then
>&2 echo 'There are still intentions in the queue.'
- sleep 1
- done
+ exit 1
+ fi
original_pkg_id=$(
# shellcheck disable=SC2016
diff --git a/bin/db-update b/bin/db-update
index 26d2d36..e1255d6 100755
--- a/bin/db-update
+++ b/bin/db-update
@@ -175,7 +175,7 @@ if ! ${no_action}; then
exit 0
fi
- if intentions_left; then
+ if intentions_left ${block_flag}; then
>&2 echo 'come back (shortly) later - There are still intentions in the queue.'
exit 0
fi
diff --git a/bin/delete-packages b/bin/delete-packages
index 7486644..bfcb9ac 100755
--- a/bin/delete-packages
+++ b/bin/delete-packages
@@ -127,7 +127,7 @@ if [ -z "${no_action_option}" ]; then
exit 0
fi
- if intentions_left; then
+ if intentions_left ${block_flag}; then
>&2 echo 'come back (shortly) later - There are still intentions in the queue.'
exit 0
fi
diff --git a/bin/modify-package-state b/bin/modify-package-state
index 9373467..2b7ebbc 100755
--- a/bin/modify-package-state
+++ b/bin/modify-package-state
@@ -145,7 +145,7 @@ if ! verbose_flock ${wait_for_lock} 8; then
exit
fi
-if intentions_left; then
+if intentions_left ${wait_for_lock}; then
>&2 echo 'There are still intentions in the queue.'
exit
fi
diff --git a/lib/intentions-queue b/lib/intentions-queue
index e9b79de..c92a4d1 100755
--- a/lib/intentions-queue
+++ b/lib/intentions-queue
@@ -68,11 +68,18 @@ execute_intention() {
"${intentions_directory}/intention.${next_number}"
}
-# intentions_left
+# intentions_left [-n]
# check if there are undone intentions left
# return 0 if there is something left to do
# return 1 if nothing is queued
+# with -n: return immediately
+# without -n: wait until nothing more to do
intentions_left() {
+ if [ ! "x$1" = 'x-n' ]; then
+ while intentions_left -n; do
+ sleep 1
+ done
+ fi
find "${intentions_directory}" \
-maxdepth 1 \
-type f \
@@ -90,7 +97,7 @@ intentions_left() {
# execute_all_intentions
# executes all intentions
execute_all_intentions() {
- while intentions_left; do
+ while intentions_left -n; do
execute_intention
done
}