Changeset 1910


Ignore:
Timestamp:
Oct 12, 2014, 1:23:00 PM (5 years ago)
Author:
bruno
Message:
  • build2ve now works for docker containers !! Just on time for LinuxCon? EMEA where I'll demonstrate it :-)
  • Need more tests however of course, especially for VE/VM which may now be broken as a consequence. Next version will be 0.13.x dur to

incompatibilities brought

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1909 r1910  
    20482048            if (($cmt eq "Sources") || ($cmt =~ /(V[EM]|RM)(build|prep)/)) {
    20492049                $src = "$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver$pbextdir.tar.gz $ENV{'PBDESTDIR'}/$pbpkg-$pbver$pbextdir.pbconf.tar.gz";
     2050                my $cmd2 = "ln -sf $pbpkg-$pbver$pbextdir.tar.gz $pbpkg-latest.tar.gz";
     2051                #my $cmd2 = "ln $pbpkg-$pbver$pbextdir.tar.gz $pbpkg-latest.tar.gz 2> /dev/null ; if [ \$? -ne 0 ]; then ln -sf $pbpkg-$pbver$pbextdir.tar.gz $pbpkg-latest.tar.gz ; fi";
    20502052                if ($cmd eq "") {
    2051                     $cmd = "ln -sf $pbpkg-$pbver$pbextdir.tar.gz $pbpkg-latest.tar.gz";
     2053                    $cmd = $cmd2;
    20522054                } else {
    2053                     $cmd = "$cmd ; ln -sf $pbpkg-$pbver$pbextdir.tar.gz $pbpkg-latest.tar.gz";
     2055                    $cmd = "$cmd ; $cmd2";
    20542056                }
    20552057            } elsif ($cmt eq "Web") {
     
    21802182
    21812183        # Repository management
    2182         open(PBS,"> $ENV{'PBBUILDDIR'}/pbscript.$$") || die "Unable to create $ENV{'PBBUILDDIR'}/pbscript.$$";
     2184        $pbscript{$v} = "$ENV{'PBBUILDDIR'}/pbscript.$$";
     2185        open(PBS,"> $pbscript{$v}") || die "Unable to create $pbscript{$v}";
    21832186        if ($pbos->{'type'} eq "rpm") {
    21842187            my $pbsha = pb_distro_get_param($pbos,pb_conf_get("ossha"));
     
    26222625    # It's already ready for CPAN
    26232626    my $shcmdbase = $shcmd;
    2624     my $dkcmd = "";
     2627    my $dkcmd;
    26252628    if ($cmt ne "CPAN") {
    26262629        if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep < 3)) {
     
    26342637            close(DOCKER);
    26352638        } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
    2636             $dkcmd .= "/usr/bin/ls -al $homedir/$tdir ; /usr/bin/bash $homedir/$tdir/".basename($pbscript1);
    2637             #$dkcmd .= "cd $cptarget ;  bash ./$pbscript1 ;  if [ '$pbkeep' == '0' ]; then rm -f $pbscript1; fi ; ";
     2639            $dkcmd = "/usr/bin/bash $homedir/$tdir-2/".basename($pbscript1);
     2640            #$dkcmd .= "/usr/bin/bash $homedir/$tdir-2/".basename($pbscript1)." ;  if [ '$pbkeep' == '0' ]; then rm -f $pbscript1; fi ; ";
    26382641        } else {
    2639             $shcmd .= " \"echo \'cd $tdir ; if [ -x $pbscript1 ]; then ./$pbscript1; fi ;  if [ '$pbkeep' == '0' ]; then rm -f ./$pbscript1\'; fi | bash\"";
     2642            $shcmd .= " \"echo \'cd $tdir ; if [ -x $pbscript1 ]; then $pbscript1; fi ;  if [ $pbkeep == 0 ]; then rm -f $pbscript1; fi\' | bash\"";
    26402643        }
    26412644    }
     
    26492652    if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) {
    26502653        pb_mkdir_p("$ENV{'PBTMP'}/vebuild");
     2654        my $tsrc = "";
    26512655        foreach my $f (split(/ +/,$src)) {
    26522656            copy("$f","$ENV{'PBTMP'}/vebuild");
    2653         }
    2654         $shcmd .= " -v $ENV{'PBBUILDDIR'}:$homedir/$bdir -v $ENV{'PBTMP'}/vebuild:$homedir/$tdir $tag{$pbstep} $dkcmd";
     2657            $tsrc .= " ".basename($f);
     2658        }
     2659        my $ts = "$ENV{'PBTMP'}/vebuild/".basename($pbscript1);
     2660        open(DOCKER," > $ts") || confess "Unable to create $ts";
     2661        print DOCKER "#!/usr/bin/bash\n";
     2662        print DOCKER "# Put content from host to guest, copying to have the correct uid/gid and rights to do so\n";
     2663        print DOCKER "# set -x\n";
     2664        print DOCKER "for i in $tsrc; do\n";
     2665        print DOCKER "  cp $homedir/$tdir-2/\$i $homedir/$tdir\n";
     2666        print DOCKER "done\n";
     2667        print DOCKER "cd $homedir/$tdir-2\n";
     2668        print DOCKER "ls -al\n";
     2669        my $sc = pb_get_content($pbscript1);
     2670        print DOCKER "$sc";
     2671        print DOCKER "# Get content back from guest in a host dir\n";
     2672        $cp2target = "$ENV{'PBBUILDDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
     2673        pb_mkdir_p("$cp2target");
     2674        chmod 0777,"$cp2target";
     2675        print DOCKER "TDIR=$homedir/$bdir-2/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\n";
     2676        print DOCKER "for i in $homedir/$bdir/*; do";
     2677        print DOCKER "  cp -r \$i \$TDIR\n";
     2678        print DOCKER "done\n";
     2679        print DOCKER "find \$TDIR -type f -print0 | xargs -0 chmod 644\n";
     2680        print DOCKER "find \$TDIR -type d -print0 | xargs -0 chmod 777 2> /dev/null\n";
     2681        close(DOCKER);
     2682        $shcmd .= " -v $ENV{'PBBUILDDIR'}:$homedir/$bdir-2 -v $ENV{'PBTMP'}/vebuild:$homedir/$tdir-2 -w $homedir/$tdir-2 $tag{$pbstep} $dkcmd";
    26552683    }
    26562684    my $ret = pb_system("$shcmd","Executing pbscript on $cptarget if needed",$cmdverb);
     
    26862714                $made="$made $pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/$j"; # if (($pbos->{'type'} ne "rpm") || ($j !~ /.src.rpm$/));
    26872715            }
     2716       
    26882717            print KEEP "$made\n";
    26892718            close(KEEP);
    2690             pb_system("$shcmdbase \"rm -rf $tdir $bdir\"","$cmt cleanup");
     2719            if (($vetype eq "docker") && ($pbstep >= 3)) {
     2720                pb_rm_rf("$cp2target");
     2721            } else {
     2722                pb_system("$shcmdbase \"rm -rf $tdir $bdir\"","$cmt cleanup");
     2723            }
    26912724
    26922725            # Sign packages locally
     
    31543187        print SCRIPT "# Preparation for pb\n";
    31553188        print SCRIPT "rm -f \$HOME/.pbrc\n";
    3156         print SCRIPT "mv .pbrc \$HOME\n";
     3189        print SCRIPT "cp .pbrc \$HOME\n";
    31573190        print SCRIPT "cd ..\n";
    31583191    }
Note: See TracChangeset for help on using the changeset viewer.