From cd0fafa5c54e93a38a3346a2985a452412c1182f Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 10 Oct 2005 21:00:28 +0000 Subject: - add return code - revert previous removal ( i didn't test the good version ) --- rpmbuildupdate | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/rpmbuildupdate b/rpmbuildupdate index 33bf6eb..f1ea95a 100755 --- a/rpmbuildupdate +++ b/rpmbuildupdate @@ -18,9 +18,18 @@ # add debian url ( like gnome or rh ) => cannot be done i think # use more Hdlist ( see Hdlist->build() ) +# list of the return code : +# 255 => usage +# 6 => cannot open the spec file +# 5 => random problem +# 4 => a external command failed +# 2 => invalid url +# 1 => only src is build +# 0 => no error + use strict; use AppConfig; - +use MDK::Common::File qw(basename); use File::Copy; use Cwd; use File::Spec; @@ -33,6 +42,8 @@ my ($log, $top, $rpm); sub system_die { my ($command, $message) = @_; $message ||= "$command failed"; + # in case we die + $! = 4; # do not forget , return value of 1 means failure in unix system($command) and die $message; } @@ -197,6 +208,7 @@ sub build_from_src { } sub build { + $! = 5; my ($spec_path, $pkg, $version, $release, $newversion) = @_; my ($message, $spec, @url, %specvars); my ($newrelease, $release_prefix) = ($1,$2) if $release =~ /^(.*\d+)(\D*)$/g; @@ -224,6 +236,7 @@ sub build { my $SPECFILE; if (!open($SPECFILE, $spec_path)) { print STDERR "Unable to open spec file $spec_path.\n"; + $! = 6; return; } @@ -405,7 +418,8 @@ sub build { unless ($found) { print "Unable to download file: URL is not valid ! :-(\n\n"; - return; + $! = 2; + return; } @@ -421,7 +435,10 @@ sub build { if (system("$rpm -ba $config{rpmoption} $spec_path $log")) { print "Binary build fails: building source only\n"; system("$rpm -bs $config{rpmoption} --nodeps $spec_path $log"); - } + $! = 1; + } else { + $! = 0; + } } if ($config{execafterbuild}) { @@ -580,7 +597,7 @@ Usage: rpmbuildupdate [options] [pkg] [newversion] --execute : execute an arbitrary perl command for each line of the spec file --execafterbuild : execute a shell command after the build, with the source and binary rpm as argument EOF - exit 0; + exit 255; } sub parse_rpmmon { @@ -627,3 +644,4 @@ sub main { } main; +exit $!; -- cgit v1.2.1