Changeset 17 in ProjectBuilder


Ignore:
Timestamp:
Jul 30, 2007, 8:03:52 PM (17 years ago)
Author:
Bruno Cornec
Message:

Still in dev. phase - lots of changes - near the end for cms2build

Location:
devel
Files:
1 added
6 edited

Legend:

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

    r16 r17  
    1717use AppConfig qw(:argcount :expand);
    1818use File::Basename;
     19use Archive::Tar;
    1920use Time::localtime qw(localtime);
    2021use POSIX qw(strftime);
    2122
    22 use lib qw (lib etc);
    23 use vars qw (%defpkgdir %extpkgdir %version @filteredfiles);
     23use lib qw (lib);
     24use vars qw (%defpkgdir %extpkgdir %version %param %filteredfiles);
    2425use common qw (env_init);
    25 use pb qw (defpkgdir extpkgdir version filteredfiles pb_init);
     26use pb qw (defpkgdir extpkgdir version param filteredfiles pb_init);
    2627use distro qw (distro_init);
    2728use cms;
     29use changelog qw (changelog);
    2830
    2931my %opts;                   # CLI Options
     
    7678    cms_init();
    7779
    78     foreach my $p (@pkgs) {
    79 
    80         if (-f "$ENV{'PBROOT'}/$p/VERSION") {
    81             open(V,"$ENV{'PBROOT'}/$p/VERSION") || die "Unable to open $ENV{'PBROOT'}/$p/VERSION";
     80    foreach my $pkg (@pkgs) {
     81
     82        if (-f "$ENV{'PBROOT'}/$pkg/VERSION") {
     83            open(V,"$ENV{'PBROOT'}/$pkg/VERSION") || die "Unable to open $ENV{'PBROOT'}/$pkg/VERSION";
    8284            $pbver = <V>;
    8385            chomp($pbver);
     
    8789        }
    8890
    89         if (-f "$ENV{'PBROOT'}/$p/TAG") {
    90             open(T,"$ENV{'PBROOT'}/$p/TAG") || die "Unable to open $ENV{'PBROOT'}/$p/TAG";
     91        if (-f "$ENV{'PBROOT'}/$pkg/TAG") {
     92            open(T,"$ENV{'PBROOT'}/$pkg/TAG") || die "Unable to open $ENV{'PBROOT'}/$pkg/TAG";
    9193            $pbtag = <T>;
    9294            chomp($pbtag);
     
    9698        }
    9799        $pbrev = $ENV{'PBREVISION'};
    98         print "Management of $p $pbver-$pbtag (rev $pbrev)\n";
     100        print "Management of $pkg $pbver-$pbtag (rev $pbrev)\n";
    99101        die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
    100102        # Clean up dest if necessary. The export will recreate it
    101         my $dest = "$ENV{'PBDESTDIR'}/$p-$pbver";
     103        my $dest = "$ENV{'PBDESTDIR'}/$pkg-$pbver";
    102104        pbrm_rf($dest) if (-d $dest);
    103105
     
    105107        # And generate some additional files
    106108        $OUTPUT_AUTOFLUSH=1;
    107         print "$ENV{'PBCMSEXP'} of $p...";
     109        print "$ENV{'PBCMSEXP'} of $pkg...";
    108110        # computes in which dir we have to work
    109         my $dir = $defpkgdir{$p};
    110         $dir = $extpkgdir{$p} if (not defined $dir);
     111        my $dir = $defpkgdir{$pkg};
     112        $dir = $extpkgdir{$pkg} if (not defined $dir);
    111113        system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null");
    112114        if ($? == -1) {
     
    125127        # Extract cms log history and store it
    126128        system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}");
    127         print "$ENV{'PBCMSLOG'} of $p...";
     129        print "$ENV{'PBCMSLOG'} of $pkg...";
    128130        if ($? == -1) {
    129131            print "failed to execute: $!\n";
     
    148150            # Find all build files first relatively to PBROOT
    149151            my %bfiles;
    150             #print "dir: $ENV{'PBCONF'}/$p\n";
    151             if (-d "$ENV{'PBCONF'}/$p/$dtype") {
    152                 opendir(BDIR,"$ENV{'PBCONF'}/$p/$dtype" || die "Unable to open dir $ENV{'PBCONF'}/$p/$dtype: $!");
     152            #print "dir: $ENV{'PBCONF'}/$pkg\n";
     153            if (-d "$ENV{'PBCONF'}/$pkg/$dtype") {
     154                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dtype" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dtype: $!");
    153155                foreach my $f (readdir(BDIR)) {
    154156                    next if ($f =~ /^\./);
    155                     $bfiles{$f} = "$ENV{'PBCONF'}/$p/$dtype/$f";
     157                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$dtype/$f";
    156158                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    157159                }
    158160                closedir(BDIR);
    159             } elsif (-d "$ENV{'PBCONF'}/$p/$dfam") {
    160                 opendir(BDIR,"$ENV{'PBCONF'}/$p/$dfam" || die "Unable to open dir $ENV{'PBCONF'}/$p/$dfam: $!");
     161            } elsif (-d "$ENV{'PBCONF'}/$pkg/$dfam") {
     162                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dfam" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dfam: $!");
    161163                foreach my $f (readdir(BDIR)) {
    162164                    next if ($f =~ /^\./);
    163                     $bfiles{$f} = "$ENV{'PBCONF'}/$p/$dfam/$f";
     165                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$dfam/$f";
    164166                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    165167                }
    166168                closedir(BDIR);
    167             } elsif (-d "$ENV{'PBCONF'}/$p/$ddir") {
    168                 opendir(BDIR,"$ENV{'PBCONF'}/$p/$ddir" || die "Unable to open dir $ENV{'PBCONF'}/$p/$ddir: $!");
     169            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir") {
     170                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir: $!");
    169171                foreach my $f (readdir(BDIR)) {
    170172                    next if ($f =~ /^\./);
    171                     $bfiles{$f} = "$ENV{'PBCONF'}/$p/$ddir/$f";
     173                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$ddir/$f";
    172174                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    173175                }
    174176                closedir(BDIR);
    175             } elsif (-d "$ENV{'PBCONF'}/$p/$ddir-$dver") {
    176                 opendir(BDIR,"$ENV{'PBCONF'}/$p/$ddir-$dver" || die "Unable to open dir $ENV{'PBCONF'}/$p/$ddir-$dver: $!");
     177            } elsif (-d "$ENV{'PBCONF'}/$pkg/$ddir-$dver") {
     178                opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$ddir-$dver" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$ddir-$dver: $!");
    177179                foreach my $f (readdir(BDIR)) {
    178180                    next if ($f =~ /^\./);
    179                     $bfiles{$f} = "$ENV{'PBCONF'}/$p/$ddir-$dver/$f";
     181                    $bfiles{$f} = "$ENV{'PBCONF'}/$pkg/$ddir-$dver/$f";
    180182                    $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    181183                }
     
    192194            my @ffiles;
    193195            my ($ffile0, $ffile1, $ffile2, $ffile3);
    194             if (-d "$ENV{'PBCONF'}/$p/pbfilter") {
    195                 $ffile0 = "$ENV{'PBCONF'}/$p/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/$p/pbfilter/$dtype.pbf");
    196                 $ffile1 = "$ENV{'PBCONF'}/$p/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/$p/pbfilter/$dfam.pbf");
    197                 $ffile2 = "$ENV{'PBCONF'}/$p/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/$p/pbfilter/$ddir.pbf");
    198                 $ffile3 = "$ENV{'PBCONF'}/$p/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/$p/pbfilter/$ddir-$dver.pbf");
     196            if (-d "$ENV{'PBCONF'}/$pkg/pbfilter") {
     197                $ffile0 = "$ENV{'PBCONF'}/$pkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$dtype.pbf");
     198                $ffile1 = "$ENV{'PBCONF'}/$pkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$dfam.pbf");
     199                $ffile2 = "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir.pbf");
     200                $ffile3 = "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/$pkg/pbfilter/$ddir-$dver.pbf");
    199201                push @ffiles,$ffile0 if (defined $ffile0);
    200202                push @ffiles,$ffile1 if (defined $ffile1);
     
    222224                if (defined $ptr) {
    223225                    foreach my $f (values %bfiles) {
    224                         filter_file($f,$ptr,"$dest/pbconf/$ddir-$dver/".basename($f));
     226                        filter_file($f,$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$pkg,$dtype,$dsuf);
    225227                    }
    226                     foreach my $f (@filteredfiles) {
    227                         filter_file($f,$ptr,"$dest/$f");
     228                    foreach my $f (keys %filteredfiles) {
     229                        filter_file($f,$ptr,"$dest/$f",$pkg,$dtype,$dsuf);
    228230                    }
    229231                }
     232            }
     233            # Prepare the dest directory for archive
     234            if (-x "$ENV{'PBCONF'}/$pkg/pbpkginit") {
     235                system("cd $dest ; $ENV{'PBCONF'}/$pkg/pbinit");
     236                if ($? == -1) {
     237                    print "failed to execute: $!\n";
     238                } elsif ($? & 127) {
     239                    printf "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     240                } else {
     241                    print " $dest\n";
     242                }
     243            }
     244            # Archive dest dir
     245            chdir "$dest/..";
     246            print "Creating $pkg tar files (gzip... ";
     247            system("tar cfphz $pkg-$pbver.tar.gz $pkg-$pbver");
     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 " OK)\n";
     254                print "Under $dest/../$pkg-$pbver.tar.gz\n";
    230255            }
    231256        }
     
    238263}
    239264
     265# Function which applies filter on files
    240266sub filter_file {
    241267
     
    244270my %filter=%$ptr;
    245271my $destfile=shift;
     272my $pkg=shift;
     273my $dtype=shift;
     274my $dsuf=shift;
    246275
    247276print "From $f to $destfile\n";
     
    259288        if ($tmp =~ /\$/) {
    260289            eval { $tmp =~ s/(\$\w+)/$1/eeg };
     290        # special case for ChangeLog
     291        } elsif (($tmp =~ /^yes$/) && ($s =~ /^PBLOG$/)) {
     292            $tmp = changelog($dtype, $pkg, $pbtag, $dsuf, \*DEST);
    261293        }
    262294        $line =~ s|$s|$tmp|;
    263295    }
    264296    print DEST $line;
    265     }
     297}
    266298close(FILE);
    267299close(DEST);
  • devel/pb/lib/common.pm

    r13 r17  
    1515use File::Path;
    1616use File::Temp qw /tempdir/;
    17 use vars qw (%defpkgdir %extpkgdir %version);
     17use vars qw (%defpkgdir %extpkgdir %version %param);
    1818use Data::Dumper;
    1919
     
    4343# Check content
    4444#
    45 die "PBROOT doesn't exist in $ENV{'PBETC'}/$proj.pb" if (not (defined $ENV{'PBROOT'}));
     45if (not defined $param{"pbroot"}) {
     46    die "param pbroot doesn't exist in $ENV{'PBETC'}/$proj.pb";
     47} else {
     48    $ENV{'PBROOT'} = $param{"pbroot"};
     49}
     50if (defined $param{"cvsroot"}) {
     51    $ENV{'CVSROOT'} = $param{"cvsroot"};
     52}
     53
    4654die "defpkgdir doesn't exist in $ENV{'PBETC'}/$proj.pb" if (not (defined %defpkgdir));
    4755
  • devel/pb/lib/pb.pm

    r15 r17  
    1111@ISA = qw(Exporter);
    1212# global vars are here
    13 @EXPORT_OK = qw(%defpkgdir %extpkgdir %version @filteredfiles &pb_init);
     13@EXPORT_OK = qw(%defpkgdir %extpkgdir %version %param %filteredfiles &pb_init);
    1414use vars @EXPORT_OK;
    15 use AppConfig qw(ARGCOUNT_ONE ARGCOUNT_HASH ARGCOUNT_LIST EXPAND_ALL);
     15use AppConfig qw(ARGCOUNT_HASH);
    1616
    1717sub pb_init {
     
    2424                            CREATE => 1,
    2525                            DEBUG => 0,
     26                            GLOBAL => {
     27                                # Each conf item is a hash
     28                                ARGCOUNT => AppConfig::ARGCOUNT_HASH
     29                            }
    2630                        });
    27 $config->define("pbroot" => { ARGCOUNT => ARGCOUNT_ONE, EXPAND => EXPAND_ALL });
    28 $config->define("cvsroot" => { ARGCOUNT => ARGCOUNT_ONE });
    29 $config->define("defpkgdir" => { ARGCOUNT => ARGCOUNT_HASH });
    30 $config->define("extpkgdir" => { ARGCOUNT => ARGCOUNT_HASH });
    31 $config->define("version" => { ARGCOUNT => ARGCOUNT_HASH });
    32 $config->define("filteredfiles" => { ARGCOUNT => ARGCOUNT_LIST });
    33 
    3431$config->file($conffile);
    3532
     
    3734# needs at least 2 levels of dir as in the upper
    3835# other dirs will be created and used
    39 $ENV{'PBROOT'} = $config->get("pbroot") || die "Unable to find pbroot in $conffile";
    40 
    41 # If CVS, gives the way to login
    42 $ENV{'CVSROOT'} = $config->get("cvsroot");
     36$ptr = $config->get("param");
     37%param = %$ptr;
    4338
    4439# List of pkg to build by default
     
    5651# List of files to filter
    5752$ptr = $config->get("filteredfiles");
    58 @filteredfiles = @$ptr;
     53%filteredfiles = %$ptr;
    5954
    6055}
  • devel/pbconf/pb.pb

    r16 r17  
    66#
    77
     8# param is a hash to ease interface
    89# Root directory of the pb project
    9 pbroot = "/users/bruno/pb/svn/devel"
     10param pbroot = "/users/bruno/pb/svn/devel"
     11
     12# Packager for ChangeLogs
     13param packager = "Bruno Cornec <bruno\@mondorescue.org>"
    1014
    1115# If CVS give login method with CVSROOT
    1216#cvsroot = ":pserver:anonymous@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe"
    13 cvsroot = " "
     17param cvsroot = " "
    1418
    1519# Hash of default package/package directory
     
    2630# List of files on which to apply filters
    2731# Files are mentioned relatively to pbroot
    28 #filteredfiles bin/pb.pl
     32#filteredfiles pb/bin/pb.pl
  • devel/pbconf/projectbuilder/pbfilter/rh.pbf

    r16 r17  
    1919filter PBDATE = $pbdate
    2020
     21# PBLOG is replaced by the changelog if value is yes
     22filter PBLOG = yes
     23
    2124# PBTAG is replaced by the tag ($pbtag in code)
    2225filter PBTAG = $pbtag
  • devel/pbconf/projectbuilder/rpm/pb.spec

    r16 r17  
    5151
    5252%changelog
     53PBLOG
Note: See TracChangeset for help on using the changeset viewer.