Changeset 2429


Ignore:
Timestamp:
Sep 2, 2019, 12:39:58 PM (7 weeks ago)
Author:
bruno
Message:

Fix setuposrepo which was not working on a per distro repo

Location:
devel
Files:
2 edited

Legend:

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

    r2427 r2429  
    627627$h = pb_conf_cache(pb_distro_conffile(),$h);
    628628my ($osrepo) = pb_conf_get_in_hash_if($h,"osrepo");
    629 return(pb_distro_setuprepo_gen($pbos,$osrepo->{$ENV{'PBPROJ'}}));
     629my $repo = pb_distro_get_param($pbos,$osrepo);
     630return(pb_distro_setuprepo_gen($pbos,$repo));
    630631}
    631632
  • devel/pb/bin/pb

    r2427 r2429  
    993993    pb_newver();
    994994} elsif ($action =~ /^sbx2docker$/) {
    995     my $savproj = $ENV{'PBPROJ'};
    996     my $pkg;
    997     my @pkg;
    998     if ($#ARGV == -1) {
    999         $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir);
    1000         @pkgs = @$pkg;
    1001     } else {
    1002         @pkgs = @ARGV;
    1003     }
    1004     #pb_log(1,"Packages to print:".Dumper(@pkgs)."\n");
    1005    
    1006     # Get the list of all VE we need to work on
    1007     my ($vm,$all);
    1008     if (not defined $ENV{'PBV'}) {
    1009         ($vm,$all) = pb_get2v("ve");
    1010     } else {
    1011         @$vm = split(/,/,$ENV{'PBV'});
    1012     }
    1013    
    1014     # TODO: parallelize
    1015     foreach my $v (@$vm) {
    1016         my $done = 0;
    1017         my $pbos = pb_distro_get_context($v);
    1018         # Docker images are (for now !) regular and use distro:ver
    1019         $pbimage = "$pbos->{'name'}".":$pbos->{'version'}";
    1020         # the first steps needs to be done with the pb project
    1021         $ENV{'PBPROJ'} = $appname;
    1022         my $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
    1023         if (($pbforce == 1) || (not defined $found)) {
    1024             # pb -p pb -m distro-ver-arch newve -i distro:ver
    1025             pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} not found, creating it\n");
    1026             pb_parallel_launchv(undef,"ve",undef,0,$pbimage);
    1027         }
    1028         $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb");
    1029         if (($pbforce == 1) || (not defined $found)) {
    1030             pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb not found, creating it\n");
    1031             # pb -p pb -m distro-ver-arch setupve
    1032             if ($savproj eq "pb") {
    1033                 pb_cms2build("SandBox");
    1034                 $done = 1;
    1035                 pb_setup2v("ve","SandBox");
    1036             } else {
    1037                 pb_setup2v("ve");
    1038             }
    1039         }
    1040         # Now back to our original project
    1041         $ENV{'PBPROJ'} = $savproj;
    1042         $found = pb_ve_docker_get_image("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'}");
    1043         if (($pbforce == 1) || (not defined $found)) {
    1044             pb_log(0,"Docker container $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'} not found, creating it\n");
    1045             # pb -p pb -m distro-ver-arch prepve
    1046             if ($savproj eq "pb") {
    1047                 pb_cms2build("SandBox");
    1048                 $done = 1;
    1049             }
    1050             pb_build2v("ve","prep");
    1051         }
    1052         pb_log(0,"Instantiating a Docker container from $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'}\n");
    1053         if (($savproj ne "pb") || ($done == 0)) {
    1054             pb_cms2build("SandBox");
    1055         }
    1056         pb_build2v("ve","build");
    1057     }
     995    pb_cms2build("SandBox");
     996    pb_all_docker($action);
     997} elsif ($action =~ /^build2docker$/) {
     998    pb_all_docker($action);
    1058999} elsif ($action =~ /^newve$/) {
    10591000    pb_parallel_launchv(undef,"ve",undef,0,$pbimage);
     
    16951636
    16961637    # Additional potential repo
    1697     my $forcerepo = pb_distro_setuprepo($pbos,"test");
     1638    pb_distro_setuprepo($pbos,"test");
    16981639    foreach my $pbpkg (@pkgs) {
    16991640    }
     
    27182659                $tag{2} = "$tag{1}-pb";
    27192660                $tag{3} = "$tag{2}-$ENV{'PBPROJ'}";
    2720                 $tag{4} = "$tag{2}-install";
    2721                 $tag{5} = "$tag{2}-test";
     2661                $tag{4} = "$tag{3}-install";
     2662                $tag{5} = "$tag{3}-test";
    27222663            } else {
    27232664                # If we were given an image name, just use it
     
    27472688            }
    27482689            print DOCKER "USER $dkaccount\n";
    2749             if ($pbstep <= 2) {
     2690            if (($pbstep <= 2) || ($pbstep > 3)) {
    27502691                $shcmd = "$cmd1 build -t $tag{$pbstep+1} $context";
     2692                #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";
    27512693            } else {
    27522694                # As we are in run phase use docker run. cmd will be completed below
     
    27542696                $shcmd = "$cmd1 run $rmatend --cidfile=\"$cidfile\" --user $dkaccount --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt";
    27552697            }
    2756             #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";
    27572698        }
    27582699        $shcmd = "setarch i386 $shcmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
     
    38023743my $vtype = shift;
    38033744my $sbx = shift;
     3745my $installtype = shift;        # either "file" or "pkg" to overwrite conf file
    38043746my $pbstep = 1;
    38053747
     
    41244066pb_apply_conf_proxy($pbos);
    41254067
    4126 # First install all required packages
     4068# Clean up packages DB
    41274069pb_system("dnf clean all","Cleaning dnf env","mayfail") if (($pbos->{'name'} eq "fedora") && ($pbos->{'version'} >= 22));
    41284070pb_system("yum clean all","Cleaning yum env","mayfail") if ((($pbos->{'name'} eq "fedora") && ($pbos->{'version'} < 22)) || ($pbos->{'name'} eq "asianux") || ($pbos->{'name'} eq "rhel"));
    4129 my ($ospkgdep) = pb_conf_get_if("ospkgdep");
    4130 
    4131 my $pkgdep = pb_distro_get_param($pbos,$ospkgdep);
    4132 my $forcerepo;
    4133 EOF
    4134     print SCRIPT "\$forcerepo = pb_distro_setuprepo_gen(\$pbos,\"$pbrepo\");\n" if ((defined $pbrepo) && ($pbrepo ne ""));
    4135     print SCRIPT << 'EOF';
    4136 pb_distro_installdeps(undef,$pbos,$forcerepo,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep))));
    41374071
    41384072EOF
     
    41404074    # Install from sandbox mean a file base install
    41414075    $itype = "file" if (defined $sbx);
     4076    $itype = $installtype if (defined $installtype);
    41424077    if ($itype =~ /^file/) {
     4078        my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc.yml","addbuildrepo");
     4079        my $pbrepo = pb_distro_get_param($pbos,$addrepo);
     4080        print SCRIPT << 'EOF';
     4081
     4082# First install all required packages
     4083my ($ospkgdep) = pb_conf_get_if("ospkgdep");
     4084my $pkgdep = pb_distro_get_param($pbos,$ospkgdep);
     4085my $forcerepo;
     4086EOF
     4087        print SCRIPT "\$forcerepo = pb_distro_setuprepo_gen(\$pbos,\"$pbrepo\");\n" if ((defined $pbrepo) && ($pbrepo ne ""));
     4088        print SCRIPT << 'EOF';
     4089pb_distro_installdeps(undef,$pbos,$forcerepo,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep))));
     4090
     4091EOF
    41434092        my $cmdget;
    4144         my ($pbver1,$pbver2,$pbextdir);
    4145         my ($tmp1,$tmp2);
    41464093        if (defined $sbx) {
    41474094            # Install from sandbox mean using the result of the just passed sbx2build command
    41484095            # Get content saved in cms2build
    41494096            my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml","pbpkg");
    4150             $pbextdir = pb_get_extdir();
    41514097            confess "Unable to get package list" if (not defined $pkg);
    4152 
     4098   
    41534099            # We consider 2 specific packages
    41544100            my $vertag1 = $pkg->{"ProjectBuilder"};
     
    41574103            pb_log(2,"Vertag1: $vertag1\n");
    41584104            pb_log(2,"Vertag2: $vertag2\n");
    4159             ($pbver1,$tmp1) = split(/-/,$vertag1);
    4160             ($pbver2,$tmp2) = split(/-/,$vertag2);
     4105            my ($pbver1,$tmp1) = split(/-/,$vertag1);
     4106            my ($pbver2,$tmp2) = split(/-/,$vertag2);
     4107            my $pbextdir = pb_get_extdir();
    41614108            $cmdget = "mv /tmp/ProjectBuilder-$pbver1$pbextdir.tar.gz ProjectBuilder-latest.tar.gz ; mv /tmp/project-builder-$pbver2$pbextdir.tar.gz project-builder-latest.tar.gz";
    41624109        } else {
     
    41894136        print SCRIPT " $cmdget ; ";
    41904137        print SCRIPT << "EOF"
    4191 gzip -cd ProjectBuilder-latest.tar.gz | tar xf - ; cd ProjectBuilder-$pbver1$pbextdir ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf ProjectBuilder-* ; gzip -cd project-builder-latest.tar.gz | tar xf - ; cd project-builder-$pbver2$pbextdir ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf project-builder-* ;","Building Project-Builder");
     4138gzip -cd ProjectBuilder-latest.tar.gz | tar xf - ; cd ProjectBuilder-`tar tfz ProjectBuilder-latest.tar.gz | head -1 | cut -d- -f2 | cut -d/ -f1` ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf ProjectBuilder-* ; gzip -cd project-builder-latest.tar.gz | tar xf - ; cd project-builder-`tar tfz project-builder-latest.tar.gz | head -1 | cut -d- -f3 | cut -d/ -f1` ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf project-builder-* ;","Building Project-Builder");
    41924139EOF
    41934140    } elsif ($itype =~ /^pkg/) {
     
    41964143my $pkgforpb = pb_distro_get_param($pbos,pb_conf_get_if("ospkg"));
    41974144my $forcerepo = pb_distro_setuposrepo($pbos);
    4198 pb_log(1,"Forcing full package install with forcerepo\n") if (defined $forcerepo);
    4199 pb_distro_installdeps(undef,$pbos,$forcerepo,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb))));
     4145pb_distro_installpkgs($pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb))));
    42004146EOF
    42014147    } else {
     
    43584304}
    43594305return;
     4306}
     4307
     4308# Build all docker CTN required to build an app
     4309sub pb_all_docker {
     4310    my $action = shift;
     4311    my $savproj = $ENV{'PBPROJ'};
     4312    my $pkg;
     4313    my @pkg;
     4314    if ($#ARGV == -1) {
     4315        $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir);
     4316        @pkgs = @$pkg;
     4317    } else {
     4318        @pkgs = @ARGV;
     4319    }
     4320    #pb_log(1,"Packages to print:".Dumper(@pkgs)."\n");
     4321   
     4322    # Get the list of all VE we need to work on
     4323    my ($vm,$all);
     4324    if (not defined $ENV{'PBV'}) {
     4325        ($vm,$all) = pb_get2v("ve");
     4326    } else {
     4327        @$vm = split(/,/,$ENV{'PBV'});
     4328    }
     4329   
     4330    my $docrepo = pb_ve_docker_repo();
     4331    # TODO: parallelize
     4332    foreach my $v (@$vm) {
     4333        my $done = 0;
     4334        my $lmsg = "";
     4335        my $lctn = "";
     4336        my $pbos = pb_distro_get_context($v);
     4337        # Docker images are (for now !) regular and use distro:ver
     4338        $pbimage = "$pbos->{'name'}".":$pbos->{'version'}";
     4339        # The two first steps need to be done with the pb project and using a stable pb version
     4340        $ENV{'PBPROJ'} = $appname;
     4341        $lctn = "$docrepo$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
     4342        my $found = pb_ve_docker_get_image($lctn);
     4343        if (($pbforce == 1) || (not defined $found)) {
     4344            # pb -p pb -m distro-ver-arch newve -i distro:ver
     4345            ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
     4346            pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4347            pb_parallel_launchv(undef,"ve",undef,0,$pbimage);
     4348        }
     4349        $lctn = "$docrepo$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb";
     4350        $found = pb_ve_docker_get_image($lctn);
     4351        if (($pbforce == 1) || (not defined $found)) {
     4352            ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
     4353            pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4354            # pb -p pb -m distro-ver-arch setupve
     4355            if ($savproj eq "pb") {
     4356                pb_cms2build("SandBox") if ($action !~ /sbx2/);
     4357                $done = 1;
     4358                pb_setup2v("ve","SandBox");
     4359            } else {
     4360                # Here we install in the CTN pb from upstream packages to have a stable version
     4361                pb_setup2v("ve",undef,"pkg");
     4362            }
     4363        }
     4364        # Now back to our original project
     4365        $ENV{'PBPROJ'} = $savproj;
     4366        $lctn = "$docrepo$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-pb-$ENV{'PBPROJ'}";
     4367        $found = pb_ve_docker_get_image($lctn);
     4368        if (($pbforce == 1) || (not defined $found)) {
     4369            ($pbforce == 1) ? $lmsg = "Forced" : $lmsg = "not found";
     4370            pb_log(0,"Docker container $lctn $lmsg, creating it\n");
     4371            # pb -p pb -m distro-ver-arch prepve
     4372            if ($savproj eq "pb") {
     4373                pb_cms2build("SandBox") if ($action !~ /sbx2/);
     4374                $done = 1;
     4375            }
     4376            pb_build2v("ve","prep");
     4377        }
     4378        pb_log(0,"Instantiating a Docker container from $lctn\n");
     4379        if (($savproj ne "pb") || ($done == 0)) {
     4380            pb_cms2build("SandBox") if ($action !~ /sbx2/);
     4381        }
     4382        pb_build2v("ve","build");
     4383    }
    43604384}
    43614385
     
    53235347}
    53245348
    5325 # Unused now
    5326 sub pb_keep_step {
    5327 
    5328 my $pbos = shift;
    5329 my $pbstep = shift;
    5330 
    5331 $pbstep = 3 if (not defined $pbstep);
    5332 
    5333 my %h;
    5334 my $h = \%h;
    5335 $h = pb_conf_cache("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml",$h);
    5336 $h->{'pbstep'}->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = $pbstep;
    5337 pb_conf_write("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml",$h);
    5338 }
    5339 
    53405349sub create_solaris_prototype {
    53415350
Note: See TracChangeset for help on using the changeset viewer.