From 9218d819b7570950ca7de64c8a482ffa376c0800 Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Sun, 6 Nov 2016 23:31:28 +0100 Subject: [PATCH 1/1] Failing Autoupdate doesn't kill the job anymor, just issues a warning. --- build-farm.conf.template | 7 ++++++ run_branches | 48 ++++++++++++++++++++++++---------------- run_build | 3 --- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/build-farm.conf.template b/build-farm.conf.template index fdaa929..268e279 100644 --- a/build-farm.conf.template +++ b/build-farm.conf.template @@ -66,6 +66,13 @@ my $farm_user_name = 'farm'; animal => "alias_assigned_by_build_team", secret => "secret_assigned_by_build_team", + # allow automatic updates of the buildfarm client code. + # Leave it *unset* to get the default behaviour, set it + # to some false value to disable automatic updates or set it + # to the name of the remote Git repo you follow for your + # buildfarm-client code. + #auto_update => 'origin', + # if force_every is a scalar it will be used on all branches, like this # for legacy reasons: # force_every => 336 , # max hours between builds, undef or 0 = unforced diff --git a/run_branches b/run_branches index 8ee1f9f..7506a52 100755 --- a/run_branches +++ b/run_branches @@ -78,35 +78,45 @@ $branch = 'global'; require $buildconf; # Check if auto-update is wanted and possible -if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update}) -{ - my $remote = $EximBuild::Conf{auto_update} // 'origin'; +eval { + if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update}) + { + my $remote = $EximBuild::Conf{auto_update} // 'origin'; - die "$0: auto-update not possible: need write permissions in @{[cwd]}\n" - if not -w '.'; + die "auto-update not possible: need write permissions in @{[cwd]}\n" + if not -w '.'; - # Get information about our remote and calculate the chance for a - # successfull auto-updat. Based on: - # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git - system("git fetch $remote") == 0 or die $? >> 8; - my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}'; die $? >> 8 if $?; - $base =~ s/^\^//; + # Get information about our remote and calculate the chance for a + # successfull auto-updat. Based on: + # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git + system("git fetch $remote") == 0 or die "'git fetch $remote' failed\n"; + my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}' or die "'git rev-parse' failed\n"; - if ($upstream ne $local) { + $base =~ s/^\^//; + + if ($upstream ne $local) { + + if ($base ne $local) { + die "the merge base is not local anymore. Refusing to `git pull`\n" + } - if ($base ne $local) { - warn "$0: the merge base is not local anymore. Refusing to `git pull`\n" - } - else { # if we're the merge base, the ff-only should work - system('git pull --ff-only') == 0 or die $? >> 8; + # except if there are local changes. We won't stop, if we + # fail to update, but we'll issue a warning + system("git pull --ff-only $remote") == 0 or die "git pull --ff-only\n"; - say "$0: re-execute after update"; - chdir $CALLED{cwd} or die "$0: Can't chdir to $CALLED{cwd}: $!\n"; + say "re-execute after update"; + chdir $CALLED{cwd} or die "Can't chdir to $CALLED{cwd}: $!\n"; exec $CALLED{argv0}, @{$CALLED{argv}}; die "Can't re-exec\n"; } } +}; + +if ($@) { + chomp $@; + warn "Automatic updated failed with `$@'\n" + ."Continue anyway\n"; } unless ( diff --git a/run_build b/run_build index 9a2fcb9..77c6de0 100755 --- a/run_build +++ b/run_build @@ -160,9 +160,6 @@ require $buildconf; #use Data::Dumper; #die Dumper \%EximBuild::conf; -# some basic checks -die "$0: need read/write permissions on '$EximBuild::conf{global_lock_dir}': $!\n" - if not -r -w $EximBuild::conf{global_lock_dir}; # Does not seem to be necessary #die "$0: permissions on '$EximBuild::conf{build_root}' should be >= 0775\n" -- 2.30.2