- Timestamp:
- Feb 7, 2011, 2:24:17 PM (14 years ago)
- Location:
- devel/pb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r1176 r1177 842 842 # We want to at least build for the underlying distro 843 843 # except if a target was given, in which case we only build for it 844 my ($tdir,$tver,$tarch); 845 ($tdir,$tver,$tarch) = split(/-/,$pbtarget) if (defined ($pbtarget)); 846 847 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init($tdir,$tver,$tarch); 848 my $tmpl = "$ddir-$dver-$arch,"; 844 my $pbos = pb_distro_get_context($pbtarget); 845 my $tmpl = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'},"; 849 846 850 847 # Get list of distributions for which we need to generate build files if no target … … 869 866 $pb{'pkg'} = $pbpkg; 870 867 $pb{'realpkg'} = $pbpkg; 868 $pb{'suf'} = $pbos->{'suffix'}; 871 869 $pb{'date'} = $pbdate; 872 870 $pb{'defpkgdir'} = $defpkgdir; … … 895 893 $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel); 896 894 897 foreach my $ d(keys %virt) {895 foreach my $v (keys %virt) { 898 896 $pm->start and next if (defined $pbparallel); 899 my ($name,$ver,$arch) = split(/-/,$d); 900 pb_log(0,"Bad format for $d") if ((not defined $name) || (not defined $ver) || (not defined $arch)) ; 901 chomp($arch); 902 my ($ddir, $dver, $dfam); 903 ($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'os'}, $pb{'suf'}, $pb{'upd'}, $pb{'arch'}) = pb_distro_init($name,$ver,$arch); 904 pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'suf'})."\n"); 897 898 # Distro context 899 my $pbos = pb_distro_get_context($v); 905 900 pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n"); 906 901 907 902 # We need to compute the real name of the package 908 my $pbrealpkg = pb_cms_get_real_pkg($pbpkg,$pb {'dtype'});903 my $pbrealpkg = pb_cms_get_real_pkg($pbpkg,$pbos->{'type'}); 909 904 $pb{'realpkg'} = $pbrealpkg; 910 pb_log(1,"Virtual package $pbpkg has a real package name of $pbrealpkg on $ ddir-$dver\n") if ($pbrealpkg ne $pbpkg);905 pb_log(1,"Virtual package $pbpkg has a real package name of $pbrealpkg on $pbos->{'name'}-$pbos->{'version'}\n") if ($pbrealpkg ne $pbpkg); 911 906 912 907 # Filter build files from the less precise up to the most with overloading … … 917 912 my %bfiles = (); 918 913 my %pkgfiles = (); 919 $build{"$ ddir-$dver-$arch"} = "yes";914 $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "yes"; 920 915 921 if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pb {'dtype'}") {922 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pb {'dtype'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);923 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ dfam") {924 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);925 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ ddir") {926 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ ddir",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);927 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ ddir-$dver") {928 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);929 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ ddir-$dver-$arch") {930 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ ddir-$dver-$arch",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);916 if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'type'}") { 917 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'type'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 918 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'family'}") { 919 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'family'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 920 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}") { 921 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 922 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}") { 923 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 924 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}") { 925 pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 931 926 } else { 932 $build{"$ ddir-$dver-$arch"} = "no";927 $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "no"; 933 928 next; 934 929 } … … 936 931 937 932 # Get all filters to apply 938 my $ptr = pb_get_filters($pbpkg, $pb{'dtype'}, $dfam, $ddir, $dver);933 my $ptr = pb_get_filters($pbpkg,$pbos); 939 934 940 935 # Apply now all the filters on all the files concerned … … 942 937 if (defined $ptr) { 943 938 # For patch support 944 $pb{'tuple'} = "$ ddir-$dver-$arch";939 $pb{'tuple'} = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 945 940 foreach my $f (values %bfiles,values %pkgfiles) { 946 pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ ddir-$dver-$arch/".basename($f),\%pb);941 pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/".basename($f),\%pb); 947 942 } 948 943 } 949 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch", \%patches, $pb {'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch");950 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbsrc", \%sources, $pb {'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextsrc");944 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch", \%patches, $pbos, "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch"); 945 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbsrc", \%sources, $pbos, "$ENV{'PBROOTDIR'}/$pbpkg/pbextsrc"); 951 946 952 947 $pm->finish if (defined $pbparallel); … … 1102 1097 sub pb_test2pkg { 1103 1098 # Get the running distro to test on 1104 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init(); 1105 pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n"); 1099 my $pbos = pb_distro_get_context(); 1106 1100 1107 1101 # Get list of packages to test … … 1111 1105 1112 1106 # Additional potential repo 1113 pb_distro_setuprepo($ ddir,$dver,$arch,$dtype,$dfam,$dos);1107 pb_distro_setuprepo($pbos); 1114 1108 foreach my $pbpkg (@pkgs) { 1115 1109 # We need to install the package to test, and deps brought with it 1116 pb_distro_installdeps(undef,$ dtype,$pbins,$pbpkg);1110 pb_distro_installdeps(undef,$pbos,$pbpkg); 1117 1111 pb_system("$ENV{'PBDESTDIR'}/pbtest","Launching test for $pbpkg","verbose"); 1118 1112 } … … 1122 1116 1123 1117 # Get the running distro to build on 1124 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init(); 1125 pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n"); 1118 my $pbos = pb_distro_get_context(); 1126 1119 1127 1120 # If needed we may add repository to the build env 1128 pb_distro_setuprepo($ ddir,$dver,$arch,$dtype,$dfam,$dos);1121 pb_distro_setuprepo($pbos); 1129 1122 1130 1123 # Get list of packages to build … … 1158 1151 1159 1152 pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n"); 1160 if ($ dtypeeq "rpm") {1153 if ($pbos->{'type'} eq "rpm") { 1161 1154 foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') { 1162 1155 if (! -d "$ENV{'PBBUILDDIR'}/$d") { … … 1169 1162 symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES"; 1170 1163 # We need to first extract the spec file 1171 my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ ddir-$dver-$arch/","$ENV{'PBBUILDDIR'}/SPECS","spec");1164 my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/","$ENV{'PBBUILDDIR'}/SPECS","spec"); 1172 1165 1173 1166 # We need to handle potential patches to upstream sources 1174 pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ ddir-$dver-$arch/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES","patch");1167 pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES","patch"); 1175 1168 1176 1169 pb_log(2,"specfile: ".Dumper(\@specfile)."\n"); … … 1179 1172 # Older Redhat use _target_platform in %configure incorrectly 1180 1173 my $specialdef = ""; 1181 if (($ ddir eq "redhat") || (($ddir eq "rhel") && ($dvereq "2.1"))) {1174 if (($pbos->{'name'} eq "redhat") || (($pbos->{'name'} eq "rhel") && ($pbos->{'version'} eq "2.1"))) { 1182 1175 $specialdef = "--define \'_target_platform \"\"\'"; 1183 1176 } … … 1186 1179 if ($f =~ /\.spec$/) { 1187 1180 # This could cause an issue in // mode 1188 pb_distro_installdeps($f,$ dtype,$pbins);1181 pb_distro_installdeps($f,$pbos); 1189 1182 pb_system("rpmbuild $specialdef --define \"packager $ENV{'PBPACKAGER'}\" --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}","verbose"); 1190 1183 last; … … 1201 1194 close(LOG); 1202 1195 1203 } elsif ($ dtypeeq "deb") {1196 } elsif ($pbos->{'type'} eq "deb") { 1204 1197 chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; 1205 1198 pb_system("tar xfz $src","Extracting sources"); … … 1208 1201 chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 1209 1202 pb_rm_rf("debian"); 1210 symlink "pbconf/$ ddir-$dver-$arch","debian" || die "Unable to symlink to pbconf/$ddir-$dver-$arch";1203 symlink "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}","debian" || die "Unable to symlink to pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 1211 1204 chmod 0755,"debian/rules"; 1212 1205 1213 pb_distro_installdeps("debian/control",$ dtype,$pbins);1206 pb_distro_installdeps("debian/control",$pbos); 1214 1207 pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose"); 1215 1208 # Get the name of the generated packages … … 1223 1216 } 1224 1217 close(LOG); 1225 } elsif ($ dtypeeq "ebuild") {1218 } elsif ($pbos->{'type'} eq "ebuild") { 1226 1219 my @ebuildfile; 1227 1220 # For gentoo we need to take pb as subsystem name … … 1233 1226 1234 1227 # We need to first extract the ebuild file 1235 @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ ddir-$dver-$arch/","$tmpd","ebuild");1228 @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/","$tmpd","ebuild"); 1236 1229 1237 1230 # Prepare the build env for gentoo … … 1264 1257 foreach my $f (@ebuildfile) { 1265 1258 if ($f =~ /\.ebuild$/) { 1266 pb_distro_installdeps($f,$ dtype,$pbins);1259 pb_distro_installdeps($f,$pbos); 1267 1260 move($f,"$tmpd/$pbpkg-$pbver.ebuild"); 1268 1261 pb_system("cd $tmpd ; ebuild $pbpkg-$pbver.ebuild clean ; ebuild $pbpkg-$pbver.ebuild digest ; ebuild $pbpkg-$pbver.ebuild package","verbose"); … … 1282 1275 } 1283 1276 1284 } elsif ($ dtypeeq "tgz") {1277 } elsif ($pbos->{'type'} eq "tgz") { 1285 1278 # Slackware family 1286 1279 $made="$made $pbpkg/$pbpkg-$pbver-*-$pbtag.tgz"; … … 1290 1283 pb_system("tar xfz $src2","Extracting pbconf"); 1291 1284 chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 1292 symlink "pbconf/$ ddir-$dver-$arch","install" || die "Unable to symlink to pbconf/$ddir-$dver-$arch";1285 symlink "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}","install" || die "Unable to symlink to pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 1293 1286 if (-x "install/pbslack") { 1294 pb_distro_installdeps("./install/pbslack",$ dtype,$pbins);1287 pb_distro_installdeps("./install/pbslack",$pbos); 1295 1288 pb_system("./install/pbslack","Building software"); 1296 1289 pb_system("sudo /sbin/makepkg -p -l y -c y $pbpkg","Packaging $pbpkg","verbose"); 1297 1290 } 1298 } elsif ($ dtypeeq "pkg") {1291 } elsif ($pbos->{'type'} eq "pkg") { 1299 1292 # Solaris 1300 1293 $made="$made $pbpkg-$pbver-$pbtag.pkg.gz"; … … 1303 1296 chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; 1304 1297 # Will host resulting packages 1305 pb_mkdir_p("$ dtype");1298 pb_mkdir_p("$pbos->{'type'}"); 1306 1299 pb_mkdir_p("$pkgdestdir/delivery"); 1307 1300 pb_system("tar xfz $src","Extracting sources under $ENV{'PBBUILDDIR'}"); 1308 1301 pb_system("tar xfz $src2","Extracting pbconf under $ENV{'PBBUILDDIR'}"); 1309 1302 chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 1310 if (-f "pbconf/$ ddir-$dver-$arch/pbbuild") {1311 chmod 0755,"pbconf/$ ddir-$dver-$arch/pbbuild";1303 if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild") { 1304 chmod 0755,"pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild"; 1312 1305 # pkginfo file is mandatory 1313 die "Unable to find pkginfo file in pbconf/$ ddir-$dver-$arch" if (! -f "pbconf/$ddir-$dver-$arch/pkginfo");1306 die "Unable to find pkginfo file in pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}" if (! -f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pkginfo"); 1314 1307 # Build 1315 pb_system("pbconf/$ ddir-$dver-$arch/pbbuild $pkgdestdir/delivery","Building software and installing under $pkgdestdir/delivery");1308 pb_system("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild $pkgdestdir/delivery","Building software and installing under $pkgdestdir/delivery"); 1316 1309 # Copy complementary files 1317 if (-f "pbconf/$ ddir-$dver-$arch/prototype") {1318 copy("pbconf/$ ddir-$dver-$arch/prototype", $pkgdestdir)1310 if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/prototype") { 1311 copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/prototype", $pkgdestdir) 1319 1312 } else { 1320 1313 # No prototype provided, calculating it 1321 1314 open(PROTO,"> $pkgdestdir/prototype") || die "Unable to create prototype file"; 1322 1315 print PROTO "i pkginfo\n"; 1323 print PROTO "i depend\n" if (-f "pbconf/$ ddir-$dver-$arch/depend");1316 print PROTO "i depend\n" if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend"); 1324 1317 $ENV{'PBSOLDESTDIR'} = "$pkgdestdir/delivery"; 1325 1318 find(\&create_solaris_prototype, "$pkgdestdir/delivery"); 1326 1319 } 1327 copy("pbconf/$ ddir-$dver-$arch/depend", $pkgdestdir) if (-f "pbconf/$ddir-$dver-$arch/depend");1328 copy("pbconf/$ ddir-$dver-$arch/pkginfo", $pkgdestdir);1329 pb_system("cd $pkgdestdir/delivery ; pkgmk -o -f ../prototype -r $pkgdestdir/delivery -d $ENV{'PBBUILDDIR'}/$ dtype","Packaging $pbpkg","verbose");1330 pb_system("cd $ENV{'PBBUILDDIR'}/$ dtype ; echo \"\" | pkgtrans -o -n -s $ENV{'PBBUILDDIR'}/$dtype$ENV{'PBBUILDDIR'}/$pbpkg-$pbver-$pbtag.pkg all","Transforming $pbpkg","verbose");1320 copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend", $pkgdestdir) if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend"); 1321 copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pkginfo", $pkgdestdir); 1322 pb_system("cd $pkgdestdir/delivery ; pkgmk -o -f ../prototype -r $pkgdestdir/delivery -d $ENV{'PBBUILDDIR'}/$pbos->{'type'}","Packaging $pbpkg","verbose"); 1323 pb_system("cd $ENV{'PBBUILDDIR'}/$pbos->{'type'} ; echo \"\" | pkgtrans -o -n -s $ENV{'PBBUILDDIR'}/$pbos->{'type'} $ENV{'PBBUILDDIR'}/$pbpkg-$pbver-$pbtag.pkg all","Transforming $pbpkg","verbose"); 1331 1324 pb_system("cd $ENV{'PBBUILDDIR'} ; gzip -9f $pbpkg-$pbver-$pbtag.pkg","Compressing $pbpkg-$pbver-$pbtag.pkg","verbose"); 1332 1325 } else { 1333 pb_log(0,"No pbconf/$ ddir-$dver-$arch/pbbuild file found for $pbpkg-$pbver in \n");1326 pb_log(0,"No pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild file found for $pbpkg-$pbver in \n"); 1334 1327 } 1335 1328 chdir ".." || die "Unable to chdir to parent dir"; 1336 pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$ dtype$pkgdestdir", "Cleanup");1337 } elsif ($ dtypeeq "hpux") {1329 pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$pbos->{'type'} $pkgdestdir", "Cleanup"); 1330 } elsif ($pbos->{'type'} eq "hpux") { 1338 1331 # HP-UX 1339 1332 chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; … … 1357 1350 pb_system("rm -rf $pbpkg-$pbver", "Cleanup"); 1358 1351 } else { 1359 die "Unknown dtype format $dtype";1352 die "Unknown OS type format $pbos->{'type'}"; 1360 1353 } 1361 1354 if (defined $pbparallel) { … … 1375 1368 1376 1369 # Find the appropriate check cmd/opts 1377 my ($oschkcmd,$oschkopt) = pb_conf_get_if("oschkcmd","oschkopt"); 1378 my $chkcmd .= pb_distro_get_param($ddir,$dver,$arch,$oschkcmd,$dtype,$dfam,$dos); 1379 my $chkopt .= pb_distro_get_param($ddir,$dver,$arch,$oschkopt,$dtype,$dfam,$dos); 1370 my ($chkcmd,$chkopt) = pb_distro_get_param($pbos,pb_conf_get_if("oschkcmd","oschkopt")); 1380 1371 1381 1372 # Packages check if needed 1382 if ($dtype eq "rpm") { 1383 if (-x $chkcmd) { 1384 pb_system("$chkcmd $chkopt $made","Checking validity of rpms with $chkcmd","verbose"); 1373 if ($pbos->{'type'} eq "rpm") { 1374 if ((defined $chkcmd) && (-x $chkcmd)) { 1375 my $cmd = "$chkcmd"; 1376 $cmd .= " $chkopt" if (defined $chkopt); 1377 $cmd .= " $made"; 1378 pb_system("$cmd","Checking validity of rpms with $chkcmd","verbose"); 1385 1379 } 1386 1380 my $rpms =""; … … 1392 1386 pb_log(0,"SRPM packages generated: $srpms\n"); 1393 1387 pb_log(0,"RPM packages generated: $rpms\n"); 1394 } elsif ($ dtypeeq "deb") {1388 } elsif ($pbos->{'type'} eq "deb") { 1395 1389 my $made2 = ""; 1396 1390 foreach my $f (split(/ /,$made)) { … … 1403 1397 } 1404 1398 } else { 1405 pb_log(0,"No check done for $ dtypeyet\n");1399 pb_log(0,"No check done for $pbos->{'type'} yet\n"); 1406 1400 pb_log(0,"Packages generated: $made\n"); 1407 1401 } … … 1490 1484 my $cmd = ""; 1491 1485 my $src = ""; 1492 my ($odir,$over,$oarch) = (undef, undef, undef); 1493 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch); 1486 my $pbos; 1494 1487 1495 1488 if ($cmt ne "Announce") { … … 1499 1492 1500 1493 # Get the running distro to consider 1501 if (defined $v) { 1502 ($odir,$over,$oarch) = split(/-/,$v); 1503 } 1504 ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init($odir,$over,$oarch); 1505 pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n"); 1494 $pbos = pb_distro_get_context($v); 1506 1495 1507 1496 # Get list of packages to build … … 1571 1560 if ($cmt =~ /^RM/) { 1572 1561 # In that case our real host is in the rmhost with the OS as key, not project as above 1573 $sshmachine = pb_distro_get_param($ ddir,$dver,$darch,$sshhost,$dfam,$dtype,$dos);1562 $sshmachine = pb_distro_get_param($pbos,$sshhost); 1574 1563 } 1575 1564 pb_log(2,"ssh: ".Dumper(($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vepath,$rbsconf))."\n"); … … 1602 1591 $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}"; 1603 1592 } elsif ($cmt eq "Packages") { 1604 $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch";1593 $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"; 1605 1594 1606 1595 my $repodir = $tdir; … … 1611 1600 # Repository management 1612 1601 open(PBS,"> $ENV{'PBBUILDDIR'}/pbscript") || die "Unable to create $ENV{'PBBUILDDIR'}/pbscript"; 1613 if ($ dtypeeq "rpm") {1602 if ($pbos->{'type'} eq "rpm") { 1614 1603 # Also make a pbscript to generate yum/urpmi bases 1615 1604 print PBS << "EOF"; … … 1618 1607 cat > $ENV{'PBPROJ'}.repo << EOT 1619 1608 [$ENV{'PBPROJ'}] 1620 name=$ ddir $dver $darch- $ENV{'PBPROJ'} Vanilla Packages1609 name=$pbos->{'name'} $pbos->{'version'} $pbos->{'arch'} - $ENV{'PBPROJ'} Vanilla Packages 1621 1610 baseurl=$pbrepo->{$ENV{'PBPROJ'}}/$repodir 1622 1611 enabled=1 … … 1634 1623 createrepo . 1635 1624 EOF 1636 if ($ dfameq "md") {1625 if ($pbos->{'family'} eq "md") { 1637 1626 # For Mandriva add urpmi management 1638 1627 print PBS << "EOF"; … … 1652 1641 EOF 1653 1642 } 1654 if ($ ddireq "fedora") {1643 if ($pbos->{'name'} eq "fedora") { 1655 1644 # Extract the spec file to please Fedora maintainers :-( 1656 1645 print PBS << "EOF"; … … 1663 1652 EOF 1664 1653 } 1665 if ($ dfameq "novell") {1654 if ($pbos->{'family'} eq "novell") { 1666 1655 # Add ymp scripts for one-click install on SuSE 1667 1656 print PBS << "EOF"; … … 1712 1701 EOF 1713 1702 } 1714 } elsif ($ dtypeeq "deb") {1703 } elsif ($pbos->{'type'} eq "deb") { 1715 1704 # Also make a pbscript to generate apt bases 1716 1705 # Cf: http://www.debian.org/doc/manuals/repository-howto/repository-howto.fr.html … … 1723 1712 # Prepare a script to ease apt setup 1724 1713 cat > $ENV{'PBPROJ'}.sources.list << EOT 1725 deb $rpd $ dvercontrib1726 deb-src $rpd $ dvercontrib1714 deb $rpd $pbos->{'version'} contrib 1715 deb-src $rpd $pbos->{'version'} contrib 1727 1716 EOT 1728 1717 chmod 644 $ENV{'PBPROJ'}.sources.list … … 1730 1719 # Up two levels to deal with the dist dir cross versions 1731 1720 cd ../.. 1732 mkdir -p dists/$ dver/contrib/binary-$darch dists/$dver/contrib/source1721 mkdir -p dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'} dists/$pbos->{'version'}/contrib/source 1733 1722 1734 1723 # Prepare a script to create apt info file … … 1742 1731 EOT 1743 1732 1744 echo "Creating Packages metadata ($ darch)"1745 dpkg-scanpackages -a$ darch $dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/binary-$darch/Packages.gz1746 dpkg-scanpackages -a$ darch $dver/$darch /dev/null | bzip2 -c9 > dists/$dver/contrib/binary-$darch/Packages.bz21747 echo "Creating Contents metadata ($ darch)"1748 apt-ftparchive contents $ dver | gzip -c9 > dists/$dver/Contents-$darch.gz1749 echo "Creating Release metadata ($ darch)"1750 cat \$TMPD/Release > dists/$ dver/contrib/binary-$darch/Release1751 echo "Architecture: $ darch" >> dists/$dver/contrib/binary-$darch/Release1733 echo "Creating Packages metadata ($pbos->{'arch'})" 1734 dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.gz 1735 dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | bzip2 -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.bz2 1736 echo "Creating Contents metadata ($pbos->{'arch'})" 1737 apt-ftparchive contents $pbos->{'version'} | gzip -c9 > dists/$pbos->{'version'}/Contents-$pbos->{'arch'}.gz 1738 echo "Creating Release metadata ($pbos->{'arch'})" 1739 cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 1740 echo "Architecture: $pbos->{'arch'}" >> dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 1752 1741 echo "Creating Source metadata" 1753 dpkg-scansources $ dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/source/Sources.gz1754 cat \$TMPD/Release > dists/$ dver/contrib/source/Release1755 echo "Architecture: Source" >> dists/$ dver/contrib/source/Release1742 dpkg-scansources $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/source/Sources.gz 1743 cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/source/Release 1744 echo "Architecture: Source" >> dists/$pbos->{'version'}/contrib/source/Release 1756 1745 echo "Creating Release metadata" 1757 apt-ftparchive release dists/$ dver > dists/$dver/Release1746 apt-ftparchive release dists/$pbos->{'version'} > dists/$pbos->{'version'}/Release 1758 1747 rm -rf \$TMPD 1759 1748 EOF 1760 } elsif ($ dtypeeq "ebuild") {1749 } elsif ($pbos->{'type'} eq "ebuild") { 1761 1750 # make a pbscript to generate links to latest version 1762 1751 print PBS << "EOF"; … … 1793 1782 # should use a hash instead... 1794 1783 my ($shcmd,$cpcmd,$cptarget,$cp2target); 1784 my ($odir,$over,$oarch); 1795 1785 if ($cmt !~ /^VE/) { 1796 1786 my $keyfile = pb_ssh_get(0); … … 1884 1874 my $j = basename($p); 1885 1875 pb_system("$cpcmd $cp2target/$delim$p$delim $ENV{'PBBUILDDIR'}/$odir/$over/$oarch 2> /dev/null","Recovery of package $j in $ENV{'PBBUILDDIR'}/$odir/$over/$oarch"); 1886 $made="$made $odir/$over/$oarch/$j"; # if (($ dtypene "rpm") || ($j !~ /.src.rpm$/));1876 $made="$made $odir/$over/$oarch/$j"; # if (($pbos->{'type'} ne "rpm") || ($j !~ /.src.rpm$/)); 1887 1877 } 1888 1878 print KEEP "$made\n"; … … 1891 1881 1892 1882 # Sign packages locally 1893 if ($ dtypeeq "rpm") {1883 if ($pbos->{'type'} eq "rpm") { 1894 1884 #pb_system("rpm --addsign --define \"_signature gpg\" --define \"_gpg_name $ENV{'PBPACKAGER'}\" --define \"__gpg_sign_cmd /usr/bin/gpg --batch --no-verbose --no-armor --no-tty --no-secmem-warning -sbo %{__signature_filename} %{__plaintext_filename} --use-agent\" $made","Signing RPM packages packages"); 1895 } elsif ($ dtypeeq "deb") {1885 } elsif ($pbos->{'type'} eq "deb") { 1896 1886 #pb_system("debsign $made","Signing DEB packages"); 1897 1887 } else { 1898 pb_log(0,"I don't know yet how to sign packages for type $ dtype.\nPlease give feedback to dev team\n");1888 pb_log(0,"I don't know yet how to sign packages for type $pbos->{'type'}.\nPlease give feedback to dev team\n"); 1899 1889 } 1900 1890 … … 1939 1929 my $hpath = "/sbin"; 1940 1930 # Solaris doesn't support -h and has halt elsewhere 1941 if ($ dtypeeq "pkg") {1931 if ($pbos->{'type'} eq "pkg") { 1942 1932 $hoption = "" ; 1943 1933 $hpath = "/usr/sbin"; … … 2150 2140 # VE here 2151 2141 # Get distro context 2152 my ($name,$ver,$darch) = split(/-/,$v); 2153 chomp($darch); 2154 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 2142 my $pbos = pb_distro_get_context($v); 2155 2143 2156 2144 # Get VE context … … 2166 2154 if (($vetype eq "chroot") || ($vetype eq "schroot")) { 2167 2155 # Architecture consistency 2168 if ($arch ne $ darch) {2169 die "Unable to launch a VE of architecture $ darch on a $arch platform" if (($darcheq "x86_64") && ($arch =~ /i?86/));2156 if ($arch ne $pbos->{'arch'}) { 2157 die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" if (($pbos->{'arch'} eq "x86_64") && ($arch =~ /i?86/)); 2170 2158 } 2171 2159 … … 2175 2163 2176 2164 # We have to rebuild the chroot 2177 if ($ dtypeeq "rpm") {2165 if ($pbos->{'type'} eq "rpm") { 2178 2166 2179 2167 # Which tool is used … … 2192 2180 } 2193 2181 2194 my $postinstall = pb_get_postinstall($ ddir,$dver,$darch,$rbspi,$verpmstyle);2182 my $postinstall = pb_get_postinstall($pbos,$rbspi,$verpmstyle); 2195 2183 if ($verpmstyle eq "rinse") { 2196 2184 # Need to reshape the mirrors generated with local before-post-install script 2197 2185 my $b4post = "--before-post-install "; 2198 my $postparam = pb_distro_get_param($ ddir,$dver,$darch,$rbsb4pi);2186 my $postparam = pb_distro_get_param($pbos,$rbsb4pi); 2199 2187 if ($postparam eq "") { 2200 2188 $b4post = ""; … … 2206 2194 my $addpkgs; 2207 2195 $postparam = ""; 2208 $postparam .= pb_distro_get_param($ ddir,$dver,$darch,$osmindep);2196 $postparam .= pb_distro_get_param($pbos,$osmindep); 2209 2197 if ($postparam eq "") { 2210 2198 $addpkgs = ""; … … 2224 2212 2225 2213 my $command = pb_check_req("rinse",0); 2226 pb_system("sudo $command --directory \"$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch\" --arch \"$darch\" --distribution \"$ddir-$dver\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $ddir-$dver ($darch)", "verbose");2214 pb_system("sudo $command --directory \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" --arch \"$pbos->{'arch'}\" --distribution \"$pbos->{'name'}-$pbos->{'version'}\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 2227 2215 } elsif ($verpmstyle eq "rpmbootstrap") { 2228 2216 my $rbsverb = ""; … … 2232 2220 my $addpkgs = ""; 2233 2221 my $postparam = ""; 2234 $postparam .= pb_distro_get_param($ ddir,$dver,$darch,$osmindep);2222 $postparam .= pb_distro_get_param($pbos,$osmindep); 2235 2223 if ($postparam eq "") { 2236 2224 $addpkgs = ""; … … 2239 2227 } 2240 2228 my $command = pb_check_req("rpmbootstrap",0); 2241 pb_system("sudo $command $rbsopt $postinstall $addpkgs $ ddir-$dver-$darch $rbsverb","Creating the rpmbootstrap VE for $ddir-$dver ($darch)", "verbose");2229 pb_system("sudo $command $rbsopt $postinstall $addpkgs $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} $rbsverb","Creating the rpmbootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 2242 2230 } elsif ($verpmstyle eq "mock") { 2243 2231 my ($rbsconf) = pb_conf_get("rbsconf"); 2244 2232 my $command = pb_check_req("mock",0); 2245 pb_system("sudo $command --init --resultdir=\"/tmp\" --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v $rbsopt","Creating the mock VE for $ ddir-$dver ($darch)");2233 pb_system("sudo $command --init --resultdir=\"/tmp\" --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v $rbsopt","Creating the mock VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})"); 2246 2234 # Once setup we need to install some packages, the pb account, ... 2247 2235 pb_system("sudo $command --install --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v su","Configuring the mock VE"); … … 2249 2237 die "Unknown verpmtype type $verpmstyle. Report to dev team"; 2250 2238 } 2251 } elsif ($ dtypeeq "deb") {2239 } elsif ($pbos->{'type'} eq "deb") { 2252 2240 my $vedebstyle = $vedebtype->{$ENV{'PBPROJ'}}; 2253 2241 2254 my $codename = pb_distro_get_param($ ddir,$dver,$darch,$oscodename);2242 my $codename = pb_distro_get_param($pbos,$oscodename); 2255 2243 my $postparam = ""; 2256 2244 my $addpkgs; 2257 $postparam .= pb_distro_get_param($ ddir,$dver,$darch,$osmindep);2245 $postparam .= pb_distro_get_param($pbos,$osmindep); 2258 2246 if ($postparam eq "") { 2259 2247 $addpkgs = ""; … … 2262 2250 } 2263 2251 my $debmir = ""; 2264 $debmir .= pb_distro_get_param($ ddir,$dver,$darch,$rbsmirrorsrv);2252 $debmir .= pb_distro_get_param($pbos,$rbsmirrorsrv); 2265 2253 2266 2254 # Get potential rbs option … … 2277 2265 2278 2266 # debootstrap works with amd64 not x86_64 2279 my $debarch = $ darch;2280 $debarch = "amd64" if ($ darcheq "x86_64");2267 my $debarch = $pbos->{'arch'}; 2268 $debarch = "amd64" if ($pbos->{'arch'} eq "x86_64"); 2281 2269 if ($vedebstyle eq "debootstrap") { 2282 2270 my $dbsverb = ""; … … 2284 2272 2285 2273 # Some perl modules are in Universe on Ubuntu 2286 $rbsopt .= " --components=main,universe" if ($ ddireq "ubuntu");2287 2288 pb_system("sudo /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch\" $debmir","Creating the debootstrap VE for $ddir-$dver ($darch)", "verbose");2274 $rbsopt .= " --components=main,universe" if ($pbos->{'name'} eq "ubuntu"); 2275 2276 pb_system("sudo /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" $debmir","Creating the debootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 2289 2277 # debootstrap doesn't create an /etc/hosts file 2290 if (! -f "$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch/etc/hosts" ) {2291 pb_system("sudo cp /etc/hosts $vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch/etc/hosts");2278 if (! -f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts" ) { 2279 pb_system("sudo cp /etc/hosts $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts"); 2292 2280 } 2293 2281 } else { 2294 2282 die "Unknown vedebtype type $vedebstyle. Report to dev team"; 2295 2283 } 2296 } elsif ($ dtypeeq "ebuild") {2284 } elsif ($pbos->{'type'} eq "ebuild") { 2297 2285 die "Please teach the dev team how to build gentoo chroot"; 2298 2286 } else { 2299 die "Unknown distribution type $ dtype. Report to dev team";2287 die "Unknown distribution type $pbos->{'type'}. Report to dev team"; 2300 2288 } 2301 2289 } 2302 2290 # Fix modes to allow access to the VE for pb user 2303 pb_system("sudo chmod 755 $vepath->{$ENV{'PBPROJ'}}/$ ddir $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch","Fixing permissions");2291 pb_system("sudo chmod 755 $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}","Fixing permissions"); 2304 2292 2305 2293 # Test if an existing snapshot exists and use it if appropriate 2306 2294 # And also use it of no local extracted VE is present 2307 if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ ddir-$dver-$darch.tar.gz") &&2295 if ((-f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 2308 2296 (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) || 2309 2297 ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i)) || 2310 2298 ($pbsnap eq 1) || 2311 (! -d "$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch"))) {2312 pb_system("sudo rm -rf $vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch ; sudo mkdir -p $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch ; sudo tar xz -C $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Extracting snapshot of $ddir-$dver-$darch.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch");2299 (! -d "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"))) { 2300 pb_system("sudo rm -rf $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; sudo mkdir -p $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; sudo tar xz -C $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Extracting snapshot of $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 2313 2301 } 2314 2302 # Nothing more to do for VE. No real launch … … 2319 2307 # RM here 2320 2308 # Get distro context 2321 my ($name,$ver,$darch) = split(/-/,$v); 2322 chomp($darch); 2323 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 2309 my $pbos = pb_distro_get_context($v); 2324 2310 2325 2311 # Get RM context … … 2679 2665 2680 2666 # Get distro context 2681 my ($name,$ver,$darch) = split(/-/,$v); 2682 chomp($darch); 2683 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch); 2667 my $pbos = pb_distro_get_context($v); 2684 2668 2685 2669 # Name of the account to deal with for VM/VE/RM … … 2800 2784 my $home = "/home"; 2801 2785 # Solaris doesn't like that we use /home 2802 $home = "/export/home" if ($ dtypeeq "pkg");2786 $home = "/export/home" if ($pbos->{'type'} eq "pkg"); 2803 2787 2804 2788 print SCRIPT << "EOF"; … … 2883 2867 # pb has to be added to portage group on gentoo 2884 2868 2885 # We need to have that pb_distro_ init function2869 # We need to have that pb_distro_get_context function 2886 2870 # Get it from Project-Builder::Distribution 2887 2871 # And we now need the conf file required for this to work created above 2888 2872 2889 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init();2890 print "distro tuple: ". join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n";2873 my $pbos = pb_distro_get_context(); 2874 print "distro tuple: ".Dumper($pbos)."\n"; 2891 2875 2892 2876 # Adapt sudoers 2893 2877 # sudo is not default on Solaris and needs to be installed first 2894 2878 # from http://www.sunfreeware.com/programlistsparc10.html#sudo 2895 if ($ dtypeeq "pkg") {2879 if ($pbos->{'type'} eq "pkg") { 2896 2880 $file="/usr/local/etc/sudoers"; 2897 2881 } else { … … 2940 2924 2941 2925 # Suse wants sudoers as 640 2942 if ((($ ddir eq "sles") && (($dver =~ /10/) || ($dver =~ /9/))) || (($ddir eq "opensuse") && ($dver=~ /10.[012]/))) {2926 if ((($pbos->{'name'} eq "sles") && (($pbos->{'version'} =~ /10/) || ($pbos->{'version'} =~ /9/))) || (($pbos->{'name'} eq "opensuse") && ($pbos->{'version'} =~ /10.[012]/))) { 2943 2927 chmod 0640,$file; 2944 2928 } 2945 2929 2946 2930 # First install all required packages 2947 pb_system("yum clean all","Cleaning yum env") if (($ ddir eq "fedora") || ($ddir eq "asianux") || ($ddireq "rhel"));2931 pb_system("yum clean all","Cleaning yum env") if (($pbos->{'name'} eq "fedora") || ($pbos->{'name'} eq "asianux") || ($pbos->{'name'} eq "rhel")); 2948 2932 my ($ospkgdep) = pb_conf_get_if("ospkgdep"); 2949 2933 2950 my $pkgdep = pb_distro_get_param($ddir,$dver,$darch,$ospkgdep,$dfam,$dtype,$dos); 2951 pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgdep)))); 2952 2953 EOF 2954 my ($instype) = pb_conf_get("pbinstalltype"); 2955 my $itype = pb_distro_get_param($ddir,$dver,$darch,$instype,$dfam,$dtype,$dos); 2934 my $pkgdep = pb_distro_get_param($pbos,$ospkgdep); 2935 pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep)))); 2936 2937 EOF 2938 my $itype = pb_distro_get_param($pbos,pb_conf_get("pbinstalltype")); 2956 2939 # Install from sandbox mean a file base install 2957 2940 $itype = "file" if (defined $sbx); … … 2973 2956 if ($vtype eq "ve") { 2974 2957 my ($vepath) = pb_conf_get("vepath"); 2975 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch/tmp");2976 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch/tmp");2958 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp"); 2959 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp"); 2977 2960 } else { 2978 2961 pb_system("scp -i $keyfile -p -o UserKnownHostsFile=/dev/null -P $nport $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz root\@$vmhost->{$ENV{'PBPROJ'}}:/tmp","Copying local project files to $vtype."); … … 2986 2969 my ($osperldep,$osperlver) = pb_conf_get_if("osperldep","osperlver"); 2987 2970 2988 my $perldep = pb_distro_get_param($ ddir,$dver,$darch,$osperldep,$dfam,$dtype,$dos);2971 my $perldep = pb_distro_get_param($pbos,$osperldep); 2989 2972 foreach my $m (split(/,/,$perldep)) { 2990 2973 # Skip empty deps … … 3002 2985 # pkg based install. We need to point to the project-builder.org repository 3003 2986 print SCRIPT << 'EOF'; 3004 my ($ospkg) = pb_conf_get_if("ospkg"); 3005 3006 my $pkgforpb = pb_distro_get_param($ddir,$dver,$darch,$ospkg,$dfam,$dtype,$dos); 3007 pb_distro_setuposrepo($ddir,$dver,$darch,$dtype,$dfam,$dos); 3008 pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgforpb)))); 2987 my $pkgforpb = pb_distro_get_param($pbos,pb_conf_get_if("ospkg")); 2988 pb_distro_setuposrepo($pbos); 2989 pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb)))); 3009 2990 EOF 3010 2991 } else { … … 3024 3005 3025 3006 my $nf="/etc/sysconfig/network"; 3026 if ((! -f $nf) && ($ dtypeeq "rpm")) {3007 if ((! -f $nf) && ($pbos->{'type'} eq "rpm")) { 3027 3008 open(NF,"> $nf") || die "Unable to create $nf"; 3028 3009 print NF "NETWORKING=yes\n"; … … 3034 3015 } 3035 3016 3036 # Adds pb_distro_ init and all functions needed from ProjectBuilder::Distribution, Conf and Base3017 # Adds pb_distro_get_context and all functions needed from ProjectBuilder::Distribution, Conf and Base 3037 3018 foreach my $d (@INC) { 3038 3019 my @f = ("$d/ProjectBuilder/Base.pm","$d/ProjectBuilder/Distribution.pm","$d/ProjectBuilder/Conf.pm"); … … 3093 3074 if ($vtype eq "ve") { 3094 3075 # Get distro context 3095 my ($name,$ver,$darch) = split(/-/,$v); 3096 chomp($darch); 3097 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 3076 my $pbos = pb_distro_get_context($v); 3098 3077 my ($vepath) = pb_conf_get("vepath"); 3099 3078 3100 3079 # Test if an existing snapshot exists and remove it if there is a VE 3101 if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ ddir-$dver-$darch.tar.gz") &&3102 (! -d "$vepath->{$ENV{'PBPROJ'}}/$ ddir/$dver/$darch")) {3103 pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$ ddir-$dver-$darch.tar.gz","Removing previous snapshot $ddir-$dver-$darch.tar.gz");3080 if ((-f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 3081 (! -d "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}")) { 3082 pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Removing previous snapshot $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz"); 3104 3083 } 3105 3084 } … … 3135 3114 foreach my $v (@$vm) { 3136 3115 # Get distro context 3137 my ($name,$ver,$darch) = split(/-/,$v); 3138 chomp($darch); 3139 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch); 3116 my $pbos = pb_distro_get_context($v); 3140 3117 3141 3118 # Prepare the script to be executed on the VM/VE/RM … … 3151 3128 print SCRIPT "sudo mount -t proc /proc /proc\n"; 3152 3129 } 3153 print SCRIPT "$pb upd\n";3130 print SCRIPT "$pbos->{'update'}\n"; 3154 3131 if ($vtype eq "ve") { 3155 3132 print SCRIPT "sudo umount /proc\n"; … … 3208 3185 open(OUT,"> $ENV{'PBTMP'}/$pbpkg.ann") || die "Unable to create $ENV{'PBTMP'}/$pbpkg.ann: $!"; 3209 3186 my %pb; 3210 $pb{'dtype'} = "announce";3211 3187 $pb{'realpkg'} = $pbpkg; 3212 3188 $pb{'ver'} = $pbver; 3213 3189 $pb{'tag'} = $pbtag; 3214 $pb{'suf'} = "N/A"; # Should not be empty even if unused3215 3190 $pb{'date'} = $pbdate; 3216 3191 $pb{'chglog'} = $chglog; … … 3538 3513 my $sdir = shift; 3539 3514 my $sources = shift; 3540 my $dtype = shift; 3541 my $dfam = shift; 3542 my $ddir = shift; 3543 my $dver = shift; 3544 my $arch = shift; 3515 my $pbos = shift; 3545 3516 my $extdir = shift; 3546 3517 … … 3548 3519 # This function works for both patches and additional sources 3549 3520 foreach my $p (sort(<$sdir/*>)) { 3550 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.all$/));3551 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.all$/);3552 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dtype$/));3553 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dtype$/);3554 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dfam$/));3555 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dfam$/);3556 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir$/));3557 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir$/);3558 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver$/));3559 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver$/);3560 $sources->{"$ ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver-$arch$/));3561 $sources->{"$ ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver-$arch$/);3521 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.all$/)); 3522 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.all$/); 3523 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'type'}$/)); 3524 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'type'}$/); 3525 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'family'}$/)); 3526 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'family'}$/); 3527 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}$/)); 3528 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}$/); 3529 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/)); 3530 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/); 3531 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/)); 3532 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/); 3562 3533 } 3563 3534 3564 3535 # Prepare also remote sources to be included - Applied after the local ones 3565 foreach my $p ("all","$ dtype","$dfam","$ddir","$ddir-$dver","$ddir-$dver-$arch") {3536 foreach my $p ("all","$pbos->{'type'}","$pbos->{'family'}","$pbos->{'name'}","$pbos->{'name'}-$pbos->{'version'}","$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}") { 3566 3537 my $f = "$extdir.".".$p"; 3567 3538 next if (not -f $f); … … 3572 3543 while (<PATCH>) { 3573 3544 chomp(); 3574 $sources->{"$ ddir-$dver-$arch"} .= "," if (defined $sources->{"$ddir-$dver-$arch"});3575 $sources->{"$ ddir-$dver-$arch"} .= "$_";3545 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if (defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}); 3546 $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "$_"; 3576 3547 } 3577 3548 close(PATCH); … … 3600 3571 sub pb_get_postinstall { 3601 3572 3602 my $ddir = shift; 3603 my $dver = shift; 3604 my $darch = shift; 3573 my $pbos = shift; 3605 3574 my $rbspi = shift; 3606 3575 my $vestyle = shift; … … 3614 3583 } 3615 3584 3616 my $postparam = pb_distro_get_param($ ddir,$dver,$darch,$rbspi);3585 my $postparam = pb_distro_get_param($pbos,$rbspi); 3617 3586 if ($postparam eq "") { 3618 3587 $post = ""; -
devel/pb/lib/ProjectBuilder/Filter.pm
r1156 r1177 53 53 54 54 The first parameter is the package name. 55 The second parameter is the distribution type. 56 The third parameter is the distribution family. 57 The fourth parameter is the distribution name. 58 The fifth parameter is the distribution version. 55 The second parameter is OS hash 59 56 60 57 The function returns a pointer on a hash of filters. … … 68 65 my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3); 69 66 my $pbpkg = shift || die "No package specified"; 70 my $dtype = shift || ""; 71 my $dfam = shift || ""; 72 my $ddir = shift || ""; 73 my $dver = shift || ""; 67 my $pbos = shift; 74 68 my $ptr = undef; # returned value pointer on the hash of filters 75 69 my %h; … … 78 72 if (-d "$ENV{'PBROOTDIR'}/pbfilter") { 79 73 $mfile00 = "$ENV{'PBROOTDIR'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/all.pbf"); 80 $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$dtype.pbf"); 81 $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$dfam.pbf"); 82 $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$ddir.pbf"); 83 $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$ddir-$dver.pbf"); 74 if (defined $pbos) { 75 $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf")); 76 $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf")); 77 $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf")); 78 $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 79 } 84 80 85 81 push @ffiles,$mfile00 if (defined $mfile00); … … 92 88 if (-d "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter") { 93 89 $ffile00 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf"); 94 $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dtype.pbf"); 95 $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dfam.pbf"); 96 $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir.pbf"); 97 $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir-$dver.pbf"); 98 90 if (defined $pbos) { 91 $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf")); 92 $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf")); 93 $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf")); 94 $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 95 } 99 96 push @ffiles,$ffile00 if (defined $ffile00); 100 97 push @ffiles,$ffile0 if (defined $ffile0);
Note:
See TracChangeset
for help on using the changeset viewer.