Changeset 69 in ProjectBuilder


Ignore:
Timestamp:
Aug 31, 2007, 3:20:15 PM (17 years ago)
Author:
Bruno Cornec
Message:

Rework interfaces of pb_init, conf files content and management to ease usage

Location:
devel/pb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r68 r69  
    2020use POSIX qw(strftime);
    2121
    22 use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles %pbroot $debug $LOG $projectbuilderver $projectbuilderrev);
     22use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles $debug $LOG $projectbuilderver $projectbuilderrev);
    2323$debug = 0;                 # Debug level
    2424$LOG = *STDOUT;             # Where to log
     
    252252
    253253        # Archive dest dir
    254         chdir "$ENV{'PBDESTDIR'}";
     254        chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
    255255        # Possibility to look at PBSRC to guess more the filename
    256256        pbsystem("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
    257257        print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
    258258        # Keep track of what is generated for build2pkg default
    259         open(LAST,"> $ENV{'PBDESTDIR'}/LAST") || die "Unable to create $ENV{'PBDESTDIR'}/LAST";
     259        open(LAST,"> $ENV{'PBDESTDIR'}/pbrc") || die "Unable to create $ENV{'PBDESTDIR'}/pbrc";
    260260        print LAST "$pbver-$pbtag\n";
    261261        close(LAST);
     
    265265    my $vertag = shift @ARGV;
    266266    if (not defined $vertag) {
    267         open(LAST,"$ENV{'PBDESTDIR'}/LAST") || die "Unable to open $ENV{'PBDESTDIR'}/LAST\nYou may want to precise as parameter version-tag";
     267        open(LAST,"$ENV{'PBDESTDIR'}/pbrc") || die "Unable to open $ENV{'PBDESTDIR'}/pbrc\nYou may want to precise as parameter version-tag";
    268268        $vertag = <LAST>;
    269269        chomp($vertag);
     
    411411    print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
    412412    print "\n";
    413     print "Syntax: pb [-vhqt][-p project] <action> [<params>...]\n";
     413    print "Syntax: pb [-vhqt][-r pbroot][-p project] <action> [<params>...]\n";
    414414    print "\n";
    415415    print "-h : This help file\n";
     
    417417    print "-t : Test mode (not done yet)\n";
    418418    print "-v : Verbose mode\n";
     419    print "\n";
     420    print "-r pbroot  : Path Name of project under the CMS \n";
     421    print "             (or use the env variable PBROOT)   \n";
    419422    print "\n";
    420423    print "-p project : Name of the project you're working on\n";
  • devel/pb/lib/ProjectBuilder/common.pm

    r68 r69  
    3232    $proj = $ENV{'PBPROJ'};
    3333}
     34
     35#
     36# We get the pbrc file for that project
     37# and use its content
     38#
     39$pbrc = pb_init("$ENV{'PBETC'}","pbrc");
     40
     41my %pbrc = %$pbrc;
     42if (not defined $proj) {
     43    # Take the first as the default project
     44    $proj = (keys %pbrc)[0];
     45    print $LOG "Using $proj as default project as none has been specified\n" if (($debug >= 0) and (defined $proj));
     46}
     47die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
     48
     49#
     50# Set delivery directory
     51#
     52my $topdir=basename($pbrc{$proj});
     53chdir $topdir || die "Unable to change directory to $topdir";
     54$ENV{'PBDESTDIR'}=$topdir."/delivery";
     55
    3456#
    3557# Use project configuration file if needed
    3658#
    3759if (not defined $ENV{'PBROOT'}) {
    38     pb_init("$ENV{'PBETC'}");
    39 
    40     if (not defined $proj) {
    41         # Take the first as the default project
    42         $proj = (keys %pbroot)[0];
    43     print $LOG "Using $proj as default project as none has been specified\n" if (($debug >= 0) and (defined $proj));
     60    if (-f $pbrc{$proj}) {
     61        $pbroot = pb_init($pbrc{$proj},"pbroot");
     62        # There is normaly only one line in it
     63        $ENV{'PBROOT'} = (values %$pbroot)[0] if (defined $pbroot);
     64        print $LOG "Using $ENV{'PBROOT'} as default pbroot from $pbrc{$proj}\n" if (($debug >= 0) and (defined $ENV{'PBROOT'}));
    4465    }
    45     die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
    46 
    47     $ENV{'PBROOT'} = $pbroot{$proj};
    48 } else {
    49     die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
     66    die "No pbroot defined - use env var PBROOT or -r pbroot " if (not defined $ENV{'PBROOT'});
    5067}
    5168
     
    101118
    102119#
    103 # Adapt to your needs
    104 # Set delivery directory
    105 # Removes all directory existing below as they are temp dir only
     120# Removes all directory existing below the delivery dir
     121# as they are temp dir only
    106122# Files stay and have to be cleaned up manually
    107123#
    108 chdir "$ENV{'PBROOT'}/..";
    109 my $path = `pwd`;
    110 chomp($path);
    111 $ENV{'PBDESTDIR'}=$path."/delivery";
    112124if (-d $ENV{'PBDESTDIR'}) {
    113125    opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
  • devel/pb/lib/ProjectBuilder/pb.pm

    r50 r69  
    99use AppConfig qw(ARGCOUNT_HASH ARGCOUNT_ONE);
    1010use Data::Dumper;
    11 use vars qw (%pbroot);
    1211
    1312sub pb_init {
    1413
    1514my $conffile = shift;
     15my $param = shift;
    1616my $trace;
    1717
     
    3333                        });
    3434$config->file($conffile);
    35 my $ptr = $config->get("pbroot") || die "Unable to find pbroot in $conffile";
     35my $ptr = $config->get($param) || die "Unable to find $param in $conffile";
    3636print "DEBUG: pbroot: ".Dumper($ptr)."\n" if ($debug >= 1);
    37 %pbroot = %$ptr;
     37return($ptr);
    3838}
    3939
Note: See TracChangeset for help on using the changeset viewer.