Changeset 1967 in ProjectBuilder


Ignore:
Timestamp:
Jun 12, 2015, 11:44:03 PM (9 years ago)
Author:
Bruno Cornec
Message:
  • newve now installs deps in container if using an upstream one
Location:
devel
Files:
2 edited

Legend:

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

    r1966 r1967  
    9393}
    9494
     95# Architecture consistency
     96my $arch = pb_get_arch();
     97if ($arch ne $pbos->{'arch'}) {
     98    die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" unless (($pbos->{'arch'} =~ /i?86/o) && ($arch eq "x86_64"));
     99}
     100
     101# If we are already root (from pbmkbm e.g.) don't use sudo, just call the command
     102my $sudocmd="";
     103if ($EFFECTIVE_USER_ID != 0) {
     104    $sudocmd ="sudo ";
     105    foreach my $proxy (qw/http_proxy ftp_proxy/) {
     106        if (defined $ENV{$proxy}) {
     107            open(CMD,"sudo sh -c 'echo \$$proxy' |") or die "can't run sudo sh?: $!";
     108            $_ = <CMD>;
     109            chomp();
     110            die "sudo not passing through env var $proxy; '$ENV{$proxy}' != '$_'\nAdd line Defaults:`whoami` env_keep += \"$proxy\" to sudoers file?" unless $_ eq $ENV{$proxy};
     111            close(CMD);
     112        }
     113    }
     114}
     115
     116# Handle cross arch on Intel based platforms
     117$sudocmd = "setarch i386 $sudocmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
     118
     119my $root = pb_path_expand($vepath->{$ENV{PBPROJ}});
     120   
    95121if (($vetype eq "chroot") || ($vetype eq "schroot") || ($vetype eq "docker")) {
    96122
     
    101127    my ($rbsb4pi,$rbspi,$vesnap,$oscodename,$osmindep,$verebuild,$rbsmirrorsrv) = pb_conf_get_if("rbsb4pi","rbspi","vesnap","oscodename","osmindep","verebuild","rbsmirrorsrv");
    102128
    103     # Architecture consistency
    104     my $arch = pb_get_arch();
    105     if ($arch ne $pbos->{'arch'}) {
    106         die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" unless (($pbos->{'arch'} =~ /i?86/o) && ($arch eq "x86_64"));
    107     }
    108 
    109     # If we are already root (from pbmkbm e.g.) don't use sudo, just call the command
    110     my $sudocmd="";
    111     if ($EFFECTIVE_USER_ID != 0) {
    112         $sudocmd ="sudo ";
    113         foreach my $proxy (qw/http_proxy ftp_proxy/) {
    114             if (defined $ENV{$proxy}) {
    115                 open(CMD,"sudo sh -c 'echo \$$proxy' |") or die "can't run sudo sh?: $!";
    116                 $_ = <CMD>;
    117                 chomp();
    118                 die "sudo not passing through env var $proxy; '$ENV{$proxy}' != '$_'\nAdd line Defaults:`whoami` env_keep += \"$proxy\" to sudoers file?" unless $_ eq $ENV{$proxy};
    119                 close(CMD);
    120             }
    121         }
    122     }
    123 
    124     # Handle cross arch on Intel based platforms
    125     $sudocmd = "setarch i386 $sudocmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
    126 
    127     my $root = pb_path_expand($vepath->{$ENV{PBPROJ}});
    128    
    129129    if (((((defined $verebuild) && ($verebuild->{$ENV{'PBPROJ'}} =~ /true/i)) || ($pbforce == 0)) && ($vetype ne "docker"))
    130130        # For docker we may have a reference image that we'll use
     
    304304        } else {
    305305            # 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'}");
     306            # That container should then be setup correctly which may not be the case yet
     307            #
     308            # We can probably only get those params now we have the distro context
     309            my ($osmindep) = pb_conf_get_if("osmindep");
     310            my $pkgs = pb_distro_get_param($pbos,$osmindep);
     311            $pkgs =~ s/,/ /g;
     312            my $tmpd = "$ENV{'PBTMP'}/Dockerfile";
     313            open(DOCKER, "> $tmpd") || die "Unable to create the docker file $tmpd";
     314            print DOCKER "FROM $pbimage\n";
     315            print DOCKER "MAINTAINER project-builder.org aka pb\n";
     316            print DIOCKER "ENV ftp_proxy $ENV{ftp_proxy}\n" if (defined $ENV{ftp_proxy});
     317            print DIOCKER "ENV http_proxy $ENV{http_proxy}\n" if (defined $ENV{http_proxy});
     318            # We are root in that container so no need to sudo, which is present potentially
     319            my $cmd2 = $pbos->{'install'};
     320            $cmd2 =~ s/sudo //g;
     321            print DOCKER "RUN $cmd2 $pkgs\n";
     322            close(DOCKER);
     323            pb_system("cd $ENV{'PBTMP'} ; $sudocmd $cmd1 build -t $docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} .","Installing dependencies $pkgs in Docker container $docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
     324            unlink($tmpd);
    307325        }
    308326    }
  • devel/pb/bin/pb

    r1963 r1967  
    26412641            print DOCKER "COPY $s $cptarget/\n";
    26422642            # call directly with perl to avoid text file busy error messages
    2643             print DOCKER "RUN cd $cptarget ; perl ./$s ; if [ '$pbkeep' == '0' ]; then rm -f $s; fi\n";
     2643            print DOCKER "RUN cd $cptarget ; perl ./$s ; if [ '$pbkeep' = '0' ]; then rm -f $s; fi\n";
    26442644            print DOCKER "RUN rm -rf $cptarget/*\n";
    26452645            print DOCKER "RUN chown -R pb $cptarget\n" if ($pbstep == 1);
Note: See TracChangeset for help on using the changeset viewer.