Changeset 200 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Oct 13, 2007, 2:26:55 AM (17 years ago)
Author:
Bruno Cornec
Message:

More fixes for handling creation/destruction of VMs
SuSE 10.0 forces bz2 files (not more recent versions)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r199 r200  
    338338
    339339        my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    340         # Suse < 10.2 forces tar.bz2 usage :-(
    341         if ($ddir eq "suse") {
    342             print "SuSE needs bz2 type of packages so recompressing...\n";
     340        # Suse 10.0 forces tar.bz2 usage :-(
     341        if (($ddir eq "suse") && ($dver eq "10.0")) {
     342            print "SuSE 10.0 needs bz2 type of packages so recompressing...\n";
    343343            my $newsrc="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.bz2";
    344344            system "gzip -cd $src | bzip2 -c6 > $newsrc";
     
    450450    my $vm = shift || undef;
    451451    my $vmexist = shift || 0;           # 0 is FALSE
     452    my $vmpid = shift || 0;             # 0 is FALSE
    452453    my $host = shift || "sshhost";
    453454    my $login = shift || "sshlogin";
    454455    my $dir = shift || "sshdir";
    455456    my $port = shift || "sshport";
     457    my $tmout = shift || "120";
    456458    my $cmd = "";
    457459
     
    537539
    538540    $port = $sshport->{$ENV{'PBPROJ'}};
     541    my $tm = $tmout->{$ENV{'PBPROJ'}};
    539542    pb_system("ssh -q -p $port $mac \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\ ; $cmd' | bash\"","Preparing $tdir on $mac");
    540543    pb_system("cd $ENV{'PBBUILDDIR'} ; scp -p -P $port $src $mac:$tdir 2> /dev/null","$cmt delivery in $tdir on $mac");
     
    542545    if ($cmt eq "VMs") {
    543546        # Get back info on pkg produced, compute their name and get them from the VM
    544         pb_system("scp -p -P $port $mac:$bdir/pbgen-$pbprojver-$pbprojtag $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $tdir on $mac");
     547        pb_system("scp -p -P $port $mac:$bdir/pbgen-$pbprojver-$pbprojtag $ENV{'PBBUILDDIR'} 2> /dev/null","Get package names in $bdir on $mac");
    545548        open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag";
    546549        my $src = <KEEP>;
     
    554557        foreach my $p (split(/ +/,$src)) {
    555558            my $j = basename($p);
    556             pb_system("scp -p -P $port $mac:\'$bdir/$p\' $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Package recovery of $j in $tdir from $mac");
     559            pb_system("scp -p -P $port $mac:\'$bdir/$p\' $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Package recovery of $j in $bdir from $mac");
    557560            $made="$made $odir/$over/$j" if (($dtype ne "rpm") || ($j !~ /.src.rpm$/));
    558561        }
     
    561564        pb_system("ssh -q -p $port $mac \"rm -rf $tdir $bdir\"","VM cleanup on $mac");
    562565        if (! $vmexist) {
    563             pb_system("ssh -q -p $port $mac \"sudo /usr/bin/poweroff \"; sleep 120 ; echo \'if [ -d /proc/$vmexist ]; then kill -9 $vmexist; fi \' | bash ; sleep 10","VM $vm halt (pid $vmexist)");
     566            pb_system("ssh -q -p $port $mac \"sudo /usr/bin/poweroff \"; sleep $tm ; echo \'if [ -d /proc/$vmpid ]; then kill -9 $vmpid; fi \' | bash ; sleep 10","VM $vm halt (pid $vmpid)");
    564567        }
    565568        pb_send2ssh("Packages","$odir"."_"."$over");
     
    582585    foreach my $v (@$vm) {
    583586        # Launch the VM
    584         my $vmexist = pb_launchvm($v);
    585         if (! $vmexist) {
    586             pb_system("sleep 300","Waiting for $v to come up");
    587         } else {
    588             print "Using VM pid $vmexist\n";
    589         }
     587        my ($vmexist,$vmpid) = pb_launchvm($v);
    590588
    591589        # Gather all required files to send them to the VM
    592590        # and launch the build thourgh pbscript
    593         pb_send2ssh("Script","$v",$vmexist,"vmhost","vmlogin","pbrc","vmport");
     591        pb_send2ssh("Script","$v",$vmexist,$vmpid,"vmhost","vmlogin","pbrc","vmport","vmtmout");
    594592
    595593    }
     
    604602
    605603    # Launch the VMs
    606     my ($ptr,$vmopt,$vmport,$vmpath) = pb_conf_get("vmtype","vmopt","vmport","vmpath");
     604    my ($ptr,$vmopt,$vmport,$vmpath,$vmtmout) = pb_conf_get("vmtype","vmopt","vmport","vmpath","vmtmout");
    607605    my $vmtype = $ptr->{$ENV{'PBPROJ'}};
    608606    if (defined $vmopt->{$ENV{'PBPROJ'}}) {
     
    646644    my ($tmpcmd,$void) = split(/ +/,$cmd);
    647645    my $vmexist = pb_check_ps($tmpcmd,$vmm);
     646    my $vmpid = 0;
    648647    if (! $vmexist) {
    649648        pb_system("$cmd &","Launching the VM $vmm");
    650     }
    651     return($vmexist);
     649        pb_system("sleep $vmtmout->{$ENV{'PBPROJ'}}","Waiting for VM $vm to come up");
     650        $vmpid = pb_check_ps($tmpcmd,$vmm);
     651    } else {
     652        print "Found an existing VM $vmm (pid $vmexist)\n";
     653    }
     654    return($vmexist,$vmpid);
    652655}
    653656
     
    682685    foreach my $v (@$vm) {
    683686        # Launch the VM
    684         my $vmexist = pb_launchvm($v);
    685         if (! $vmexist) {
    686             pb_system("sleep 300","Waiting for $v to come up");
    687         } else {
    688             print "Using VM pid $vmexist\n";
    689         }
     687        my ($vmexist,$vmpid) = pb_launchvm($v);
    690688
    691689        # Gather all required files to send them to the VM
    692690        # and launch the build thourgh pbscript
    693         pb_send2ssh("VMs","$v",$vmexist,"vmhost","vmlogin","pbrc","vmport");
     691        pb_send2ssh("VMs","$v",$vmexist,$vmpid,"vmhost","vmlogin","pbrc","vmport","vmtmout");
    694692    }
    695693}
Note: See TracChangeset for help on using the changeset viewer.