Changeset 2426 in ProjectBuilder for devel/pb/bin/pb
- Timestamp:
- Sep 1, 2019, 3:18:34 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.