diff options
author | Julien Danjou <jdanjou@mandriva.org> | 2003-07-11 14:40:50 +0000 |
---|---|---|
committer | Julien Danjou <jdanjou@mandriva.org> | 2003-07-11 14:40:50 +0000 |
commit | b208a4b773e51346d358c07afbe94c07158107f3 (patch) | |
tree | 540ed16b58b651cca6e56023a102dead3bd3bbb0 | |
parent | 52398fc78ba15ac10c68742bf5f47685a9fdb9f6 (diff) | |
download | bootsplash-b208a4b773e51346d358c07afbe94c07158107f3.tar bootsplash-b208a4b773e51346d358c07afbe94c07158107f3.tar.gz bootsplash-b208a4b773e51346d358c07afbe94c07158107f3.tar.bz2 bootsplash-b208a4b773e51346d358c07afbe94c07158107f3.tar.xz bootsplash-b208a4b773e51346d358c07afbe94c07158107f3.zip |
version 0.2
-rwxr-xr-x | rpmbuildupdate | 133 |
1 files changed, 100 insertions, 33 deletions
diff --git a/rpmbuildupdate b/rpmbuildupdate index 057cb61..f162197 100755 --- a/rpmbuildupdate +++ b/rpmbuildupdate @@ -15,47 +15,68 @@ use strict; use AppConfig; -my $mount_point = "/mnt/BIG/distrib/cooker/SRPMS/"; my $defaultrelease = "1mdk"; my %config; + +sub build_from_src +{ + $_ = shift; + my $nv = shift; + my $b = qx[basename $_]; + if($b =~ m|^(.*)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) + { &build($1, $nv, $_); } +} + sub build { my $pkg = shift; my $newversion = shift; + my $pkgrpm = shift; my $found = 0; - my ($pkge, $pkgrpm, $version, $release); + my ($pkge, $version, $release, $email); my ($spec, @url, $basename); my (@rpms, %specvars); print "===> Building $pkg $newversion\n"; - opendir(MP, $mount_point) or die "$mount_point is not a directory"; - @rpms = readdir(MP); - $pkge = $pkg; $pkge =~ s/\+/\\\+/; - foreach (@rpms) + # Search for file if we do not use --src + if(!$config{src}) { - if(m|^($pkge)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) - { $pkgrpm = $_; $version = $2; $release = $3; $found = 1;} + opendir(MP, $config{mountpoint}) or die "$config{mountpoint} is not a directory"; + @rpms = readdir(MP); + + foreach (@rpms) + { + if(m|^($pkge)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) + { $pkgrpm = $_; $version = $2; $release = $3; $found = 1;} + } + + closedir(MP); + + if($found == 0) { print "Package $pkg has no source, skipping.\n\n"; return; } + } + else + { + my $pkgrpm_basename = qx[basename $pkgrpm]; + if($pkgrpm_basename =~ m|^($pkge)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) + { $version = $2; $release = $3; $found = 1;} } - closedir(MP); - - if($found == 0) { print "Package $pkg has no source, skipping.\n\n"; return; } - - if (0) { - system("rpm -i $pkgrpm"); + if ($config{src}) { + system("rpm -ivh $pkgrpm"); + wait; } else { - system("/usr/sbin/urpmi --auto --force ".$mount_point.$pkgrpm); + system("sudo /usr/sbin/urpmi --auto --force ".$config{mountpoint}."/".$pkgrpm); #{ print "Error while urpmi $pkgrpm\n"; return; }; wait; - system("/usr/sbin/urpmi --install-src --force ".$mount_point.$pkgrpm); + system("/usr/sbin/urpmi --install-src --force ".$config{mountpoint}."/".$pkgrpm); #{ print "Error while urpmi --install-src $pkgrpm\n"; return; } wait; } @@ -74,15 +95,27 @@ sub build while(<SPECFILE>) { - s/$version/$newversion/g if($_ !~ /Patch/i); + # s/// version + s/\%define\s+version\s+$version/\%define version $newversion/g; + s/Version:\s+$version/Version: $newversion/g; + $spec .= $_; - $spec =~ s/\%define release (.*)/\%define release $defaultrelease/; + $spec =~ s/\%define(\s+)release(\s+)(.*)/\%define release $defaultrelease/; push(@url, $2) if(/(Source|Url|Source0):\s+(\S+)/i); # For %vars ! $specvars{$1} = $2 if(/\%define\s+(.+?)\s+(.+)/g); $specvars{version} = $1 if(!$specvars{version} && /Version:\s+(.+)/gi); $specvars{name} = $1 if(!$specvars{name} && /Name:\s+(.+)/gi); + + if(/\%changelog/) + { + $email = $ENV{EMAIL} || + qx[awk -F: '/$ENV{USER}/{print \$5}' /etc/passwd|tr -d '\n']." <$ENV{USER}\@mandrakesoft.com> "; + $spec .= "* ".qx[LC_TIME=C date '+%a %b %d %Y'|tr -d '\n']." ".$email. + " ".$newversion."-".$defaultrelease."\n"; + $spec .= "- New release $newversion\n\n"; + } } close(SPECFILE); @@ -127,21 +160,26 @@ sub build # If gz was downloaded, recompressing it in bz2 if(-f $basename) { - print "Bzipping $basename... "; system("bzme ".$basename); - print "done\n"; $basename =~ s/bz2/gz/; } } - + $found = 1 if(-e $basename); $basename =~ s/bz2/gz/; $found = 1 if(-e $basename); } - if(!$found) { print "Unable to download file: URL is not valid ! :-/\n\n"; return; } + if(!$found) + { print "Unable to download file: URL is not valid ! :-/\n\n"; return; } - system("rpm -ba ../SPECS/".$pkg.".spec"); + if(system("rpm -ba ../SPECS/".$pkg.".spec")) + { + wait; + print "Build fails: building source only\n"; + exit; + system("rpm -bs ../SPECS/".$pkg.".spec"); + } wait; } @@ -156,28 +194,52 @@ sub parse_argv my $conf = AppConfig->new({ CASE => 1 }); $conf->define("rpmmon", - { ARGS => "!", DEFAULT => 0, ARGCOUNT => AppConfig::ARGCOUNT_NONE } + { ARGS => "=s", + ALIAS => "r", + ARGCOUNT => AppConfig::ARGCOUNT_NONE } + ); + + $conf->define("mountpoint", + { ARGS => "=s", + ALIAS => "m", + DEFAULT => "/mnt/BIG/distrib/cooker/SRPMS/", + ARGCOUNT => AppConfig::ARGCOUNT_ONE } + ); + + $conf->define("src", + { ARGS => "=s", + ALIAS => "s", + ARGCOUNT => AppConfig::ARGCOUNT_ONE } ); + $conf->args(); $config{rpmmon} = $conf->get("rpmmon"); + $config{mountpoint} = $conf->get("mountpoint"); + $config{src} = $conf->get("src"); + } sub usage { - print "rpmbuildupdate v0.1 helps you build up to date RPMs.\n\n"; + print "rpmbuildupdate v0.2 helps you build up to date RPMs.\n\n"; print "By Julien Danjou <jdanjou\@mandrakesoft.com>\n"; print "Copyright (c) 2003 by MandrakeSoft.\n"; print "This is free software under the GPL License.\n"; print "Usage: rpmbuildupdate [options] [pkg] [newversion]\n\n"; - print " --rpmmon <file>: Parse output of rpmmon from file\n\n"; + print " --rpmmon <file>: Parse output of rpmmon from file\n"; + print " -m <mount point>: Specify mount point of \n"; + print " --src <src.rpm file> <new version>: Build new version from this source RPM\n"; exit 0; } sub parse_rpmmon { - open(RPMMON, shift()); + my $f; + ($f = shift()); + -f $f or die "Error: $f is not a file.\n"; + open(RPMMON, $f); while(<RPMMON>) { &build($1, $3) if(/^\s+(\S+)\s+(\S+)\s+(\S+)$/ && ! /Package/); &build($2, $4) if(/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/ && ! /Package/); } @@ -187,18 +249,23 @@ sub parse_rpmmon sub main { &parse_argv; - &wget_check; - if(!$config{rpmmon}) + if($config{rpmmon}) + { + -d $config{mountpoint} or die $config{mountpoint}." is not a directory.\n"; + &parse_rpmmon($config{rpmmon}); + } + elsif($config{src} && $ARGV[0]) { &build_from_src($config{src}, $ARGV[0]); } + elsif($ARGV[0] && $ARGV[1]) { - my $pkg = shift @ARGV or &usage; - my $version = shift @ARGV or &usage; - &build($pkg, $version); + -d $config{mountpoint} or die $config{mountpoint}." is not a directory.\n"; + &build($ARGV[0], $ARGV[1]); } else - { &parse_rpmmon($ARGV[0]); } + { &usage; } + } &main; |