Changeset 88


Ignore:
Timestamp:
Sep 3, 2007, 4:36:22 PM (13 years ago)
Author:
Bruno Cornec
Message:

Prepare for new actions on delivery on SSH

Location:
devel/pb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r87 r88  
    2929use ProjectBuilder::Changelog qw (pb_changelog);
    3030use ProjectBuilder::Version qw (pb_version_init);
    31 use ProjectBuilder::Base qw (pb_conf_read pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb);
     31use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb);
    3232
    3333my %opts;                   # CLI Options
     
    9999    pb_cms2build();
    100100    pb_build2pkg();
    101 } elsif ($action =~ /^build2ftp$/) {
    102     pb_build2ftp();
    103 } elsif ($action =~ /^pkg2ftp$/) {
    104     pb_pkg2ftp();
     101} elsif ($action =~ /^build2ssh$/) {
     102    pb_build2ssh();
     103} elsif ($action =~ /^pkg2ssh$/) {
     104    pb_pkg2ssh();
    105105} else {
    106106    print $LOG "'$action' is not available\n";
     
    263263        my $pkg = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
    264264        $pkg = { } if (not defined $pkg);
    265         my %pkg = %$pkg;
    266         if ((not defined $pkg{$pbpkg}) || ($pkg{$pbpkg} ne "$pbver-$pbtag")) {
    267             $pkg{$pbpkg} = "$pbver-$pbtag";
    268         }
    269 
    270         print $LOG "DEBUG pkg: ".Dumper(\%pkg)."\n" if ($debug >= 1);
     265        if ((not defined $pkg->{$pbpkg}) || ($pkg->{$pbpkg} ne "$pbver-$pbtag")) {
     266            $pkg->{$pbpkg} = "$pbver-$pbtag";
     267        }
     268
     269        print $LOG "DEBUG pkg: ".Dumper($pkg)."\n" if ($debug >= 1);
    271270        open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
    272         foreach my $p (keys %pkg) {
    273             print PKG "pbpkg $p = $pkg{$p}\n";
     271        foreach my $p (keys %$pkg) {
     272            print PKG "pbpkg $p = $pkg->{$p}\n";
    274273        }
    275274        close(PKG);
     
    290289    my $pkg = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
    291290    $pkg = { } if (not defined $pkg);
    292     my %pkg = %$pkg;
    293291
    294292    chdir "$ENV{'PBBUILDDIR'}";
    295293    foreach my $pbpkg (@pkgs) {
    296         my $vertag = $pkg{$pbpkg};
     294        my $vertag = $pkg->{$pbpkg};
    297295        # get the version of the current package - maybe different
    298296        ($pbver,$pbtag) = split(/-/,$vertag);
     
    337335}
    338336
    339 sub pb_build2ftp {
     337sub pb_build2ssh {
     338
     339    my @src;
    340340
    341341    # Get list of packages to build
     
    350350    my $pkg = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
    351351    $pkg = { } if (not defined $pkg);
    352     my %pkg = %$pkg;
    353352
    354353    chdir "$ENV{'PBBUILDDIR'}";
    355354    foreach my $pbpkg (@pkgs) {
    356         my $vertag = $pkg{$pbpkg};
     355        my $vertag = $pkg->{$pbpkg};
    357356        # get the version of the current package - maybe different
    358357        ($pbver,$pbtag) = split(/-/,$vertag);
     
    360359        my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    361360        print $LOG "Source file: $src\n" if ($debug >= 0);
    362 
     361        push @src, $src;
    363362    }
    364 }
    365 sub pb_pkg2ftp {
     363    my $pt = pb_conf_get("sshhost", "sshlogin", "sshdir");
     364    my ($sshhost,$sshlogin,$sshdir) = @$pt;
     365    my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
     366    my $dir = "$sshdir->{$ENV{'PBPROJ'}}/src";
     367    pb_system("ssh -q $mac \"mkdir -p $dir","Preparing $dir on $mac");
     368    pb_system("scp -p ".join(' ',@src)." $mac:$dir","Source delivery in $dir on $mac");
     369}
     370
     371sub pb_pkg2ssh {
    366372
    367373    # Get list of packages to build
     
    376382    my $pkg = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
    377383    $pkg = { } if (not defined $pkg);
    378     my %pkg = %$pkg;
    379384
    380385    chdir "$ENV{'PBBUILDDIR'}";
    381386    foreach my $pbpkg (@pkgs) {
    382         my $vertag = $pkg{$pbpkg};
     387        my $vertag = $pkg->{$pbpkg};
    383388        # get the version of the current package - maybe different
    384389        ($pbver,$pbtag) = split(/-/,$vertag);
  • devel/pb/lib/ProjectBuilder/Base.pm

    r87 r88  
    193193
    194194# Function which returns a pointer on a hash
     195# corresponding to a declaration (arg2) in the main conf file
     196# and test the returned vaue as they need to exist in that case
     197sub pb_conf_get {
     198
     199my @param = @_;
     200
     201my $ptr = pb_conf_read("$ENV{'PBETC'}", @param);
     202my @ptr;
     203if ($#param == 0) {
     204    push @ptr, $ptr;
     205} else {
     206    @ptr = @$ptr;
     207}
     208foreach my $i (0..$#param) {
     209    die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $ptr[$i]);
     210    my $p = $ptr[$i];
     211    $p->{$ENV{'PBPROJ'}} = $p->{'default'} if (not defined $p->{$ENV{'PBPROJ'}});
     212    die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $p->{$ENV{'PBPROJ'}});
     213}
     214if ($#param == 0) {
     215    print "DEBUG: param: ".Dumper($ptr[0])."\n" if ($debug >= 1);
     216    return($ptr[0]);
     217} else {
     218    my $ptr = \@ptr;
     219    print "DEBUG: param: ".Dumper($ptr)."\n" if ($debug >= 1);
     220    return($ptr);
     221}
     222}
     223
     224# Function which returns a pointer on a hash
    195225# corresponding to a declaration (arg2) in a conf file (arg1)
    196226sub pb_conf_read {
     
    222252}
    223253if ($#param == 0) {
    224     print "DEBUG: param: ".Dumper($ptr[0])."\n" if ($debug >= 1);
     254    print "DEBUG: param: $param[0] ".Dumper($ptr[0])."\n" if ($debug >= 1);
    225255    return($ptr[0]);
    226256} else {
    227257    my $ptr = \@ptr;
    228     print "DEBUG: params: ".Dumper($ptr)."\n" if ($debug >= 1);
     258    print "DEBUG: params: ".Dumper(@param)." ".Dumper($ptr)."\n" if ($debug >= 1);
    229259    return($ptr);
    230260}
    231 }
    232 
    233 sub pb_conf_init {
    234 
    235 my $conffile = shift;
    236 my $ptr;
    237 my $trace;
    238 
    239 if ($debug > 0) {
    240     $trace = 1;
    241 } else {
    242     $trace = 0;
    243 }
    244 
    245 my $config = AppConfig->new({
    246                             # Auto Create variables mentioned in Conf file
    247                             DEBUG => $trace,
    248                             CREATE => '1',
    249                             GLOBAL => {
    250                                 # Each conf item is a hash
    251                                 ARGCOUNT => ARGCOUNT_HASH,
    252                             },
    253                         });
    254 $config->file($conffile);
    255 
    256 # Root of the project to build
    257 # needs at least 2 levels of dir as in the upper
    258 # other dirs will be created and used
    259 
    260261}
    261262
     
    266267my $ret;
    267268
    268 my ($cms,$cvsroot) = pb_conf_read("$ENV{'PBETC'}","cms","cvsroot");
    269 die "No CMS defined for $proj" if (not defined $cms);
    270 my %cms = %$cms;
    271 die "No CMS defined for $proj" if (not defined $cms{$proj});
    272 
    273 if ($cms{$proj} eq "svn") {
     269my $cms = pb_conf_get("cms");
     270# This one is optional
     271my $cvsroot = pb_conf_read($ENV{'PBETC'},"cvsroot");
     272
     273if ($cms->{$proj} eq "svn") {
    274274    $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; svnversion .)`;
    275275    chomp($ENV{'PBREVISION'});
     
    277277    $ENV{'PBCMSLOGFILE'}="svn.log";
    278278    $ENV{'PBCMSEXP'}="svn export";
    279 } elsif ($cms{$proj} eq "cvs") {
     279} elsif ($cms->{$proj} eq "cvs") {
    280280    $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate  -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
    281281    chomp($ENV{'PBREVISION'});
    282282    $ENV{'PBCMSLOG'}="cvs log";
    283283    $ENV{'PBCMSLOGFILE'}="cvs.log";
    284     $ENV{'PBCMSEXP'}="cvs export"
     284    $ENV{'PBCMSEXP'}="cvs export";
    285285    #
    286286    # Export content if needed
    287287    #
    288     $ENV{'CVSROOT'} = $cvsroot{$proj} if (defined $cvsroot{$proj});
    289 } else {
    290     die "CMS $cms{$proj} unknown";
     288    $ENV{'CVSROOT'} = $cvsroot->{$proj} if (defined $cvsroot->{$proj});
     289} else {
     290    die "cms $cms->{$proj} unknown";
    291291}
    292292}
  • devel/pb/lib/ProjectBuilder/Changelog.pm

    r87 r88  
    1010use File::Basename;
    1111use English;
    12 use ProjectBuilder::Base qw (pb_conf_read);
     12use ProjectBuilder::Base qw (pb_conf_read _conf_get);
    1313
    1414sub pb_changelog {
     
    6666    my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
    6767    #print "**$ndate**\n";
    68     my $packager = pb_conf_read("$ENV{'PBETC'}", "packager");
    69     my %packager = %$packager;
     68    my $packager = pb_conf_get("packager");
     69
    7070    if (($dtype eq "rpm") || ($dtype eq "fc")) {
    7171        if ($ver !~ /-/) {
     
    7979            $ver2 = "$ver$dsuf";
    8080        }
    81         print $OUTPUT "* $ndate $packager{$ENV{'PBPROJ'}} $ver2\n";
     81        print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
    8282        print $OUTPUT "- Updated to $ver\n";
    8383        }
     
    102102
    103103    if ($dtype eq "deb") {
    104         print $OUTPUT " -- $packager{$ENV{'PBPROJ'}} $n2date\n\n";
     104        print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n";
    105105        print $OUTPUT "\n";
    106106        }
Note: See TracChangeset for help on using the changeset viewer.