Changeset 353


Ignore:
Timestamp:
Apr 5, 2008, 2:36:14 AM (11 years ago)
Author:
bruno
Message:
  • pb_env_init does just setup env variables now. It does CMS checks and conf only if called on a CMS opration
  • systematic use of ENV VAR for PBPROJVER, PBPROJTAG, PBPACKAGER
  • new function to get package list for cms only context and the old one is simplified
  • setup2vm works also with fedora-6-i386
  • build2vm nearly works now
  • $DESTDIR/pbrc contains now aal the keys needed to be independant when building (pbroot, pbprojver, pbprojtag, pbpackager)
  • remove ntp calls for the moment (not ready)
Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r352 r353  
    377377# Handles project name if any
    378378# And get global params
    379 if (defined $opts{'p'}) {
    380     ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
    381     = pb_env_init($opts{'p'},$pbinit);
    382 } else {
    383     ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
    384     = pb_env_init(undef,$pbinit);
    385 }
     379($filteredfiles, $supfiles, $defpkgdir, $extpkgdir) = pb_env_init($opts{'p'},$pbinit,$action);
    386380
    387381pb_log(0,"Project: $ENV{'PBPROJ'}\n");
    388382pb_log(0,"Action: $action\n");
    389 
    390 # Keep those project values to store them at the end each time
    391 my $pbprojtag = $ENV{'PBTAG'};
    392 my $pbprojver = $ENV{'PBVER'};
    393383
    394384# Act depending on action
     
    432422    pb_launchv("vm",$ENV{'PBV'},1);
    433423} elsif ($action =~ /^setupve$/) {
    434     my $pbscript = pb_setup_v("ve");
    435     # That buil script needs to be run as root
    436     $pbaccount = "root";
    437     pb_script2v($pbscript,"ve");
     424    pb_setup_v("ve");
    438425} elsif ($action =~ /^setupvm$/) {
    439     my $pbscript = pb_setup_v("vm");
    440     # That buil script needs to be run as root
    441     $pbaccount = "root";
    442     pb_script2v($pbscript,"vm");
     426    pb_setup_v("vm");
    443427} elsif ($action =~ /^newproj$/) {
    444428    # Nothing to do - already done in pb_env_init
     
    451435sub pb_cms2build {
    452436
    453     my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
     437    my $ptr = pb_cms_get_pkg($defpkgdir,$extpkgdir);
    454438    @pkgs = @$ptr;
    455439
     
    460444    # declare packager for filtering
    461445    my ($tmp) = pb_conf_get("pbpackager");
    462     my $pbpackager = $tmp->{$ENV{'PBPROJ'}};
     446    $ENV{'PBPACKAGER'} = $tmp->{$ENV{'PBPROJ'}};
    463447
    464448    foreach my $pbpkg (@pkgs) {
    465449        $ENV{'PBPKG'} = $pbpkg;
    466         $ENV{'PBVER'} = $pbprojver;
    467         $ENV{'PBTAG'} = $pbprojtag;
    468450        if ((defined $pkgv) && (defined $pkgv->{$pbpkg})) {
    469451            $pbver = $pkgv->{$pbpkg};
    470             $ENV{'PBVER'} = $pbver;
    471452        } else {
    472             $pbver = $ENV{'PBVER'};
     453            $pbver = $ENV{'PBPROJVER'};
    473454        }
    474455        if ((defined $pkgt) && (defined $pkgt->{$pbpkg})) {
    475456            $pbtag = $pkgt->{$pbpkg};
    476             $ENV{'PBTAG'} = $pbtag;
    477457        } else {
    478             $pbtag = $ENV{'PBTAG'};
     458            $pbtag = $ENV{'PBPROJTAG'};
    479459        }
    480460
     
    567547            if (defined $ptr) {
    568548                foreach my $f (values %bfiles,values %pkgfiles) {
    569                     pb_filter_file_pb("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir,$pbpackager,$chglog);
     549                    pb_filter_file_pb("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver/".basename($f),$dtype,$pbsuf,$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$defpkgdir,$extpkgdir,$ENV{'PBPACKAGER'},$chglog);
    570550                }
    571551            }
     
    589569        if (defined $filteredfiles->{$pbpkg}) {
    590570            foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
    591                 pb_filter_file_inplace($ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
     571                pb_filter_file_inplace($ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'});
    592572                $liste = "$f $liste";
    593573            }
     
    597577        # Prepare the dest directory for archive
    598578        if (-x "$ENV{'PBROOTDIR'}/$pbpkg/pbinit") {
    599             pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
     579            pb_filter_file("$ENV{'PBROOTDIR'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$ENV{'PBPACKAGER'});
    600580            chmod 0755,"$ENV{'PBTMP'}/pbinit";
    601581            pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOTDIR'}/$pbpkg/pbinit");
     
    609589
    610590        # Keep track of what is generated by default
    611         open(LAST,"> $ENV{'PBDESTDIR'}/pbrc") || die "Unable to create $ENV{'PBDESTDIR'}/pbrc";
    612         #print LAST "pbroot $pbprojver-$pbprojtag = $ENV{'PBROOTDIR'}\n";
    613         # Why not use pbproj ?
     591        # We need to store the dir and info on version-tag
     592        # Base our content on the existing .pb file
     593        copy("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb","$ENV{'PBDESTDIR'}/pbrc");
     594        open(LAST,">> $ENV{'PBDESTDIR'}/pbrc") || die "Unable to create $ENV{'PBDESTDIR'}/pbrc";
    614595        print LAST "pbroot $ENV{'PBPROJ'} = $ENV{'PBROOTDIR'}\n";
     596        print LAST "pbprojver $ENV{'PBPROJ'} = $ENV{'PBPROJVER'}\n";
     597        print LAST "pbprojtag $ENV{'PBPROJ'} = $ENV{'PBPROJTAG'}\n";
     598        print LAST "pbpackager $ENV{'PBPROJ'} = $ENV{'PBPACKAGER'}\n";
    615599        close(LAST);
    616600
    617601        # Keep track of per package version
    618         my ($pkg) = pb_conf_read_if("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
     602        my ($pkg) = pb_conf_read_if("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
    619603        $pkg = { } if (not defined $pkg);
    620604        if ((not defined $pkg->{$pbpkg}) || ($pkg->{$pbpkg} ne "$pbver-$pbtag")) {
     
    623607
    624608        pb_log(2,"DEBUG pkg: ".Dumper($pkg)."\n");
    625         open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
     609        open(PKG,"> $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb";
    626610        foreach my $p (keys %$pkg) {
    627611            print PKG "pbpkg $p = $pkg->{$p}\n";
     
    635619
    636620sub pb_build2pkg {
    637 
    638     # Get list of packages to build
    639     my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
    640     @pkgs = @$ptr;
    641621
    642622    # Get the running distro to build on
     
    644624    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
    645625
     626    # Get list of packages to build
    646627    # Get content saved in cms2build
    647     my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
     628    my $ptr = pb_get_pkg();
     629    @pkgs = @$ptr;
     630
     631    my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
    648632    $pkg = { } if (not defined $pkg);
    649 
    650     # declare packager (via env var in VM/VE
    651     my $pbpackager;
    652     if (not defined $ENV{'PBPACKAGER'}) {
    653         my ($tmp) = pb_conf_get("pbpackager");
    654         $pbpackager = $tmp->{$ENV{'PBPROJ'}};
    655     } else {
    656         $pbpackager = $ENV{'PBPACKAGER'};
    657     }
    658633
    659634    chdir "$ENV{'PBBUILDDIR'}";
     
    687662            foreach my $f (@specfile) {
    688663                if ($f =~ /\.spec$/) {
    689                     pb_system("rpmbuild --define \'packager $pbpackager\' --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}");
     664                    pb_system("rpmbuild --define \'packager $ENV{'PBPACKAGER'}\' --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}");
    690665                    last;
    691666                }
     
    766741    }
    767742    # Keep track of what is generated so that we can get them back from VMs
    768     open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
     743    open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    769744    print KEEP "$made\n";
    770745    close(KEEP);
     
    815790    my $cmd = "";
    816791
    817     # Get list of packages to build
    818     my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
     792    my $ptr = pb_get_pkg();
    819793    @pkgs = @$ptr;
    820794
     
    827801    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
    828802
     803    # Get list of packages to build
    829804    # Get content saved in cms2build
    830     my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb","pbpkg");
     805    my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
    831806    $pkg = { } if (not defined $pkg);
    832807
     
    848823    }
    849824    if (($cmt eq "vm") || ($cmt eq "ve")) {
    850         $src="$src $ENV{'PBDESTDIR'}/pbscript $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb $ENV{'PBETC'}";
     825        $src="$src $ENV{'PBDESTDIR'}/pbscript $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc";
    851826    } elsif ($cmt eq "Script") {
    852827        $src="$src $ENV{'PBDESTDIR'}/pbscript";
    853828    } elsif ($cmt eq "Packages") {
    854829        # Get package list from file made during build2pkg
    855         open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
     830        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    856831        $src = <KEEP>;
    857832        chomp($src);
     
    945920    if (($cmt eq "vm") || ($cmt eq "ve")) {
    946921        # Get back info on pkg produced, compute their name and get them from the VM
    947         pb_system("$cpcmd $cp2target/pbgen-$pbprojver-$pbprojtag $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $cp2target");
    948         open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
     922        pb_system("$cpcmd $cp2target/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'} $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $cp2target");
     923        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    949924        my $src = <KEEP>;
    950925        chomp($src);
     
    954929        # Change pgben to make the next send2target happy
    955930        my $made = "";
    956         open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
     931        open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    957932        foreach my $p (split(/ +/,$src)) {
    958933            my $j = basename($p);
     
    11261101# Prepare the script to be executed on the VM/VE
    11271102# in $ENV{'PBDESTDIR'}/pbscript
    1128 my ($ntp) = pb_conf_get($vtype."ntp");
    1129 my $vntp = $ntp->{$ENV{'PBPROJ'}};
     1103#my ($ntp) = pb_conf_get($vtype."ntp");
     1104#my $vntp = $ntp->{$ENV{'PBPROJ'}};
    11301105
    11311106open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript";
     
    11421117$date[1]++;
    11431118my $upddate = strftime("%m%d%H%M%Y", @date);
    1144 print SCRIPT "echo Setting up date on $vntp...\n";
     1119#print SCRIPT "echo Setting up date on $vntp...\n";
    11451120# Or use ntpdate if available TBC
    11461121print SCRIPT "sudo date $upddate\n";
    1147 # This exports avoids pb_env_init to deal with PBCONF stuff
    1148 print SCRIPT "export PBCONF=/tmp\n";
    1149 print SCRIPT "export PBVER=$ENV{'PBVER'}\n";
    1150 print SCRIPT "export PBTAG=$ENV{'PBTAG'}\n";
     1122# Get list of packages to build and get some ENV vars as well
     1123my $ptr = pb_get_pkg();
     1124@pkgs = @$ptr;
     1125my $p = join(' ',@pkgs) if (@pkgs);
     1126print SCRIPT "export PBPROJVER=$ENV{'PBPROJVER'}\n";
     1127print SCRIPT "export PBPROJTAG=$ENV{'PBPROJTAG'}\n";
    11511128print SCRIPT "export PBPACKAGER=\"$ENV{'PBPACKAGER'}\"\n";
    11521129print SCRIPT "# Build\n";
    1153 # Get list of packages to build
    1154 my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
    1155 @pkgs = @$ptr;
    1156 my $p = join(' ',@pkgs) if (@pkgs);
    11571130print SCRIPT "echo Building packages on $vtype...\n";
    11581131print SCRIPT "pb -p $ENV{'PBPROJ'} build2pkg $p\n";
     
    12471220my $vtype = shift;
    12481221
     1222my ($vm,$all) = pb_get_v($vtype);
     1223
    12491224# Script generated
    12501225my $pbscript = "$ENV{'PBDESTDIR'}/setupv";
    12511226
    1252 # Name of the account to deal with for VM/VE
    1253 # Do not use the one passed potentially with -a
    1254 my ($pbaccount) = pb_conf_get($vtype."login");
    1255 
    1256 if ($vtype eq "vm") {
    1257     # Prepare the key to be used and transfered remotely
    1258     my $keyfile = pb_ssh_get(1);
     1227foreach my $v (@$vm) {
     1228    # Name of the account to deal with for VM/VE
     1229    # Do not use the one passed potentially with -a
     1230    my ($pbac) = pb_conf_get($vtype."login");
     1231
     1232    if ($vtype eq "vm") {
     1233        # Prepare the key to be used and transfered remotely
     1234        my $keyfile = pb_ssh_get(1);
     1235       
     1236        my ($vmhost,$vmport) = pb_conf_get("vmhost","vmport");
     1237        my $nport = $vmport->{$ENV{'PBPROJ'}};
     1238        $nport = "$pbport" if (defined $pbport);
    12591239   
    1260     my ($vmhost,$vmport) = pb_conf_get("vmhost","vmport");
    1261     my $nport = $vmport->{$ENV{'PBPROJ'}};
    1262     $nport = "$pbport" if (defined $pbport);
    1263 
    1264     pb_system("cat $keyfile.pub | ssh -q -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir .ssh ; chmod 700 .ssh ; cat > .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password");
    1265     # once this is done, we can do what we want on the VM remotely
    1266 }
    1267 
    1268 # Prepare the script to be executed on the VM/VE
    1269 # in $ENV{'PBDESTDIR'}/setupv
    1270 
    1271 open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
    1272 print SCRIPT << 'EOF';
     1240        # Launch the VM
     1241        my ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
     1242
     1243        # Skip that VM if something went wrong
     1244        return if (($vmpid == 0) && ($vmexist == 0));
     1245   
     1246        pb_system("cat $keyfile.pub | ssh -q -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password");
     1247        # once this is done, we can do what we want on the VM remotely
     1248    }
     1249   
     1250    # Prepare the script to be executed on the VM/VE
     1251    # in $ENV{'PBDESTDIR'}/setupv
     1252   
     1253    open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
     1254    print SCRIPT << 'EOF';
    12731255#!/usr/bin/perl -w
    12741256
     
    12811263while (<PBFILE>) {
    12821264EOF
    1283 print SCRIPT << "EOF";
    1284     \$found = 1 if (/^$pbaccount->{$ENV{'PBPROJ'}}:/);
     1265    print SCRIPT << "EOF";
     1266    \$found = 1 if (/^$pbac->{$ENV{'PBPROJ'}}:/);
    12851267EOF
    1286 print SCRIPT << 'EOF';
     1268    print SCRIPT << 'EOF';
    12871269}
    12881270close(PBFILE);
     
    12931275    }
    12941276EOF
    1295 print SCRIPT << "EOF";
    1296 system "groupadd $pbaccount->{$ENV{'PBPROJ'}}";
    1297 system "useradd $pbaccount->{$ENV{'PBPROJ'}} -g $pbaccount->{$ENV{'PBPROJ'}} -m -d /home/$pbaccount->{$ENV{'PBPROJ'}}";
     1277    print SCRIPT << "EOF";
     1278system "groupadd $pbac->{$ENV{'PBPROJ'}}";
     1279system "useradd $pbac->{$ENV{'PBPROJ'}} -g $pbac->{$ENV{'PBPROJ'}} -m -d /home/$pbac->{$ENV{'PBPROJ'}}";
    12981280
    12991281# For pb
    1300 chdir "/home/$pbaccount->{$ENV{'PBPROJ'}}";
     1282chdir "/home/$pbac->{$ENV{'PBPROJ'}}";
    13011283mkdir ".ssh",0700;
    13021284# Allow those accessing root to access the build account
    13031285copy("\$ENV{'HOME'}/.ssh/authorized_keys",".ssh/authorized_keys");
    13041286chmod 0600,".ssh/authorized_keys";
    1305 system 'chown -R $pbaccount->{$ENV{'PBPROJ'}}:$pbaccount->{$ENV{'PBPROJ'}} .ssh';
     1287system 'chown -R $pbac->{$ENV{'PBPROJ'}}:$pbac->{$ENV{'PBPROJ'}} .ssh';
    13061288
    13071289EOF
    1308 print SCRIPT << 'EOF';
     1290    print SCRIPT << 'EOF';
    13091291}
    13101292
     
    13151297while (<PBFILE>) {
    13161298EOF
    1317 print SCRIPT << "EOF";
    1318     s/^$pbaccount->{$ENV{'PBPROJ'}}:\!\!:/$pbaccount->{$ENV{'PBPROJ'}}:*:/;
    1319     s/^$pbaccount->{$ENV{'PBPROJ'}}:\!:/$pbaccount->{$ENV{'PBPROJ'}}:*:/;   #SLES 9 e.g.
     1299    print SCRIPT << "EOF";
     1300    s/^$pbac->{$ENV{'PBPROJ'}}:\!\!:/$pbac->{$ENV{'PBPROJ'}}:*:/;
     1301    s/^$pbac->{$ENV{'PBPROJ'}}:\!:/$pbac->{$ENV{'PBPROJ'}}:*:/; #SLES 9 e.g.
    13201302EOF
    1321 print SCRIPT << 'EOF';
     1303    print SCRIPT << 'EOF';
    13221304    print PBOUT $_;
    13231305}
     
    13351317while (<PBFILE>) {
    13361318EOF
    1337 print SCRIPT << "EOF";
    1338     next if (/^$pbaccount->{$ENV{'PBPROJ'}}   /);
     1319    print SCRIPT << "EOF";
     1320    next if (/^$pbac->{$ENV{'PBPROJ'}}   /);
    13391321EOF
    1340 print SCRIPT << 'EOF';
     1322    print SCRIPT << 'EOF';
    13411323    s/Defaults[ \t]+requiretty//;
    13421324    print PBOUT $_;
     
    13441326close(PBFILE);
    13451327EOF
    1346 print SCRIPT << "EOF";
    1347 # This is needed in order to be able to halt the machine from the $pbaccount->{$ENV{'PBPROJ'}} account at least
    1348 print PBOUT "$pbaccount->{$ENV{'PBPROJ'}}   ALL=(ALL) NOPASSWD:ALL\n";
     1328    print SCRIPT << "EOF";
     1329# This is needed in order to be able to halt the machine from the $pbac->{$ENV{'PBPROJ'}} account at least
     1330print PBOUT "$pbac->{$ENV{'PBPROJ'}}   ALL=(ALL) NOPASSWD:ALL\n";
    13491331EOF
    1350 print SCRIPT << 'EOF';
     1332    print SCRIPT << 'EOF';
    13511333close(PBOUT);
    13521334rename("$file.new",$file);
     
    13541336
    13551337EOF
    1356 
    1357 my $SCRIPT = \*SCRIPT;
    1358 
    1359 pb_install_deps($SCRIPT);
    1360 
    1361 print SCRIPT << 'EOF';
     1338       
     1339    my $SCRIPT = \*SCRIPT;
     1340   
     1341    pb_install_deps($SCRIPT);
     1342   
     1343    print SCRIPT << 'EOF';
    13621344# Suse wants sudoers as 640
    13631345if (($ddir eq "sles") || (($ddir eq "suse")) && ($dver ne "10.3")) {
     
    13661348
    13671349# Sync date
    1368 system "/usr/sbin/ntpdate ntp.pool.org";
     1350#system "/usr/sbin/ntpdate ntp.pool.org";
    13691351
    13701352system "rm -rf project-builder-* ; wget --passive-ftp ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz ; tar xvfz project-builder-latest.tar.gz ; cd project-builder-* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf project-builder-*";
    13711353EOF
    1372 
    1373 # Adds pb_distro_init from ProjectBuilder::Distribution
    1374 foreach my $d (@INC) {
    1375     my $f = "$d/ProjectBuilder/Distribution.pm";
    1376     if (-f "$f") {
    1377         open(PBD,"$f") || die "Unable to open $f";
    1378         while (<PBD>) {
    1379             next if (/^package/);
    1380             next if (/^use Exporter/);
    1381             next if (/^\@our /);
    1382             print SCRIPT $_;
    1383         }
    1384         close(PBD);
    1385         last;
    1386     }
    1387 }
    1388 close(SCRIPT);
    1389 chmod 0755,"$pbscript";
    1390 return($pbscript);
     1354   
     1355    # Adds pb_distro_init from ProjectBuilder::Distribution
     1356    foreach my $d (@INC) {
     1357        my $f = "$d/ProjectBuilder/Distribution.pm";
     1358        if (-f "$f") {
     1359            open(PBD,"$f") || die "Unable to open $f";
     1360            while (<PBD>) {
     1361                next if (/^package/);
     1362                next if (/^use Exporter/);
     1363                next if (/^\@our /);
     1364                print SCRIPT $_;
     1365            }
     1366            close(PBD);
     1367            last;
     1368        }
     1369    }
     1370    close(SCRIPT);
     1371    chmod 0755,"$pbscript";
     1372
     1373    # That build script needs to be run as root
     1374    $pbaccount = "root";
     1375    pb_script2v($pbscript,$vtype);
     1376}
     1377return;
    13911378}
    13921379
     
    14121399    }
    14131400
    1414     system "yum -y $opt install rpm-build wget patch ntp sudo perl-DateManip perl-ExtUtils-MakeMaker";
     1401    system "yum -y $opt install rpm-build wget patch ntp sudo perl-DateManip perl-File-MimeInfo perl-ExtUtils-MakeMaker";
    14151402} elsif (( $dfam eq "rh" ) || ($ddir eq "sles") || (($ddir eq "suse") && (($dver eq "10.1") || ($dver eq "10.0"))) || (($ddir eq "mandrake") && ($dver eq "10.1")) || ($ddir eq "slackware")) {
    14161403    # Suppose pkg are installed already
     
    14261413    system "export TERM=linux ; liste=\"\" ; for i in make wget patch sudo perl-DateManip perl-File-HomeDir xntp; do rpm -q \$i 1> /dev/null 2> /dev/null ; if [ \$\? != 0 ]; then liste=\"\$liste \$i\"; fi; done; echo \"Liste: \$liste\" ; if [ \"\$liste\" != \"\" ]; then yast2 -i \$liste ; fi";
    14271414} elsif ( $dfam eq "md" ) {
    1428         system "urpmi.update -a ; urpmi --auto rpm-build wget sudo patch ntp-client perl-DateManip";
     1415        system "urpmi.update -a ; urpmi --auto rpm-build wget sudo patch ntp-client perl-File-MimeInfo perl-DateManip";
    14291416} elsif ( $dfam eq "du" ) {
    14301417    if (( $dver eq "3.1" ) && ($ddir eq "debian")) {
    14311418        #system "apt-get update";
    1432         system "apt-get -y install wget patch ssh sudo debian-builder dh-make fakeroot ntpdate libdate-manip-perl";
     1419        system "apt-get -y install wget patch ssh sudo debian-builder dh-make fakeroot ntpdate libfile-mimeinfo-perl libdate-manip-perl";
    14331420    } else  {
    1434         system "apt-get update; apt-get -y install wget patch openssh-server dpkg-dev sudo debian-builder dh-make fakeroot ntpdate rses5-dev libdate-manip-perl";
     1421        system "apt-get update; apt-get -y install wget patch openssh-server dpkg-dev sudo debian-builder dh-make fakeroot ntpdate rses5-dev libfile-mimeinfo-perl libdate-manip-perl";
    14351422    }
    14361423} elsif ( $dfam eq "gen" ) {
  • devel/pb/lib/ProjectBuilder/Base.pm

    r347 r353  
    3232
    3333our @ISA = qw(Exporter);
    34 our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg pb_get_uri pb_cms_get_uri $debug $LOG);
     34our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg pb_cms_get_pkg pb_get_uri pb_cms_get_uri $debug $LOG);
    3535
    3636$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
     
    4040my $proj=shift || undef;
    4141my $pbinit=shift || undef;
     42my $action=shift;
    4243my $ver;
    4344my $tag;
     
    181182#
    182183# The following part is only useful when in cms2build
    183 # In VMs/VEs we want to skip that by providing a good PBCONFDIR env var.
     184# In VMs/VEs we want to skip that by providing good env vars.
    184185# return values in that case are useless
    185186#
    186 return if (defined $ENV{'PBCONFDIR'});
    187 
    188 #
    189 # Check pbconf cms compliance
    190 #
    191 pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
    192 
    193 # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
    194 #
    195 if (not defined $ENV{'PBROOTDIR'}) {
    196     if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
    197         opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
    198         my $maxmtime = 0;
    199         foreach my $d (readdir(DIR)) {
    200             pb_log(3,"Looking at \'$d\'...");
    201             next if ($d =~ /^\./);
    202             next if (! -d "$ENV{'PBCONFDIR'}/$d");
    203             my $s = stat("$ENV{'PBCONFDIR'}/$d");
    204             next if (not defined $s);
    205             pb_log(3,"KEEP\n");
    206             # Keep the most recent
    207             pb_log(2," $s->mtime\n");
    208             if ($s->mtime > $maxmtime) {
    209                 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
    210                 $maxmtime = $s->mtime;
     187if ($action =~ /^cms2/) {
     188
     189    #
     190    # Check pbconf cms compliance
     191    #
     192    pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
     193
     194    # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
     195    #
     196    if (not defined $ENV{'PBROOTDIR'}) {
     197        if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
     198            opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
     199            my $maxmtime = 0;
     200            foreach my $d (readdir(DIR)) {
     201                pb_log(3,"Looking at \'$d\'...");
     202                next if ($d =~ /^\./);
     203                next if (! -d "$ENV{'PBCONFDIR'}/$d");
     204                my $s = stat("$ENV{'PBCONFDIR'}/$d");
     205                next if (not defined $s);
     206                pb_log(3,"KEEP\n");
     207                # Keep the most recent
     208                pb_log(2," $s->mtime\n");
     209                if ($s->mtime > $maxmtime) {
     210                    $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
     211                    $maxmtime = $s->mtime;
     212                }
    211213            }
    212         }
    213         closedir(DIR);
    214         die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
    215         pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
    216         pb_log(1,"         Please use -r release if you want to use another release\n");
     214            closedir(DIR);
     215            die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
     216            pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
     217            pb_log(1,"         Please use -r release if you want to use another release\n");
     218        } else {
     219            my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
     220            # That's always the environment variable that will be used
     221            die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
     222            $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
     223        }
    217224    } else {
    218         my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
    219         # That's always the environment variable that will be used
    220         die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
    221         $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
    222     }
    223 } else {
    224     # transform in full path if relative
    225     $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
    226     pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
    227     die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
    228 }
    229 
    230 my %version = ();
    231 my %defpkgdir = ();
    232 my %extpkgdir = ();
    233 my %filteredfiles = ();
    234 my %supfiles = ();
    235 
    236 if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
    237     # List of pkg to build by default (mandatory)
    238     my ($defpkgdir,$pbpackager) = pb_conf_get("defpkgdir","pbpackager");
    239     # List of additional pkg to build when all is called (optional)
    240     # Valid version names (optional)
    241     # List of files to filter (optional)
    242     # Project version and tag (optional)
    243     my ($extpkgdir, $version, $filteredfiles, $supfiles, $pkgv, $pkgt) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles","projver","projtag");
    244     pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
    245     pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
    246     pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
    247     pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
    248     pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
    249     # Global
    250     %defpkgdir = %$defpkgdir;
    251     %extpkgdir = %$extpkgdir if (defined $extpkgdir);
    252     %version = %$version if (defined $version);
    253     %filteredfiles = %$filteredfiles if (defined $filteredfiles);
    254     %supfiles = %$supfiles if (defined $supfiles);
    255     #
    256     # Get global Version/Tag
    257     #
    258     if (not defined $ENV{'PBVER'}) {
    259         if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
    260             $ENV{'PBVER'}=$pkgv->{$ENV{'PBPROJ'}};
    261         } else {
    262             die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    263         }
    264     }
    265     die "Invalid version name $ENV{'PBVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBVER'} =~ /$version{$ENV{'PBPROJ'}}/));
     225        # transform in full path if relative
     226        $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
     227        pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
     228        die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
     229    }
     230
     231    my %version = ();
     232    my %defpkgdir = ();
     233    my %extpkgdir = ();
     234    my %filteredfiles = ();
     235    my %supfiles = ();
    266236   
    267     if (not defined $ENV{'PBTAG'}) {
    268         if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
    269             $ENV{'PBTAG'}=$pkgt->{$ENV{'PBPROJ'}};
    270         } else {
    271             die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    272         }
    273     }
    274     die "Invalid tag name $ENV{'PBTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBTAG'} !~ /[0-9.]+/);
    275 
    276 
    277     if (not defined $ENV{'PBPACKAGER'}) {
    278         if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
    279             $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
    280         } else {
    281             die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    282         }
    283     }
    284 } else {
    285     if (defined $pbinit) {
    286         my $ptr = pb_get_pkg();
    287         my @pkgs = @$ptr;
    288         @pkgs = ("pkg1") if (not @pkgs);
    289 
    290         open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    291         print CONF << "EOF";
     237    if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
     238        # List of pkg to build by default (mandatory)
     239        my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
     240        # List of additional pkg to build when all is called (optional)
     241        # Valid version names (optional)
     242        # List of files to filter (optional)
     243        # Project version and tag (optional)
     244        my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
     245        pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
     246        pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
     247        pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
     248        pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
     249        pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
     250        # Global
     251        %defpkgdir = %$defpkgdir;
     252        %extpkgdir = %$extpkgdir if (defined $extpkgdir);
     253        %version = %$version if (defined $version);
     254        %filteredfiles = %$filteredfiles if (defined $filteredfiles);
     255        %supfiles = %$supfiles if (defined $supfiles);
     256        #
     257        # Get global Version/Tag
     258        #
     259        if (not defined $ENV{'PBPROJVER'}) {
     260            if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
     261                $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
     262            } else {
     263                die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
     264            }
     265        }
     266        die "Invalid version name $ENV{'PBPROJVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBPROJVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBPROJVER'} =~ /$version{$ENV{'PBPROJ'}}/));
     267       
     268        if (not defined $ENV{'PBPROJTAG'}) {
     269            if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
     270                $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
     271            } else {
     272                die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
     273            }
     274        }
     275        die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
     276   
     277   
     278        if (not defined $ENV{'PBPACKAGER'}) {
     279            if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
     280                $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
     281            } else {
     282                die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
     283            }
     284        }
     285    } else {
     286        if (defined $pbinit) {
     287            my $ptr = pb_get_pkg();
     288            my @pkgs = @$ptr;
     289            @pkgs = ("pkg1") if (not @pkgs);
     290   
     291            open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
     292            print CONF << "EOF";
    292293#
    293294# Project Builder configuration file
     
    389390EOF
    390391       
    391         foreach my $pp (@pkgs) {
    392             print CONF << "EOF";
     392            foreach my $pp (@pkgs) {
     393                print CONF << "EOF";
    393394#pkgver $pp = stable
    394395#pkgtag $pp = 3
    395396EOF
    396         }
    397         foreach my $pp (@pkgs) {
    398             print CONF << "EOF";
     397            }
     398            foreach my $pp (@pkgs) {
     399                print CONF << "EOF";
    399400# Hash of default package/package directory
    400401#defpkgdir $pp = dir-$pp
    401402EOF
    402         }
    403 
    404         print CONF << "EOF";
     403            }
     404   
     405            print CONF << "EOF";
    405406# Hash of additional package/package directory
    406407#extpkgdir minor-pkg = dir-minor-pkg
     
    409410# Files are mentioned relatively to pbroot/defpkgdir
    410411EOF
    411         foreach my $pp (@pkgs) {
    412             print CONF << "EOF";
     412            foreach my $pp (@pkgs) {
     413                print CONF << "EOF";
    413414#filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
    414415#supfiles $pp = $pp.init
    415416EOF
    416         }
    417         close(CONF);
    418         pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
    419         open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
    420         print CONF << "EOF";
     417            }
     418            close(CONF);
     419            pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
     420            open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
     421            print CONF << "EOF";
    421422#
    422423# \$Id\$
     
    454455#filter PBURL = http://www.$ENV{'PBPROJ'}.org
    455456EOF
    456         close(CONF);
    457         open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
    458         print CONF << "EOF";
     457            close(CONF);
     458            open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
     459            print CONF << "EOF";
    459460#
    460461# \$Id\$
     
    481482
    482483EOF
    483         close(CONF);
    484         open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
    485         print CONF << "EOF";
     484            close(CONF);
     485            open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
     486            print CONF << "EOF";
    486487#
    487488# \$Id\$
     
    506507
    507508EOF
    508         close(CONF);
    509         open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
    510         print CONF << "EOF";
     509            close(CONF);
     510            open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
     511            print CONF << "EOF";
    511512# Specific group for Mandriva for $ENV{'PBPROJ'}
    512513# Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
     
    518519
    519520EOF
    520         close(CONF);
    521         open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
    522         print CONF << "EOF";
     521            close(CONF);
     522            open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
     523            print CONF << "EOF";
    523524# Specific group for SuSE for $ENV{'PBPROJ'}
    524525# Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
     
    530531
    531532EOF
    532         close(CONF);
    533         foreach my $pp (@pkgs) {
    534             pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
    535             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
    536             print CONF << "EOF";
     533            close(CONF);
     534            foreach my $pp (@pkgs) {
     535                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
     536                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
     537                print CONF << "EOF";
    537538Source: PBPKG
    538539Section: PBGRP
     
    555556
    556557EOF
    557             close(CONF);
    558             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
    559             print CONF << "EOF";
     558                close(CONF);
     559                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
     560                print CONF << "EOF";
    560561This package is debianized by PBPACKAGER
    561562`date`
     
    586587
    587588EOF
    588             close(CONF);
    589             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
    590             print CONF << "EOF";
     589                close(CONF);
     590                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
     591                print CONF << "EOF";
    591592PBLOG
    592593EOF
    593             close(CONF);
    594             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
    595             print CONF << "EOF";
     594                close(CONF);
     595                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
     596                print CONF << "EOF";
    5965974
    597598EOF
    598             close(CONF);
    599             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
    600             print CONF << "EOF";
     599                close(CONF);
     600                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
     601                print CONF << "EOF";
    601602EOF
    602             close(CONF);
    603             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
    604             print CONF << "EOF";
     603                close(CONF);
     604                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
     605                print CONF << "EOF";
    605606INSTALL
    606607COPYING
     
    609610README
    610611EOF
    611             close(CONF);
    612             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
    613             print CONF << 'EOF';
     612                close(CONF);
     613                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
     614                print CONF << 'EOF';
    614615#!/usr/bin/make -f
    615616# -*- makefile -*-
     
    746747
    747748EOF
    748             close(CONF);
    749             pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
    750             open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
    751             print CONF << 'EOF';
     749                close(CONF);
     750                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
     751                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
     752                print CONF << 'EOF';
    752753#
    753754# $Id$
     
    796797
    797798EOF
    798             close(CONF);
    799             pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
    800 
    801             pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
    802         }
    803     } else {
    804         die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
    805     }
    806 }
    807 umask 0022;
    808 return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
     799                close(CONF);
     800                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
     801   
     802                pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
     803            }
     804        } else {
     805            die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
     806        }
     807    }
     808    umask 0022;
     809    return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
     810} else {
     811    # Setup the variables from what has been stored at the end of cms2build
     812    my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
     813    $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
     814
     815    ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
     816    $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
     817
     818    ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
     819    $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
     820
     821    ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
     822    $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
     823
     824    return;
     825}
    809826}
    810827
     
    832849#system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
    833850system($cmd);
     851pb_log(1,"Executing $cmd\n");
    834852my $res = $?;
    835853if ($res == -1) {
     
    15271545
    15281546#
    1529 # Return the list of packages we are working on
    1530 #
    1531 sub pb_get_pkg {
     1547# Return the list of packages we are working on in a CMS action
     1548#
     1549sub pb_cms_get_pkg {
    15321550
    15331551my @pkgs = ();
     
    15441562    @pkgs = @ARGV;
    15451563}
     1564pb_log(0,"Packages: ".join(',',@pkgs)."\n");
     1565return(\@pkgs);
     1566}
     1567
     1568#
     1569# Return the list of packages we are working on in a non CMS action
     1570#
     1571sub pb_get_pkg {
     1572
     1573my @pkgs = ();
     1574
     1575my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
     1576@pkgs = keys %$var;
     1577
    15461578pb_log(0,"Packages: ".join(',',@pkgs)."\n");
    15471579return(\@pkgs);
Note: See TracChangeset for help on using the changeset viewer.