From e44c918e5d6b060d3a62e523848cf64f8b414395 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 7 Feb 2005 16:51:09 +0000 Subject: - new option execafterbuild, to run a script after build the rpm - add the proper credit - version 0.5 --- rpmbuildupdate | 33 ++++++++++++++++++++++++++++++--- rpmbuildupdate.bash-completion | 4 ++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/rpmbuildupdate b/rpmbuildupdate index d310a7e..f0da7c2 100755 --- a/rpmbuildupdate +++ b/rpmbuildupdate @@ -23,6 +23,7 @@ use File::Copy; use MDK::Common::File qw(:all); use Cwd; use File::Spec; +use Hdlist; my %config; @@ -397,7 +398,23 @@ 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"); - } + } + } + if ($config{execafterbuild}) + { + if (my $hdlist_spec = Hdlist::specnew($spec_path)) + { + my @rpms_upload; + push(@rpms_upload, $hdlist_spec->srcrpm); + foreach ($hdlist_spec->binrpm()) + { + -f $_ or next; + push(@rpms_upload, $_); + } + system("$config{execafterbuild} @rpms_upload"); + } else { + print "Unable to parse spec to detect builded rpms\n"; + } } } @@ -490,6 +507,13 @@ sub parse_argv { DEFAULT => "", ARGCOUNT => AppConfig::ARGCOUNT_ONE }); + + $conf->define("execafterbuild", { + ARGS => "=s", + DEFAULT => "", + ARGCOUNT => AppConfig::ARGCOUNT_ONE + }); + foreach my $f ('/etc/rpmbuildupdate.conf', "$ENV{HOME}/.rpmbuildupdaterc") { -f $f && $conf->file($f); @@ -508,14 +532,16 @@ sub parse_argv { $config{rpmoption} = $conf->get("rpmoption"); $config{log} = $conf->get("log"); $config{execute} = $conf->get("execute"); + $config{execafterbuild} = $conf->get("execafterbuild"); } sub usage { print <: specify rpm top dir (default: `rpm --eval \%_topdir`) --nobuild|-c: do not build the package. Only download files. --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; } diff --git a/rpmbuildupdate.bash-completion b/rpmbuildupdate.bash-completion index 4efb285..6c88289 100644 --- a/rpmbuildupdate.bash-completion +++ b/rpmbuildupdate.bash-completion @@ -1,4 +1,4 @@ -# bash completion for rpmctl +# bash completion for rpmbuildupdate # $Id$ _rpmbuildupdate() @@ -24,7 +24,7 @@ _rpmbuildupdate() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--rpmmon --srpms --rpmoption \ --release --changelog --deps --log --nosource \ - --noupdate --top --nobuild --execute -c' -- $cur ) ) + --noupdate --top --nobuild --execute -c --execafterbuild' -- $cur ) ) else # get source rpm path for file in /etc/rpmbuildupdate $HOME/.rpmbuildupdaterc; do -- cgit v1.2.1