Changeset 1367 in ProjectBuilder for devel


Ignore:
Timestamp:
Nov 27, 2011, 3:44:49 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Fix a bug in the recursive function pb_list_bfiles where file handle should not be global
  • patch command and option are now variables in p.conf under ospatchcmd and ospatchopt
  • Add support for patches for deb family of distributions
Location:
devel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf

    r1365 r1367  
    532532oschkcmd deb = /usr/bin/lintian
    533533oschkopt deb =
     534ospatchcmd default = /usr/bin/patch
     535ospatchopt default = -s -p1
    534536
    535537# sha method for yum repo
  • devel/pb-modules/etc/pb.conf.pod

    r1348 r1367  
    150150 Conffile: pb
    151151 Example: osnover gentoo = true
     152
     153=item B<ospatchcmd>
     154
     155 Nature: Optional
     156 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch).
     157 Value: package patch command. For RPM is implicit.
     158 Conffile: pb
     159 Example: ospatchcmd deb = /usr/bin/patch
     160
     161=item B<ospatchopt>
     162
     163 Nature: Optional
     164 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch).
     165 Value: package patch options.
     166 Conffile: pb
     167 Example: ospatchcmd deb = -s -p1
    152168
    153169=item B<ospathcmd-*>
  • devel/pb/bin/pb

    r1365 r1367  
    954954                        # Filter potential patches (local + remote)
    955955                        pb_mkdir_p("$dest/pbconf/$v/pbpatch");
     956                        # If Debian based distribution, then prepare what will be done at build time
     957                        my ($patchcmd,$patchopt);
     958                        if ($pbos->{'type'} eq "deb") {
     959                            ($patchcmd,$patchopt) = pb_distro_get_param($pbos,pb_conf_get_if("ospatchcmd","ospatchopt"));
     960                            open(SCRIPT,"> $dest/pbconf/$v/pbpatch/pbapplypatch") || die "Unable to create $dest/pbconf/$v/pbpatch/pbapplypatch";
     961                            print SCRIPT "#!/bin/bash\n";
     962                            print SCRIPT "set -x\n" if ($pbdebug gt 1);
     963                        }
    956964                        foreach my $pf (split(/,/,$pb->{'patches'}->{$v})) {
    957965                            my $pp = basename($pf);
     
    959967                            pb_filter_file_inplace($ptr,"$dest/pbconf/$v/pbpatch/$pp",$pb);
    960968                            pb_system("gzip -9f $dest/pbconf/$v/pbpatch/$pp","","quiet");
     969                            if ($pbos->{'type'} eq "deb") {
     970                                # If Debian based distribution, then prepare what will be done at build time
     971                                # by applying the patches that will be available under the debian/patches dir
     972                                print SCRIPT "$patchcmd $patchopt \< debian/patches/$pp\n";
     973                            }
    961974                        }
     975                        if ($pbos->{'type'} eq "deb") {
     976                            close(SCRIPT);
     977                            chmod 0755,"$dest/pbconf/$v/pbpatch/pbapplypatch";
     978                        }
     979                        #pb_system("cat $dest/pbconf/$v/pbpatch/pbapplypatch","APPLY","verbose");
    962980                    }
    963981                    if (defined $pb->{'sources'}->{$v}) {
     
    12631281            my @f = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbpatch/","debian/patches","patch");
    12641282
    1265             # If we use quilt to manage patches, we then setup the env correctly as per http://pkg-perl.alioth.debian.org/howto/quilt.html
    1266             # Generate Debian patch series for quilt
    1267             # If we use dpatch to manage patches, we then setup the 00list file as well
    1268             open(SERIE,"> debian/patches/series") || die "Unable to write in debian/patches/series";
    1269             open(LIST,"> debian/patches/00list") || die "Unable to write in debian/patches/00list";
     1283            # By default we use format 1.0 - Cf man dpkg-source
     1284            my $debsrcfmt = "1.0";
     1285            my $debsrcfile = "debian/source/format";
     1286            if (-f $debsrcfile) {
     1287                $debsrcfmt = pb_get_content($debsrcfile);
     1288            }
     1289               
     1290            if ($debsrcfmt =~ /^3.*quilt/) {
     1291                # If we use quilt to manage patches, we then setup the env correctly
     1292                # as per http://pkg-perl.alioth.debian.org/howto/quilt.html
     1293                # Generate Debian patch series for quilt
     1294                open(SERIE,"> debian/patches/series") || die "Unable to write in debian/patches/series";
     1295                $ENV{'QUILT_PATCHES'}="debian/patches";
     1296            } else {
     1297                # If we use dpatch to manage patches, we then setup the 00list file as well
     1298                open(SERIE,"> debian/patches/00list") || die "Unable to write in debian/patches/00list";
     1299            }
    12701300            foreach my $f (sort @f) {
    1271                 # We also need to ncompress them
     1301                # Skip the script made to apply the patches to the Debian tree
     1302                next if ($f =~ /pbapplypatch/);
     1303                # We also need to uncompress them
     1304                pb_system("gzip -d $f","","quiet");
     1305                $f =~ s/\.gz$//;
    12721306                print SERIE "$f\n";
    1273                 print LIST "$f\n";
    12741307            }
    12751308            close(SERIE);
    1276             close(LIST);
    1277             $ENV{'QUILT_PATCHES'}="debian/patches";
     1309            if ($debsrcfmt =~ /^1.*/) {
     1310                # In that case we need to apply the patches ourselves locally
     1311                pb_system("cat debian/patches/pbapplypatch","APPLY","verbose");
     1312                pb_system("debian/patches/pbapplypatch","Applying patches to $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} tree");
     1313            }
     1314            if (@f) {
     1315                # We have patches, so modify the name of files to be Debian compliant
     1316                move("../$src","../$pbpkg-$pbver.orig.tar.gz");
     1317            }
    12781318
    12791319            # We need to handle potential additional sources to upstream sources
     
    34773517# subdir to keep if recursive mode, empty by default
    34783518my $subdir = shift || "";
     3519# In a recursive function , we need a local var as DIR handle
     3520my $bdir;
    34793521
    34803522pb_log(2,"DEBUG: entering pb_list_bfiles in $dir: ".Dumper($bfiles)."\n");
    3481 opendir(BDIR,"$dir") || die "Unable to open dir $dir: $!";
    3482 foreach my $f (readdir(BDIR)) {
     3523opendir($bdir,"$dir") || die "Unable to open dir $dir: $!";
     3524foreach my $f (readdir($bdir)) {
    34833525    pb_log(3,"DEBUG: pb_list_bfiles found $f\n");
    34843526    next if ($f =~ /^\./);
     
    34993541    }
    35003542}
    3501 closedir(BDIR);
     3543closedir($bdir);
    35023544pb_log(2,"DEBUG: exiting pb_list_bfiles: ".Dumper($bfiles)."\n");
    35033545}
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r1252 r1367  
    2020use ProjectBuilder::Version;
    2121use ProjectBuilder::Base;
     22use ProjectBuilder::Conf;
     23use ProjectBuilder::Distribution;
    2224use ProjectBuilder::Changelog;
    2325
     
    215217            my $i = 0;
    216218            if (defined $pb->{'patches'}->{$tuple}) {
     219                my ($patchcmd,$patchopt) = pb_distro_get_param($pb->{'pbos'},pb_conf_get_if("ospatchcmd","ospatchopt"));
    217220                foreach my $p (split(/,/,$pb->{'patches'}->{$tuple})) {
    218221                    pb_log(3,"DEBUG($tuple) Adding patch command $i\n");
    219                     print DEST "%patch$i -p1\n";
     222                    print DEST "%patch$i $patchopt\n";
    220223                    $i++;
    221224                }
Note: See TracChangeset for help on using the changeset viewer.