index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/get-assignment | 48 | ||||
-rwxr-xr-x | bin/return-assignment | 63 |
diff --git a/bin/get-assignment b/bin/get-assignment index fb4e257..179487e 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -2,6 +2,7 @@ # receive one package to be built from the build-list whose dependencies # are already satisfied or which breaks a dependency cycle +# accepts a comma separated list of prefered packages as the first argument # exit code shows state of success: # 0: ok, I gave you an assignment @@ -14,34 +15,30 @@ # shellcheck source=conf/default.conf . "${0%/*}/../conf/default.conf" -# TODO: hand out blocked packages if they are a prefered package - mkdir -p "${work_dir}/package-states" hand_out_assignment() { - # locked and blocked packages won't be handed out - if package_locked_or_blocked "$1" "$2" "$3" "$4"; then - return 0 - fi - # we don't care anymore if an older version of this package was - # "locked" or "broken" (we keep only marker for older "done" packages) - find "${work_dir}/package-states" -maxdepth 1 | \ - grep "/$(str_to_regex "${1}")\(\.[^.]\+\)\{3\}\.\(locked\|broken\)\$" | \ - grep -v "/$(str_to_regex "$1.$2.$3.$4.")[^.]\+\$" | \ - xargs -rn1 rm -f - - { - grep -vxF "$1 $2 $3 $4" "${work_dir}/build-list" || \ - true - printf '%s %s %s %s\n' "$1" "$2" "$3" "$4" - } | \ - sponge "${work_dir}/build-list" + # "locked" or "broken" + find "${work_dir}/package-states" -maxdepth 1 -regextype grep \ + -regex ".*/$(str_to_regex "$1")\(\.[^.]\+\)\{3\}\.\(locked\|broken\)" \ + -not -regex ".*/$(str_to_regex "$1.$2.$3.$4.")[^.]\+" \ + -delete + + # move that build order to the end of the build-list + sed -i ' + /^'"$(str_to_regex "$1 $2 $3 $4")"'$/ { + $ b + d + } + $ a '"$1 $2 $3 $4"' + ' "${work_dir}/build-list" echo "$1 $2 $3 $4" # shellcheck disable=SC2154 - echo "${slave}" > "${work_dir}/package-states/$1.$2.$3.$4.locked" + echo "${slave}" >> \ + "${work_dir}/package-states/$1.$2.$3.$4.locked" # lock every loop this package breaks find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \ @@ -90,9 +87,12 @@ while read -r package git_revision mod_git_revision repository; do generate_package_metadata "${package}.${git_revision}.${mod_git_revision}.${repository}" if [ -f "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked" ]; then - if [ "${slave}" = "$(head -n1 "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked")" ]; then - echo "${package} ${git_revision} ${mod_git_revision} ${repository}" - exit + # has this slave already got or does he prefer this assignment? + # note, that the dependencies are met, because this package is already locked + if grep -qxF "${slave}" "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked" || \ + printf ',%s,' "$1" | \ + grep -qF ",${package},"; then + hand_out_assignment "${package} ${git_revision} ${mod_git_revision} ${repository}" fi elif [ ! -f "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.blocked" ]; then pending_packages=true @@ -171,7 +171,7 @@ for iteration in 'prefered' 'fresh' 'loops' 'broken'; do while read -r package git_revision mod_git_revision repository; do - # package locked? + # package locked? (we have taken care of those in the previous loop) if [ -f "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.locked" ]; then continue fi diff --git a/bin/return-assignment b/bin/return-assignment index 7fb6005..36875bc 100755 --- a/bin/return-assignment +++ b/bin/return-assignment @@ -54,8 +54,8 @@ if [ "$5" = 'ERROR' ]; then fi # shellcheck disable=SC2154 - if [ "${slave}" != "$(head -n1 "${work_dir}/package-states/$1.$2.$3.$4.locked")" ]; then - # whoops, this package is built by someone else + if ! grep -qxF "${slave}" "${work_dir}/package-states/$1.$2.$3.$4.locked"; then + # whoops, this package is not built by this slave exit 0 fi @@ -67,31 +67,38 @@ if [ "$5" = 'ERROR' ]; then --transform="s|^|$1.$2.$3.$4.|" \ '*.build-log.gz' - head -n1 \ - "${work_dir}/package-states/$1.$2.$3.$4.locked" >> \ + # shellcheck disable=SC2154 + echo "${slave}" >> \ "${work_dir}/package-states/$1.$2.$3.$4.broken" - rm "${work_dir}/package-states/$1.$2.$3.$4.locked" - - # unlock every loop this package would have broken and which is not - # broken by another locked package - locked_packages=$( - find "${work_dir}/package-states/" -maxdepth 1 -name '*.locked' -printf '%f\n' | \ - sed 's@^\(.\+\)\.\([0-9a-f]\{40\}\.\)\{2\}[^.]\+\.locked$@\1@' - ) - find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \ - -regex '.*/loop_[0-9]\+' \ - -exec grep -qxF "$1" '{}' \; \ - -not -exec grep -qxF "${locked_packages}" '{}' \; \ - -exec rm '{}.locked' \; - - # move build order to end of build list - - sed -i \ - "/^$(str_to_regex "$1 $2 $3 $4")\$/d" \ - "${work_dir}/build-list" - echo "$1 $2 $3 $4" >> \ - "${work_dir}/build-list" + # shellcheck disable=SC2154 + sed -i ' + /^'"$(str_to_regex "${slave}")"'$/d + ' "${work_dir}/package-states/$1.$2.$3.$4.locked" + if [ ! -s "${work_dir}/package-states/$1.$2.$3.$4.locked" ]; then + rm "${work_dir}/package-states/$1.$2.$3.$4.locked" + + # unlock every loop this package would have broken and which is not + # broken by another locked package + locked_packages=$( + find "${work_dir}/package-states/" -maxdepth 1 -name '*.locked' -printf '%f\n' | \ + sed 's@^\(.\+\)\.\([0-9a-f]\{40\}\.\)\{2\}[^.]\+\.locked$@\1@' + ) + find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \ + -regex '.*/loop_[0-9]\+' \ + -exec grep -qxF "$1" '{}' \; \ + -not -exec grep -qxF "${locked_packages}" '{}' \; \ + -exec rm '{}.locked' \; + + # move that build order to the end of the build-list + sed -i ' + /^'"$(str_to_regex "$1 $2 $3 $4")"'$/ { + $ b + d + } + $ a '"$1 $2 $3 $4"' + ' "${work_dir}/build-list" + fi exit 0 @@ -118,6 +125,12 @@ if ! grep -qxF "$1 $2 $3 $4" "${work_dir}/build-list" || exit 2 fi +# shellcheck disable=SC2154 +if ! grep -qxF "${slave}" "${work_dir}/package-states/$1.$2.$3.$4.locked"; then + >&2 echo 'Whoops, this package is not built by this slave.' + exit 2 +fi + clean_up_tmp_dir() { cd "${base_dir}" rm -rf --one-file-system "${tmp_dir}" |