Changeset 1966 in ProjectBuilder


Ignore:
Timestamp:
Jun 11, 2015, 11:12:51 AM (9 years ago)
Author:
Bruno Cornec
Message:

Add the possibility to use an existing docker image for newve with -i
option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/VE.pm

    r1958 r1966  
    8383my ($vepath) = pb_conf_get("vepath");
    8484
     85if ($vetype eq "docker") {
     86    # Check acces to registry
     87    ($dockerregistry) = pb_conf_get("dockerregistry");
     88    if ((defined $dockerregistry) && (defined $dockerregistry->{$ENV{'PBPROJ'}})) {
     89        pb_ve_docker_registry($dockerregistry->{$ENV{'PBPROJ'}});
     90    } else {
     91        die "When using docker you need to declare a dockerregistry parameter. Read the man page"
     92    }
     93}
     94
    8595if (($vetype eq "chroot") || ($vetype eq "schroot") || ($vetype eq "docker")) {
    8696
     
    90100    # We can probably only get those params now we have the distro context
    91101    my ($rbsb4pi,$rbspi,$vesnap,$oscodename,$osmindep,$verebuild,$rbsmirrorsrv) = pb_conf_get_if("rbsb4pi","rbspi","vesnap","oscodename","osmindep","verebuild","rbsmirrorsrv");
    92     if ($vetype eq "docker") {
    93         # Check acces to registry
    94         ($dockerregistry) = pb_conf_get("dockerregistry");
    95         if ((defined $dockerregistry) && (defined $dockerregistry->{$ENV{'PBPROJ'}})) {
    96             pb_ve_docker_registry($dockerregistry->{$ENV{'PBPROJ'}});
    97         } else {
    98             die "When using docker you need to declare a dockerregistry parameter. Read the man page"
    99         }
    100     }
    101102
    102103    # Architecture consistency
     
    128129    if (((((defined $verebuild) && ($verebuild->{$ENV{'PBPROJ'}} =~ /true/i)) || ($pbforce == 0)) && ($vetype ne "docker"))
    129130        # For docker we may have a reference image that we'll use
    130         || (($vetype eq "docker") && ($pbforce == 0))) {
     131        || (($vetype eq "docker") && ($pbforce == 0) && ((not defined $pbimage) || ($pbimage eq "")))) {
    131132
    132133        my ($verpmtype,$vedebtype) = pb_conf_get("verpmtype","vedebtype");
     
    291292        # step 0 : nothing at creation -> tag n-v-a (made below)
    292293
    293         # Snaphot the VE to serve as an input for docker
    294         pb_ve_snap($pbos,$root);
    295         # Create the docker image from the previous bootstrap
    296         # Need sudo to be able to create all files correctly
    297         # TODO: check before that the image doesn't already exist in the docker registry
    298         my $pbimage = "$docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    299         pb_system("$sudocmd $cmd1 import - $pbimage < $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz");
    300         pb_system("$cmd1 push $pbimage");
     294        if ((not defined $pbimage) || ($pbimage eq "")) {
     295            # Snaphot the VE to serve as an input for docker
     296            pb_ve_snap($pbos,$root);
     297            # Create the docker image from the previous bootstrap
     298            # Need sudo to be able to create all files correctly
     299            # TODO: check before that the image doesn't already exist in the docker registry
     300           
     301            my $pbimage = "$docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
     302            pb_system("$sudocmd $cmd1 import - $pbimage < $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz");
     303            pb_system("$cmd1 push $pbimage");
     304        } else {
     305            # If we pass a parameter to -i, this is the name of an existing upstream image for that distro-ver-arch
     306            pb_system("$sudocmd $cmd1 tag $pbimage $docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
     307        }
    301308    }
    302309
     
    394401return($found);
    395402}
     403
    396404sub pb_ve_get_type {
    397405
Note: See TracChangeset for help on using the changeset viewer.