Changeset 1909 in ProjectBuilder


Ignore:
Timestamp:
Oct 10, 2014, 2:02:57 PM (10 years ago)
Author:
Bruno Cornec
Message:
  • Some improvements for build2ve for docker. Remains to handle the correct launch of the script (pb of multiple commands for now) and of

the volumes due to different UIDs between host and guest. I may need 4
volumes for that

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1908 r1909  
    24122412    my $dkaccount = "";
    24132413    my $cmd1 = "";
     2414    my $homedir = "";
    24142415    if ($cmt =~ /^VE/) {
    24152416        $tp = pb_path_expand($vepath->{$ENV{'PBPROJ'}});
     
    24712472            } else {
    24722473                # As we are in run phase use docker run. cmd will be completed below
    2473                 $shcmd = "$cmd1 run --cidfile=\"$ENV{'PBTMP'}/ctn.cid\" $tag{$pbstep}";
     2474                $shcmd = "$cmd1 run --cidfile=\"$ENV{'PBTMP'}/ctn.cid\" --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt";
    24742475            }
    24752476            #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";
     
    24772478        $shcmd = "setarch i386 $shcmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
    24782479        $cpcmd = "sudo /bin/cp -r ";
    2479         my $homedir = "";
    24802480        if (($cmt =~ /VE/) && ($vetype ne "docker")) {
    24812481            # We need to get the home dir of the target account to deliver in the right place
     
    24972497                close(CID);
    24982498                pb_system("$cmd1 rm $cid","","quiet");
     2499                unlink("$ENV{'PBTMP'}/ctn.cid");
    24992500            } else {
    25002501                $homedir = "/";
     
    25462547            print DOCKER "RUN mkdir -p $cptarget\n";
    25472548            print DOCKER "RUN cd $cptarget ; for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\n";
     2549        } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
     2550            # Nothing to do here
    25482551        } else {
    2549             pb_system("$shcmd \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\ ; $cmd' | bash -e\"","Preparing $tdir on $cptarget");
     2552            pb_system("$shcmd \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done ; $cmd\' | bash -e\"","Preparing $tdir on $cptarget");
    25502553        }
    25512554    } else {
     
    25912594        }
    25922595        print DOCKER "RUN cd $cptarget ; $cmd\n" if ((defined $cmd) && ($cmd ne ""));
     2596    } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
     2597        # Nothing to do
    25932598    } else {
    25942599        pb_system("cd $ENV{'PBBUILDDIR'} ; $cpcmd $src $cptarget 2> /dev/null","$cmt delivery in $cptarget");
     
    26172622    # It's already ready for CPAN
    26182623    my $shcmdbase = $shcmd;
     2624    my $dkcmd = "";
    26192625    if ($cmt ne "CPAN") {
    26202626        if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep < 3)) {
     
    26272633            print DOCKER "RUN chown -R pb $cptarget\n" if ($pbstep == 1);
    26282634            close(DOCKER);
     2635        } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
     2636            $dkcmd .= "/usr/bin/ls -al $homedir/$tdir ; /usr/bin/bash $homedir/$tdir/".basename($pbscript1);
     2637            #$dkcmd .= "cd $cptarget ;  bash ./$pbscript1 ;  if [ '$pbkeep' == '0' ]; then rm -f $pbscript1; fi ; ";
    26292638        } else {
    26302639            $shcmd .= " \"echo \'cd $tdir ; if [ -x $pbscript1 ]; then ./$pbscript1; fi ;  if [ '$pbkeep' == '0' ]; then rm -f ./$pbscript1\'; fi | bash\"";
     
    26382647    }
    26392648    # this is where we lanch the execution
     2649    if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
     2650        pb_mkdir_p("$ENV{'PBTMP'}/vebuild");
     2651        foreach my $f (split(/ +/,$src)) {
     2652            copy("$f","$ENV{'PBTMP'}/vebuild");
     2653        }
     2654        $shcmd .= " -v $ENV{'PBBUILDDIR'}:$homedir/$bdir -v $ENV{'PBTMP'}/vebuild:$homedir/$tdir $tag{$pbstep} $dkcmd";
     2655    }
    26402656    my $ret = pb_system("$shcmd","Executing pbscript on $cptarget if needed",$cmdverb);
    26412657
     
    38773893die "Aborting, one or more of the children failed." if ((not $all_ok) && ($Global::pb_stop_on_error));
    38783894
     3895$sbx = "" if (not defined $sbx);
    38793896# Launch the VM/VE/RM
    38803897pb_log(2,"DEBUG: before parallel launch, pbscript hash is:".Dumper(%pbscript)."\n");
Note: See TracChangeset for help on using the changeset viewer.