Changeset 1177 in ProjectBuilder
- Timestamp:
- Feb 7, 2011, 2:24:17 PM (14 years ago)
- Location:
- devel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/bin/pbdistrocheck
r1156 r1177 118 118 119 119 my $dist = shift @ARGV || undef ; 120 my @param = undef; 121 @param = split(/-/,$dist) if (defined $dist); 122 123 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init(@param); 120 my $pbos = pb_distro_get_context($dist); 124 121 my $sep = "\n"; 125 122 if (defined $opts{'l'}) { … … 137 134 $sep = "," if (defined $opts{'s'}); 138 135 if (not defined $opts{'s'}) { 139 $ dos = "OS:\t$dos";140 $ ddir = "Name:\t$ddir";141 $ dver = "Ver:\t$dver";142 $ dfam = "Family:\t$dfam";143 $ dtype = "Type:\t$dtype";144 $pb suf = "Suffix:\t$pbsuf";145 $pb upd = "Update:\t$pbupd";146 $pb ins = "Install:\t$pbins";147 $ arch = "Arch:\t$arch";136 $pbos->{'os'} = "OS:\t$pbos->{'os'}"; 137 $pbos->{'name'} = "Name:\t$pbos->{'name'}"; 138 $pbos->{'version'} = "Ver:\t$pbos->{'version'}"; 139 $pbos->{'family'} = "Family:\t$pbos->{'family'}"; 140 $pbos->{'type'} = "Type:\t$pbos->{'type'}"; 141 $pbos->{'suffix'} = "Suffix:\t$pbos->{'suffix'}"; 142 $pbos->{'update'} = "Update:\t$pbos->{'update'}"; 143 $pbos->{'install'} = "Install:\t$pbos->{'install'}"; 144 $pbos->{'arch'} = "Arch:\t$pbos->{'arch'}"; 148 145 print "Project-Builder tuple:\n"; 149 146 } 150 print join($sep,($ dos, $ddir, $dver, $arch, $dtype, $dfam, $pbsuf, $pbupd, $pbins))."\n";147 print join($sep,($pbos->{'os'}, $pbos->{'name'}, $pbos->{'version'}, $pbos->{'arch'}, $pbos->{'type'}, $pbos->{'family'}, $pbos->{'suffix'}, $pbos->{'update'}, $pbos->{'install'}))."\n"; 151 148 } -
devel/pb-modules/etc/pb.conf
r1176 r1177 146 146 # Ganularity is the following: 147 147 # 148 #os name149 # ostype 150 # osfamily 151 # os 152 # os -ver153 # os -ver-arch148 #os (linux) 149 # ostype (rpm) 150 # osfamily (md) 151 # osname (mandriva) 152 # osname-ver 153 # osname-ver-arch 154 154 155 155 # Group OS by family to handle common actions more easily (filtering, install command, ...) … … 176 176 177 177 # Group family by build types 178 # Key is osfamily, Value is buildtype178 # Key is osfamily, Value is ostype 179 179 ostype du = deb 180 180 ostype slack = tgz -
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r1167 r1177 26 26 27 27 our @ISA = qw(Exporter); 28 our @EXPORT = qw(pb_distro_conffile pb_distro_ init pb_distro_get pb_distro_getlsb pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_setuposrepo pb_distro_get_param);28 our @EXPORT = qw(pb_distro_conffile pb_distro_get pb_distro_getlsb pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_setuposrepo pb_distro_get_param pb_distro_get_context); 29 29 ($VERSION,$REVISION) = pb_version_init(); 30 30 … … 46 46 # Return information on the running distro 47 47 # 48 my ($ddir, $dver, $dfam, $dtype, $pbsuf, $dos, $pbupd, $pbins, $arch) = pb_distro_init();49 print "distro tuple: ".Dumper($ ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch)."\n";48 my $pbos = pb_distro_get_context(); 49 print "distro tuple: ".Dumper($pbos->name, $pbos->ver, $pbos->fam, $pbos->type, $pbos->pbsuf, $pbos->pbupd, $pbos->pbins, $pbos->arch)."\n"; 50 50 # 51 51 # Return information on the requested distro 52 52 # 53 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init("ubuntu","7.10","x86_64");54 print "distro tuple: ".Dumper($ ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch)."\n";53 my $pbos = pb_distro_get_context("ubuntu-7.10-x86_64"); 54 print "distro tuple: ".Dumper($pbos->name, $pbos->ver, $pbos->fam, $pbos->type, $pbos->pbsuf, $pbos->pbupd, $pbos->pbins, $pbos->arch)."\n"; 55 55 # 56 56 # Return information on the running distro 57 57 # 58 58 my ($ddir,$dver) = pb_distro_get(); 59 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init($ddir,$dver);60 print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch)."\n";61 59 62 60 =head1 USAGE … … 78 76 =item B<pb_distro_init> 79 77 80 This function returns a list of 8 parameters indicating the distribution name, version, family, type of build system, suffix of packages, update command line, installation command line and architecture of the underlying Linux distribution. The value of the 8fields may be "unknown" in case the function was unable to recognize on which distribution it is running.78 This function returns a hash of parameters indicating the distribution name, version, family, type of build system, suffix of packages, update command line, installation command line and architecture of the underlying Linux distribution. The value of the fields may be "unknown" in case the function was unable to recognize on which distribution it is running. 81 79 82 80 As an example, Ubuntu and Debian are in the same "du" family. As well as RedHat, RHEL, CentOS, fedora are on the same "rh" family. 83 Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu a d Debian have the same "deb" type of build system.81 Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu and Debian have the same "deb" type of build system. 84 82 And "fc" is the extension generated for all Fedora packages (Version will be added by pb). 85 All th ese information arestored in an external configuration file typically at /etc/pb/pb.conf83 All this information is stored in an external configuration file typically at /etc/pb/pb.conf 86 84 87 85 When passing the distribution name and version as parameters, the B<pb_distro_init> function returns the parameter of that distribution instead of the underlying one. … … 95 93 sub pb_distro_init { 96 94 97 my $ddir = shift || undef; 98 my $dver = shift || undef; 99 my $dfam = "unknown"; 100 my $dtype = "unknown"; 101 my $dos = "unknown"; 102 my $dsuf = "unknown"; 103 my $dupd = "unknown"; 104 my $dins = "unknown"; 105 my $darch = shift || undef; 106 my $dnover = "false"; 107 my $drmdot = "false"; 95 my $pbos = { 96 'name' => undef, 97 'version' => undef, 98 'arch' => undef, 99 'family' => "unknown", 100 'suffix' => "unknown", 101 'update' => "unknown", 102 'install' => "unknown", 103 'type' => "unknown", 104 'os' => "unknown", 105 'nover' => "false", 106 'rmdot' => "false", 107 }; 108 $pbos->{'name'} = shift; 109 $pbos->{'version'} = shift; 110 $pbos->{'arch'} = shift; 108 111 109 112 # Adds conf file for distribution description … … 113 116 114 117 # If we don't know which distribution we're on, then guess it 115 ($ ddir,$dver) = pb_distro_get() if ((not defined $ddir) || (not defined $dver));118 ($pbos->{'name'},$pbos->{'version'}) = pb_distro_get() if ((not defined $pbos->{'name'}) || (not defined $pbos->{'version'})); 116 119 117 120 # For some rare cases, typically nover ones 118 $ ddir = "unknown" if (not defined $ddir);119 $ dver = "unknown" if (not defined $dver);121 $pbos->{'name'} = "unknown" if (not defined $pbos->{'name'}); 122 $pbos->{'version'} = "unknown" if (not defined $pbos->{'version'}); 120 123 121 124 # Initialize arch 122 $darch=pb_get_arch() if (not defined $darch); 123 124 my ($osfamily,$ostype,$osupd,$osins,$ossuffix,$osnover,$osremovedotinver,$os) = pb_conf_get("osfamily","ostype","osupd","osins","ossuffix","osnover","osremovedotinver","os"); 125 $pbos->{'arch'} = pb_get_arch() if (not defined $pbos->{'arch'}); 125 126 126 127 # Dig into the tuple to find the best answer 127 $dfam = pb_distro_get_param($ddir,$dver,$darch,$osfamily); 128 $dtype = pb_distro_get_param($ddir,$dver,$darch,$ostype,$dfam); 129 $dos = pb_distro_get_param($ddir,$dver,$darch,$os,$dfam,$dtype); 130 $dupd = pb_distro_get_param($ddir,$dver,$darch,$osupd,$dfam,$dtype,$dos); 131 $dins = pb_distro_get_param($ddir,$dver,$darch,$osins,$dfam,$dtype,$dos); 132 $dsuf = pb_distro_get_param($ddir,$dver,$darch,$ossuffix,$dfam,$dtype,$dos); 133 $dnover = pb_distro_get_param($ddir,$dver,$darch,$osnover,$dfam,$dtype,$dos); 134 $drmdot = pb_distro_get_param($ddir,$dver,$darch,$osremovedotinver,$dfam,$dtype,$dos); 128 # Do NOT factorize here, as it won't work as of now for hash creation 129 $pbos->{'family'} = pb_distro_get_param($pbos,pb_conf_get("osfamily")); 130 $pbos->{'type'} = pb_distro_get_param($pbos,pb_conf_get("ostype")); 131 ($pbos->{'os'},$pbos->{'install'},$pbos->{'suffix'},$pbos->{'nover'},$pbos->{'rmdot'},$pbos->{'update'}) = pb_distro_get_param($pbos,pb_conf_get("os","osins","ossuffix","osnover","osremovedotinver","osupd")); 132 #($pbos->{'family'},$pbos->{'type'},$pbos->{'os'},$pbos->{'install'},$pbos->{'suffix'},$pbos->{'nover'},$pbos->{'rmdot'},$pbos->{'update'}) = pb_distro_get_param($pbos,pb_conf_get("osfamily","ostype","os","osins","ossuffix","osnover","osremovedotinver","osupd")); 135 133 136 134 # Some OS have no interesting version 137 $ dver = "nover" if ($dnover eq "true");135 $pbos->{'version'} = "nover" if ((defined $pbos->{'nover'}) && ($pbos->{'nover'} eq "true")); 138 136 139 137 # For some OS remove the . in version name for extension 140 my $dver2 = $ dver;141 $dver2 =~ s/\.//g if ( $drmdot eq "true");142 143 if ((not defined $ dsuf) || ($dsufeq "")) {144 # By default suffix is a concatenation of .ddir and dver145 $ dsuf = ".$ddir$dver2"138 my $dver2 = $pbos->{'version'}; 139 $dver2 =~ s/\.//g if ((defined $pbos->{'rmdot'}) && ($pbos->{'rmdot'} eq "true")); 140 141 if ((not defined $pbos->{'suffix'}) || ($pbos->{'suffix'} eq "")) { 142 # By default suffix is a concatenation of name and version 143 $pbos->{'suffix'} = ".$pbos->{'name'}$dver2" 146 144 } else { 147 145 # concat just the version to what has been found 148 $ dsuf = ".$dsuf$dver2";146 $pbos->{'suffix'} = ".$pbos->{'suffix'}$dver2"; 149 147 } 150 148 … … 152 150 # $opt="--exclude=*.i?86"; 153 151 # } 154 pb_log(2,"DEBUG: pb_distro_init: $ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $dins, $darch\n");155 156 return($ ddir, $dver, $dfam, $dtype, $dos, $dsuf, $dupd, $dins, $darch);152 pb_log(2,"DEBUG: pb_distro_init: ".Dumper($pbos)."\n"); 153 154 return($pbos); 157 155 } 158 156 … … 276 274 $l =~ s/LSB_VERSION=/LSB Version:\t/; 277 275 } 278 $c =~ s/^[A-z ]*:[\t ]*// if (defined $s); 279 $r =~ s/^[A-z ]*:[\t ]*// if (defined $s); 280 $d =~ s/^[A-z ]*:[\t ]*// if (defined $s); 281 $i =~ s/^[A-z ]*:[\t ]*// if (defined $s); 282 $l =~ s/^[A-z ]*:[\t ]*// if (defined $s); 276 my $regexp = "^[A-z ]*:[\t ]*"; 277 $c =~ s/$regexp// if (defined $s); 278 $r =~ s/$regexp// if (defined $s); 279 $d =~ s/$regexp// if (defined $s); 280 $i =~ s/$regexp// if (defined $s); 281 $l =~ s/$regexp// if (defined $s); 283 282 return($l, $i, $d, $r, $c); 284 283 } else { … … 290 289 =item B<pb_distro_installdeps> 291 290 292 This function install the dependencies required to build the package on a n RPM based distro293 dependencies can be passed as a parameter in which case they are not computed291 This function install the dependencies required to build the package on a distro. 292 Dependencies can be passed as a parameter in which case they are not computed 294 293 295 294 =cut … … 299 298 # SPEC file 300 299 my $f = shift || undef; 301 my $dtype = shift || undef; 302 my $dupd = shift || undef; 300 my $pbos = shift; 303 301 my $deps = shift || undef; 304 302 305 303 # Protection 306 return if (not defined $ dupd);307 308 # Get depende cies in the build file if not forced309 $deps = pb_distro_getdeps($f, $ dtype) if (not defined $deps);304 return if (not defined $pbos->{'update'}); 305 306 # Get dependencies in the build file if not forced 307 $deps = pb_distro_getdeps($f, $pbos) if (not defined $deps); 310 308 pb_log(2,"deps: $deps\n"); 311 309 return if ((not defined $deps) || ($deps =~ /^\s*$/)); 312 310 if ($deps !~ /^[ ]*$/) { 313 311 # This may not be // proof. We should test for availability of repo and sleep if not 314 pb_system("$ dupd$deps","Installing dependencies ($deps)");312 pb_system("$pbos->{'update'} $deps","Installing dependencies ($deps)"); 315 313 } 316 314 } … … 325 323 326 324 my $f = shift || undef; 327 my $ dtype = shift || undef;325 my $pbos = shift; 328 326 329 327 my $regexp = ""; … … 332 330 333 331 # Protection 334 return("") if (not defined $ dtype);332 return("") if (not defined $pbos->{'type'}); 335 333 return("") if (not defined $f); 336 334 337 pb_log(3,"entering pb_distro_getdeps: $ dtype- $f\n");338 if ($ dtypeeq "rpm") {335 pb_log(3,"entering pb_distro_getdeps: $pbos->{'type'} - $f\n"); 336 if ($pbos->{'type'} eq "rpm") { 339 337 # In RPM this could include files, but we do not handle them atm. 340 338 $regexp = '^BuildRequires:(.*)$'; 341 } elsif ($ dtypeeq "deb") {339 } elsif ($pbos->{'type'} eq "deb") { 342 340 $regexp = '^Build-Depends:(.*)$'; 343 } elsif ($ dtypeeq "ebuild") {341 } elsif ($pbos->{'type'} eq "ebuild") { 344 342 $sep = '"'.$/; 345 343 $regexp = '^DEPEND="(.*)"\n' … … 377 375 $/ = $oldsep; 378 376 pb_log(2,"now deps: $deps\n"); 379 my $deps2 = pb_distro_only_deps_needed($ dtype,$deps);377 my $deps2 = pb_distro_only_deps_needed($pbos,$deps); 380 378 return($deps2); 381 379 } … … 390 388 sub pb_distro_only_deps_needed { 391 389 392 my $ dtype = shift || undef;390 my $pbos = shift; 393 391 my $deps = shift || undef; 394 392 … … 397 395 # Avoid to install what is already there 398 396 foreach my $p (split(/ /,$deps)) { 399 if ($ dtypeeq "rpm") {397 if ($pbos->{'type'} eq "rpm") { 400 398 my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet"); 401 399 next if ($res eq 0); 402 } elsif ($ dtypeeq "deb") {400 } elsif ($pbos->{'type'} eq "deb") { 403 401 my $res = pb_system("dpkg -L $p","","quiet"); 404 402 next if ($res eq 0); 405 } elsif ($ dtypeeq "ebuild") {403 } elsif ($pbos->{'type'} eq "ebuild") { 406 404 } else { 407 405 # Not reached … … 424 422 sub pb_distro_setuposrepo { 425 423 426 my $ddir = shift || undef; 427 my $dver = shift; 428 my $darch = shift; 429 my $dtype = shift || undef; 430 my $dfam = shift || undef; 431 my $dos = shift || undef; 432 433 pb_distro_setuprepo_gen($ddir,$dver,$darch,$dtype,$dfam,$dos,pb_distro_conffile(),"osrepo"); 424 my $pbos = shift; 425 426 pb_distro_setuprepo_gen($pbos,pb_distro_conffile(),"osrepo"); 434 427 } 435 428 … … 442 435 sub pb_distro_setuprepo { 443 436 444 my $ddir = shift || undef; 445 my $dver = shift; 446 my $darch = shift; 447 my $dtype = shift || undef; 448 my $dfam = shift || undef; 449 my $dos = shift || undef; 450 451 pb_distro_setuprepo_gen($ddir,$dver,$darch,$dtype,$dfam,$dos,"$ENV{'PBDESTDIR'}/pbrc","addrepo"); 437 my $pbos = shift; 438 439 pb_distro_setuprepo_gen($pbos,"$ENV{'PBDESTDIR'}/pbrc","addrepo"); 452 440 } 453 441 … … 460 448 sub pb_distro_setuprepo_gen { 461 449 462 my $ddir = shift || undef; 463 my $dver = shift; 464 my $darch = shift; 465 my $dtype = shift || undef; 466 my $dfam = shift || undef; 467 my $dos = shift || undef; 450 my $pbos = shift; 468 451 my $pbconf = shift || undef; 469 452 my $pbkey = shift || undef; … … 474 457 return if (not defined $addrepo); 475 458 476 my $param = pb_distro_get_param($ ddir,$dver,$darch,$addrepo,$dfam,$dtype,$dos);459 my $param = pb_distro_get_param($pbos,$addrepo); 477 460 return if ($param eq ""); 478 461 … … 491 474 492 475 # The repo file can be a real file or a package 493 if ($ dtypeeq "rpm") {476 if ($pbos->{'type'} eq "rpm") { 494 477 if ($bn =~ /\.rpm$/) { 495 478 my $pn = $bn; … … 508 491 pb_log(0,"Unable to deal with repository file $i on rpm distro ! Please report to dev team\n"); 509 492 } 510 } elsif ($ dtypeeq "deb") {493 } elsif ($pbos->{'type'} eq "deb") { 511 494 if (($bn =~ /\.sources.list$/) && (not -f "/etc/apt/sources.list.d/$bn")) { 512 495 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository"); … … 530 513 sub pb_distro_get_param { 531 514 532 my $param = ""; 533 my $ddir = shift; 534 my $dver = shift; 535 my $darch = shift; 536 my $opt = shift; 537 my $dfam = shift || "unknown"; 538 my $dtype = shift || "unknown"; 539 my $dos = shift || "unknown"; 540 541 pb_log(2,"DEBUG: pb_distro_get_param on $ddir-$dver-$darch for ".Dumper($opt)."\n"); 542 if (defined $opt->{"$ddir-$dver-$darch"}) { 543 $param = $opt->{"$ddir-$dver-$darch"}; 544 } elsif (defined $opt->{"$ddir-$dver"}) { 545 $param = $opt->{"$ddir-$dver"}; 546 } elsif (defined $opt->{"$ddir"}) { 547 $param = $opt->{"$ddir"}; 548 } elsif (defined $opt->{$dfam}) { 549 $param = $opt->{$dfam}; 550 } elsif (defined $opt->{$dtype}) { 551 $param = $opt->{$dtype}; 552 } elsif (defined $opt->{$dos}) { 553 $param = $opt->{$dos}; 554 } elsif (defined $opt->{"default"}) { 555 $param = $opt->{"default"}; 515 my @param; 516 my $param; 517 my $pbos = shift; 518 519 pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n"); 520 foreach my $opt (@_) { 521 if (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) { 522 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}; 523 } elsif (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}"}) { 524 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}"}; 525 } elsif (defined $opt->{"$pbos->{'name'}"}) { 526 $param = $opt->{"$pbos->{'name'}"}; 527 } elsif (defined $opt->{$pbos->{'family'}}) { 528 $param = $opt->{$pbos->{'family'}}; 529 } elsif (defined $opt->{$pbos->{'type'}}) { 530 $param = $opt->{$pbos->{'type'}}; 531 } elsif (defined $opt->{$pbos->{'os'}}) { 532 $param = $opt->{$pbos->{'os'}}; 533 } elsif (defined $opt->{"default"}) { 534 $param = $opt->{"default"}; 535 } else { 536 $param = ""; 537 } 538 539 # Allow replacement of variables inside the parameter such as name, version, arch for rpmbootstrap 540 # but not shell variable which are backslashed 541 if ($param =~ /[^\\]\$/) { 542 pb_log(3,"Expanding variable on $param\n"); 543 eval { $param =~ s/(\$\w+)/$1/eeg }; 544 } 545 push @param,$param; 546 } 547 548 pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} returns ==".Dumper(@param)."==\n"); 549 550 # Return one param in scalar context, an array if not. 551 my $nb = @param; 552 if ($nb eq 1) { 553 return($param); 556 554 } else { 557 $param = ""; 558 } 559 560 # Allow replacement of variables inside the parameter such as ddir, dver, darch for rpmbootstrap 561 # but not shell variable which are backslashed 562 if ($param =~ /[^\\]\$/) { 563 pb_log(3,"Expanding variable on $param\n"); 564 eval { $param =~ s/(\$\w+)/$1/eeg }; 565 } 566 567 pb_log(2,"DEBUG: pb_distro_get_param on $ddir-$dver-$darch returns ==$param==\n"); 568 return($param); 569 570 } 571 555 return(@param); 556 } 557 } 558 559 =item B<pb_distro_get_context> 560 561 This function gets the OS context passed as parameter and return the corresponding distribution hash 562 563 =cut 564 565 566 sub pb_distro_get_context { 567 568 my $os = shift; 569 my $pbos; 570 571 if (defined $os) { 572 my ($name,$ver,$darch) = split(/-/,$os); 573 pb_log(0,"Bad format for $os") if ((not defined $name) || (not defined $ver) || (not defined $darch)) ; 574 chomp($darch); 575 $pbos = pb_distro_init($name,$ver,$darch); 576 } else { 577 $pbos = pb_distro_init(); 578 } 579 return($pbos); 580 } 572 581 573 582 =back -
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); -
devel/rpmbootstrap/bin/rpmbootstrap
r1128 r1177 164 164 165 165 GetOptions("help|?|h" => \$opts{'h'}, 166 167 168 169 170 171 172 173 174 175 176 166 "man|m" => \$opts{'man'}, 167 "verbose|v+" => \$opts{'v'}, 168 "quiet|q" => \$opts{'q'}, 169 "log-files|l=s" => \$opts{'l'}, 170 "script|s=s" => \$opts{'s'}, 171 "print-rpms|p" => \$opts{'p'}, 172 "download-only|d" => \$opts{'d'}, 173 "keep|k" => \$opts{'k'}, 174 "iso|i=s" => \$opts{'i'}, 175 "add|a=s" => \$opts{'a'}, 176 "version|V=s" => \$opts{'V'}, 177 177 ) || pb_syntax(-1,0); 178 178 … … 193 193 $pbLOG = \*pbLOG; 194 194 $pbdebug = 0 if ($pbdebug == -1); 195 195 } 196 196 pb_log_init($pbdebug, $pbLOG); 197 197 #pb_display_init("text",""); … … 214 214 # 215 215 pb_log(0,"Starting VE build for $ENV{'PBV'}\n"); 216 my ($name,$ver,$darch) = split(/-/,$ENV{'PBV'}); 217 chomp($darch); 218 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch); 216 my $pbos = pb_distro_get_context($ENV{'PBV'}); 219 217 220 218 # … … 233 231 if (not defined $vepath) { 234 232 my ($vestdpath) = pb_conf_get_if("vepath"); 235 $vepath = "$vestdpath->{'default'}/$ ddir/$dver/$darch";233 $vepath = "$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"; 236 234 } 237 235 … … 243 241 # Get the package list to download, store them in a cache directory 244 242 # 245 my ($rbsmindep,$rbsmirrorsrv) = pb_conf_get("rbsmindep","rbsmirrorsrv");246 243 my ($rbscachedir) = pb_conf_get_if("rbscachedir"); 247 my $pkgs = pb_distro_get_param($ddir,$dver,$darch,$rbsmindep); 248 my $mirror = pb_distro_get_param($ddir,$dver,$darch,$rbsmirrorsrv); 244 my ($pkgs,$mirror) = pb_distro_get_param($pbos->{'name'},$pbos->{'version'},$pbos->{'arch'},pb_conf_get("rbsmindep","rbsmirrorsrv")); 249 245 250 246 my $cachedir = "/var/cache/rpmbootstrap"; … … 252 248 253 249 # Point to the right subdir and create it if needed 254 $cachedir .= "/$ ddir-$dver-$darch";250 $cachedir .= "/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 255 251 pb_mkdir_p($cachedir) if (! -d $cachedir); 256 252 … … 266 262 if ($mirror =~ /i386/) { 267 263 # Some distro have an i586 or i686 mirror dir instead for i386 268 warn "Unable to download packages from $mirror for $ ddir-$dver-$darch.";264 warn "Unable to download packages from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}."; 269 265 $mirror =~ s|/i386/|/i586/|; 270 266 $response = $ua->get($mirror); 271 267 if (! $response->is_success) { 272 die "Unable to download packages from $mirror for $ ddir-$dver-$darch";268 die "Unable to download packages from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 273 269 } 274 270 } … … 279 275 my $repo = $mirror; 280 276 my $found = 0; 281 if ($pb ins=~ /yum/) {277 if ($pbos->{'install'} =~ /yum/) { 282 278 my $response1; 283 279 while ($found == 0) { … … 290 286 my ($scheme, $account, $host, $port, $path) = pb_get_uri($repo); 291 287 die "Unable to find the repodata structure of the mirror $mirror\nPlease check the URL or warn the dev team.\n" if ($path =~ /^[\/]+$/); 292 288 293 289 # / not reached, so looping 294 290 next; … … 302 298 303 299 # Manages architectures specificities 304 my $parch = $ darch;305 $parch = "i[3456]86" if ($ darcheq "i386");300 my $parch = $pbos->{'arch'}; 301 $parch = "i[3456]86" if ($pbos->{'arch'} eq "i386"); 306 302 307 303 # Get the list of packages and their URL in this hash … … 331 327 my $osupdname = ""; 332 328 333 if ($pb ins=~ /yum/) {329 if ($pbos->{'install'} =~ /yum/) { 334 330 $oscachedir = "$vepath/var/cache/yum/core/packages/"; 335 331 $osupdcachedir = "$vepath/var/cache/yum/updates-released/packages/"; 336 332 $osupdname = "YUM"; 337 333 # Recent Fedora release use a new yum cache dir 338 if (($ ddir eq "fedora") && ($dver> 8)) {339 $oscachedir = "$vepath/var/cache/yum/$ darch/$dver/fedora/packages";340 $osupdcachedir = "$vepath/var/cache/yum/$ darch/$dver/updates/packages";334 if (($pbos->{'name'} eq "fedora") && ($pbos->{'version'} > 8)) { 335 $oscachedir = "$vepath/var/cache/yum/$pbos->{'arch'}/$pbos->{'version'}/fedora/packages"; 336 $osupdcachedir = "$vepath/var/cache/yum/$pbos->{'arch'}/$pbos->{'version'}/updates/packages"; 341 337 $osupdcachedir = "$vepath/var/cache/yum/updates-released/packages/"; 342 338 } 343 } elsif ($pb ins=~ /zypper/) {344 $oscachedir = "$vepath/var/cache/zypp/packages/opensuse/suse/$ darch";339 } elsif ($pbos->{'install'} =~ /zypper/) { 340 $oscachedir = "$vepath/var/cache/zypp/packages/opensuse/suse/$pbos->{'arch'}"; 345 341 $osupdname = "Zypper"; 346 } elsif ($pb ins=~ /urpmi/) {342 } elsif ($pbos->{'install'} =~ /urpmi/) { 347 343 $oscachedir = "$vepath/var/cache/urpmi/rpms"; 348 344 $osupdname = "URPMI"; … … 373 369 pb_log(1,"Package $p1 already in cache\n"); 374 370 } 375 371 376 372 # End if download only 377 373 if ($opts{'d'}) { 378 374 next; 379 375 } 380 376 381 377 # 382 378 # Copy the cached .RPM files into the oscachedir directory, so that os doesn't need to download them again. 383 379 # 384 380 pb_log(1,"Link package into $oscachedir\n"); 385 386 381 copy("$cachedir/$p1",$oscachedir) if (defined $oscachedir); 382 symlink("$oscachedir/$p1","$osupdcachedir/p1") if (defined $osupdcachedir); 387 383 388 384 # And extract it to the finale dir 389 385 pb_system("cd $vepath ; rpm2cpio $cachedir/$p1 | cpio -ivdum","Extracting package $p1 into $vepath"); 390 386 391 387 # Remove cached package if not asked to keep 392 388 if (! $opts{'k'}) { 393 389 unlink("$cachedir/$p1"); 394 390 } 395 391 396 392 } 397 393 } else { … … 403 399 404 400 if ($warning ge 1) { 405 pb_log(0,"$warning WARNINGS found.\nMaybe you should review your package list for $ddir-$dver-$darch\nand remove$lwpkg\n");401 pb_log(0,"$warning WARNINGS found.\nMaybe you should review your package list for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\nand remove$lwpkg\n"); 406 402 } 407 403 … … 415 411 416 412 # yum needs that distro-release package be installed, so force it 417 if ($pbins =~ /yum/) { 413 if ($pbos->{'install'} =~ /yum/) { 414 my $ddir = $pbos->{'name'}; 418 415 foreach my $p1 (<$cachedir/($ddir|redhat)-release-*.rpm>) { 419 416 copy("$cachedir/$p1","$vepath/tmp"); … … 432 429 # BUGFIX: 433 430 # 434 if ((($ ddir eq "centos") || ($ddir eq "rhel")) && ($dvereq "5")) {431 if ((($pbos->{'name'} eq "centos") || ($pbos->{'name'} eq "rhel")) && ($pbos->{'version'} eq "5")) { 435 432 pb_log(1,"BUGFIX for centos-5\n"); 436 433 pb_mkdir_p("$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx"); … … 458 455 459 456 pb_log(1,"Adapting $osupdname repository entries\n"); 460 if ($pb ins=~ /yum/) {457 if ($pbos->{'install'} =~ /yum/) { 461 458 # 462 459 # Force the architecture for yum … … 468 465 # yum.conf as well 469 466 foreach my $i (<$vepath/etc/yum.repos.d/*>,"$vepath/etc/yum.conf") { 470 pb_system("sed -i -e 's/\$basearch/$ darch/g' $i","","quiet");471 pb_system("sed -i -e 's/\$releasever/$ dver/g' $i","","quiet");467 pb_system("sed -i -e 's/\$basearch/$pbos->{'arch'}/g' $i","","quiet"); 468 pb_system("sed -i -e 's/\$releasever/$pbos->{'version'}/g' $i","","quiet"); 472 469 pb_system("sed -i -e 's/^mirrorlist/#mirrorlist/' $i","","quiet"); 473 470 # rather use neutral separators here … … 475 472 } 476 473 $minipkglist = "ldconfig yum passwd vim-minimal dhclient authconfig"; 477 } elsif ($pb ins=~ /zypper/) {474 } elsif ($pbos->{'install'} =~ /zypper/) { 478 475 pb_mkdir_p("$vepath/etc/zypp/repos.d"); 479 open(REPO,"> $vepath/etc/zypp/repos.d/$ ddir-$dver") || die "Unable to create repo file";476 open(REPO,"> $vepath/etc/zypp/repos.d/$pbos->{'name'}-$pbos->{'version'}") || die "Unable to create repo file"; 480 477 my $baseurl = dirname(dirname($mirror)); 481 478 # Setup the repo 482 479 print REPO << 'EOF'; 483 480 [opensuse] 484 name=$ ddir-$dver481 name=$pbos->{'name'}-$pbos->{'version'} 485 482 baseurl=$baseurl 486 483 enabled=1 … … 491 488 $minipkglist = "zypper vim-minimal dhclient"; 492 489 # Bootstraping zypper 493 if ($ dvereq "10.2") {494 pb_system("chroot $vepath /bin/bash -c \"yes | /usr/bin/zypper sa $baseurl $ ddir-$dver\"","Bootstrapping Zypper");495 } 496 } elsif ($pb ins=~ /urpmi/) {490 if ($pbos->{'version'} eq "10.2") { 491 pb_system("chroot $vepath /bin/bash -c \"yes | /usr/bin/zypper sa $baseurl $pbos->{'name'}-$pbos->{'version'}\"","Bootstrapping Zypper"); 492 } 493 } elsif ($pbos->{'install'} =~ /urpmi/) { 497 494 # Setup the repo 498 495 my $baseurl = dirname(dirname(dirname($mirror))); … … 505 502 # No need for sudo here 506 503 # 507 $pb ins=~ s/sudo//g;508 pb_system("chroot $vepath /bin/bash -c \"$pb ins $minipkglist \"","Bootstrapping OS by running $pbins$minipkglist");504 $pbos->{'install'} =~ s/sudo//g; 505 pb_system("chroot $vepath /bin/bash -c \"$pbos->{'install'} $minipkglist \"","Bootstrapping OS by running $pbos->{'install'} $minipkglist"); 509 506 510 507 # … … 517 514 if (defined $opts{'a'}) { 518 515 $opts{'a'} =~ s/,/ /g; 519 pb_system("chroot $vepath /bin/bash -c \"$pb ins $opts{'a'} \"","Adding packages to OS by running $pbins$opts{'a'}");516 pb_system("chroot $vepath /bin/bash -c \"$pbos->{'install'} $opts{'a'} \"","Adding packages to OS by running $pbos->{'install'} $opts{'a'}"); 520 517 } 521 518 … … 524 521 # 525 522 pb_log(1,"Cleaning up\n"); 526 if ($pb ins=~ /yum/) {523 if ($pbos->{'install'} =~ /yum/) { 527 524 pb_system("chroot $vepath /usr/bin/yum clean all","Cleaning yum"); 528 525 }
Note:
See TracChangeset
for help on using the changeset viewer.