Changeset 2463


Ignore:
Timestamp:
Jan 18, 2020, 6:27:50 PM (5 weeks ago)
Author:
Bruno Cornec
Message:

Fix *2docker, tested with Fedora 30

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r2459 r2463  
    26492649            # pbimage is used for docker and is setup to the right name depending on the step:
    26502650            # TODO: This is not coded yet
    2651             my $pbimage = undef;
    26522651            # step 0 : nothing at creation -> tag n-v-a (made in VE.pm)
    26532652            # step 1 : n-v-a + setup -> tag n-v-a-pb
     
    26612660                $tag{2} = "$tag{1}-pb";
    26622661                $tag{3} = "$tag{2}-$ENV{'PBPROJ'}";
    2663                 $tag{4} = "$tag{2}-install-$ENV{'PBPROJ'}";
    2664                 $tag{5} = "$tag{2}-test-$ENV{'PBPROJ'}";
     2662                $tag{4} = "$tag{2}-install";
     2663                $tag{5} = "$tag{2}-test";
    26652664            } else {
    26662665                # If we were given an image name, just use it
     
    26742673            # TODO: we don't do anything with found !!
    26752674            my $found = pb_ve_docker_get_image($tag{$pbstep});
     2675            my $origimage = undef;
     2676            if (($pbstep > 3) && (not defined $found)) {
     2677                    # initiate these images from the last n-v-a-pb-pbproj below
     2678                    $found = 0;
     2679                    $origimage = "$tag{3}";
     2680            } else {
     2681                    $origimage = "$tag{$pbstep}";
     2682            }
    26762683            cluck "No image $tag{$pbstep} available in Docker, please create one first\n" if (not defined $found);
    26772684            # Now we use that image to do what is needed
     
    26802687            my $tmpd = "$context/Dockerfile";
    26812688            open(DOCKER, "> $tmpd") || confess "Unable to create the docker file $tmpd";
    2682             print DOCKER "FROM $tag{$pbstep}\n";
     2689            print DOCKER "FROM $origimage\n";
    26832690            print DOCKER "MAINTAINER project-builder.org aka pb\n";
    26842691            if ($pbstep == 1) {
     
    26902697            }
    26912698            print DOCKER "USER $dkaccount\n";
    2692             if (($pbstep <= 2) || ($pbstep > 3)) {
     2699            my $rmatend = "";
     2700            # As we are in run phase use docker run. cmd will be completed below
     2701            $rmatend = "--rm" if ($pbdebug lt 1);
     2702            if ($pbstep <= 2) {
    26932703                $shcmd = "$cmd1 build -t $tag{$pbstep+1} $context";
    26942704                #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";
     2705            } elsif ($pbstep > 3) {
     2706                # We force the destruciton of the image before recreating it for install or test
     2707                $shcmd = "$cmd1 rmi $tag{$pbstep} ; ";
     2708                $shcmd .= "$cmd1 build -t $tag{$pbstep} $context ; ";
     2709                $shcmd .= "$cmd1 run $rmatend --cidfile=\"$cidfile\" --user $dkaccount --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt ";
    26952710            } else {
    2696                 my $rmatend = "";
    2697                 # As we are in run phase use docker run. cmd will be completed below
    2698                 $rmatend = "--rm" if ($pbdebug lt 1);
     2711                # pbstep 3
    26992712                $shcmd = "$cmd1 run $rmatend --cidfile=\"$cidfile\" --user $dkaccount --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt";
    27002713            }
     
    28052818                copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$tpdir/tmp");
    28062819            } else {
    2807                 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz","$context");
    2808                 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$context");
    2809                 print DOCKER "COPY ProjectBuilder-$pbver1$pbextdir.tar.gz /tmp/\n";
    2810                 print DOCKER "COPY project-builder-$pbver2$pbextdir.tar.gz /tmp/\n";
     2820                if ($pbstep <= 3) {
     2821                    copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz","$context");
     2822                    copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$context");
     2823                    print DOCKER "COPY ProjectBuilder-$pbver1$pbextdir.tar.gz /tmp/\n";
     2824                    print DOCKER "COPY project-builder-$pbver2$pbextdir.tar.gz /tmp/\n";
     2825                }
    28112826            }
    28122827        } else {
     
    31583173my $pbforce=shift;          # Force stop of VM. Default not.
    31593174my $snapme = shift;         # By default do not snap a VM/VE/RM
    3160 my $usesnap = shift;            # By default study the usage of the snapshot feature of VM/VE/RM   
     3175my $usesnap = shift;        # By default study the usage of the snapshot feature of VM/VE/RM   
    31613176my $pbimage=shift;          # Which image to use to start the VM/VE
    31623177my $vexist = undef;
     
    43864401        # pb -p pb -m distro-ver-arch newve -i distro:ver
    43874402        ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
    4388         pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4403        pb_log(0,"Docker image $lctn $lmsg, creating it\n");
    43894404        pb_launchv(undef,"ve",$v,$action,0,$pbforce,undef,undef,$pbimage);
    43904405    }
     4406    # Remove ref to pbimage so the rest uses the previous one built
     4407    $pbimage = undef;
    43914408    $lctn = "$docrepo$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb";
    43924409    $found = pb_ve_docker_get_image($lctn);
    43934410    if (($pbforce == 1) || (not defined $found)) {
    43944411        ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
    4395         pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4412        pb_log(0,"Docker image $lctn $lmsg, creating it\n");
    43964413        # pb -p pb -m distro-ver-arch setupve
    43974414        if ($savproj eq "pb") {
     
    44104427    if (($pbforce == 1) || (not defined $found)) {
    44114428        ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
    4412         pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4429        pb_log(0,"Docker image $lctn $lmsg, creating it\n");
    44134430        # pb -p pb -m distro-ver-arch prepve
    44144431        if ($savproj eq "pb") {
Note: See TracChangeset for help on using the changeset viewer.