Changeset 141 in ProjectBuilder
- Timestamp:
- Sep 13, 2007, 2:47:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r140 r141 34 34 my $pbtag; # Global Tag variable 35 35 my $pbver; # Global Version variable 36 my $pbscript; # Name of the script 36 37 my %pbver; # per package 37 38 my %pbtag; # per package … … 43 44 my $LOG = \*STDOUT; 44 45 45 getopts('hl:m:p:qr: tv',\%opts);46 getopts('hl:m:p:qr:s:tv',\%opts); 46 47 47 48 my ($projectbuilderver,$projectbuilderrev) = pb_version_init(); … … 75 76 if (defined $opts{'m'}) { 76 77 $ENV{'PBVM'} = $opts{'m'}; 78 } 79 if (defined $opts{'s'}) { 80 $pbscript = $opts{'s'}; 77 81 } 78 82 … … 117 121 pb_cms2build(); 118 122 pb_build2vm(); 123 } elsif ($action =~ /^launchvm$/) { 124 pb_launchvm(); 119 125 } elsif ($action =~ /^clean$/) { 120 126 } else { … … 456 462 # Change pgben to make the next send2ssh happy 457 463 open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag") || die "Unable to write $ENV{'PBBUILDDIR'}/pbgen-$pbprojver-$pbprojtag"; 458 my $made = "";459 464 foreach my $p (split(/ +/,$src)) { 460 465 my $j = basename($p); 461 466 pb_system("scp -p -P $port $mac:\'$bdir/$p\' $ENV{'PBBUILDDIR'}/$odir/$over 2> /dev/null","Package recovery of $j in $tdir from $mac"); 462 $made = "$made $odir/$over/$j"; 463 } 464 print KEEP "$made\n"; 467 } 468 print KEEP "$odir/$over/*\n"; 465 469 close(KEEP); 466 470 #pb_system("ssh -q -p $port $mac \"rm -rf dirname("$sshdir->{$ENV{'PBPROJ'}}"); sudo /usr/bin/poweroff\"","VM cleanup and halt on $mac"); 467 471 pb_send2ssh("Packages","$odir"."_"."$over"); 468 #pb_rm_rf("$ENV{'PBBUILDDIR'}/$odir"); 469 } 470 } 471 472 pb_rm_rf("$ENV{'PBBUILDDIR'}/$odir"); 473 } 474 } 475 476 sub launchvm { 477 my ($vm,$all) = pb_get_vm(); 478 479 # Prepare the script to be executed on the VM 480 # in $ENV{'PBDESTDIR'}/pbscript 481 copy($pbscript,"$ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript"; 482 chmod 0755,"$ENV{'PBDESTDIR'}/pbscript"; 483 484 foreach my $v (@$vm) { 485 # Launch the VMs 486 my ($ptr,$vmopt,$vmport,$vmpath) = pb_conf_get("vmtype","vmopt","vmport","vmpath"); 487 my $vmtype = $ptr->{$ENV{'PBPROJ'}}; 488 if (defined $vmopt->{$ENV{'PBPROJ'}}) { 489 $ENV{'PBVMOPT'} = $vmopt->{$ENV{'PBPROJ'}}; 490 } else { 491 $ENV{'PBVMOPT'} = ""; 492 } 493 494 my $cmd; 495 if ($vmtype eq "qemu") { 496 my $arch = `uname -m`; 497 chomp($arch); 498 my $qemucmd; 499 my $qemucmd32; 500 my $qemucmd64; 501 if ($arch eq "x86_64") { 502 $qemucmd32 = "/usr/bin/qemu-system-i386"; 503 $qemucmd64 = "/usr/bin/qemu"; 504 } else { 505 $qemucmd32 = "/usr/bin/qemu"; 506 $qemucmd64 = "/usr/bin/qemu-system-x86_64"; 507 } 508 if ($v =~ /_64/) { 509 $qemucmd = "$qemucmd64 -no-kqemu"; 510 } else { 511 $qemucmd = "$qemucmd32"; 512 } 513 if (! -f "$vmpath->{$ENV{'PBPROJ'}}/$v.qemu") { 514 print "Unable to find VM $vmpath->{$ENV{'PBPROJ'}}/$v.qemu"; 515 next; 516 } 517 $cmd = "$qemucmd $ENV{'PBVMOPT'} -redir tcp:$vmport->{$ENV{'PBPROJ'}}:10.0.2.15:22 $vmpath->{$ENV{'PBPROJ'}}/$v.qemu" 518 } elsif ($vmtype eq "xen") { 519 } elsif ($vmtype eq "vmware") { 520 } else { 521 die "VM of type $vmtype not supported. Report to the dev team"; 522 } 523 pb_system("$cmd &","Launching the VM"); 524 pb_system("sleep 300","Waiting for it to come up"); 525 526 # Gather all required files to send them to the VM and launch the build thourgh pbscript 527 pb_send2ssh("VMs","$v","vmhost","vmlogin","pbrc","vmport"); 528 } 529 } 472 530 sub pb_build2vm { 473 531 my ($vm,$all) = pb_get_vm(); … … 610 668 print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n"; 611 669 print "\n"; 612 print "Syntax: pb [-vhqt][-r pbroot][-p project][ -m \"mach-1[,...]\"] <action> [<pkg1>...]\n";670 print "Syntax: pb [-vhqt][-r pbroot][-p project][[-s script] -m \"mach-1[,...]\"] <action> [<pkg1>...]\n"; 613 671 print "\n"; 614 672 print "-h : This help file\n"; … … 617 675 print "-v : Verbose mode\n"; 618 676 print "\n"; 619 print "-m machine : Name of the virtual Machines you want\n";677 print "-m machine : Name of the Virtual Machines you want\n"; 620 678 print " to build on (space separated). All if none precised\n"; 621 679 print " (or use the env variable PBVM) \n"; 680 print "\n"; 681 print "-s script : Name of the script you want\n"; 682 print " to execute on the related VMs.\n"; 622 683 print "\n"; 623 684 print "-p project : Name of the project you're working on\n"; … … 646 707 print "\t VM supported are QEMU \n"; 647 708 print "\n"; 709 print "\tlaunchvm: Launch a virtual machine and execute potentially\n"; 710 print "\t a script on it\n"; 711 print "\n"; 648 712 print "\tcms2vm: cms2build + build2vm\n"; 649 713 print "\n";
Note:
See TracChangeset
for help on using the changeset viewer.