aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrpmbuildupdate65
1 files changed, 30 insertions, 35 deletions
diff --git a/rpmbuildupdate b/rpmbuildupdate
index d16e27a..2f45c5c 100755
--- a/rpmbuildupdate
+++ b/rpmbuildupdate
@@ -139,25 +139,21 @@ sub build_from_spec {
sub build_from_repository {
my ($pkg, $newversion) = @_;
- my $pkge = $pkg;
- $pkge =~ s/\+/\\+/;
- my $found = 0;
my $pkgrpm;
foreach my $srpm_dir (split(/,/, $config{srpms})) {
opendir(MP, $srpm_dir) or die "$srpm_dir is not a directory";
my @rpms = readdir(MP);
foreach (@rpms) {
- if (m|^($pkge)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) {
+ if (/^\Q$pkg\E-[^-]+-[^-]+\.\w+\.rpm/) {
$pkgrpm = "$srpm_dir/$_";
- $found = 1;
last;
}
}
closedir(MP);
- last if $found;
+ last if $pkgrpm;
}
- if ($found == 0) {
+ unless ($pkgrpm) {
print "Package $pkg has no source, skipping.\n\n";
return;
}
@@ -166,26 +162,21 @@ sub build_from_repository {
sub build_from_src {
my ($pkgrpm, $newversion) = @_;
- my $b = basename($pkgrpm);
- die "Cannot parse the name of rpm " if $b !~ m|^(.*)-([^-]+)-([^-]+)\.[^\.]+\.rpm|;
- my $pkg = $1;
-
$pkgrpm = File::Spec->rel2abs($pkgrpm);
fill_global_variable($pkgrpm);
my $found = 0;
- my ($version, $release);
+ my ($name, $version, $release);
chdir("$top/SOURCES") or die "Unable to chdir to $top/SOURCES";
- my $pkge = $pkg;
- $pkge =~ s/\+/\\+/;
-
my $pkgrpm_basename = basename($pkgrpm);
- if ($pkgrpm_basename =~ m|^(.*)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) {
- $pkg = $1;
+ if ($pkgrpm_basename =~ /^(.*)-([^-]+)-([^-]+)\.\w+\.rpm/) {
+ $name = $1;
$version = $2;
$release = $3;
+ } else {
+ die "Cannot parse the name of rpm $pkgrpm_basename";
}
if ($config{deps}) {
@@ -194,8 +185,8 @@ sub build_from_src {
system_die("$rpm -ivh $pkgrpm $log");
- my $spec_path="../SPECS/$pkg.spec";
- build($spec_path,$pkg,$version,$release,$newversion);
+ my $spec_path="../SPECS/$name.spec";
+ build($spec_path, $name, $version, $release, $newversion);
}
sub build {
@@ -232,16 +223,23 @@ sub build {
my $tar_ball='';
while (<$SPECFILE>) {
# Doing a s/// version
- s/\%define\s+version\s+$version/\%define version $newversion/g;
- s/Version:\s+$version/Version: $newversion/g;
- s/Release\s*:\s*$release/Release: $newrelease/;
- s/\%define(\s+)release(\s+)(.*)/\%define release $newrelease/;
+ s/\%define\s+version\s+$version/\%define version $newversion/;
+ s/\%define\s+release\s+$release/\%define release $newrelease/;
+ s/Version:\s+$version/Version: $newversion/i;
+ s/Release:\s+$release/Release: $newrelease/i;
eval $config{execute} if $config{execute};
$spec .= $_;
- push(@url, $2) if /(Source[0-9]*)\s*:\s+((?:ftp|svns?|https?):\S+)/i;
- $tar_ball=$2 if /(Source[0-9]*)\s*:\s+([^:\s]+)/i && ! $tar_ball;
+
+ if (/^Source[0-9]*:\s+(\S+)/i) {
+ my $source = $1;
+ if ($source =~ /(?:ftp|svns?|https?):\/\/\S+/) {
+ push(@url, $source);
+ } else {
+ $tar_ball= $source unless $tar_ball;
+ };
+ }
# For %vars !
$specvars{$1} = $2 if /\%define\s+(\S+?)\s+(\S+)/g;
@@ -249,7 +247,7 @@ sub build {
$specvars{$i} = $1 if !$specvars{$i} && /$i\s*:\s+(\S+)/gi;
}
- if (/(:?^|[^%])\%changelog/g) {
+ if (/^\%changelog/) {
$message =~ s/\%\%VERSION/$newversion/;
my @l = getpwuid($<);
my $packager = `rpm --eval '\%packager'`;
@@ -294,8 +292,8 @@ sub build {
# http://jabberstudio.org/files/ejogger/
# http://jabberstudio.org/projects/ejogger/project/view.php
- foreach my $sf (@sf_like) {
- if ( $url =~ m/$sf->{regexp}/ ) {
+ foreach my $sf (@sf_like) {
+ if ($url =~ m/$sf->{regexp}/) {
$sf->{download} =~ s/^/"/;
$sf->{download} =~ s/$/"/;
$url =~ s/$sf->{regexp}/"$sf->{download}"/eeg;
@@ -311,10 +309,9 @@ sub build {
foreach (@url) {
# Replace variable from spec (%blabla)
while (/\%/) {
- s/\%\{(.*?)\}/$specvars{$1}/g;
- s/\%(\w+)/$specvars{$1}/g;
- s/\%\{name\}/$pkg/gi;
- s/\%\{version\}/$newversion/gi;
+ s/\%\{?(\w+)\}?/$specvars{$1}/g;
+ s/\%\{name\}/$pkg/g;
+ s/\%\{version\}/$newversion/g;
}
my $basename = basename($_);
@@ -335,11 +332,9 @@ sub build {
my @rpmsrh = readdir(MP);
my $pkgrpmrh;
- my $pkge = $pkg;
- $pkge =~ s/\+/\\+/;
foreach (@rpmsrh) {
- if (m|^($pkge)-([^-]+)-([^-]+)\.[^\.]+\.rpm|) {
+ if (/^\Q$pkg\E-[^-]+-[^-]+\.\w+\.rpm/) {
$pkgrpmrh = $_;
last;
}