- Timestamp:
- Sep 2, 2019, 12:39:58 PM (6 years ago)
- Location:
- devel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r2427 r2429 627 627 $h = pb_conf_cache(pb_distro_conffile(),$h); 628 628 my ($osrepo) = pb_conf_get_in_hash_if($h,"osrepo"); 629 return(pb_distro_setuprepo_gen($pbos,$osrepo->{$ENV{'PBPROJ'}})); 629 my $repo = pb_distro_get_param($pbos,$osrepo); 630 return(pb_distro_setuprepo_gen($pbos,$repo)); 630 631 } 631 632 -
devel/pb/bin/pb
r2427 r2429 993 993 pb_newver(); 994 994 } 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); 1058 999 } elsif ($action =~ /^newve$/) { 1059 1000 pb_parallel_launchv(undef,"ve",undef,0,$pbimage); … … 1695 1636 1696 1637 # Additional potential repo 1697 my $forcerepo =pb_distro_setuprepo($pbos,"test");1638 pb_distro_setuprepo($pbos,"test"); 1698 1639 foreach my $pbpkg (@pkgs) { 1699 1640 } … … 2718 2659 $tag{2} = "$tag{1}-pb"; 2719 2660 $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"; 2722 2663 } else { 2723 2664 # If we were given an image name, just use it … … 2747 2688 } 2748 2689 print DOCKER "USER $dkaccount\n"; 2749 if ( $pbstep <= 2) {2690 if (($pbstep <= 2) || ($pbstep > 3)) { 2750 2691 $shcmd = "$cmd1 build -t $tag{$pbstep+1} $context"; 2692 #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context"; 2751 2693 } else { 2752 2694 # As we are in run phase use docker run. cmd will be completed below … … 2754 2696 $shcmd = "$cmd1 run $rmatend --cidfile=\"$cidfile\" --user $dkaccount --name $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}-$cmt"; 2755 2697 } 2756 #$shcmd = "$cmd1 build $dockeropt->{$ENV{'PBPROJ'}} -t $tag{$pbstep+1} $context";2757 2698 } 2758 2699 $shcmd = "setarch i386 $shcmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64')); … … 3802 3743 my $vtype = shift; 3803 3744 my $sbx = shift; 3745 my $installtype = shift; # either "file" or "pkg" to overwrite conf file 3804 3746 my $pbstep = 1; 3805 3747 … … 4124 4066 pb_apply_conf_proxy($pbos); 4125 4067 4126 # First install all required packages4068 # Clean up packages DB 4127 4069 pb_system("dnf clean all","Cleaning dnf env","mayfail") if (($pbos->{'name'} eq "fedora") && ($pbos->{'version'} >= 22)); 4128 4070 pb_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 EOF4134 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))));4137 4071 4138 4072 EOF … … 4140 4074 # Install from sandbox mean a file base install 4141 4075 $itype = "file" if (defined $sbx); 4076 $itype = $installtype if (defined $installtype); 4142 4077 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 4083 my ($ospkgdep) = pb_conf_get_if("ospkgdep"); 4084 my $pkgdep = pb_distro_get_param($pbos,$ospkgdep); 4085 my $forcerepo; 4086 EOF 4087 print SCRIPT "\$forcerepo = pb_distro_setuprepo_gen(\$pbos,\"$pbrepo\");\n" if ((defined $pbrepo) && ($pbrepo ne "")); 4088 print SCRIPT << 'EOF'; 4089 pb_distro_installdeps(undef,$pbos,$forcerepo,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep)))); 4090 4091 EOF 4143 4092 my $cmdget; 4144 my ($pbver1,$pbver2,$pbextdir);4145 my ($tmp1,$tmp2);4146 4093 if (defined $sbx) { 4147 4094 # Install from sandbox mean using the result of the just passed sbx2build command 4148 4095 # Get content saved in cms2build 4149 4096 my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml","pbpkg"); 4150 $pbextdir = pb_get_extdir();4151 4097 confess "Unable to get package list" if (not defined $pkg); 4152 4098 4153 4099 # We consider 2 specific packages 4154 4100 my $vertag1 = $pkg->{"ProjectBuilder"}; … … 4157 4103 pb_log(2,"Vertag1: $vertag1\n"); 4158 4104 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(); 4161 4108 $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"; 4162 4109 } else { … … 4189 4136 print SCRIPT " $cmdget ; "; 4190 4137 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");4138 gzip -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"); 4192 4139 EOF 4193 4140 } elsif ($itype =~ /^pkg/) { … … 4196 4143 my $pkgforpb = pb_distro_get_param($pbos,pb_conf_get_if("ospkg")); 4197 4144 my $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)))); 4145 pb_distro_installpkgs($pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb)))); 4200 4146 EOF 4201 4147 } else { … … 4358 4304 } 4359 4305 return; 4306 } 4307 4308 # Build all docker CTN required to build an app 4309 sub 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 } 4360 4384 } 4361 4385 … … 5323 5347 } 5324 5348 5325 # Unused now5326 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 5340 5349 sub create_solaris_prototype { 5341 5350
Note:
See TracChangeset
for help on using the changeset viewer.