Changeset 1942 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Feb 5, 2015, 10:54:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r1927 r1942 56 56 my %pbscript; # Name of the scripts per V 57 57 my $pbrev; # Global REVISION variable 58 my $pbaccount; # Login to use to connect to the VM/RM59 58 my $pbtarget = undef; # Target os-ver-arch you want to build for 60 59 my $pbport; # Port to use to connect to the VM/RM … … 462 461 463 462 None exists for the moment. 463 464 =head1 ENVIRONMENT VARIABLES 465 466 =item B<PBACCOUNT> 467 468 Login to use to connect to the VM/RM, undef by default 469 470 =back 464 471 465 472 =head1 CONFIGURATION FILES … … 757 764 } 758 765 if (defined $opts{'a'}) { 759 $ pbaccount= $opts{'a'};766 $ENV{'PBACCOUNT'} = $opts{'a'}; 760 767 die "option -a requires a -s script option" if (not defined $pbscript{'default'}); 761 768 } … … 1941 1948 1942 1949 # Keep track of what is generated so that we can get them back from VMs/RMs 1943 my $pb keep= "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";1944 open(KEEP,"> $pb keep") || die "Unable to create $pbkeep:$!";1950 my $pbstore = "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 1951 open(KEEP,"> $pbstore") || die "Unable to create $pbstore $!"; 1945 1952 print KEEP "$made\n"; 1946 1953 close(KEEP); … … 2138 2145 if ($cmt !~ /^VE/) { 2139 2146 $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$remhost"; 2140 # Overwrite account value if passed as parameter 2141 $mac = "$pbaccount\@$remhost" if (defined $pbaccount); 2142 pb_log(2, "DEBUG: pbaccount: $pbaccount => mac: $mac\n") if (defined $pbaccount); 2147 # Overwrite account value if passed as parameter or forced 2148 $mac = "$ENV{'PBACCOUNT'}\@$remhost" if (defined $ENV{'PBACCOUNT'}); 2143 2149 } else { 2144 2150 # VE 2151 $mac = $sshlogin->{$ENV{'PBPROJ'}}; 2145 2152 # Overwrite account value if passed as parameter (typically for setup2v) 2146 $mac = $ sshlogin->{$ENV{'PBPROJ'}};2147 $mac = $pbaccount if (defined $pbaccount);2148 }2153 $mac = $ENV{'PBACCOUNT'} if (defined $ENV{'PBACCOUNT'}); 2154 } 2155 pb_log(2, "DEBUG: mac: $mac\n"); 2149 2156 2150 2157 my $tdir; … … 2586 2593 } 2587 2594 } else { 2588 pb_system("$cpcmd $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz $mac:/tmp","Copying local project files to $vetype.");2595 pb_system("$cpcmd $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz $mac:/tmp","Copying local project files to VM/RM"); 2589 2596 } 2590 2597 } … … 2640 2647 #$dkcmd .= "/bin/bash $homedir/$tdir-2/".basename($pbscript1)." ; if [ '$pbkeep' == '0' ]; then rm -f $pbscript1; fi ; "; 2641 2648 } else { 2642 $shcmd .= " \"echo \'cd $tdir ; if [ -x $pbscript1 ]; then $pbscript1; fi ; if [ $pbkeep == 0 ]; then rm -f $pbscript1; fi\' | bash\""; 2649 my $s = basename($pbscript1); 2650 $shcmd .= " \"echo \'cd $tdir ; if [ -x $s ]; then ./$s; fi ; if [ $pbkeep == 0 ]; then rm -f $s; fi\' | bash\""; 2643 2651 } 2644 2652 } … … 2728 2736 2729 2737 # We want to send them to the ssh account so overwrite what has been done before 2730 undef $pbaccount;2731 2738 pb_log(2,"Before sending pkgs, vexist: $vexist, vpid: $vpid\n"); 2732 pb_send2target("Packages","$ENV{'PBDESTDIR'}/pbscript.$$",$pbos->{'name'}."-".$pbos->{'version'}."-".$pbos->{'arch'},$vexist,$vpid );2739 pb_send2target("Packages","$ENV{'PBDESTDIR'}/pbscript.$$",$pbos->{'name'}."-".$pbos->{'version'}."-".$pbos->{'arch'},$vexist,$vpid,undef,undef,undef); 2733 2740 pb_rm_rf("$ENV{'PBBUILDDIR'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 2734 2741 } … … 2858 2865 ($vexist,$vpid) = pb_launchv($pbscript,$vtype,$v,$action,$pbstep,$pbforce,$snapme,$pbsnap,$pbimage); 2859 2866 2860 # Skip that V if something went wrong2861 if (($v pid == 0) && ($vexist == 0)) {2867 # Skip that VM/RM if something went wrong 2868 if (($vtype =~ /(v|r)m/) && ($vpid == 0) && ($vexist == 0)) { 2862 2869 $pm->finish if (defined $pbparallel); 2863 2870 next; 2864 2871 } 2872 2865 2873 $pm->finish if (defined $pbparallel); 2866 2874 } … … 2996 3004 ($vexist,$vmmport) = pb_check_ps($tmpcmd,$vmm); 2997 3005 $vpid = 0; 3006 2998 3007 if (! $vexist) { 2999 3008 if ($pbstep == 0) { … … 3032 3041 } 3033 3042 } else { 3034 pb_log(0,"Found an existing VM $vmm (pid $vexist )\n");3043 pb_log(0,"Found an existing VM $vmm (pid $vexist - Port $vmmport)\n"); 3035 3044 # Set the correct port here based on what is done 3036 3045 $pbport = $vmmport; … … 3483 3492 my ($pbac) = pb_conf_get($vtype."login"); 3484 3493 my ($key,$zero0,$zero1,$zero2); 3485 my ($vexist,$vpid);3486 3494 3487 3495 # Prepare the script to be executed on the VM/VE/RM … … 3534 3542 $nport = pb_get_port($vmport,$pbos,$vtype); 3535 3543 3536 # Skip that VM/RM if something went wrong3537 next if (($vpid == 0) && ($vexist == 0));3538 3539 3544 # Store the pub key part in a variable 3540 3545 open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub"; … … 3671 3676 } 3672 3677 3678 # TODO: systemd support 3673 3679 # Keep the VM in text mode 3674 3680 $file="/etc/inittab"; … … 3912 3918 chmod 0755,"$pbscript{$v}"; 3913 3919 3914 # That build script needs to be run as root and force stop of VM at end3915 $pbaccount = "root";3916 3917 # Force shutdown of VM except if it was already launched3918 # TODO: FIX here as it doesn't work anymore3919 my $pbforce = 0;3920 if ((! $vexist) && ($vtype eq "vm")) {3921 $pbforce = 1;3922 }3923 3924 3920 $pm->finish if (defined $pbparallel); 3925 3921 } 3926 3922 $pm->wait_all_children if (defined $pbparallel); 3927 3923 die "Aborting, one or more of the children failed." if ((not $all_ok) && ($Global::pb_stop_on_error)); 3924 3925 # These build scripts need to be run as root and force stop of VM at end 3926 $ENV{'PBACCOUNT'} = "root"; 3928 3927 3929 3928 $sbx = "" if (not defined $sbx); … … 4693 4692 $nport = "$pbport" if (defined $pbport); 4694 4693 # Maybe in // mode so use the env var set up as an offset to the base port 4695 $nport += $ENV{'PBVMPORT'}if ((defined $pbparallel) && (defined $ENV{'PBVMPORT'}));4694 $nport = $nport + $ENV{'PBVMPORT'} -1 if ((defined $pbparallel) && (defined $ENV{'PBVMPORT'})); 4696 4695 } 4697 4696 pb_log(2,"pb_get_port returns $nport\n");
Note:
See TracChangeset
for help on using the changeset viewer.