Changeset 1942 in ProjectBuilder


Ignore:
Timestamp:
Feb 5, 2015, 10:54:32 PM (9 years ago)
Author:
Bruno Cornec
Message:
  • pb works again with VMs (pbaccount is now a ENV var and the script executed is now without a full path name and the port used is now correct again)
Location:
devel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-doc/pb-demo

    r1915 r1942  
    5757# Create Docker container
    5858docker images
    59 pb -p pb -m mageia-4-x86_64 -T docker newve
     59#pb -p pb -m mageia-4-x86_64 -T docker newve
    6060docker images
    6161docker run -ti <imgid> /bin/bash
     
    7676ssh bruno@www.mondorescue.org ls -altrg /prj/ftp/test/mageia/4/x86_64
    7777
     78# Look at what was created
     79docker images
     80docker history localhost:5000/pb:mageia-4-x86_64-pb-pb
    7881
    7982# Now  show how easy it's to build for another project for which I'm upstream
  • devel/pb/bin/pb

    r1927 r1942  
    5656my %pbscript;                       # Name of the scripts per V
    5757my $pbrev;                          # Global REVISION variable
    58 my $pbaccount;                      # Login to use to connect to the VM/RM
    5958my $pbtarget = undef;               # Target os-ver-arch you want to build for
    6059my $pbport;                         # Port to use to connect to the VM/RM
     
    462461
    463462None exists for the moment.
     463
     464=head1 ENVIRONMENT VARIABLES
     465
     466=item B<PBACCOUNT>   
     467
     468Login to use to connect to the VM/RM, undef by default
     469
     470=back
    464471
    465472=head1 CONFIGURATION FILES
     
    757764}
    758765if (defined $opts{'a'}) {
    759     $pbaccount = $opts{'a'};
     766    $ENV{'PBACCOUNT'} = $opts{'a'};
    760767    die "option -a requires a -s script option" if (not defined $pbscript{'default'});
    761768}
     
    19411948
    19421949    # Keep track of what is generated so that we can get them back from VMs/RMs
    1943     my $pbkeep = "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    1944     open(KEEP,"> $pbkeep") || 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 $!";
    19451952    print KEEP "$made\n";
    19461953    close(KEEP);
     
    21382145    if ($cmt !~ /^VE/) {
    21392146        $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'});
    21432149    } else {
    21442150        # VE
     2151        $mac = $sshlogin->{$ENV{'PBPROJ'}};
    21452152        # 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");
    21492156
    21502157    my $tdir;
     
    25862593            }
    25872594        } 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");
    25892596        }
    25902597    }
     
    26402647            #$dkcmd .= "/bin/bash $homedir/$tdir-2/".basename($pbscript1)." ;  if [ '$pbkeep' == '0' ]; then rm -f $pbscript1; fi ; ";
    26412648        } 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\"";
    26432651        }
    26442652    }
     
    27282736
    27292737            # We want to send them to the ssh account so overwrite what has been done before
    2730             undef $pbaccount;
    27312738            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);
    27332740            pb_rm_rf("$ENV{'PBBUILDDIR'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}");
    27342741        }
     
    28582865    ($vexist,$vpid) = pb_launchv($pbscript,$vtype,$v,$action,$pbstep,$pbforce,$snapme,$pbsnap,$pbimage);
    28592866   
    2860     # Skip that V if something went wrong
    2861     if (($vpid == 0) && ($vexist == 0)) {
     2867    # Skip that VM/RM if something went wrong
     2868    if (($vtype =~ /(v|r)m/) && ($vpid == 0) && ($vexist == 0)) {
    28622869        $pm->finish if (defined $pbparallel);
    28632870        next;
    28642871    }
     2872   
    28652873    $pm->finish if (defined $pbparallel);
    28662874}
     
    29963004    ($vexist,$vmmport) = pb_check_ps($tmpcmd,$vmm);
    29973005    $vpid = 0;
     3006   
    29983007    if (! $vexist) {
    29993008        if ($pbstep == 0) {
     
    30323041        }
    30333042    } 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");
    30353044        # Set the correct port here based on what is done
    30363045        $pbport = $vmmport;
     
    34833492    my ($pbac) = pb_conf_get($vtype."login");
    34843493    my ($key,$zero0,$zero1,$zero2);
    3485     my ($vexist,$vpid);
    34863494
    34873495    # Prepare the script to be executed on the VM/VE/RM
     
    35343542        $nport = pb_get_port($vmport,$pbos,$vtype);
    35353543   
    3536         # Skip that VM/RM if something went wrong
    3537         next if (($vpid == 0) && ($vexist == 0));
    3538    
    35393544        # Store the pub key part in a variable
    35403545        open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub";
     
    36713676    }
    36723677
     3678# TODO: systemd support
    36733679# Keep the VM in text mode
    36743680$file="/etc/inittab";
     
    39123918    chmod 0755,"$pbscript{$v}";
    39133919
    3914     # That build script needs to be run as root and force stop of VM at end
    3915     $pbaccount = "root";
    3916 
    3917     # Force shutdown of VM except if it was already launched
    3918     # TODO: FIX here as it doesn't work anymore
    3919     my $pbforce = 0;
    3920     if ((! $vexist) && ($vtype eq "vm")) {
    3921         $pbforce = 1;
    3922     }
    3923    
    39243920    $pm->finish if (defined $pbparallel);
    39253921}
    39263922$pm->wait_all_children if (defined $pbparallel);
    39273923die "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";
    39283927
    39293928$sbx = "" if (not defined $sbx);
     
    46934692    $nport = "$pbport" if (defined $pbport);
    46944693    # 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'}));
    46964695}
    46974696pb_log(2,"pb_get_port returns $nport\n");
Note: See TracChangeset for help on using the changeset viewer.