Changeset 262 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Oct 27, 2007, 2:18:22 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r239 r262 44 44 my $pbport; # Port to use to connect to the VM 45 45 my $newver; # New version to create 46 my $iso; # ISO iage for the VM to create 46 47 my $LOG = \*STDOUT; 47 48 48 getopts('a:h l:m:P:p:qr:s:tvV:',\%opts);49 getopts('a:hi:l:m:P:p:qr:s:tvV:',\%opts); 49 50 50 51 my ($projectbuilderver,$projectbuilderrev) = pb_version_init(); … … 90 91 if (defined $opts{'V'}) { 91 92 $newver = $opts{'V'}; 93 } 94 if (defined $opts{'i'}) { 95 $iso = $opts{'i'}; 92 96 } 93 97 … … 136 140 pb_build2vm(); 137 141 } elsif ($action =~ /^launchvm$/) { 138 pb_launchvm($ENV{'PBVM'} );142 pb_launchvm($ENV{'PBVM'},0); 139 143 } elsif ($action =~ /^script2vm$/) { 140 144 pb_script2vm($pbscript); 141 145 } elsif ($action =~ /^newver$/) { 142 146 pb_newver(); 147 } elsif ($action =~ /^newvm$/) { 148 pb_launchvm($ENV{'PBVM'},1); 143 149 } elsif ($action =~ /^clean$/) { 144 150 } else { … … 600 606 foreach my $v (@$vm) { 601 607 # Launch the VM 602 my ($vmexist,$vmpid) = pb_launchvm($v );608 my ($vmexist,$vmpid) = pb_launchvm($v,0); 603 609 604 610 # Gather all required files to send them to the VM … … 611 617 sub pb_launchvm { 612 618 my $vm = shift; 613 619 my $create = shift || 0; # By default do not create a VM 620 621 die "-i iso parameter needed" if (((not defined $iso) || ($iso eq "")) && ($create != 0)); 614 622 die "No VM defined, unable to launch" if (not defined $vm); 615 623 # Keep only the first VM in case many were given … … 617 625 618 626 # Launch the VMs 619 my ($ptr,$vmopt,$vmport,$vmpath,$vmtmout ) = pb_conf_get("vmtype","vmopt","vmport","vmpath","vmtmout");627 my ($ptr,$vmopt,$vmport,$vmpath,$vmtmout,$vmsize) = pb_conf_get("vmtype","vmopt","vmport","vmpath","vmtmout","vmsize"); 620 628 my $vmtype = $ptr->{$ENV{'PBPROJ'}}; 629 if (not defined $ENV{'PBVMOPT'}) { 630 $ENV{'PBVMOPT'} = ""; 631 } 621 632 if (defined $vmopt->{$ENV{'PBPROJ'}}) { 622 $ENV{'PBVMOPT'} = $vmopt->{$ENV{'PBPROJ'}}; 623 } else { 624 $ENV{'PBVMOPT'} = ""; 633 $ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}"; 625 634 } 626 635 my $nport = $vmport->{$ENV{'PBPROJ'}}; … … 648 657 } 649 658 $vmm = "$vmpath->{$ENV{'PBPROJ'}}/$vm.qemu"; 650 if ( ! -f "$vmm") {651 die "Unable to find VM $vmm";659 if ($create != 0) { 660 $ENV{'PBVMOPT'} .= " -cdrom $iso -boot d"; 652 661 } 653 662 $cmd = "$vmcmd $ENV{'PBVMOPT'} -redir tcp:$nport:10.0.2.15:22 $vmm" … … 661 670 my $vmpid = 0; 662 671 if (! $vmexist) { 672 if ($create != 0) { 673 pb_system("/usr/bin/qemu-img create -f qcow2 $vmm $vmsize->{$ENV{'PBPROJ'}}","Creating the QEMU VM"); 674 } 675 if (! -f "$vmm") { 676 die "Unable to find VM $vmm"; 677 } 663 678 pb_system("$cmd &","Launching the VM $vmm"); 664 679 pb_system("sleep $vmtmout->{$ENV{'PBPROJ'}}","Waiting for VM $vm to come up"); … … 708 723 foreach my $v (@$vm) { 709 724 # Launch the VM 710 my ($vmexist,$vmpid) = pb_launchvm($v );725 my ($vmexist,$vmpid) = pb_launchvm($v,0); 711 726 712 727 # Gather all required files to send them to the VM … … 715 730 } 716 731 } 732 717 733 718 734 sub pb_newver { … … 888 904 print "\t and executes a script on it \n"; 889 905 print "\n"; 890 print "\tnewver: Create a new version of the project derived \n"; 891 print "\t from the current one \n"; 892 print "\n"; 893 } 906 print "\tnewvm: Create a new virtual machine\n"; 907 print "\n"; 908 print "\tnewver: Create a new version of the project derived \n"; 909 print "\t from the current one \n"; 910 print "\n"; 911 }
Note:
See TracChangeset
for help on using the changeset viewer.