summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-01-22 15:41:04 +0100
committerErich Eckner <git@eckner.net>2019-01-22 15:41:04 +0100
commitb468ce1d1b7edab972cc18a6655b7e8fe55b416a (patch)
treec6782d1051367b7a609fd7091355ffb3b9a7643b
parent350468476ee86bfcf7f717dd9a8496bee172c236 (diff)
downloadbuilder-b468ce1d1b7edab972cc18a6655b7e8fe55b416a.tar.xz
bin/return-assignment: only reschedule packages that have not been touched since the currently-reported-as-broken build has begun
-rwxr-xr-xbin/return-assignment84
1 files changed, 73 insertions, 11 deletions
diff --git a/bin/return-assignment b/bin/return-assignment
index a4612cf..0f14d84 100755
--- a/bin/return-assignment
+++ b/bin/return-assignment
@@ -219,16 +219,26 @@ if [ "$6" = 'ERROR' ]; then
} | \
mysql_run_query
- # release lock on build-list - otherwise seed-build-list won't run
- flock -u 9
-
if ! ${was_broken_before}; then
- haskell_rebuild_packages=$(
- find "${build_log_directory}/error" -type f \
- -name "$1.$2.$3.$4.$5.*.build-log.gz" \
- -exec zgrep -qFx ' The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.' {} \; \
- -exec zcat {} \; | \
+ # this will hold a list of "$time_stamp $haskell_package" meaning
+ # that the given $haskell_package did not work at the given
+ # $time_stamp
+ broken_haskell_packages=$(mktemp 'tmp.return-assignment.broken-haskell-packages.XXXXXXXXXX' --tmpdir)
+ trap 'rm "${broken_haskell_packages}"' EXIT
+
+ find "${build_log_directory}/error" -type f \
+ -name "$1.$2.$3.$4.$5.*.build-log.gz" \
+ -exec zgrep -qFx ' The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.' {} \; \
+ -printf '%p\n' | \
+ sed '
+ s/^.*\.\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\)\.build-log\.gz$/\1 \0/
+ ' | \
+ while read -r build_time build_log; do
+ build_time=$(
+ date +%s -d"${build_time}"
+ )
+ zcat "${build_log}" | \
sed -n '
s/^installed package \(.*\) is broken due to missing package .*$/\1/
T
@@ -236,12 +246,64 @@ if [ "$6" = 'ERROR' ]; then
' | \
tr ' ' '\n' | \
sed '
+ s/^/'"${build_time}"'\t/
+ s/-[0-9.]\+$//
+ '
+ done | \
+ sort -k2,2 -k1nr,1 | \
+ uniq -f1 > \
+ "${broken_haskell_packages}"
+
+ # now we look if the broken packages have been rebuilt in the meantime
+ haskell_rebuild_packages=$(
+ # shellcheck disable=SC2016
+ {
+ printf 'CREATE TEMPORARY TABLE `broken`(`time_stamp` BIGINT,`pkgname` VARCHAR(64),UNIQUE KEY `pkgname`(`pkgname`),KEY `time_stamp`(`time_stamp`));\n'
+ printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `broken`(`time_stamp`,`pkgname`);\n' \
+ "${broken_haskell_packages}"
+ printf 'SELECT DISTINCT `broken`.`pkgname`'
+ printf ' FROM `broken`'
+ printf ' WHERE NOT EXISTS ('
+ printf 'SELECT 1'
+ printf ' FROM `binary_packages`'
+ mysql_join_binary_packages_binary_packages_in_repositories
+ mysql_join_binary_packages_in_repositories_repositories
+ printf ' AND ('
+ printf '`repositories`.`is_on_master_mirror`'
+ printf ' OR `repositories`.`id`=%s' \
+ "${repository_ids__any_build_list}"
+ printf ')'
+ mysql_join_binary_packages_build_assignments
+ printf ' JOIN `architecture_compatibilities`'
+ printf ' ON `architecture_compatibilities`.`fully_compatible`'
+ printf ' AND `architecture_compatibilities`.`built_for`=`build_assignments`.`architecture`'
+ printf ' JOIN `architectures`'
+ printf ' ON `architecture_compatibilities`.`runs_on`=`architectures`.`id`'
+ printf ' AND `architectures`.`name`=from_base64("%s")' \
+ "$(
+ printf '%s' "$5" | \
+ base64 -w0
+ )"
+ printf ' WHERE ('
+ printf '`binary_packages`.`pkgname`=`broken`.`pkgname`'
+ printf ' OR `binary_packages`.`pkgname`=CONCAT("haskell-",`broken`.`pkgname`)'
+ printf ') AND ('
+ printf '`build_assignments`.`return_date`>FROM_UNIXTIME(`broken`.`time_stamp`)'
+ printf ' OR `repositories`.`id`=%s' \
+ "${repository_ids__any_build_list}"
+ printf ')'
+ printf ');\n'
+ } | \
+ mysql_run_query | \
+ sed '
s/^/-p ^(haskell-)?/
- s/-[0-9.]\+$/\$/
- ' | \
- sort -u
+ s/$/$/
+ '
)
+ # release lock on build-list - otherwise seed-build-list won't run
+ flock -u 9
+
rescheduled_packages=$(
if [ -n "${haskell_rebuild_packages}" ]; then
# shellcheck disable=SC2086