Changeset 2004 in ProjectBuilder


Ignore:
Timestamp:
Sep 30, 2015, 5:48:25 PM (9 years ago)
Author:
Bruno Cornec
Message:

Solve remaining rights issues with docker

  • Erase destination files in case one already existed with right preventing us to copy on it
  • Use the dkaccount to run the container, instead of the user launching the docker command
  • Use the variable dkaccount instead of a hardcoded pb reference
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r2003 r2004  
    24832483            } else {
    24842484                # As we are in run phase use docker run. cmd will be completed below
    2485                 $shcmd = "$cmd1 run --cidfile=\"$ENV{'PBTMP'}/ctn.cid\" --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt";
     2485                $shcmd = "$cmd1 run --cidfile=\"$ENV{'PBTMP'}/ctn.cid\" --user $dkaccount --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt";
    24862486            }
    24872487            #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";
     
    26432643            print DOCKER "RUN cd $cptarget ; perl ./$s ; if [ '$pbkeep' = '0' ]; then rm -f $s; fi\n";
    26442644            print DOCKER "RUN rm -rf $cptarget/*\n";
    2645             print DOCKER "RUN chown -R pb $cptarget\n" if ($pbstep == 1);
     2645            print DOCKER "RUN chown -R $dkaccount $cptarget\n" if ($pbstep == 1);
    26462646            close(DOCKER);
    26472647        } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
     
    26722672        print DOCKER "# set -x\n";
    26732673        print DOCKER "for i in $tsrc; do\n";
     2674        print DOCKER "  # Cleanup first to avoid rights issues for root owned files e.g.\n";
     2675        print DOCKER "  rm -f $homedir/$tdir/\$i\n";
    26742676        print DOCKER "  cp $homedir/$tdir-2/\$i $homedir/$tdir\n";
    26752677        print DOCKER "done\n";
    2676         print DOCKER "cd $homedir/$tdir-2\n";
    2677         print DOCKER "ls -al\n";
    2678         my $sc = pb_get_content($pbscript1);
    2679         print DOCKER "$sc";
    2680         print DOCKER "# Get content back from guest in a host dir\n";
     2678        print DOCKER "(cd $homedir/$tdir-2 ; ls -al)\n";
     2679        print DOCKER pb_get_content($pbscript1);
     2680        print DOCKER "\n# Get content back from guest in a host dir\n";
    26812681        $cp2target = "$ENV{'PBBUILDDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    26822682        pb_mkdir_p("$cp2target");
     
    26842684        print DOCKER "TDIR=$homedir/$bdir-2/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\n";
    26852685        print DOCKER "for i in $homedir/$bdir/*; do";
     2686        print DOCKER "  # Cleanup first to avoid rights issues for root owned files e.g.\n";
     2687        print DOCKER "  rm -f \$TDIR/\$i\n";
    26862688        print DOCKER "  cp -r \$i \$TDIR\n";
    26872689        print DOCKER "done\n";
     
    32093211        print SCRIPT "rm -f \$HOME/.pbrc\n";
    32103212        print SCRIPT "cp .pbrc \$HOME\n";
     3213        # TODO: Why ?
    32113214        print SCRIPT "cd ..\n";
    32123215    }
Note: See TracChangeset for help on using the changeset viewer.