summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-06-02 10:13:00 +0200
committerErich Eckner <git@eckner.net>2017-06-02 10:13:57 +0200
commit538b87e91cd880f81fbba4f4ad46135eef6aa695 (patch)
tree30ce0e1551473a36a6b82af3e0be5d4235b02f94
parentc5527d82042b5b27306ded6e44fabcee09f94cb3 (diff)
downloadbuilder-538b87e91cd880f81fbba4f4ad46135eef6aa695.tar.xz
bin/get-package-updates: new option "-b"
-rwxr-xr-xbin/get-package-updates63
1 files changed, 58 insertions, 5 deletions
diff --git a/bin/get-package-updates b/bin/get-package-updates
index ce02978..fc6cf29 100755
--- a/bin/get-package-updates
+++ b/bin/get-package-updates
@@ -10,6 +10,53 @@
. "${0%/*}/../conf/default.conf"
+usage() {
+ >&2 echo ''
+ >&2 echo 'get-package-updates: check for packages that need to be built,'
+ >&2 echo ' and build a list in the proper build order'
+ >&2 echo ''
+ >&2 echo 'possible options:'
+ >&2 echo ' -b|--block: If necessary, wait for lock blocking.'
+ >&2 echo ' -h|--help: Show this help and exit.'
+ [ -z "$1" ] && exit 1 || exit $1
+}
+
+eval set -- "$(
+ getopt -o bh \
+ --long block \
+ --long help \
+ -n "$(basename "$0")" -- "$@" || \
+ echo usage
+)"
+
+block=false
+
+while true
+do
+ case "$1" in
+ -b|--block)
+ block=true
+ ;;
+ -h|--help)
+ usage 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ >&2 echo 'Whoops, forgot to implement option "'"$1"'" internally.'
+ exit -1
+ ;;
+ esac
+ shift
+done
+
+if [ $# -ne 0 ]; then
+ >&2 echo 'Too many arguments.'
+ usage
+fi
+
# delete_package package
# mark $package for deletion
delete_package() {
@@ -47,11 +94,17 @@ done
# Create a lock file for build list.
-exec 9> "${build_list_lock_file}"
-if ! flock -n 9; then
- >&2 echo 'come back (shortly) later - I cannot lock build list.'
- exit
-fi
+while true; do
+ exec 9> "${build_list_lock_file}"
+ if flock -n 9; then
+ break
+ fi
+ if ! ${block}; then
+ >&2 echo 'come back (shortly) later - I cannot lock build list.'
+ exit
+ fi
+ sleep 0.1
+done
echo 'Check modified packages from the last update, and put them to the build list.'