- Timestamp:
- Sep 1, 2019, 3:18:34 AM (6 years ago)
- Location:
- devel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/etc/pb.yml.pod
r2410 r2426 27 27 =over 4 28 28 29 =item B<add repo>30 31 Nature: Optional 32 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here. 33 Value: comma separated list of URLs that point to repository files, or packages to install . The values may not include substitutions.34 Conffile: project 35 Example: add repo:29 =item B<addbuildrepo> 30 31 Nature: Optional 32 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here. 33 Value: comma separated list of URLs that point to repository files, or packages to install at project build time. The values may not include substitutions. 34 Conffile: project 35 Example: addbuildrepo: 36 36 centos-5-x86_64: file:///prj/extras.repo,http://mirror.centos.org/centos/5.8/extras/x86_64/RPMS/chrpath-0.13-3.el5.centos.x86_64.rpm 37 38 =item B<addinstallrepo> 39 40 Nature: Optional 41 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here. 42 Value: comma separated list of URLs that point to repository files, or packages to install at project installation time. The values may not include substitutions. 43 Conffile: project 44 Example: addinstallrepo: 45 centos-7-x86_64: ftp://ftp.project-builder.org/centos/7/x86_64/pb.repo 46 47 =item B<addtestrepo> 48 49 Nature: Optional 50 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here. 51 Value: comma separated list of URLs that point to repository files, or packages to install at project test time. The values may not include substitutions. 52 Conffile: project 53 Example: addtestrepo: 54 centos-7-x86_64: ftp://ftp.project-builder.org/centos/7/x86_64/pb.repo 37 55 38 56 =item B<cachedir> -
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2402 r2426 29 29 30 30 our @ISA = qw(Exporter); 31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_get_all pb_conf_get_hash pb_conf_cache pb_conf_update_v0 );31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_get_all pb_conf_get_hash pb_conf_cache pb_conf_update_v0 pb_conf_get_in_hash_if); 32 32 ($VERSION,$REVISION,$PBCONFVER) = pb_version_init(); 33 33 -
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r2410 r2426 69 69 =over 4 70 70 71 =item B<pb_distro_ conffile>72 73 This function returns the mandatory configuration file used for distribution/OS detection71 =item B<pb_distro_api> 72 73 This function returns the mandatory configuration file used for api 74 74 75 75 =cut … … 605 605 606 606 pb_log(3, "INFO: Adding osrepo from config file\n"); 607 return(pb_distro_setuprepo_gen_conf($pbos,pb_distro_conffile(),"osrepo")); 607 my %h; 608 my $h = \%h; 609 # Adds conf file for availability of conf elements either from the local build env or from a VE/VM/RM in which the conf file has been passed 610 $h = pb_conf_cache(pb_distro_conffile(),$h); 611 my ($osrepo) = pb_conf_get_in_hash_if($h,"osrepo"); 612 return(pb_distro_setuprepo_gen($pbos,$osrepo->{$ENV{'PBPROJ'}})); 608 613 } 609 614 610 615 =item B<pb_distro_setuprepo> 611 616 612 This function sets up potential additional repository to the build environment617 This function sets up potential additional repository to the build/install/test environment 613 618 614 619 =cut … … 617 622 618 623 my $pbos = shift; 619 620 pb_log(3, "INFO: Adding addrepo from config file\n"); 621 return(pb_distro_setuprepo_gen_conf($pbos,"$ENV{'PBDESTDIR'}/pbrc.yml","addrepo")); 622 } 623 =item B<pb_distro_setuprepo_gen_conf> 624 625 This function sets up in a generic way potential additional repository using conf files 626 627 =cut 628 629 sub pb_distro_setuprepo_gen_conf { 630 631 my $pbos = shift; 632 my $pbconf = shift; 633 my $pbkey = shift; 634 635 return undef if (not defined $pbconf); 636 return undef if (not defined $pbkey); 637 my ($addrepo) = pb_conf_read($pbconf,$pbkey); 638 return undef if (not defined $addrepo); 639 640 my $param = pb_distro_get_param($pbos,$addrepo); 641 return undef if ($param eq ""); 642 643 pb_log(1, "INFO: Adding repos $param\n"); 644 return(pb_distro_setuprepo_gen($pbos,$param)); 645 } 646 624 my $repotype = shift; 625 626 my %h; 627 my $h = \%h; 628 # Adds conf file for availability of conf elements either from the local build env or from a VE/VM/RM in which the conf file has been passed 629 $h = pb_conf_cache("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml",$h) if ((defined $ENV{'PBROOTDIR'}) && (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml")); 630 $h = pb_conf_cache("$ENV{'PBDESTDIR'}/pbrc.yml",$h) if ((defined $ENV{'PBDESTDIR'}) && (-f "$ENV{'PBDESTDIR'}/pbrc.yml")); 631 632 pb_log(3, "INFO: Adding addrepo from config file for $repotype\n"); 633 if ($repotype =~ /install/) { 634 # Give a probable default if nothing is provided to avoid overloading conf files 635 # 636 my ($addrepo) = pb_conf_get_in_hash_if($h,"addinstallrepo"); 637 if ((not defined $addrepo) || (not defined $addrepo->{$ENV{'PBPROJ'}})) { 638 my ($pbrepo) = pb_conf_get_in_hash_if($h,"pbrepo"); 639 return undef if (not defined $pbrepo); 640 my $url = "$pbrepo->{$ENV{'PBPROJ'}}"; 641 my ($testver,$delivery) = pb_conf_get_in_hash_if($h,"testver","delivery"); 642 $delivery->{$ENV{'PBPROJ'}} = "" if (not defined $delivery->{$ENV{'PBPROJ'}}); 643 $url .= "/$delivery->{$ENV{'PBPROJ'}}/"; 644 my $repotag = ""; 645 $repotag = "-$delivery->{$ENV{'PBPROJ'}}" if ($delivery->{$ENV{'PBPROJ'}} ne ""); 646 $url .= "/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/$ENV{PBPROJ}$repotag."; 647 my $ext = ""; 648 if ($pbos->{'type'} eq "rpm") { 649 $ext = "repo"; 650 if ($pbos->{'family'} eq "md") { 651 $ext = "addmedia"; 652 } 653 } elsif ($pbos->{'type'} eq "deb") { 654 $ext = ".sources.list"; 655 } 656 $url .= $ext; 657 return(pb_distro_setuprepo_gen($pbos,$url)); 658 } else { 659 my ($addrepo) = pb_conf_get_in_hash_if($h,"addinstallrepo"); 660 return(pb_distro_setuprepo_gen($pbos,$addrepo->{$ENV{'PBPROJ'}})); 661 } 662 } else { 663 my ($addrepo) = pb_conf_get_in_hash_if($h,"add".$repotype."repo"); 664 return(pb_distro_setuprepo_gen($pbos,$addrepo->{$ENV{'PBPROJ'}})); 665 } 666 } 647 667 648 668 =item B<pb_distro_setuprepo_gen> -
devel/pb/bin/pb
r2396 r2426 391 391 Update the distribution in the remote machine 392 392 393 =item B<install2pkg> 394 395 Install the project packages locally 396 393 397 =item B<test2pkg> 394 398 395 Test a package locally 399 Test the project packages locally 400 401 =item B<install2vm> 402 403 Install the project packages in a virtual machine 404 405 =item B<install2ve> 406 407 Install the project packages in a virtual environment 408 409 =item B<install2rm> 410 411 Install the project packages in a remote machine 396 412 397 413 =item B<test2vm> 398 414 399 Test a package in a virtual machine415 Test the project packages in a virtual machine, after installation 400 416 401 417 =item B<test2ve> 402 418 403 Test a package in a virtual environment419 Test the project packages in a virtual environment, after installation 404 420 405 421 =item B<test2rm> 406 422 407 Test a package in a remote machine423 Test the project packages in a remote machine, after installation 408 424 409 425 =item B<checkssh> … … 702 718 You may also need to specify additional repository files to use or rpms to install. Note the URL for repositories is not the URL of the repository, but the URL of a file that can be put in the yum.repos.d or apt.sources.d directory. 703 719 704 add repo:720 addbuildrepo: 705 721 centos-5-i386: http://localhost/pb/centos-extras.repo,http://mirror.centos.org/centos/5/extras/i386/RPMS/chrpath-0.13-3.el5.centos.i386.rpm 706 722 … … 911 927 pb_cms2build("CMS"); 912 928 pb_build2ssh(); 913 } elsif ( $action =~ /^sbx2ssh$/) {929 } elsif (($action =~ /^sbx2ssh$/) || ($action =~ /^sbx2pkg2ssh$/)) { 914 930 pb_cms2build("SandBox"); 915 931 pb_build2ssh(); … … 955 971 pb_cms2build("SandBox"); 956 972 pb_build2v("vm","build"); 973 } elsif ($action =~ /^install2vm$/) { 974 pb_build2v("vm","install"); 975 } elsif ($action =~ /^install2ve$/) { 976 pb_build2v("ve","install"); 977 } elsif ($action =~ /^install2rm$/) { 978 pb_build2v("rm","install"); 957 979 } elsif ($action =~ /^launchvm$/) { 958 980 pb_parallel_launchv(undef,"vm",undef,3,$pbimage); … … 1080 1102 } elsif ($action =~ /^snapvm$/) { 1081 1103 pb_snap2v("vm"); 1104 } elsif ($action =~ /^install2pkg$/) { 1105 pb_install2pkg(); 1082 1106 } elsif ($action =~ /^test2pkg$/) { 1083 1107 pb_test2pkg(); … … 1587 1611 # Do we have additional script to run to prepare the environement for the project ? 1588 1612 # Then include it in the pbconf delivery 1589 foreach my $pbvf (<$ENV{'PBROOTDIR'}/$pbpkg/pbv*.pre>,<$ENV{'PBROOTDIR'}/$pbpkg/pbv*.post> , <$ENV{'PBROOTDIR'}/$pbpkg/pbtest*>) {1613 foreach my $pbvf (<$ENV{'PBROOTDIR'}/$pbpkg/pbv*.pre>,<$ENV{'PBROOTDIR'}/$pbpkg/pbv*.post>) { 1590 1614 pb_log(1,"Handling file $pbvf\n"); 1591 1615 if (-x "$pbvf") { … … 1644 1668 } 1645 1669 1646 sub pb_ test2pkg {1670 sub pb_install2pkg { 1647 1671 # Get the running distro to test on 1648 1672 my $pbos = pb_distro_get_context(); … … 1654 1678 1655 1679 # Additional potential repo 1656 my $forcerepo = pb_distro_setuprepo($pbos); 1680 my $forcerepo = pb_distro_setuprepo($pbos,"install"); 1681 foreach my $pbpkg (@pkgs) { 1682 # We need to install the package to test, and deps brought with it 1683 pb_distro_installdeps(undef,$pbos,$forcerepo,$pbpkg,"local"); 1684 } 1685 } 1686 1687 sub pb_test2pkg { 1688 # Get the running distro to test on 1689 my $pbos = pb_distro_get_context(); 1690 1691 # Get list of packages to test 1692 # Get content saved in cms2build 1693 my $ptr = pb_get_pkg(); 1694 @pkgs = @$ptr; 1695 1696 # Additional potential repo 1697 my $forcerepo = pb_distro_setuprepo($pbos,"test"); 1657 1698 foreach my $pbpkg (@pkgs) { 1658 1699 # We need to install the package to test, and deps brought with it … … 1670 1711 1671 1712 # If needed we may add repository to the build env 1672 my $forcerepo = pb_distro_setuprepo($pbos );1713 my $forcerepo = pb_distro_setuprepo($pbos,"build"); 1673 1714 pb_log(1,"Forcing full package install with forcerepo\n") if (defined $forcerepo); 1674 1715 … … 1727 1768 my $do_install = shift; 1728 1769 1729 1730 1731 1770 # Call build2prep in case we have new deps we want to take in account 1771 # without redoing the prep phase (can be long and that helps debugging 1772 # build dependencies issues 1732 1773 pb_build2prep(); 1733 1774 pb_log(0,"INFO: ------ Starting to build package ------\n"); … … 2175 2216 my $vpid = shift; # 0 is FALSE 2176 2217 my $snapme = shift; # 0 is FALSE 2177 my $pbstep = shift; # 3 is usage of container2218 my $pbstep = shift; # == 3 is usage of container 2178 2219 2179 2220 $vexist = 0 if (not defined $vexist); … … 2290 2331 } elsif ($cmt =~ /(V[EM]|RM)Script/) { 2291 2332 $src="$src $pbscript{$v}"; 2292 } elsif ($cmt =~ /(V[EM]|RM) test/) {2293 $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc.yml $pbscript{$v} $ENV{'PBDESTDIR'}/pbtest";2333 } elsif ($cmt =~ /(V[EM]|RM)(install|test)/) { 2334 $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc.yml $pbscript{$v}"; 2294 2335 } elsif (($cmt eq "Announce") || ($cmt eq "Web") || ($cmt eq "CPAN")) { 2295 2336 $src="$src $ENV{'PBTMP'}/pbscript"; … … 2371 2412 } elsif ($cmt eq "CPAN") { 2372 2413 $tdir = "$remdir"; 2373 } elsif ($cmt =~ /(V[EM]|RM)(build|test| prep)/) {2414 } elsif ($cmt =~ /(V[EM]|RM)(build|test|install|prep)/) { 2374 2415 $tdir = $remdir."/$ENV{'PBPROJ'}/pbdelivery"; 2375 2416 $bdir = $remdir."/$ENV{'PBPROJ'}/pbbuild"; … … 2672 2713 # step 2 : n-v-a-pb + build -> tag n-v-a-pb-pbproj 2673 2714 # step 3 : n-v-a-pb-pbproj at use 2715 # step 4 : n-v-a-pb-pbproj-install based on #3 2716 # step 5 : n-v-a-pb-pbproj-test based on #4 2674 2717 if ((not defined $pbimage) || ($pbimage eq "")) { 2675 2718 # If no image name given, create a naming convention … … 2677 2720 $tag{2} = "$tag{1}-pb"; 2678 2721 $tag{3} = "$tag{2}-$ENV{'PBPROJ'}"; 2722 $tag{4} = "$tag{3}-install"; 2723 $tag{5} = "$tag{3}-test"; 2679 2724 } else { 2680 2725 # If we were given an image name, just use it … … 2682 2727 $tag{2} = $pbimage; 2683 2728 $tag{3} = $pbimage; 2729 $tag{4} = $pbimage; 2730 $tag{5} = $pbimage; 2684 2731 } 2685 2732 # If we do not create the image, then use the one we should have … … 2738 2785 } 2739 2786 $cptarget = "$tpdir/$homedir/$tdir"; 2740 if ($cmt =~ /VE(build|prep )/) {2787 if ($cmt =~ /VE(build|prep|install|test)/) { 2741 2788 $cp2target = "$tpdir/$homedir/$bdir"; 2742 2789 } … … 2909 2956 print DOCKER "(cd $homedir/$tdir-2 ; ls -al)\n"; 2910 2957 print DOCKER pb_get_content($pbscript2); 2911 print DOCKER "\n# Get content back from guest in a host dir\n"; 2912 # Host dir seen as TDIR in container 2913 $cp2target = "$ENV{'PBBUILDDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 2914 pb_mkdir_p("$cp2target"); 2915 chmod 0777,"$cp2target"; 2916 print DOCKER "TDIR=$homedir/$bdir-2/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\n"; 2917 print DOCKER "for i in $homedir/$bdir/*; do\n"; 2918 print DOCKER " # Cleanup first to avoid rights issues for root owned files e.g.\n"; 2919 print DOCKER " j=\`basename \$i\`\n"; 2920 print DOCKER " if [ -d \$TDIR/\$j ]; then\n"; 2921 print DOCKER " rmdir --ignore-fail-on-non-empty \$TDIR/\$j\n"; 2922 print DOCKER " else\n"; 2923 print DOCKER " rm -f \$TDIR/\$j\n"; 2924 print DOCKER " fi\n"; 2925 print DOCKER " cp -r \$i \$TDIR\n"; 2926 print DOCKER "done\n"; 2927 print DOCKER "find \$TDIR -type f -print0 | xargs -0 chmod 644 && /bin/true\n"; 2928 print DOCKER "find \$TDIR -type d -print0 | xargs -0 chmod 777 2> /dev/null && /bin/true\n"; 2929 #print DOCKER "ls -al \$TDIR\n"; 2958 # Not useful for test or install 2959 if ($pbstep == 3) { 2960 print DOCKER "\n# Get content back from guest in a host dir\n"; 2961 # Host dir seen as TDIR in container 2962 $cp2target = "$ENV{'PBBUILDDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 2963 pb_mkdir_p("$cp2target"); 2964 chmod 0777,"$cp2target"; 2965 print DOCKER "TDIR=$homedir/$bdir-2/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}-$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\n"; 2966 print DOCKER "for i in $homedir/$bdir/*; do\n"; 2967 print DOCKER " # Cleanup first to avoid rights issues for root owned files e.g.\n"; 2968 print DOCKER " j=\`basename \$i\`\n"; 2969 print DOCKER " if [ -d \$TDIR/\$j ]; then\n"; 2970 print DOCKER " rmdir --ignore-fail-on-non-empty \$TDIR/\$j\n"; 2971 print DOCKER " else\n"; 2972 print DOCKER " rm -f \$TDIR/\$j\n"; 2973 print DOCKER " fi\n"; 2974 print DOCKER " cp -r \$i \$TDIR\n"; 2975 print DOCKER "done\n"; 2976 print DOCKER "find \$TDIR -type f -print0 | xargs -0 chmod 644 && /bin/true\n"; 2977 print DOCKER "find \$TDIR -type d -print0 | xargs -0 chmod 777 2> /dev/null && /bin/true\n"; 2978 #print DOCKER "ls -al \$TDIR\n"; 2979 } 2930 2980 print DOCKER "exit 0\n"; 2931 2981 close(DOCKER); … … 3073 3123 my $vtype = shift; 3074 3124 my $action = shift; # It an action is defined then use send2target 3075 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use )3125 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use 4: install 5: test) 3076 3126 my $pbimage=shift; # Which image to use to start the VM/VE 3077 3127 my $pbforce=shift; # Force stop of VM. Default not. … … 3154 3204 my $v = shift; # Only 1 VM/VE/RM treated here 3155 3205 my $action = shift; # It an action is defined then use send2target 3156 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use )3206 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use 4: install 5: test) 3157 3207 my $pbforce=shift; # Force stop of VM. Default not. 3158 3208 my $snapme = shift; # By default do not snap a VM/VE/RM … … 3420 3470 if ($action eq "prep") { 3421 3471 $pbstep = 2; 3422 } else { 3472 } elsif ($action eq "install") { 3473 $pbstep = 4; 3474 } elsif ($action eq "test") { 3475 $pbstep = 5; 3476 } elsif ($action eq "build") { 3423 3477 $pbstep = 3; 3424 3478 # Need to be traversed by others if using containers … … 3426 3480 chmod 0751,"$ENV{'PBBUILDDIR'}"; 3427 3481 } 3482 } else { 3483 pb_log(0,"pb_build2v: unknown action $action\n"); 3484 confess "Unable to continue"; 3428 3485 } 3429 3486 … … 3547 3604 print SCRIPT "echo $action"."ing packages on $vtype...\n"; 3548 3605 3549 if (($action eq "test") && (! -x "$ENV{'PBDESTDIR'}/pbtest")) {3550 cluck "No test script ($ENV{'PBDESTDIR'}/pbtest) found when in test mode. Aborting ...";3551 next;3552 }3553 3606 print SCRIPT "pb --version\n"; 3554 3607 my $act = "$action"."2pkg"; … … 4066 4119 } 4067 4120 4068 my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc.yml","add repo");4121 my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc.yml","addbuildrepo"); 4069 4122 my $pbrepo = pb_distro_get_param($pbos,$addrepo); 4070 4123 print SCRIPT << 'EOF';
Note:
See TracChangeset
for help on using the changeset viewer.