Ignore:
Timestamp:
08/31/07 15:20:15 (6 years ago)
Author:
bruno
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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'}: $!"; 
Note: See TracChangeset for help on using the changeset viewer.