Changes in devel/pb/bin/pb.pl [30:20] in ProjectBuilder


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb.pl

    r30 r20  
    88# Provided under the GPL v2
    99
    10 # Syntax: see at end
     10# Syntax: pb [-p project] <action> [<params>...]
    1111
    1212use strict 'vars';
     13use Switch;
    1314use Getopt::Std;
    1415use Data::Dumper;
     
    1617use AppConfig qw(:argcount :expand);
    1718use File::Basename;
    18 use File::Copy;
     19use Archive::Tar;
    1920use Time::localtime qw(localtime);
    2021use POSIX qw(strftime);
    2122
    22 use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles $debug $LOG);
     23use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles);
    2324%extpkgdir = ();
    2425%filteredfiles = ();
    25 $debug = 0;                 # Debug level
    26 $LOG = *STDOUT;             # Where to log
    2726use lib qw (lib);
    2827use common qw (env_init);
     
    4342my $pbdate = strftime("%Y-%m-%d", @date);
    4443
    45 getopts('hl:p:qtv',\%opts);
    46 
    47 if (defined $opts{'h'}) {
    48     syntax();
    49     exit(0);
    50 }
    51 if (defined $opts{'v'}) {
    52     $debug++;
    53 }
    54 if (defined $opts{'q'}) {
    55     $debug=-1;
    56 }
    57 if (defined $opts{'l'}) {
    58     open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
    59     $LOG = *LOG;
    60     $debug = 0  if ($debug == -1);
    61     }
     44getopts('p:t',\%opts);
     45
    6246# Handles project name if any
    6347if (defined $opts{'p'}) {
     
    7559# Get Action
    7660$action = shift @ARGV;
    77 die syntax() if (not defined $action);
    78 
    79 print $LOG "Project $ENV{'PBPROJ'}\n" if ($debug >= 0);
    80 print $LOG "Action: $action\n" if ($debug >= 0);
     61die "Syntax: pb [-p project] <action> [<params>...]" if (not defined $action);
     62
     63print "Project $ENV{'PBPROJ'}\n";
     64#print "Action: $action - ARGV:".Dumper(\@ARGV);
    8165
    8266# Act depending on action
    8367if ($action =~ /^cms2build$/) {
    84     my $ptr = get_pkg();
    85     @pkgs = @$ptr;
     68    print "Action: cms2build\n";
     69    # Get packages list
     70    if (not defined $ARGV[0]) {
     71        @pkgs = keys %defpkgdir;
     72    } elsif ($ARGV[0] =~ /^all$/) {
     73        @pkgs = keys %defpkgdir;
     74        if (defined %extpkgdir) {
     75            my $k = keys %extpkgdir;
     76            if (defined $k) {
     77                push(@pkgs, keys %extpkgdir);
     78            }
     79        }
     80    } else {
     81        @pkgs = @ARGV;
     82    }
     83    print "Packages:\n";
     84    print Dumper(@pkgs);
    8685    cms_init();
    8786
    88     foreach my $pbpkg (@pkgs) {
    89         if (-f "$ENV{'PBROOT'}/$pbpkg/VERSION") {
    90             open(V,"$ENV{'PBROOT'}/$pbpkg/VERSION") || die "Unable to open $ENV{'PBROOT'}/$pbpkg/VERSION";
     87    foreach my $pkg (@pkgs) {
     88
     89        if (-f "$ENV{'PBROOT'}/$pkg/VERSION") {
     90            open(V,"$ENV{'PBROOT'}/$pkg/VERSION") || die "Unable to open $ENV{'PBROOT'}/$pkg/VERSION";
    9191            $pbver = <V>;
    9292            chomp($pbver);
     
    9696        }
    9797
    98         if (-f "$ENV{'PBROOT'}/$pbpkg/TAG") {
    99             open(T,"$ENV{'PBROOT'}/$pbpkg/TAG") || die "Unable to open $ENV{'PBROOT'}/$pbpkg/TAG";
     98        if (-f "$ENV{'PBROOT'}/$pkg/TAG") {
     99            open(T,"$ENV{'PBROOT'}/$pkg/TAG") || die "Unable to open $ENV{'PBROOT'}/$pkg/TAG";
    100100            $pbtag = <T>;
    101101            chomp($pbtag);
     
    105105        }
    106106        $pbrev = $ENV{'PBREVISION'};
    107         print $LOG "\n" if ($debug >= 0);
    108         print $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n" if ($debug >= 0);
     107        print "Management of $pkg $pbver-$pbtag (rev $pbrev)\n";
    109108        die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
    110109        # Clean up dest if necessary. The export will recreate it
    111         my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
     110        my $dest = "$ENV{'PBDESTDIR'}/$pkg-$pbver";
    112111        pbrm_rf($dest) if (-d $dest);
    113112
     
    115114        # And generate some additional files
    116115        $OUTPUT_AUTOFLUSH=1;
    117 
     116        print "$ENV{'PBCMSEXP'} of $pkg...";
    118117        # computes in which dir we have to work
    119         my $dir = $defpkgdir{$pbpkg};
    120         $dir = $extpkgdir{$pbpkg} if (not defined $dir);
    121         pbsystem("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir");
     118        my $dir = $defpkgdir{$pkg};
     119        $dir = $extpkgdir{$pkg} if (not defined $dir);
     120        system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null");
     121        if ($? == -1) {
     122            print "failed to execute: $!\n";
     123        } elsif ($? & 127) {
     124            printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     125        } else {
     126            print " Done under $dest\n";
     127        }
    122128
    123129        # Creates a REVISION file
     
    127133
    128134        # Extract cms log history and store it
    129         pbsystem("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info");
    130 
    131         my %build;
     135        system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}");
     136        print "$ENV{'PBCMSLOG'} of $pkg...";
     137        if ($? == -1) {
     138            print "failed to execute: $!\n";
     139        } elsif ($? & 127) {
     140            printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     141        } else {
     142            print " OK\n";
     143        }
    132144        open(D,"$ENV{'PBCONF'}/DISTROS") || die "Unable to find $ENV{'PBCONF'}/DISTROS\n";
    133145        while (<D>) {
     
    135147            my ($dir,$ver) = split(/_/,$d);
    136148            chomp($ver);
     149            print "Generating build files for $dir ($ver)\n";
    137150            my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init($dir,$ver);
    138             print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1);
    139             print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
     151            #print Dumper($ddir, $dver, $dfam, $dtype, $dsuf);
     152            #print "Filtering DDD => $pbdate, TTT => $pbtag, RRR => $pbtag$dsuf, VVV => $pbver\n";
    140153
    141154            # Filter build files from the less precise up to the most with overloading
     
    144157            # Find all build files first relatively to PBROOT
    145158            my %bfiles;
    146             print $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);
    147             $build{"$ddir-$dver"} = "yes";
    148             if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") {
    149                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!";
     159            #print "dir: $ENV{'PBCONF'}/$pkg\n";
     160            if (-d "$ENV{'PBCONF'}/$pkg/$dtype") {
     161                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dtype" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dtype: $!");
    150162                foreach my $f (readdir(BDIR)) {
    151163                    next if ($f =~ /^\./);
    152                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f";
     164                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$dtype/$f";
    153165                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    154166                }
    155167                closedir(BDIR);
    156             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") {
    157                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!";
     168            } elsif (-d "$ENV{'PBCONF'}/$pkg/$dfam") {
     169                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dfam" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dfam: $!");
    158170                foreach my $f (readdir(BDIR)) {
    159171                    next if ($f =~ /^\./);
    160                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f";
     172                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$dfam/$f";
    161173                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    162174                }
    163175                closedir(BDIR);
    164             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") {
    165                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!";
     176            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir") {
     177                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir: $!");
    166178                foreach my $f (readdir(BDIR)) {
    167179                    next if ($f =~ /^\./);
    168                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f";
     180                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$ddir/$f";
    169181                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    170182                }
    171183                closedir(BDIR);
    172             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") {
    173                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!";
     184            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir-$dver") {
     185                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir-$dver" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir-$dver: $!");
    174186                foreach my $f (readdir(BDIR)) {
    175187                    next if ($f =~ /^\./);
    176                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f";
     188                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$ddir-$dver/$f";
    177189                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    178190                }
    179191                closedir(BDIR);
    180192            } else {
    181                 $build{"$ddir-$dver"} = "no";
     193                print "No Build Files found for $ddir-$dver\n";
    182194                next;
    183195            }
    184             print $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);
     196            print "bfiles: ".Dumper(\%bfiles)."\n";
    185197
    186198            # Get all filters to apply
     
    189201            my @ffiles;
    190202            my ($ffile0, $ffile1, $ffile2, $ffile3);
    191             if (-d "$ENV{'PBCONF'}/$pbpkg/pbfilter") {
    192                 $ffile0 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dtype.pbf");
    193                 $ffile1 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dfam.pbf");
    194                 $ffile2 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir.pbf");
    195                 $ffile3 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir-$dver.pbf");
     203            if (-d "$ENV{'PBCONF'}/$pkg/pbfilter") {
     204                $ffile0 = "$ENV{'PBCONF'}/$pkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$dtype.pbf");
     205                $ffile1 = "$ENV{'PBCONF'}/$pkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$dfam.pbf");
     206                $ffile2 = "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir.pbf");
     207                $ffile3 = "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir-$dver.pbf");
    196208                push @ffiles,$ffile0 if (defined $ffile0);
    197209                push @ffiles,$ffile1 if (defined $ffile1);
     
    210222            my $ptr;
    211223            if (@ffiles) {
    212                 print $LOG "DEBUG ffiles: ".Dumper(\@ffiles)."\n" if ($debug >= 1);
     224                print "ffiles: ".Dumper(\@ffiles)."\n";
    213225                $config->file(@ffiles);
    214226                $ptr = $config->get("filter");
    215                 print $LOG "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1);
     227                print "f:".Dumper($ptr)."\n";
    216228            } else {
    217229                $ptr = { };
     
    223235            if (defined $ptr) {
    224236                foreach my $f (values %bfiles) {
    225                     filter_file($f,$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$pbpkg,$dtype,$dsuf);
     237                    filter_file($f,$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$pkg,$dtype,$dsuf);
    226238                }
    227239                foreach my $f (keys %filteredfiles) {
    228                     filter_file($f,$ptr,"$dest/$f",$pbpkg,$dtype,$dsuf);
    229                 }
    230             }
    231         }
    232         if ($debug >= 0) {
    233             my @found;
    234             my @notfound;
    235             foreach my $b (keys %build) {
    236                 push @found,$b if ($build{$b} =~ /yes/);
    237                 push @notfound,$b if ($build{$b} =~ /no/);
    238             }
    239             print $LOG "Build files generated for ".join(',',@found)."\n";
    240             print $LOG "No Build files found for ".join(',',@notfound)."\n";
     240                    filter_file($f,$ptr,"$dest/$f",$pkg,$dtype,$dsuf);
     241                }
     242            }
    241243        }
    242244        close(D);
    243245        # Prepare the dest directory for archive
    244         if (-x "$ENV{'PBCONF'}/$pbpkg/pbpkginit") {
    245             pbsystem("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
    246         }
    247 
     246        if (-x "$ENV{'PBCONF'}/$pkg/pbpkginit") {
     247            system("cd $dest ; $ENV{'PBCONF'}/$pkg/pbinit");
     248            if ($? == -1) {
     249                print "failed to execute: $!\n";
     250            } elsif ($? & 127) {
     251                printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     252            } else {
     253                print " $dest\n";
     254            }
     255        }
    248256        # Archive dest dir
    249         chdir "$ENV{'PBDESTDIR'}";
    250         # Possibility to look at PBSRC to guess more the filename
    251         pbsystem("tar cfphz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
     257        chdir "$dest/..";
     258        print "Creating $pkg tar files (gzip... ";
     259        system("tar cfphz $pkg-$pbver.tar.gz $pkg-$pbver");
    252260        if ($? == -1) {
    253             print $LOG "failed to execute: $!\n" if ($debug >= 0);
     261            print "failed to execute: $!\n";
    254262        } elsif ($? & 127) {
    255             printf $LOG "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without' if ($debug >= 0);
    256         } else {
    257             print $LOG " OK)\n" if ($debug >= 0);
    258             print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
    259             # Keep track of what is generated for build2pkg default
    260             open(LAST,"> $ENV{'PBDESTDIR'}/LAST") || die "Unable to create $ENV{'PBDESTDIR'}/LAST";
    261             print LAST "$pbver-$pbtag\n";
    262             close(LAST);
    263         }
    264     }
    265 } elsif ($action =~ /^build2pkg$/) {
    266     # Check whether we have a specific version to build
    267     my $vertag = shift @ARGV;
    268     if (not defined $vertag) {
    269         open(LAST,"$ENV{'PBDESTDIR'}/LAST") || die "Unable to open $ENV{'PBDESTDIR'}/LAST\nYou may want to precise as parameter version-tag";
    270         $vertag = <LAST>;
    271         chomp($vertag);
    272         close(LAST);
    273     }
    274     ($pbver,$pbtag) = split(/-/,$vertag);
    275 
    276     # Get list of packages to build
    277     my $ptr = get_pkg();
    278     @pkgs = @$ptr;
    279 
    280     # Get the running distro to build on
    281     my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init();
    282     print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1);
    283 
    284     chdir "$ENV{'PBBUILDDIR'}";
    285     foreach my $pbpkg (@pkgs) {
    286         my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    287         print $LOG "Handling source file $src\n" if ($debug >= 0);
    288 
    289         if ($dtype eq "rpm") {
    290             # rpm has its own standard build directory
    291             my $tmp=`rpmquery --eval '%{_topdir}' 2> /dev/null`;
    292             chomp($tmp);
    293             $ENV{'PBBUILDDIR'}=$tmp;
    294             print $LOG "Working under $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
    295             foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
    296                 if (! -d "$ENV{'PBBUILDDIR'}/$d") {
    297                 pbmkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
    298                 }
    299             }
    300 
    301             # We need to first extract the spec file
    302             symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
    303             my @specfile;
    304             @specfile = extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
    305 
    306             print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
    307             # set LANGUAGE to check for correct log messages
    308             $ENV{'LANGUAGE'}="C";
    309             #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
    310             foreach my $f (@specfile) {
    311                 if ($f =~ /\.spec$/) {
    312                     pbsystem("rpmbuild -ba $f","Building package with $f");
    313                     last;
    314                 }
    315             }
    316         } elsif ($dtype eq "tgz") {
    317             pbmkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
    318         } elsif ($dtype eq "ebuild") {
    319             pbmkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
    320         } else {
     263            printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     264        } else {
     265            print " OK)\n";
     266            print "Under $dest/../$pkg-$pbver.tar.gz\n";
    321267        }
    322268    }
    323269} else {
    324     print $LOG "'$action' is not available\n";
    325     syntax();
     270    print "'$action' is not available\n";
     271    print "Available actions are:\n";
     272    print "    cms2build\n";
    326273}
    327274
     
    333280my %filter=%$ptr;
    334281my $destfile=shift;
    335 my $pbpkg=shift;
     282my $pkg=shift;
    336283my $dtype=shift;
    337284my $dsuf=shift;
    338285
    339 print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
     286print "From $f to $destfile\n";
    340287pbmkdir_p(dirname($destfile)) if (! -d dirname($destfile));
    341288open(DEST,"> $destfile") || die "Unable to create $destfile";
     
    345292    foreach my $s (keys %filter) {
    346293        # Process single variables
    347         print $LOG "DEBUG filter{$s}: $filter{$s}\n" if ($debug > 1);
     294        #print "debug: $filter{$s}\n";
    348295        my $tmp = $filter{$s};
    349296        next if (not defined $tmp);
     
    353300        # special case for ChangeLog
    354301        } elsif (($tmp =~ /^yes$/) && ($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
    355             my $p = $defpkgdir{$pbpkg};
    356             $p = $extpkgdir{$pbpkg} if (not defined $p);
    357             changelog($dtype, $pbpkg, $pbtag, $dsuf, $p, \*DEST);
     302            my $p = $defpkgdir{$pkg};
     303            $p = $extpkgdir{$pkg} if (not defined $p);
     304            changelog($dtype, $pkg, $pbtag, $dsuf, $p, \*DEST);
    358305            $tmp = "";
    359306        }
     
    365312close(DEST);
    366313}
    367 
    368 sub get_pkg {
    369 
    370 my @pkgs;
    371 
    372 # Get packages list
    373 if (not defined $ARGV[0]) {
    374     @pkgs = keys %defpkgdir;
    375 } elsif ($ARGV[0] =~ /^all$/) {
    376     @pkgs = keys %defpkgdir;
    377     if (defined %extpkgdir) {
    378         my $k = keys %extpkgdir;
    379         if (defined $k) {
    380             push(@pkgs, keys %extpkgdir);
    381         }
    382     }
    383 } else {
    384     @pkgs = @ARGV;
    385 }
    386 print $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);
    387 return(\@pkgs);
    388 }
    389 
    390 sub extract_build_files {
    391 
    392 my $src=shift;
    393 my $dir=shift;
    394 my $ddir=shift;
    395 my @files;
    396 
    397 pbsystem("tar xfz $src $dir >/dev/null","Extracting build files");
    398 opendir(DIR,"$dir") || die "Unable to open directory $dir";
    399 foreach my $f (readdir(DIR)) {
    400     next if ($f =~ /^\./);
    401     move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
    402     print $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);
    403     push @files,"$ddir/$f";
    404 }
    405 closedir(DIR);
    406 # Not enough but still a first cleanup
    407 pbrm_rf("$dir");
    408 return(@files);
    409 }
    410 
    411 sub syntax {
    412 
    413     print "Syntax: pb [-vhqt][-p project] <action> [<params>...]\n";
    414     print "\n";
    415     print "-h : This help file\n";
    416     print "-q : Quiet mode\n";
    417     print "-t : Test mode (not done yet)\n";
    418     print "-v : Verbose mode\n";
    419     print "\n";
    420     print "-p project : Name of the project you're working on\n";
    421     print "             (or use the env variable PBPROJ)     \n";
    422     print "\n";
    423     print "<action> can be:\n";
    424     print "\n";
    425     print "\tcms2build: Create a tar file of the project under your CMS\n";
    426     print "\t           CMS supported are SVN and CVS\n";
    427     print "\t           parameters are packages to build\n";
    428     print "\t           if not using default list\n";
    429     print "\n";
    430     print "\tbuild2pkg: Create packages for your running distribution  \n";
    431     print "\t           first parameter is version-tag to build\n";
    432     print "\t           if not using default version-tag\n";
    433     print "\t           following parameters are packages to build\n";
    434     print "\t           if not using default list\n";
    435     print "\n";
    436     print "\n";
    437 }
Note: See TracChangeset for help on using the changeset viewer.