From eda35a90de7ebe44362fcb0444c7be5139a4567d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 4 May 2017 22:40:29 +0200 Subject: main parts should work - still a lot of TODOs left :-) --- bin/build-packages | 37 +++++++++++++++++++++-------- bin/get-assignment | 3 ++- bin/return-assignment | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/slave-build-connect | 8 ++++--- 4 files changed, 97 insertions(+), 14 deletions(-) create mode 100755 bin/return-assignment (limited to 'bin') diff --git a/bin/build-packages b/bin/build-packages index d4fc8b9..0fc20f7 100755 --- a/bin/build-packages +++ b/bin/build-packages @@ -6,9 +6,7 @@ # TODOs: # include package customizations -# handle failed builds -# actually upload the package -# use different build commands for different repositories +# use different build commands for different repositories - do we need this actually? # sign packages . "${0%/*}/../conf/default.conf" @@ -49,13 +47,32 @@ while true; do exit 1 fi - ( - cd "${PKGBUILD%/*}" - staging-i686-build - ) - # imagine a blinking cursor here - >&2 echo 'whoops, end of program reached.' - exit 42 + cd "${PKGBUILD%/*}" + success=false + for parameters in '' '-c'; do + rm -f *.pkg.tar.xz + if staging-i686-build ${parameters}; then + # build successful + tar -c *.pkg.tar.xz | \ + ssh \ + -i "${master_build_server_identity}" \ + -p "${master_build_server_port}" \ + "${master_build_server_user}@${master_build_server}" \ + 'return-assignment' "${package}" "${git_revision}" "${repository}" + success=true + break + fi + done + + if ! ${success}; then + ssh \ + -i "${master_build_server_identity}" \ + -p "${master_build_server_port}" \ + "${master_build_server_user}@${master_build_server}" \ + 'return-assignment' "${package}" "${git_revision}" "${repository}" 'ERROR' + fi + + continue ;; diff --git a/bin/get-assignment b/bin/get-assignment index 69bfb3f..ab33737 100755 --- a/bin/get-assignment +++ b/bin/get-assignment @@ -14,7 +14,8 @@ # maximum allowed parallel jobs per ip # TODO: -# respect build-manually-list +# respect build-manually-list ("blocked") +# respect broken packages . "${0%/*}/../conf/default.conf" diff --git a/bin/return-assignment b/bin/return-assignment new file mode 100755 index 0000000..a010dd4 --- /dev/null +++ b/bin/return-assignment @@ -0,0 +1,63 @@ +#!/bin/bash + +# report back on a build assignment +# either on success via: +# "$0 $package $revision $repository" and tar'ed packages on stdin +# or on failure via: +# "$0 $package $revision $repository ERROR" + +# TODO: +# properly handle if built package is out of date +# sign package database + +. "${0%/*}/../conf/default.conf" + +if [ "$4" == 'ERROR' ]; then +# the build failed on the build slave + + mv "${work_dir}/package-states/$1.$2.$3."{locked,broken} + + # unlock every loop this package would have broken and which is not + # broken by another locked package + ( + # loops broken by another locked package + ls "${work_dir}/package-states/"{*.*.*,$1.$2.$3}.locked | \ + sort | \ + uniq -u | \ + sed 's|\.locked$||' | \ + xargs -n1 sed '1d' | \ + sort -u | \ + sed 'p' + # loops broken by this package + sed '1d' "${work_dir}/package-states/$1.$2.$3" + ) | \ + sort | \ + uniq -u | \ + sed 's|$|.locked|' | \ + xargs -rn1 rm -f + + exit 0 + +fi + +# the build was successful on the build slave + +# extract package +mkdir -p "${master_mirror_directory}/$3-staging/" +cd "${master_mirror_directory}/$3-staging/" +new_files="$(tar -xv --wildcards '*.pkg.tar.xz')" +repo-add "$3-staging.db.tar.gz" $(echo "${new_files}" | grep '\.pkg\.tar\.xz$') +#new_files="$(tar -xv --wildcards '*.pkg.tar.xz'{,.sig})" +#repo-add -v -s -k "${repo_key}" "$3-staging.tar.gz" $(echo "${new_files}" | grep '\.pkg\.tar\.xz$') + +# remove all loops which are broken by this package +sed '1d' "${work_dir}/package-states/$1.$2.$3" | \ + sort -u | \ + sed 'p;s|$|.locked|' | \ + xargs -rn1 rm -f + +# remove package from build list +sed -i "/^$1 $2 $3\$/d" "${work_dir}/build-list" + +# remove package lock file +rm "${work_dir}/package-states/$1.$2.$3.locked" diff --git a/bin/slave-build-connect b/bin/slave-build-connect index 4fff765..555b694 100755 --- a/bin/slave-build-connect +++ b/bin/slave-build-connect @@ -2,8 +2,10 @@ . "${0%/*}/../conf/default.conf" -if [ "${SSH_ORIGINAL_COMMAND% *}" == "get-assignment" ]; then - /bin/bash -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}" "$@" +if [ "${SSH_ORIGINAL_COMMAND%% *}" == "get-assignment" ] || \ + [ "${SSH_ORIGINAL_COMMAND%% *}" == "return-assignment" ]; then + /bin/bash -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}" else - >&2 echo "Invalid command: ${SSH_ORIGINAL_COMMAND} $@" + >&2 echo "Invalid command: '${SSH_ORIGINAL_COMMAND%% *}'" + exit 1 fi -- cgit v1.2.3-70-g09d2