Changeset 1907 in ProjectBuilder for devel/pb/bin/pb
- Timestamp:
- Oct 10, 2014, 11:32:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r1906 r1907 252 252 RM means Remote Machine, and could be a physical or Virtual one. 253 253 This is one buildfarm integration for pb. 254 255 =item B<prepvm> 256 257 Prepare the VMs to have all requirements to build the project 258 259 =item B<prepve> 260 261 Prepare the VEs to have all requirements to build the project 262 263 =item B<preprm> 264 265 Prepare the RMs to have all requirements to build the project 254 266 255 267 =item B<sbx2vm> … … 855 867 } elsif ($action =~ /^build2vm$/) { 856 868 pb_build2v("vm","build"); 869 } elsif ($action =~ /^preprm$/) { 870 pb_build2v("rm","prep"); 871 } elsif ($action =~ /^prepve$/) { 872 pb_build2v("ve","prep"); 873 } elsif ($action =~ /^prepvm$/) { 874 pb_build2v("vm","prep"); 857 875 } elsif ($action =~ /^cms2rm$/) { 858 876 pb_cms2build("CMS"); … … 1000 1018 sub pb_cms2build { 1001 1019 1002 my $param = shift || undef;1003 my $web = shift || undef;1020 my $param = shift; 1021 my $web = shift; 1004 1022 1005 1023 my $pkg; … … 1528 1546 } 1529 1547 pb_log(0,"INFO: ------ Finished preparing build environment ------\n"); 1530 open(PKG,">> $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb") || die "Unable to append to $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb";1531 print PKG "pbstep $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} = 2\n";1532 close(PKG);1533 1548 } 1534 1549 … … 1541 1556 my $pbos = pb_distro_get_context(); 1542 1557 1543 # Check whether the preparation phase has already been done or not1544 my ($pbstep) = pb_distro_get_param($pbos,pb_conf_read_if("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbstep"));1545 pb_build2prep() if ((not defined $pbstep) || ($pbstep < 2));1546 1547 1558 # Get list of packages to build 1548 1559 my $ptr = pb_get_pkg(); … … 1934 1945 print KEEP "$made\n"; 1935 1946 close(KEEP); 1936 open(PKG,">> $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb") || die "Unable to append to $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb";1937 print PKG "pbstep $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} = 3\n";1938 close(PKG);1939 1947 pb_distro_installdeps(undef,$pbos,$ret) if ($do_install); 1940 }1941 1942 sub create_solaris_prototype {1943 1944 my $uidgid = "bin bin";1945 my $pkgdestdir = $ENV{'PBSOLDESTDIR'};1946 1947 return if ($_ =~ /^$pkgdestdir$/);1948 if (-d $_) {1949 my $n = $File::Find::name;1950 $n =~ s~$pkgdestdir/~~;1951 print PROTO "d none $n 0755 $uidgid\n";1952 } elsif (-x $_) {1953 my $n = $File::Find::name;1954 $n =~ s~$pkgdestdir/~~;1955 print PROTO "f none $n 0755 $uidgid\n";1956 } elsif (-f $_) {1957 my $n = $File::Find::name;1958 $n =~ s~$pkgdestdir/~~;1959 print PROTO "f none $n 0644 $uidgid\n";1960 }1961 1948 } 1962 1949 … … 1975 1962 1976 1963 my $cmt = shift; 1977 my $pbscript = shift || undef; 1978 my $v = shift || undef; 1979 my $vexist = shift || 0; # 0 is FALSE 1980 my $vpid = shift || 0; # 0 is FALSE 1981 my $snapme = shift || 0; # 0 is FALSE 1982 my $pbstep = shift || 3; # 3 is usage of container 1983 1964 my $pbscript = shift; 1965 my $v = shift; 1966 my $vexist = shift; # 0 is FALSE 1967 my $vpid = shift; # 0 is FALSE 1968 my $snapme = shift; # 0 is FALSE 1969 my $pbstep = shift; # 3 is usage of container 1970 1971 $vexist = 0 if (not defined $vexist); 1972 $vpid = 0 if (not defined $vpid); 1973 $snapme = 0 if (not defined $snapme); 1974 $pbstep = 3 if (not defined $pbstep); 1984 1975 pb_log(2,"DEBUG: pb_send2target($cmt,".Dumper($v).",$vexist,$vpid)\n"); 1985 1976 my $host = "sshhost"; … … 2085 2076 } 2086 2077 2087 if ($cmt =~ /(V[EM]|RM) build/) {2078 if ($cmt =~ /(V[EM]|RM)(build|prep)/) { 2088 2079 $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $pbscript{$v}"; 2089 2080 } elsif ($cmt =~ /(V[EM]|RM)Script/) { … … 2161 2152 } elsif ($cmt eq "CPAN") { 2162 2153 $tdir = "$remdir"; 2163 } elsif ($cmt =~ /(V[EM]|RM)(build|test )/) {2154 } elsif ($cmt =~ /(V[EM]|RM)(build|test|prep)/) { 2164 2155 $tdir = $remdir."/$ENV{'PBPROJ'}/delivery"; 2165 2156 $bdir = $remdir."/$ENV{'PBPROJ'}/build"; … … 2423 2414 if ($cmt =~ /^VE/) { 2424 2415 $tp = pb_path_expand($vepath->{$ENV{'PBPROJ'}}); 2416 $vetype = pb_ve_get_type($vetype); 2425 2417 if ($vetype eq "docker") { 2426 2418 $tpdir = "/"; … … 2428 2420 $tpdir = pb_path_expand("$tp/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 2429 2421 } 2430 $vetype = pb_ve_get_type($vetype);2431 2422 my $arch = pb_get_arch(); 2432 2423 if ($vetype eq "chroot") { … … 2561 2552 $logres = "> "; 2562 2553 } 2554 2555 if ($cmt =~ /SandBox/) { 2556 # Install from sandbox mean using the result of the just passed sbx2build command 2557 # Get content saved in cms2build 2558 my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg"); 2559 my $pbextdir = pb_get_extdir(); 2560 confess "Unable to get package list" if (not defined $pkg); 2561 2562 # We consider 2 specific packages 2563 my $vertag1 = $pkg->{"ProjectBuilder"}; 2564 my $vertag2 = $pkg->{"project-builder"}; 2565 # get the version of the current package - maybe different 2566 pb_log(2,"Vertag1: $vertag1\n"); 2567 pb_log(2,"Vertag2: $vertag2\n"); 2568 my ($pbver1,$tmp1) = split(/-/,$vertag1); 2569 my ($pbver2,$tmp2) = split(/-/,$vertag2); 2570 if ($cmt =~ /VE/) { 2571 # Copy inside the VE 2572 if ($vetype ne "docker") { 2573 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz","$tpdir/tmp"); 2574 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$tpdir/tmp"); 2575 } else { 2576 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz","$context"); 2577 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$context"); 2578 print DOCKER "COPY ProjectBuilder-$pbver1$pbextdir.tar.gz /tmp/\n"; 2579 print DOCKER "COPY project-builder-$pbver2$pbextdir.tar.gz /tmp/\n"; 2580 } 2581 } else { 2582 pb_system("$cpcmd $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz $mac:/tmp","Copying local project files to $vetype."); 2583 } 2584 } 2585 2563 2586 # For docker everything is done in the Dockerfile 2564 2587 if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep < 3)) { … … 2580 2603 pb_system("$shcmd \"sudo chown -R $mac $tdir\"","Adapt owner in $tdir to $mac"); 2581 2604 } else { 2582 print DOCKER "RUN sed -i '/requiretty/d' /etc/sudoers " if ($pbstep == 1);2605 print DOCKER "RUN sed -i '/requiretty/d' /etc/sudoers\n" if ($pbstep == 1); 2583 2606 } 2584 2607 } … … 2615 2638 } 2616 2639 # this is where we lanch the execution 2617 pb_system("$shcmd","Executing pbscript on $cptarget if needed",$cmdverb);2640 my $ret = pb_system("$shcmd","Executing pbscript on $cptarget if needed",$cmdverb); 2618 2641 2619 2642 if ($cmt =~ /^(V[EM]|RM)build/) { … … 2700 2723 } 2701 2724 if (($cmt =~ /^VE/) && ($snapme != 0)) { 2702 pb_ve_snap($pbos,$tp);2703 2725 if ($vetype eq "docker") { 2704 2726 foreach my $f (split(/ +/,$src)) { 2705 2727 unlink("$context/$f"); 2706 2728 } 2729 } else { 2730 pb_ve_snap($pbos,$tp); 2707 2731 } 2708 2732 } … … 2714 2738 my $vtype=shift; 2715 2739 my $pbstep=shift; # Which step are we in (0: create, 1: setup pb, 2: prep pbproj, 3: use to build) 2716 my $pbforce=shift || 0; # Force stop of VM. Default not. 2717 my $snapme=shift || 0; # Do we have to create a snapshot. Default not. 2718 my $pbimage=shift || undef; # Which image to use to start the VM/VE 2719 my $vm; 2720 my $all; 2740 my $pbforce=shift; # Force stop of VM. Default not. 2741 my $snapme=shift; # Do we have to create a snapshot. Default not. 2742 my $pbimage=shift; # Which image to use to start the VM/VE 2743 2744 $pbforce = 0 if (not defined $pbforce); 2745 $snapme = 0 if (not defined $snapme); 2721 2746 2722 2747 pb_log(2,"DEBUG: pb_script2v($vtype,$pbstep,$pbforce,$snapme)\n"); … … 2729 2754 my $pbscript=shift; 2730 2755 my $vtype = shift; 2731 my $action = shift; 2756 my $action = shift; # It an action is defined then use send2target 2732 2757 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use) 2733 my $pbforce=shift || 0; # Force stop of VM. Default not.2734 my $snapme = shift || 0;# By default do not snap a VM/VE/RM2735 my $usesnap = shift || 1; # By default study the usage of the snapshot feature of VM/VE/RM2736 my $pbimage=shift || undef;# Which image to use to start the VM/VE2758 my $pbforce=shift; # Force stop of VM. Default not. 2759 my $snapme = shift; # By default do not snap a VM/VE/RM 2760 my $usesnap = shift; # By default study the usage of the snapshot feature of VM/VE/RM 2761 my $pbimage=shift; # Which image to use to start the VM/VE 2737 2762 my $vm; 2738 2763 my $all; 2764 2765 $pbforce = 0 if (not defined $pbforce); 2766 $snapme = 0 if (not defined $snapme); 2767 $usesnap = 1 if (not defined $usesnap); 2739 2768 2740 2769 # Adapt // mode to memory size … … 2777 2806 my $pbscript = $pbscript->{$v} if (defined $pbscript->{$v}); 2778 2807 $pbscript = $pbscript->{'default'} if (not defined $pbscript); 2779 confess "No script defined so unable to launch it in $v" if (not defined $pbscript);2780 2808 ($vexist,$vpid) = pb_launchv($pbscript,$vtype,$v,$action,$pbstep,$pbforce,$snapme,$pbsnap,$pbimage); 2781 2809 … … 2795 2823 my $pbscript=shift; 2796 2824 my $vtype = shift; 2797 my $v = shift; 2798 my $action = shift; 2825 my $v = shift; # Only 1 VM/VE/RM treated here 2826 my $action = shift; # It an action is defined then use send2target 2799 2827 my $pbstep=shift; # Which step are we in (0: create, 1: setup, 2: build 3: use) 2800 my $pbforce=shift || 0; # Force stop of VM. Default not.2801 my $snapme = shift || 0;# By default do not snap a VM/VE/RM2802 my $usesnap = shift || 1;# By default study the usage of the snapshot feature of VM/VE/RM2803 my $pbimage=shift || undef;# Which image to use to start the VM/VE2828 my $pbforce=shift; # Force stop of VM. Default not. 2829 my $snapme = shift; # By default do not snap a VM/VE/RM 2830 my $usesnap = shift; # By default study the usage of the snapshot feature of VM/VE/RM 2831 my $pbimage=shift; # Which image to use to start the VM/VE 2804 2832 my $vexist = undef; 2805 2833 my $vpid = undef; 2834 2835 $pbforce = 0 if (not defined $pbforce); 2836 $snapme = 0 if (not defined $snapme); 2837 $usesnap = 1 if (not defined $usesnap); 2806 2838 2807 2839 # Check that v exists … … 2813 2845 } 2814 2846 2815 pb_log(2,"DEBUG: pb_launchv( script,vtype,v,step,force,snapme,usesnap: $pbscript,$vtype,$v,$pbstep,$pbforce,$snapme,$usesnap)\n");2847 pb_log(2,"DEBUG: pb_launchv(vtype,v,step,force,snapme,usesnap: $vtype,$v,$pbstep,$pbforce,$snapme,$usesnap)\n"); 2816 2848 pb_log(2,"DEBUG: pb_launchv(pbimage: $pbimage)\n") if (defined $pbimage); 2849 pb_log(2,"DEBUG: pb_launchv(pbimage: $pbscript)\n") if (defined $pbscript); 2817 2850 pb_log(2,"DEBUG: pb_launchv(action: $action)\n") if (defined $action); 2818 2851 # Keep only the first VM in case many were given … … 2967 3000 # Force the creation of the VE and no snapshot usable 2968 3001 $vetype = pb_ve_get_type($vetype); 2969 pb_ve_launch($v,$pbs cript,$pbforce,$pbstep,$usesnap,$vetype,$pbimage);3002 pb_ve_launch($v,$pbstep,$usesnap,$vetype,$pbimage); 2970 3003 $vexist = 0; 2971 3004 $vpid = 0; 2972 3005 } else { 2973 # RM here2974 # Get distro context2975 my $pbos = pb_distro_get_context($v);2976 2977 3006 # Get RM context 2978 3007 my ($ptr,$rmpath) = pb_conf_get("rmtype","rmpath"); … … 3034 3063 3035 3064 my $vtype = shift; 3036 my $action = shift || "build"; #build, test or prep 3037 my $pbforce=shift || 0; # Force stop of VM. Default not. 3065 my $action = shift; #build, test or prep 3066 my $pbforce=shift; # Force stop of VM. Default not. 3067 3068 $action = "build" if (not defined $action); 3069 $pbforce = 0 if (not defined $pbforce); 3038 3070 3039 3071 my $pbstep; … … 3101 3133 print SCRIPT "export PBPROJ=$ENV{'PBPROJ'}\n"; 3102 3134 3103 if ( $action eq "build") {3135 if (($action eq "build") || ($action eq "prep")) { 3104 3136 print SCRIPT "# Preparation for pb\n"; 3105 3137 print SCRIPT "rm -f \$HOME/.pbrc\n"; … … 3109 3141 3110 3142 # VE needs a good /proc, tolerate one being potentially left around after a failure 3143 $vetype = pb_ve_get_type($vetype); 3111 3144 if (($vtype eq "ve") && ($vetype ne "docker")) { 3112 3145 print SCRIPT "[ -d /proc/1 ] || sudo /bin/mount -t proc /proc /proc\n"; … … 3358 3391 3359 3392 my $vtype = shift; 3360 my $sbx = shift || undef;3393 my $sbx = shift; 3361 3394 my $pbstep = 1; 3362 3395 … … 3463 3496 # once this is done, we can do what we need on the VM/RM remotely 3464 3497 } elsif ($vtype eq "ve") { 3498 $vetype = pb_ve_get_type($vetype); 3465 3499 if ($vetype ne "docker") { 3466 3500 print SCRIPT << "EOF"; … … 3727 3761 my ($pbver1,$tmp1) = split(/-/,$vertag1); 3728 3762 my ($pbver2,$tmp2) = split(/-/,$vertag2); 3729 # Copy inside the VE3730 if ($vtype eq "ve") {3731 my ($vepath) = pb_conf_get("vepath");3732 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp");3733 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp");3734 } else {3735 pb_system("scp -i $keyfile -p -o UserKnownHostsFile=/dev/null -P $nport $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1$pbextdir.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2$pbextdir.tar.gz root\@$vmhost->{$ENV{'PBPROJ'}}:/tmp","Copying local project files to $vtype.");3736 }3737 3763 $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"; 3738 3764 } else { … … 3851 3877 # Launch the VM/VE/RM 3852 3878 pb_log(2,"DEBUG: before parallel launch, pbscript hash is:".Dumper(%pbscript)."\n"); 3853 pb_parallel_launchv(\%pbscript,$vtype,uc($vtype)."Script" ,$pbstep,$pbforce);3879 pb_parallel_launchv(\%pbscript,$vtype,uc($vtype)."Script".$sbx,$pbstep,$pbforce); 3854 3880 return; 3855 3881 } … … 3859 3885 3860 3886 my $vtype = shift; 3861 my $pbstep = 3;3887 my $pbstep = 2; 3862 3888 3863 3889 my ($vm,$all) = pb_get2v($vtype); … … 3923 3949 EOF 3924 3950 # VE needs a good /proc 3951 $vetype = pb_ve_get_type($vetype); 3925 3952 if (($vtype eq "ve") && ($vetype ne "docker")) { 3926 3953 print SCRIPT "sudo /bin/mount -t proc /proc /proc\n"; … … 4760 4787 } 4761 4788 4762 sub pb_get_extdir (){4789 sub pb_get_extdir { 4763 4790 4764 4791 # the pbrc file should contain it and whatever the key, we take it … … 4776 4803 } 4777 4804 4805 # Unused now 4806 sub pb_keep_step { 4807 4808 my $pbos = shift; 4809 my $pbstep = shift; 4810 4811 $pbstep = 3 if (not defined $pbstep); 4812 4813 my %h; 4814 my $h = \%h; 4815 $h = pb_conf_cache("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb",$h); 4816 $h->{'pbstep'}->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = $pbstep; 4817 pb_conf_write("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb",$h); 4818 } 4819 4820 sub create_solaris_prototype { 4821 4822 my $uidgid = "bin bin"; 4823 my $pkgdestdir = $ENV{'PBSOLDESTDIR'}; 4824 4825 return if ($_ =~ /^$pkgdestdir$/); 4826 if (-d $_) { 4827 my $n = $File::Find::name; 4828 $n =~ s~$pkgdestdir/~~; 4829 print PROTO "d none $n 0755 $uidgid\n"; 4830 } elsif (-x $_) { 4831 my $n = $File::Find::name; 4832 $n =~ s~$pkgdestdir/~~; 4833 print PROTO "f none $n 0755 $uidgid\n"; 4834 } elsif (-f $_) { 4835 my $n = $File::Find::name; 4836 $n =~ s~$pkgdestdir/~~; 4837 print PROTO "f none $n 0644 $uidgid\n"; 4838 } 4839 } 4840 4841 4778 4842 1;
Note:
See TracChangeset
for help on using the changeset viewer.