Changeset 2162 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Jan 4, 2017, 12:38:26 AM (4 years ago)
Author:
Bruno Cornec
Message:

Start coding a sbx2docker action WIP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r2150 r2162  
    271271
    272272sbx2build + build2ve
     273
     274=item B<sbx2docker>
     275
     276sbx2build + build2ve with a potential build of all necessary docker containers to perform it
    273277
    274278=item B<sbx2rm>
     
    928932} elsif ($action =~ /^newver$/) {
    929933    pb_newver();
     934} elsif ($action =~ /^sbx2docker$/) {
     935    my $savproj = $ENV{'PBPROJ'};
     936    my $pkg;
     937    my @pkg;
     938    if ($#ARGV == -1) {
     939        $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir);
     940        @pkgs = @$pkg;
     941    } else {
     942        @pkgs = @ARGV;
     943    }
     944    #pb_log(1,"Packages to print:".Dumper(@pkgs)."\n");
     945   
     946    # Get the list of all VE we need to work on
     947    my ($vm,$all);
     948    if (not defined $ENV{'PBV'}) {
     949        ($vm,$all) = pb_get2v("ve");
     950    } else {
     951        @$vm = split(/,/,$ENV{'PBV'});
     952    }
     953   
     954    # TODO: parallelize
     955    foreach my $v (@$vm) {
     956        my $done = 0;
     957        my $pbos = pb_distro_get_context($v);
     958        # Docker images are (for now !) regular and use distro:ver
     959        $pbimage = "$pbos->{'name'}".":$pbos->{'version'}";
     960        # the first steps needs to be done with the pb project
     961        $ENV{'PBPROJ'} = $appname;
     962        my $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
     963        if (($pbforce == 1) || (not defined $found)) {
     964            # pb -p pb -m distro-ver-arch newve -i distro:ver
     965            pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} not found, creating it\n");
     966            pb_parallel_launchv(undef,"ve",undef,0,$pbimage);
     967        }
     968        $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb");
     969        if (($pbforce == 1) || (not defined $found)) {
     970            pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb not found, creating it\n");
     971            # pb -p pb -m distro-ver-arch setupve
     972            if ($savproj eq "pb") {
     973                pb_cms2build("SandBox");
     974                $done = 1;
     975                pb_setup2v("ve","SandBox");
     976            } else {
     977                pb_setup2v("ve");
     978            }
     979        }
     980        # Now back to our original project
     981        $ENV{'PBPROJ'} = $savproj;
     982        $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'}");
     983        if (($pbforce == 1) || (not defined $found)) {
     984            pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'} not found, creating it\n");
     985            # pb -p pb -m distro-ver-arch prepve
     986            if ($savproj eq "pb") {
     987                pb_cms2build("SandBox");
     988                $done = 1;
     989            }
     990            pb_build2v("ve","prep");
     991        }
     992        pb_log(0,"Instantiating a Docker container from $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'}\n");
     993        if (($savproj ne "pb") || ($done == 0)) {
     994            pb_cms2build("SandBox");
     995        }
     996        pb_build2v("ve","build");
     997    }
    930998} elsif ($action =~ /^newve$/) {
    931999    pb_parallel_launchv(undef,"ve",undef,0,$pbimage);
     
    24992567            }
    25002568            # If we do not create the image, then use the one we should have
     2569            # TODO: we don't do anything with found !!
    25012570            my $found = pb_ve_docker_get_image($tag{$pbstep});
     2571            confess "No image $tag{$pbstep} available in Docker, please create one first\n" if (not defined $found);
    25022572            # Now we use that image to do what is needed
    25032573            # use a dockerfile to ease the creation of next images
Note: See TracChangeset for help on using the changeset viewer.