Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-10-24 13:46:13 +0200
committerErich Eckner <git@eckner.net>2017-10-24 13:46:13 +0200
commit9f16621f04457bca9ac720ed542fe4626d344a1f (patch)
tree3fc4cb98b2baea554b38eb12a7ea308489fbf9bb /bin
parent62ae0182ea898f88445d9402010c3e0d9194d0f5 (diff)
bin/build-packages, bin/get-assignment: add options to prefer a build order
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build-packages22
-rwxr-xr-xbin/get-assignment99
2 files changed, 91 insertions, 30 deletions
diff --git a/bin/build-packages b/bin/build-packages
index b06a1c7..2c326fa 100755
--- a/bin/build-packages
+++ b/bin/build-packages
@@ -17,11 +17,15 @@ usage() {
>&2 echo ' -l|--local pkgname.git-revision.git-mod-revision.repository:'
>&2 echo ' Build the given package without asking / reporting to the'
>&2 echo ' build master (except -u is given). Cannot be combined with'
- >&2 echo ' -n, -t or -x.'
+ >&2 echo ' -n, -p, -t or -x.'
>&2 echo ' -n count: Build $count packages (if available), then exit.'
>&2 echo ' $count=0 is interpreted as infinity.'
>&2 echo ' The default is $count=1 or 0 iff -t or -x is given.'
>&2 echo ' Cannot be combined with -l.'
+ >&2 echo ' -p|--prefer pkgname:'
+ >&2 echo ' Ask the build master to get an assignment for the given'
+ >&2 echo ' package but built what is offered anyway. Cannot be combined'
+ >&2 echo ' with -l.'
>&2 echo ' -s|--straw $straw:'
>&2 echo ' Use this straw instead of the preconfigured ones. -- May be'
>&2 echo ' given multiple times to allow using multiple straws.'
@@ -35,9 +39,10 @@ usage() {
}
eval set -- "$(
- getopt -o hl:n:s:t:ux \
+ getopt -o hl:n:p:s:t:ux \
--long help \
--long local: \
+ --long prefer: \
--long straw: \
--long upload \
-n "$(basename "$0")" -- "$@" || \
@@ -47,6 +52,7 @@ eval set -- "$(
unset count
unset forced_package
unset forced_straws
+unset prefered_package
exit_after_failure=false
upload_to_build_master=false
timeout=0
@@ -71,6 +77,14 @@ do
[ "${count}" -eq 0 ] && \
count=-1
;;
+ -p|--prefer)
+ shift
+ if [ -n "${prefered_package}" ]; then
+ >&2 echo 'Option -p, --prefer can be given only once.'
+ usage
+ fi
+ prefered_package="$1"
+ ;;
-s|--straw)
shift
forced_straws="${forced_straws} $1"
@@ -105,6 +119,7 @@ fi
if [ -n "${forced_package}" ]; then
if [ -n "${count}" ] || \
[ "${timeout}" -ne 0 ] || \
+ [ -n "${prefered_package}" ] || \
${exit_after_failure}; then
>&2 echo 'Conflicting flags.'
usage
@@ -143,11 +158,12 @@ while [ "${count}" -ne 0 ]; do
err=0
if [ -z "${forced_package}" ]; then
package=$(
+ # shellcheck disable=SC2029
ssh \
-i "${master_build_server_identity}" \
-p "${master_build_server_port}" \
"${master_build_server_user}@${master_build_server}" \
- 'get-assignment'
+ 'get-assignment' "${prefered_package}"
) || err=$?
else
package=$(
diff --git a/bin/get-assignment b/bin/get-assignment
index ece83c7..fc56398 100755
--- a/bin/get-assignment
+++ b/bin/get-assignment
@@ -34,6 +34,13 @@ hand_out_assignment() {
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"
+
echo "$1 $2 $3 $4"
# shellcheck disable=SC2154
echo "${slave}" > "${work_dir}/package-states/$1.$2.$3.$4.locked"
@@ -101,51 +108,89 @@ if ! ${pending_packages}; then
exit 3
fi
-# Find first package of build-list whose dependencies are all met
-
-for hand_out_broken in false true; do
+# Find first package of build-list whose "dependencies" are all met
+# 1st: prefered packages on the build list which have all dependencies met
+# 2nd: unbroken packages on the build list which have all dependencies met
+# 3rd: unbroken packages breaking a loop
+
+for iteration in 'prefered' 'fresh' 'loops' 'broken'; do
+
+ case "${iteration}" in
+ 'prefered')
+ hand_out_broken=true
+ hand_out_loop=false
+ echo "$1" | \
+ tr ',' '\n' | \
+ sort -u > \
+ "${tmp_dir}/hand-out-only-these-packages"
+ ;;
+ 'fresh')
+ hand_out_broken=false
+ hand_out_loop=false
+ {
+ grep -vxF 'break_loops' "${work_dir}/build-list"
+ find "${work_dir}/package-states" -name '*.broken' -printf '%f\n' | \
+ sed '
+ s|\.\([^.]\+\)\.\([^.]\+\)\.\([^.]\+\)\.[^.]\+$| \1 \2 \3|
+ p
+ '
+ } | \
+ sort -k1,1 -k2 | \
+ uniq -u | \
+ cut -d' ' -f1 | \
+ uniq > \
+ "${tmp_dir}/hand-out-only-these-packages"
+ ;;
+ 'loops')
+ hand_out_broken=false
+ hand_out_loop=true
+ find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \
+ -regex '.*/loop_[0-9]\+' \
+ -exec cat {} \; | \
+ sort -u > \
+ "${tmp_dir}/hand-out-only-these-packages"
+ ;;
+ esac
+
+ grep -vxF 'break_loops' "${work_dir}/build-list" | \
+ cat -n | \
+ sort -k2,2 | \
+ join -1 1 -2 2 -o 2.1,2.2,2.3,2.4,2.5 "${tmp_dir}/hand-out-only-these-packages" - | \
+ sort -k1,1 | \
+ sed 's|^\s*\S\+\s\+||' > \
+ "${tmp_dir}/try-to-hand-out-these-packages"
- # shellcheck disable=SC2094
while read -r package git_revision mod_git_revision repository; do
- if [ -z "${git_revision}${mod_git_revision}${repository}" ] && \
- [ "${package}" = 'break_loops' ]; then
- if ${hand_out_broken}; then
- first=true
- while read -r s; do
- if [ "${s}" = 'break_loops' ] && \
- ${first}; then
- first=false
- continue
- fi
- printf '%s\n' "${s}"
- done < \
- "${work_dir}/build-list" | \
- sponge "${work_dir}/build-list"
- insert_break_loops_orders "${work_dir}/build-list"
- break
- else
- continue
- fi
- fi
-
if package_locked_or_blocked "${package}" "${git_revision}" "${mod_git_revision}" "${repository}"; then
continue
fi
+ # package broken?
if ! ${hand_out_broken} && \
[ -f "${work_dir}/package-states/${package}.${git_revision}.${mod_git_revision}.${repository}.broken" ]; then
continue
fi
+ # dependencies met?
if [ -n "$(find_dependencies_on_build_list "${package}" "${git_revision}" "${mod_git_revision}" "${repository}")" ]; then
- continue
+ # do we hand out looped packages?
+ if ! ${hand_out_loop}; then
+ continue
+ fi
+ # is it a looped package?
+ if ! find "${work_dir}/build-list.loops" -maxdepth 1 -regextype grep \
+ -regex '.*/loop_[0-9]\+' \
+ -exec cat {} \; | \
+ grep -qxF "${package}"; then
+ continue
+ fi
fi
hand_out_assignment "${package}" "${git_revision}" "${mod_git_revision}" "${repository}"
done < \
- "${work_dir}/build-list"
+ "${tmp_dir}/try-to-hand-out-these-packages"
done