diff options
author | Guillaume Rousse <guillomovitch@mandriva.org> | 2005-01-09 18:30:39 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mandriva.org> | 2005-01-09 18:30:39 +0000 |
commit | 25f7f290f43b7e153cc5b7807aaa7e48b9bc8260 (patch) | |
tree | 7cf4636a6f8b4c6298fec5ca786b5cb98a2ec8ef | |
parent | 04bb41fee3ce5f57fe9cff520fcb72be2fd5113b (diff) | |
download | bootsplash-25f7f290f43b7e153cc5b7807aaa7e48b9bc8260.tar bootsplash-25f7f290f43b7e153cc5b7807aaa7e48b9bc8260.tar.gz bootsplash-25f7f290f43b7e153cc5b7807aaa7e48b9bc8260.tar.bz2 bootsplash-25f7f290f43b7e153cc5b7807aaa7e48b9bc8260.tar.xz bootsplash-25f7f290f43b7e153cc5b7807aaa7e48b9bc8260.zip |
regexp cleanup
-rwxr-xr-x | rpmbuildupdate | 65 |
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; } |