Changeset 207
- Timestamp:
- 09/27/15 18:19:06 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r206 r207 71 71 # this can be changed by the Vendor: header in the spec file 72 72 $specglobals{'vendor'} = 'debbuild'; 73 74 # more things that should be parsed from rpm's macro files 75 $specglobals{_default_patch_fuzz} = 0; 73 76 74 77 # Initialized globals … … 975 978 qq(/bin/chmod -Rf a+rX,u+w,g-w,o-w .\n); 976 979 977 } elsif ( my ($patchnum,$patchopts) = (/^\%patch(\d*)(\s+.+)?$/) ) { 978 unless ( $patchnum ) { 979 $patchnum = ( $patchopts =~ s/-P\s+(\d+)// ? $1 : 0 ); 980 } elsif (/^\%patch(\d*)/) { 981 my $line = $_; 982 983 # Things rpmbuild Does 984 # -> blindly follows Patch(.*): ==> %patch$1 985 # %patch0 does not in fact equal %patch without -P 986 # spaces optional between flag and argument 987 # multiple -P options actually trigger multiple patch events. >_< 988 # can we emulate this? 989 # yes we can! 990 # add patch{nn} to the list 991 my @patchlist; 992 push @patchlist, "$1" if $1; 993 994 # options: 995 # -P patch number 996 # -p path strip. passed to patch as-is 997 # -b backup file postfix. literal, if eg "bkfile", backup files will be "filebkfile", not "file.bkfile". Passed to 998 # patch as-is, with a minor flag adjustment 999 # -E Remove empty files. Passed to patch as-is 1000 1001 # from /usr/lib/rpm/macros; doesn't seem to be used by rpmbuild currently 1002 # Default patch flags 1003 #%_default_patch_flags -s 1004 1005 my @pbits = split /\s+/; 1006 my $plev = 0; 1007 my $psuff = ''; 1008 my $noempty = 0; 1009 shift @pbits; 1010 my $pnflag = 0; 1011 while (my $popt = shift @pbits) { 1012 if ($popt =~ /^-P(\d*)/) { 1013 $pnflag = 1; 1014 # push the patchnum onto the list 1015 if ($1) { 1016 push @patchlist, "$1"; 1017 } else { 1018 my $tmp = shift @pbits; 1019 die "Invalid patch number $tmp: $line" if $tmp !~ /^\d+$/; 1020 push @patchlist, $tmp; 1021 } 1022 } elsif ($popt =~ (/^-b([^\s]*)/) ) { 1023 if ($1) { 1024 $psuff = "-b --suffix $1"; 1025 } else { 1026 $psuff = "-b --suffix ".shift(@pbits); 1027 } 1028 } elsif ($popt =~ (/^-p([^\s]*)/) ) { 1029 if ($1) { 1030 $plev = $1; 1031 } else { 1032 $plev = shift @pbits; 1033 } 1034 } elsif ($popt =~ (/^-E/) ) { 1035 $noempty = 1; 1036 } 1037 } # while (shift @pbits) 1038 1039 # add the "null" patch to the list unless we've got a -P flag, or there's already a patch on the list 1040 push @patchlist, '' unless $pnflag || @patchlist; 1041 1042 my $patchopts = " -p$plev $psuff"; 1043 $patchopts .= " --fuzz=".$specglobals{_default_patch_fuzz}; 1044 $patchopts .= " -E" if $noempty; 1045 1046 foreach my $pnum (@patchlist) { 1047 $prepscript .= qq(echo "Patch ).($pnum eq '' ? '' : "#$pnum ").qq(($pkgdata{main}{$pnum}):"\n); 1048 if ( $pkgdata{main}{$pnum} =~ /\.(?:Z|gz|bz2|xz)$/ ) { 1049 # Compressed patch. You weirdo. 1050 my $decompressor; 1051 $decompressor = '/bin/gzip' if $pkgdata{main}{$pnum} =~ /\.(?:Z|gz)$/; 1052 $decompressor = '/bin/bzip2' if $pkgdata{main}{$pnum} =~ /\.bz2$/; 1053 $decompressor = '/usr/bin/xz' if $pkgdata{main}{$pnum} =~ /\.xz$/; 1054 $prepscript .= qq($decompressor -dc $topdir/SOURCES/$pkgdata{main}{$pnum} | /usr/bin/patch $patchopts\n\n); 1055 } elsif ( $pkgdata{main}{$pnum} =~ /\.zip$/ ) { 1056 # .zip'ed patch. *backs away slowly* 1057 $prepscript .= qq(/usr/bin/unzip $topdir/SOURCES/$pkgdata{main}{$pnum} | /usr/bin/patch $patchopts\n\n); 1058 } else { 1059 $prepscript .= "/bin/cat $topdir/SOURCES/$pkgdata{main}{$pnum} | /usr/bin/patch $patchopts\n\n"; 1060 } 980 1061 } 981 $prepscript .= qq(echo "Patch #$patchnum ($pkgdata{main}{"patch$patchnum"}):"\n); 982 # If there are options passed, use'em. 983 # Otherwise, catch a bare %patch and ASS-U-ME it's '-p0'-able. 984 # Will break on options that don't provide -pnn, but what the hell. 985 # Need to decompress .bz2 and .gz patches on the fly. Not sure why one 986 # would ever have such things, but there they are... and rpmbuild supports 'em 987 # patch originally suggested by Lucian Cristian for .bz2 988 # reworked and expanded to support .Z/.gz/.xz as well 989 if ( $pkgdata{main}{"patch$patchnum"} =~ /\.(?:Z|gz|bz2|xz)$/ ) { 990 my $decompressor; 991 $decompressor = 'gzip' if $pkgdata{main}{"patch$patchnum"} =~ /\.(?:Z|gz)$/; 992 $decompressor = 'bzip2' if $pkgdata{main}{"patch$patchnum"} =~ /\.bz2$/; 993 $decompressor = 'xz' if $pkgdata{main}{"patch$patchnum"} =~ /\.xz$/; 994 $prepscript .= qq(/bin/$decompressor -d < $topdir/SOURCES/$pkgdata{main}{"patch$patchnum"} | patch ); 995 $prepscript .= $patchopts if $patchopts; 996 $prepscript .= "-p0" if !$patchopts; 997 $prepscript .= qq( -s\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n); 998 } else { 999 $prepscript .= "patch "; 1000 $prepscript .= $patchopts if $patchopts; 1001 $prepscript .= "-p0" if !$patchopts; 1002 $prepscript .= " -s <$topdir/SOURCES/".$pkgdata{main}{"patch$patchnum"}."\n"; 1003 } 1062 1004 1063 } else { 1005 1064 $prepscript .= expandmacros($_,'gp'); … … 1163 1222 } elsif (my ($patchnum, $patch) = (/^patch(\d*):\s*(.+)/i)) { 1164 1223 $patch =~ s/\s*$//; 1165 $patchnum = 0 unless $patchnum;1166 $pkgdata{main}{ "patch$patchnum"} = basename($patch);1224 $patchnum = '' if !defined($patchnum); 1225 $pkgdata{main}{$patchnum} = basename($patch); 1167 1226 } elsif (/^buildarch(?:itecture)?:\s*(.+)/i) { 1168 1227 $pkgdata{main}{arch} = $1;
Note:
See TracChangeset
for help on using the changeset viewer.