Changeset 202 for trunk


Ignore:
Timestamp:
08/16/15 19:20:07 (9 years ago)
Author:
kdeugau
Message:

/trunk

Fix and refine Sourcenn: and Patchnn: preamble handling. Patch by
Andreas Scherer:

Consistent handling of default sources and patches.

rpmbuild permits both "Source:" and "Patch:" settings for the first
(resp. "0th") object, omitting the "0" quantifier. Also the two macros
"%setup" and "%patch" can refer to their respective "defaults" by
omitting the "0". The "%patch" macro may be invoked for a particular
object either as "%patch<number>" or as "%patch -P <number>".

This patch tries to clean up both the setting in the "preamble" and the
application in the "%prep" section. Source and patch files are stripped
with the help of the File::Basename->basename() function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r200 r202  
    3131use Cwd 'abs_path';     # for finding where files really are
    3232use Config;
     33use File::Basename;
    3334
    3435my $version = "0.11.3"; #VERSION#
     
    668669                $_ !~ /^%(?:attr|build|changelog|check|clean|config|configure|defattr|define|description|
    669670                dir|doc|docdir|else|endif|files|ghost|if|ifarch|ifn|ifnarch|ifnos|ifnxxx|fos|ifxxx|
    670                 install|makeinstall|package|patch\d+|post|postun|pre|prep|preun|readme|setup[^\s]*|
     671                install|makeinstall|package|patch\d*|post|postun|pre|prep|preun|readme|setup[^\s]*|
    671672                triggerin|triggerpostun|triggerun|verify|verifyscript)\b/x
    672673        ) {
     
    986987                qq(/bin/chmod -Rf a+rX,u+w,g-w,o-w .\n);
    987988
    988       } elsif ( my ($patchnum,$patchopts) = (/^\%patch([^\s]+)(\s+.+)?$/) ) {
    989         chomp $patchnum;
     989      } elsif ( my ($patchnum,$patchopts) = (/^\%patch(\d*)(\s+.+)?$/) ) {
     990        unless ( $patchnum ) {
     991           $patchnum = ( $patchopts =~ s/-P\s+(\d+)// ? $1 : 0 );
     992        }
    990993        $prepscript .= qq(echo "Patch #$patchnum ($pkgdata{main}{"patch$patchnum"}):"\n);
    991994        # If there are options passed, use'em.
     
    11651168      } elsif (/^buildroot:\s*(.+)/i) {
    11661169        $specglobals{buildroot} = $1;
    1167       } elsif (my ($sval) = /^source0?:\s*(.+)/i) {
    1168         $sval =~ s/\s*$//;
    1169         $pkgdata{main}{source} = $sval;
    1170         # Do this here since we don't use any URL forms elsewhere (maybe some other time)
    1171         $pkgdata{main}{source} =~ s|^.+/([^/]+)$|$1|;
    1172         $pkgdata{sources}{0} = $pkgdata{main}{source};
    1173         # .tar, .tar.gz, .tar.Z, .tar.bz2, .tar.xz, .tgz, .zip
    1174         die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz|Z))?|tgz|zip)$/;
    1175       } elsif (my ($srcnum, $src) = (/^source([0-9]+):\s*(.+)/i)) {
     1170      } elsif (my ($srcnum, $src) = (/^source(\d*):\s*(.+)/i)) {
    11761171        $src =~ s/\s*$//;
    1177         $pkgdata{sources}{$srcnum} = $src;
    1178         # Do this here since we don't use any URL forms elsewhere (maybe some other time)
    1179         $pkgdata{sources}{$srcnum} =~ s|^.+/([^/]+)$|$1|;
    1180       } elsif (/^patch([^:]+):\s*(.+)$/i) {
    1181         my $patchname = "patch$1";
    1182         $pkgdata{main}{$patchname} = $2;
    1183         if ($pkgdata{main}{$patchname} =~ /\//) {
    1184           # URL-style patch.  Rare but not unheard-of.
    1185           my @patchbits = split '/', $pkgdata{main}{$patchname};
    1186           $pkgdata{main}{$patchname} = $patchbits[$#patchbits];
    1187         }
    1188         chomp $pkgdata{main}{$patchname};
     1172        $srcnum = 0 unless $srcnum;
     1173        $pkgdata{main}{source} = basename($src);
     1174        $pkgdata{sources}{0} = $pkgdata{main}{source} if 0 == $srcnum;
     1175      } elsif (my ($patchnum, $patch) = (/^patch(\d*):\s*(.+)/i)) {
     1176        $patch =~ s/\s*$//;
     1177        $patchnum = 0 unless $patchnum;
     1178        $pkgdata{main}{"patch$patchnum"} = basename($patch);
    11891179      } elsif (/^buildarch(?:itecture)?:\s*(.+)/i) {
    11901180        $pkgdata{main}{arch} = $1;
Note: See TracChangeset for help on using the changeset viewer.