Message ID | 1431434941-15155-1-git-send-email-martin.strbacka@nic.cz |
---|---|
State | Superseded |
Delegated to: | Jo-Philipp Wich |
Headers | show |
I tested the patch in my build system and it seems to work ok. Having a proper error code from the feeds updating would enable better control flow in a build script, so hopefully this gets accepted.
On 12/05/2015 14:49, Martin Strbacka wrote: > Hello, > I found out that if I make a mistake in a branch or commit expression in the feeds.conf file the updating procedure fails silently. This patch fixes this behavior and returns error code 1 if something went wrong. > > Best Regards, > Martin Strbačka > > Signed-off-by: Martin Strbacka <martin.strbacka@nic.cz> would it not be easier to do this --> if (!update_feed(...)) { exit 1; } also i am not sure if we want the script to abort if one of the feeds has failed John > --- > scripts/feeds | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/scripts/feeds b/scripts/feeds > index 89cb5a2..ece9bb0 100755 > --- a/scripts/feeds > +++ b/scripts/feeds > @@ -687,6 +687,7 @@ sub update { > my %opts; > my $feed_name; > my $perform_update=1; > + my $failed=0; > > $ENV{SCAN_COOKIE} = $$; > $ENV{OPENWRT_VERBOSE} = 's'; > @@ -711,8 +712,10 @@ sub update { > if ( ($#ARGV == -1) or $opts{a}) { > foreach my $feed (@feeds) { > my ($type, $name, $src) = @$feed; > - next unless update_feed($type, $name, $src, $perform_update) == 1; > - last; > + if(update_feed($type, $name, $src, $perform_update) == 1) { > + $failed=1; > + last; > + } > } > } else { > while ($feed_name = shift @ARGV) { > @@ -721,14 +724,13 @@ sub update { > if($feed_name ne $name) { > next; > } > - update_feed($type, $name, $src, $perform_update); > + update_feed($type, $name, $src, $perform_update) == 0 or $failed=1; > } > } > } > > refresh_config(); > - > - return 0; > + return $failed; > } > > sub feed_config() { > > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel >
John Crispin wrote:
> also i am not sure if we want the script to abort if one of the feeds has
failed
The typical scenario for somone building regularly private builds is that
updating fails due to conflicting local modifications. The user might have a
"daily" build script that updates the sources and then continues with the
build. Having the build script to stop after a feed update failure is
practical. You generally want to fix the conflict instead of just charging
blindly ahead and building from partially stale sources.
For example, my build environment contains this proposed patch and the daily
build script includes check for update failure:
./scripts/feeds update -a
[ "$?" -ne 0 ] && echo "Updating the feeds failed." && exit 1
If you feel that the "break after one feed fails to update" is to strict, one
solution could be to continue updating other feeds despite the failure, but
still return the error code in any case just to indicate that one feed
failed. That would enable the user to select, if he wants to check for that
error code.
Currently the error code is lost. There is no feedback of a possible failure.
On 22.5.2015 16:59, John Crispin wrote: > also i am not sure if we want the script to abort if one of the feeds > has failed > I have submitted an alternative version that simplifies the code and just returns the error information, but tries to update all feeds despite failure at one of them. https://patchwork.ozlabs.org/patch/475985/
Hello John, On 22.5.2015 15:59, John Crispin wrote: > would it not be easier to do this --> > > if (!update_feed(...)) { > exit 1; > } I have nothing against that. But this leads again to aborting the script after first failure. > > also i am not sure if we want the script to abort if one of the feeds > has failed But that's what it did originally. Martin
diff --git a/scripts/feeds b/scripts/feeds index 89cb5a2..ece9bb0 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -687,6 +687,7 @@ sub update { my %opts; my $feed_name; my $perform_update=1; + my $failed=0; $ENV{SCAN_COOKIE} = $$; $ENV{OPENWRT_VERBOSE} = 's'; @@ -711,8 +712,10 @@ sub update { if ( ($#ARGV == -1) or $opts{a}) { foreach my $feed (@feeds) { my ($type, $name, $src) = @$feed; - next unless update_feed($type, $name, $src, $perform_update) == 1; - last; + if(update_feed($type, $name, $src, $perform_update) == 1) { + $failed=1; + last; + } } } else { while ($feed_name = shift @ARGV) { @@ -721,14 +724,13 @@ sub update { if($feed_name ne $name) { next; } - update_feed($type, $name, $src, $perform_update); + update_feed($type, $name, $src, $perform_update) == 0 or $failed=1; } } } refresh_config(); - - return 0; + return $failed; } sub feed_config() {
Hello, I found out that if I make a mistake in a branch or commit expression in the feeds.conf file the updating procedure fails silently. This patch fixes this behavior and returns error code 1 if something went wrong. Best Regards, Martin Strbačka Signed-off-by: Martin Strbacka <martin.strbacka@nic.cz> --- scripts/feeds | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)