index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2017-04-23 12:02:07 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-04-23 12:02:07 +0200 |
commit | 1b08ec576fc105be8542a61aceb1b3683557e4b3 (patch) | |
tree | 40102ead0f24f5f599fb74c25e2024403346ada2 /bin | |
parent | 977b56f34af45e9ae72e0648796a18b8c7482215 (diff) |
-rwxr-xr-x | bin/get-assignment | 48 |
diff --git a/bin/get-assignment b/bin/get-assignment index f74399d..fed7056 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -3,6 +3,16 @@ # receive one package to be built from the build-list whose dependencies # are already satisfied or which breaks a dependency cycle +# exit code shows state of success: +# 0: ok, I gave you an assignment +# 1: come back (shortly) later - I was running already +# 2: come back later - there are still packages to be built, +# but currently none has all its dependencies ready +# 3: come back after the next run of get-package-updates - currently +# there are no pending packages +# 4: come back, when you've done your work - you hit the limit on +# maximum allowed parallel jobs per ip + # TODO: # respect build-manually-list @@ -27,7 +37,41 @@ hand_out_assignment() { # Create a lock file. exec 9> "${lock_file}" -flock -n 9 || exit +if ! flock -n 9; then + >&2 echo 'come back (shortly) later - I was running already' + exit 1 +fi + +# Check if there are any pending packages at all and if the requester +# has already hit its max_parallel_build_per_client limit. + +num_jobs=0 +pending_packages=false + +while read -r package git_revision repository; do + + if [ -f "${work_dir}/package-states/${package}.${git_revision}.${repository}.locked" ]; + then + if [ "${SSH_CLIENT%% *}" = "$(cat "${work_dir}/package-states/${package}.${git_revision}.${repository}.locked")" ]; then + num_jobs=$[${num_jobs}+1]; + fi + else + pending_packages=true + fi + +done < "${work_dir}/build-list" + +if ! ${pending_packages}; then + >&2 echo 'come back after the next run of get-package-updates - currently there are no pending packages' + rm -f "${lock_file}" + exit 3 +fi + +if [ ${num_jobs} -ge ${max_parallel_build_per_client} ]; then + >&2 echo "come back, when you've done your work - you hit the limit on maximum allowed parallel jobs per ip" + rm -f "${lock_file}" + exit 4 +fi while read -r package git_revision repository; do @@ -62,4 +106,6 @@ fi # Remove the lock file +>&2 echo 'come back later - there are still packages to be built, but currently none has all its dependencies ready' rm -f "${lock_file}" +exit 2 |