Changeset 442 in ProjectBuilder for devel/pb/bin
- Timestamp:
- May 15, 2008, 1:32:36 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r437 r442 791 791 my $vmpid = shift || 0; # 0 is FALSE 792 792 793 pb_log(2,"DEBUG: pb_send2target($cmt,$v,$vmexist,$vmpid)\n"); 793 794 my $host = "sshhost"; 794 795 my $login = "sshlogin"; … … 1027 1028 pb_log(2,"Before sending pkgs, vmexist: $vmexist, vmpid: $vmpid\n"); 1028 1029 pb_send2target("Packages",$odir."-".$over."-".$oarch,$vmexist,$vmpid); 1029 if ((! $vmexist) && ($cmt eq "vm")) {1030 pb_system("$shcmd \"sudo /sbin/halt -p \"; sleep $tm ; echo \'if [ -d /proc/$vmpid ]; then kill -9 $vmpid; fi \' | bash ; sleep 10","VM $v halt (pid $vmpid)");1031 }1032 1030 pb_rm_rf("$ENV{'PBBUILDDIR'}/$odir"); 1031 } 1032 pb_log(2,"Before halt, vmexist: $vmexist, vmpid: $vmpid\n"); 1033 if ((! $vmexist) && (($cmt eq "vm") || ($cmt eq "Script"))) { 1034 pb_system("$shcmd \"sudo /sbin/halt -p \"; sleep $tm ; echo \'if [ -d /proc/$vmpid ]; then kill -9 $vmpid; fi \' | bash ; sleep 10","VM $v halt (pid $vmpid)"); 1033 1035 } 1034 1036 } … … 1037 1039 my $pbscript=shift; 1038 1040 my $vtype=shift; 1039 1041 my $force=shift || 0; # Force stop of VM. Default not 1042 my $vm1=shift || undef; # Only that VM to treat 1043 my $vm; 1044 my $all; 1045 1046 pb_log(2,"DEBUG: pb_script2v($pbscript,$vtype,$force,$vm1)\n"); 1040 1047 # Prepare the script to be executed on the VM 1041 1048 # in $ENV{'PBDESTDIR'}/pbscript … … 1045 1052 } 1046 1053 1047 my ($vm,$all) = pb_get_v($vtype); 1054 if (not defined $vm1) { 1055 ($vm,$all) = pb_get_v($vtype); 1056 } else { 1057 @$vm = ($vm1); 1058 } 1048 1059 my ($vmexist,$vmpid) = (undef,undef); 1049 1060 … … 1052 1063 if ($vtype eq "vm") { 1053 1064 ($vmexist,$vmpid) = pb_launchv($vtype,$v,0); 1065 pb_log(2,"DEBUG: After pb_launchv, vmexist: $vmexist, vmpid: $vmpid\n"); 1054 1066 1055 1067 # Skip that VM if something went wrong 1056 next if (($vmpid == 0) && ($vmexist ==0)); 1068 next if (($vmpid == 0) && ($vmexist == 0)); 1069 1070 # If force stopping the VM then reset vmexist 1071 if ($force == 1) { 1072 $vmpid = $vmexist; 1073 $vmexist = 0; 1074 } 1057 1075 } 1058 1076 1059 1077 # Gather all required files to send them to the VM 1060 1078 # and launch the build through pbscript 1079 pb_log(2,"DEBUG: Before send2target, vmexist: $vmexist, vmpid: $vmpid\n"); 1061 1080 pb_send2target("Script","$v",$vmexist,$vmpid); 1062 1081 … … 1069 1088 my $create = shift || 0; # By default do not create a VM 1070 1089 1090 pb_log(2,"DEBUG: pb_launchv($vtype,$v,$create)\n"); 1071 1091 die "No VM/VE defined, unable to launch" if (not defined $v); 1072 1092 # Keep only the first VM in case many were given … … 1144 1164 pb_log(0,"Found an existing VM $vmm (pid $vmexist)\n"); 1145 1165 } 1166 pb_log(2,"DEBUG: pb_launchv returns ($vmexist,$vmpid)\n"); 1146 1167 return($vmexist,$vmpid); 1147 1168 # VE here … … 1383 1404 1384 1405 # Skip that VM if something went wrong 1385 returnif (($vmpid == 0) && ($vmexist == 0));1406 next if (($vmpid == 0) && ($vmexist == 0)); 1386 1407 1387 1408 # Store the pub key part in a variable … … 1533 1554 system "pb 2>&1 | head -5"; 1534 1555 EOF 1535 if ((! $vmexist) && ($vtype eq "vm")) {1536 print SCRIPT << 'EOF';1537 pb_system("sudo /sbin/halt -p","Halting the VM");1538 EOF1539 }1540 1541 1556 # Adds pb_distro_init from ProjectBuilder::Distribution 1542 1557 foreach my $d (@INC) { … … 1559 1574 chmod 0755,"$pbscript"; 1560 1575 1561 # That build script needs to be run as root 1576 # That build script needs to be run as root and force stop of VM at end 1562 1577 $pbaccount = "root"; 1563 pb_script2v($pbscript,$vtype); 1578 1579 # Force shutdown of VM exept if it was already launched 1580 my $force = 0; 1581 if ((! $vmexist) && ($vtype eq "vm")) { 1582 $force = 1; 1583 } 1584 1585 pb_script2v($pbscript,$vtype,$force,$v); 1564 1586 } 1565 1587 return;
Note:
See TracChangeset
for help on using the changeset viewer.