Changeset 1177


Ignore:
Timestamp:
Feb 7, 2011, 2:24:17 PM (9 years ago)
Author:
bruno
Message:

r4161@eelzbach2: bruno | 2011-02-06 21:07:30 +0100

  • Introduction of a new hash $pbos to manage all os related info through a single data structure. All functions reviewed accordingly. Externally transparent, hopefully, but much cleaner code as a consequence. VM/VE/RM remains to be tested.
Location:
devel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/bin/pbdistrocheck

    r1156 r1177  
    118118
    119119my $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);
     120my $pbos = pb_distro_get_context($dist);
    124121my $sep = "\n";
    125122if (defined $opts{'l'}) {
     
    137134    $sep = "," if (defined $opts{'s'});
    138135    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         $pbsuf = "Suffix:\t$pbsuf";
    145         $pbupd = "Update:\t$pbupd";
    146         $pbins = "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'}";
    148145        print "Project-Builder tuple:\n";
    149146    }
    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";
    151148}
  • devel/pb-modules/etc/pb.conf

    r1176 r1177  
    146146# Ganularity is the following:
    147147#
    148 #osname
    149 # ostype
    150 #   osfamily
    151 #     os
    152 #       os-ver
    153 #         os-ver-arch
     148#os (linux)
     149# ostype (rpm)
     150#   osfamily (md)
     151#     osname (mandriva)
     152#       osname-ver
     153#         osname-ver-arch
    154154
    155155# Group OS by family to handle common actions more easily (filtering, install command, ...)
     
    176176
    177177# Group family by build types
    178 # Key is osfamily, Value is build type
     178# Key is osfamily, Value is ostype
    179179ostype du = deb
    180180ostype slack = tgz
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1167 r1177  
    2626 
    2727our @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);
     28our @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);
    2929($VERSION,$REVISION) = pb_version_init();
    3030
     
    4646  # Return information on the running distro
    4747  #
    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";
    5050  #
    5151  # Return information on the requested distro
    5252  #
    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";
    5555  #
    5656  # Return information on the running distro
    5757  #
    5858  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";
    6159
    6260=head1 USAGE
     
    7876=item B<pb_distro_init>
    7977
    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 8 fields may be "unknown" in case the function was unable to recognize on which distribution it is running.
     78This 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.
    8179
    8280As 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 ad Debian have the same "deb" type of build system.
     81Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu and Debian have the same "deb" type of build system.
    8482And "fc" is the extension generated for all Fedora packages (Version will be added by pb).
    85 All these information are stored in an external configuration file typically at /etc/pb/pb.conf
     83All this information is stored in an external configuration file typically at /etc/pb/pb.conf
    8684
    8785When 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.
     
    9593sub pb_distro_init {
    9694
    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";
     95my $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;
    108111
    109112# Adds conf file for distribution description
     
    113116
    114117# 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'}));
    116119
    117120# 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'});
    120123
    121124# 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'});
    125126
    126127# 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"));
    135133
    136134# 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"));
    138136
    139137# 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) || ($dsuf eq "")) {
    144     # By default suffix is a concatenation of .ddir and dver
    145     $dsuf = ".$ddir$dver2"
     138my $dver2 = $pbos->{'version'};
     139$dver2 =~ s/\.//g if ((defined $pbos->{'rmdot'}) && ($pbos->{'rmdot'} eq "true"));
     140
     141if ((not defined $pbos->{'suffix'}) || ($pbos->{'suffix'} eq "")) {
     142    # By default suffix is a concatenation of name and version
     143    $pbos->{'suffix'} = ".$pbos->{'name'}$dver2"
    146144} else {
    147145    # concat just the version to what has been found
    148     $dsuf = ".$dsuf$dver2";
     146    $pbos->{'suffix'} = ".$pbos->{'suffix'}$dver2";
    149147}
    150148
     
    152150#   $opt="--exclude=*.i?86";
    153151#   }
    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);
     152pb_log(2,"DEBUG: pb_distro_init: ".Dumper($pbos)."\n");
     153
     154return($pbos);
    157155}
    158156
     
    276274        $l =~ s/LSB_VERSION=/LSB Version:\t/;
    277275    }
    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);
    283282    return($l, $i, $d, $r, $c);
    284283} else {
     
    290289=item B<pb_distro_installdeps>
    291290
    292 This function install the dependencies required to build the package on an RPM based distro
    293 dependencies can be passed as a parameter in which case they are not computed
     291This function install the dependencies required to build the package on a distro.
     292Dependencies can be passed as a parameter in which case they are not computed
    294293
    295294=cut
     
    299298# SPEC file
    300299my $f = shift || undef;
    301 my $dtype = shift || undef;
    302 my $dupd = shift || undef;
     300my $pbos = shift;
    303301my $deps = shift || undef;
    304302
    305303# Protection
    306 return if (not defined $dupd);
    307 
    308 # Get dependecies in the build file if not forced
    309 $deps = pb_distro_getdeps($f, $dtype) if (not defined $deps);
     304return 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);
    310308pb_log(2,"deps: $deps\n");
    311309return if ((not defined $deps) || ($deps =~ /^\s*$/));
    312310if ($deps !~ /^[    ]*$/) {
    313311    # 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)");
    315313    }
    316314}
     
    325323
    326324my $f = shift || undef;
    327 my $dtype = shift || undef;
     325my $pbos = shift;
    328326
    329327my $regexp = "";
     
    332330
    333331# Protection
    334 return("") if (not defined $dtype);
     332return("") if (not defined $pbos->{'type'});
    335333return("") if (not defined $f);
    336334
    337 pb_log(3,"entering pb_distro_getdeps: $dtype - $f\n");
    338 if ($dtype eq  "rpm") {
     335pb_log(3,"entering pb_distro_getdeps: $pbos->{'type'} - $f\n");
     336if ($pbos->{'type'} eq  "rpm") {
    339337    # In RPM this could include files, but we do not handle them atm.
    340338    $regexp = '^BuildRequires:(.*)$';
    341 } elsif ($dtype eq "deb") {
     339} elsif ($pbos->{'type'} eq "deb") {
    342340    $regexp = '^Build-Depends:(.*)$';
    343 } elsif ($dtype eq "ebuild") {
     341} elsif ($pbos->{'type'} eq "ebuild") {
    344342    $sep = '"'.$/;
    345343    $regexp = '^DEPEND="(.*)"\n'
     
    377375$/ = $oldsep;
    378376pb_log(2,"now deps: $deps\n");
    379 my $deps2 = pb_distro_only_deps_needed($dtype,$deps);
     377my $deps2 = pb_distro_only_deps_needed($pbos,$deps);
    380378return($deps2);
    381379}
     
    390388sub pb_distro_only_deps_needed {
    391389
    392 my $dtype = shift || undef;
     390my $pbos = shift;
    393391my $deps = shift || undef;
    394392
     
    397395# Avoid to install what is already there
    398396foreach my $p (split(/ /,$deps)) {
    399     if ($dtype eq  "rpm") {
     397    if ($pbos->{'type'} eq  "rpm") {
    400398        my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet");
    401399        next if ($res eq 0);
    402     } elsif ($dtype eq "deb") {
     400    } elsif ($pbos->{'type'} eq "deb") {
    403401        my $res = pb_system("dpkg -L $p","","quiet");
    404402        next if ($res eq 0);
    405     } elsif ($dtype eq "ebuild") {
     403    } elsif ($pbos->{'type'} eq "ebuild") {
    406404    } else {
    407405        # Not reached
     
    424422sub pb_distro_setuposrepo {
    425423
    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");
     424my $pbos = shift;
     425
     426pb_distro_setuprepo_gen($pbos,pb_distro_conffile(),"osrepo");
    434427}
    435428
     
    442435sub pb_distro_setuprepo {
    443436
    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");
     437my $pbos = shift;
     438
     439pb_distro_setuprepo_gen($pbos,"$ENV{'PBDESTDIR'}/pbrc","addrepo");
    452440}
    453441
     
    460448sub pb_distro_setuprepo_gen {
    461449
    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;
     450my $pbos = shift;
    468451my $pbconf = shift || undef;
    469452my $pbkey = shift || undef;
     
    474457return if (not defined $addrepo);
    475458
    476 my $param = pb_distro_get_param($ddir,$dver,$darch,$addrepo,$dfam,$dtype,$dos);
     459my $param = pb_distro_get_param($pbos,$addrepo);
    477460return if ($param eq "");
    478461
     
    491474
    492475    # The repo file can be a real file or a package
    493     if ($dtype eq "rpm") {
     476    if ($pbos->{'type'} eq "rpm") {
    494477        if ($bn =~ /\.rpm$/) {
    495478            my $pn = $bn;
     
    508491            pb_log(0,"Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
    509492        }
    510     } elsif ($dtype eq "deb") {
     493    } elsif ($pbos->{'type'} eq "deb") {
    511494        if (($bn =~ /\.sources.list$/) && (not -f "/etc/apt/sources.list.d/$bn")) {
    512495            pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository");
     
    530513sub pb_distro_get_param {
    531514
    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"};
     515my @param;
     516my $param;
     517my $pbos = shift;
     518
     519pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n");
     520foreach 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
     548pb_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.
     551my $nb = @param;
     552if ($nb eq 1) {
     553    return($param);
    556554} 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
     561This function gets the OS context passed as parameter and return the corresponding distribution hash
     562
     563=cut
     564
     565
     566sub pb_distro_get_context {
     567
     568my $os = shift;
     569my $pbos;
     570
     571if (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}
     579return($pbos);
     580}
    572581
    573582=back
  • devel/pb/bin/pb

    r1176 r1177  
    842842        # We want to at least build for the underlying distro
    843843        # 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'},";
    849846
    850847        # Get list of distributions for which we need to generate build files if no target
     
    869866        $pb{'pkg'} = $pbpkg;
    870867        $pb{'realpkg'} = $pbpkg;
     868        $pb{'suf'} = $pbos->{'suffix'};
    871869        $pb{'date'} = $pbdate;
    872870        $pb{'defpkgdir'} = $defpkgdir;
     
    895893            $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
    896894
    897             foreach my $d (keys %virt) {
     895            foreach my $v (keys %virt) {
    898896                $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);
    905900                pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n");
    906901   
    907902                # 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'});
    909904                $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);
    911906   
    912907                # Filter build files from the less precise up to the most with overloading
     
    917912                my %bfiles = ();
    918913                my %pkgfiles = ();
    919                 $build{"$ddir-$dver-$arch"} = "yes";
     914                $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "yes";
    920915   
    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);
    931926                } else {
    932                     $build{"$ddir-$dver-$arch"} = "no";
     927                    $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "no";
    933928                    next;
    934929                }
     
    936931   
    937932                # 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);
    939934   
    940935                # Apply now all the filters on all the files concerned
     
    942937                if (defined $ptr) {
    943938                    # For patch support
    944                     $pb{'tuple'} = "$ddir-$dver-$arch";
     939                    $pb{'tuple'} = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    945940                    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);
    947942                    }
    948943                }
    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");
    951946
    952947                $pm->finish if (defined $pbparallel);
     
    11021097sub pb_test2pkg {
    11031098    # 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();
    11061100
    11071101    # Get list of packages to test
     
    11111105
    11121106    # Additional potential repo
    1113     pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos);
     1107    pb_distro_setuprepo($pbos);
    11141108    foreach my $pbpkg (@pkgs) {
    11151109        # 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);
    11171111        pb_system("$ENV{'PBDESTDIR'}/pbtest","Launching test for $pbpkg","verbose");
    11181112    }
     
    11221116
    11231117    # 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();
    11261119
    11271120    # 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);
    11291122
    11301123    # Get list of packages to build
     
    11581151
    11591152        pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n");
    1160         if ($dtype eq "rpm") {
     1153        if ($pbos->{'type'} eq "rpm") {
    11611154            foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
    11621155                if (! -d "$ENV{'PBBUILDDIR'}/$d") {
     
    11691162            symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
    11701163            # 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");
    11721165
    11731166            # 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");
    11751168
    11761169            pb_log(2,"specfile: ".Dumper(\@specfile)."\n");
     
    11791172            # Older Redhat use _target_platform in %configure incorrectly
    11801173            my $specialdef = "";
    1181             if (($ddir eq "redhat") || (($ddir eq "rhel") && ($dver eq "2.1"))) {
     1174            if (($pbos->{'name'} eq "redhat") || (($pbos->{'name'} eq "rhel") && ($pbos->{'version'} eq "2.1"))) {
    11821175                $specialdef = "--define \'_target_platform \"\"\'";
    11831176            }
     
    11861179                if ($f =~ /\.spec$/) {
    11871180                    # This could cause an issue in // mode
    1188                     pb_distro_installdeps($f,$dtype,$pbins);
     1181                    pb_distro_installdeps($f,$pbos);
    11891182                    pb_system("rpmbuild $specialdef --define \"packager $ENV{'PBPACKAGER'}\" --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}","verbose");
    11901183                    last;
     
    12011194            close(LOG);
    12021195
    1203         } elsif ($dtype eq "deb") {
     1196        } elsif ($pbos->{'type'} eq "deb") {
    12041197            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}";
    12051198            pb_system("tar xfz $src","Extracting sources");
     
    12081201            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver";
    12091202            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'}";
    12111204            chmod 0755,"debian/rules";
    12121205
    1213             pb_distro_installdeps("debian/control",$dtype,$pbins);
     1206            pb_distro_installdeps("debian/control",$pbos);
    12141207            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose");
    12151208            # Get the name of the generated packages
     
    12231216            }
    12241217            close(LOG);
    1225         } elsif ($dtype eq "ebuild") {
     1218        } elsif ($pbos->{'type'} eq "ebuild") {
    12261219            my @ebuildfile;
    12271220            # For gentoo we need to take pb as subsystem name
     
    12331226
    12341227            # 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");
    12361229
    12371230            # Prepare the build env for gentoo
     
    12641257            foreach my $f (@ebuildfile) {
    12651258                if ($f =~ /\.ebuild$/) {
    1266                     pb_distro_installdeps($f,$dtype,$pbins);
     1259                    pb_distro_installdeps($f,$pbos);
    12671260                    move($f,"$tmpd/$pbpkg-$pbver.ebuild");
    12681261                    pb_system("cd $tmpd ; ebuild $pbpkg-$pbver.ebuild clean ; ebuild $pbpkg-$pbver.ebuild digest ; ebuild $pbpkg-$pbver.ebuild package","verbose");
     
    12821275            }
    12831276
    1284         } elsif ($dtype eq "tgz") {
     1277        } elsif ($pbos->{'type'} eq "tgz") {
    12851278            # Slackware family
    12861279            $made="$made $pbpkg/$pbpkg-$pbver-*-$pbtag.tgz";
     
    12901283            pb_system("tar xfz $src2","Extracting pbconf");
    12911284            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'}";
    12931286            if (-x "install/pbslack") {
    1294                 pb_distro_installdeps("./install/pbslack",$dtype,$pbins);
     1287                pb_distro_installdeps("./install/pbslack",$pbos);
    12951288                pb_system("./install/pbslack","Building software");
    12961289                pb_system("sudo /sbin/makepkg -p -l y -c y $pbpkg","Packaging $pbpkg","verbose");
    12971290            }
    1298         } elsif ($dtype eq "pkg") {
     1291        } elsif ($pbos->{'type'} eq "pkg") {
    12991292            # Solaris
    13001293            $made="$made $pbpkg-$pbver-$pbtag.pkg.gz";
     
    13031296            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}";
    13041297            # Will host resulting packages
    1305             pb_mkdir_p("$dtype");
     1298            pb_mkdir_p("$pbos->{'type'}");
    13061299            pb_mkdir_p("$pkgdestdir/delivery");
    13071300            pb_system("tar xfz $src","Extracting sources under $ENV{'PBBUILDDIR'}");
    13081301            pb_system("tar xfz $src2","Extracting pbconf under $ENV{'PBBUILDDIR'}");
    13091302            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";
    13121305                # 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");
    13141307                # 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");
    13161309                # 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)
    13191312                } else {
    13201313                    # No prototype provided, calculating it
    13211314                    open(PROTO,"> $pkgdestdir/prototype") || die "Unable to create prototype file";
    13221315                    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");
    13241317                    $ENV{'PBSOLDESTDIR'} = "$pkgdestdir/delivery";
    13251318                    find(\&create_solaris_prototype, "$pkgdestdir/delivery");
    13261319                }
    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");
    13311324                pb_system("cd $ENV{'PBBUILDDIR'} ;  gzip -9f $pbpkg-$pbver-$pbtag.pkg","Compressing $pbpkg-$pbver-$pbtag.pkg","verbose");
    13321325            } 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");
    13341327            }
    13351328            chdir ".." || die "Unable to chdir to parent dir";
    1336             pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$dtype $pkgdestdir", "Cleanup");
    1337         } elsif ($dtype eq "hpux") {
     1329            pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$pbos->{'type'} $pkgdestdir", "Cleanup");
     1330        } elsif ($pbos->{'type'} eq "hpux") {
    13381331            # HP-UX
    13391332            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}";
     
    13571350            pb_system("rm -rf $pbpkg-$pbver", "Cleanup");
    13581351        } else {
    1359             die "Unknown dtype format $dtype";
     1352            die "Unknown OS type format $pbos->{'type'}";
    13601353        }
    13611354        if (defined $pbparallel) {
     
    13751368
    13761369    # 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"));
    13801371
    13811372    # 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");
    13851379        }
    13861380        my $rpms ="";
     
    13921386        pb_log(0,"SRPM packages generated: $srpms\n");
    13931387        pb_log(0,"RPM packages generated: $rpms\n");
    1394     } elsif ($dtype eq "deb") {
     1388    } elsif ($pbos->{'type'} eq "deb") {
    13951389        my $made2 = "";
    13961390        foreach my $f (split(/ /,$made)) {
     
    14031397        }
    14041398    } else {
    1405         pb_log(0,"No check done for $dtype yet\n");
     1399        pb_log(0,"No check done for $pbos->{'type'} yet\n");
    14061400        pb_log(0,"Packages generated: $made\n");
    14071401    }
     
    14901484    my $cmd = "";
    14911485    my $src = "";
    1492     my ($odir,$over,$oarch) = (undef, undef, undef);
    1493     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch);
     1486    my $pbos;
    14941487
    14951488    if ($cmt ne "Announce") {
     
    14991492
    15001493        # 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);
    15061495
    15071496        # Get list of packages to build
     
    15711560    if ($cmt =~ /^RM/) {
    15721561        # 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);
    15741563    }
    15751564    pb_log(2,"ssh: ".Dumper(($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vepath,$rbsconf))."\n");
     
    16021591        $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}";
    16031592    } 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'}";
    16051594
    16061595        my $repodir = $tdir;
     
    16111600        # Repository management
    16121601        open(PBS,"> $ENV{'PBBUILDDIR'}/pbscript") || die "Unable to create $ENV{'PBBUILDDIR'}/pbscript";
    1613         if ($dtype eq "rpm") {
     1602        if ($pbos->{'type'} eq "rpm") {
    16141603            # Also make a pbscript to generate yum/urpmi bases
    16151604            print PBS << "EOF";
     
    16181607cat > $ENV{'PBPROJ'}.repo << EOT
    16191608[$ENV{'PBPROJ'}]
    1620 name=$ddir $dver $darch - $ENV{'PBPROJ'} Vanilla Packages
     1609name=$pbos->{'name'} $pbos->{'version'} $pbos->{'arch'} - $ENV{'PBPROJ'} Vanilla Packages
    16211610baseurl=$pbrepo->{$ENV{'PBPROJ'}}/$repodir
    16221611enabled=1
     
    16341623createrepo .
    16351624EOF
    1636             if ($dfam eq "md") {
     1625            if ($pbos->{'family'} eq "md") {
    16371626                # For Mandriva add urpmi management
    16381627                print PBS << "EOF";
     
    16521641EOF
    16531642            }
    1654             if ($ddir eq "fedora") {
     1643            if ($pbos->{'name'} eq "fedora") {
    16551644                # Extract the spec file to please Fedora maintainers :-(
    16561645                print PBS << "EOF";
     
    16631652EOF
    16641653            }
    1665             if ($dfam eq "novell") {
     1654            if ($pbos->{'family'} eq "novell") {
    16661655                # Add ymp scripts for one-click install on SuSE
    16671656                print PBS << "EOF";
     
    17121701EOF
    17131702            }
    1714         } elsif ($dtype eq "deb") {
     1703        } elsif ($pbos->{'type'} eq "deb") {
    17151704            # Also make a pbscript to generate apt bases
    17161705            # Cf: http://www.debian.org/doc/manuals/repository-howto/repository-howto.fr.html
     
    17231712# Prepare a script to ease apt setup
    17241713cat > $ENV{'PBPROJ'}.sources.list << EOT
    1725 deb $rpd $dver contrib
    1726 deb-src $rpd $dver contrib
     1714deb $rpd $pbos->{'version'} contrib
     1715deb-src $rpd $pbos->{'version'} contrib
    17271716EOT
    17281717chmod 644 $ENV{'PBPROJ'}.sources.list
     
    17301719# Up two levels to deal with the dist dir cross versions
    17311720cd ../..
    1732 mkdir -p dists/$dver/contrib/binary-$darch dists/$dver/contrib/source
     1721mkdir -p dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'} dists/$pbos->{'version'}/contrib/source
    17331722
    17341723# Prepare a script to create apt info file
     
    17421731EOT
    17431732
    1744 echo "Creating Packages metadata ($darch)"
    1745 dpkg-scanpackages -a$darch $dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/binary-$darch/Packages.gz
    1746 dpkg-scanpackages -a$darch $dver/$darch /dev/null | bzip2 -c9 > dists/$dver/contrib/binary-$darch/Packages.bz2
    1747 echo "Creating Contents metadata ($darch)"
    1748 apt-ftparchive contents $dver | gzip -c9 > dists/$dver/Contents-$darch.gz
    1749 echo "Creating Release metadata ($darch)"
    1750 cat \$TMPD/Release > dists/$dver/contrib/binary-$darch/Release
    1751 echo "Architecture: $darch" >> dists/$dver/contrib/binary-$darch/Release
     1733echo "Creating Packages metadata ($pbos->{'arch'})"
     1734dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.gz
     1735dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | bzip2 -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.bz2
     1736echo "Creating Contents metadata ($pbos->{'arch'})"
     1737apt-ftparchive contents $pbos->{'version'} | gzip -c9 > dists/$pbos->{'version'}/Contents-$pbos->{'arch'}.gz
     1738echo "Creating Release metadata ($pbos->{'arch'})"
     1739cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release
     1740echo "Architecture: $pbos->{'arch'}" >> dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release
    17521741echo "Creating Source metadata"
    1753 dpkg-scansources $dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/source/Sources.gz
    1754 cat \$TMPD/Release > dists/$dver/contrib/source/Release
    1755 echo "Architecture: Source" >> dists/$dver/contrib/source/Release
     1742dpkg-scansources $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/source/Sources.gz
     1743cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/source/Release
     1744echo "Architecture: Source" >> dists/$pbos->{'version'}/contrib/source/Release
    17561745echo "Creating Release metadata"
    1757 apt-ftparchive release dists/$dver > dists/$dver/Release
     1746apt-ftparchive release dists/$pbos->{'version'} > dists/$pbos->{'version'}/Release
    17581747rm -rf \$TMPD
    17591748EOF
    1760         } elsif ($dtype eq "ebuild") {
     1749        } elsif ($pbos->{'type'} eq "ebuild") {
    17611750            # make a pbscript to generate links to latest version
    17621751            print PBS << "EOF";
     
    17931782    # should use a hash instead...
    17941783    my ($shcmd,$cpcmd,$cptarget,$cp2target);
     1784    my ($odir,$over,$oarch);
    17951785    if ($cmt !~ /^VE/) {
    17961786        my $keyfile = pb_ssh_get(0);
     
    18841874                my $j = basename($p);
    18851875                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 (($dtype ne "rpm") || ($j !~ /.src.rpm$/));
     1876                $made="$made $odir/$over/$oarch/$j"; # if (($pbos->{'type'} ne "rpm") || ($j !~ /.src.rpm$/));
    18871877            }
    18881878            print KEEP "$made\n";
     
    18911881
    18921882            # Sign packages locally
    1893             if ($dtype eq "rpm") {
     1883            if ($pbos->{'type'} eq "rpm") {
    18941884                #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 ($dtype eq "deb") {
     1885            } elsif ($pbos->{'type'} eq "deb") {
    18961886                #pb_system("debsign $made","Signing DEB packages");
    18971887            } 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");
    18991889            }
    19001890
     
    19391929        my $hpath = "/sbin";
    19401930        # Solaris doesn't support -h and has halt elsewhere
    1941         if ($dtype eq "pkg") {
     1931        if ($pbos->{'type'} eq "pkg") {
    19421932            $hoption = "" ;
    19431933            $hpath = "/usr/sbin";
     
    21502140        # VE here
    21512141        # 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);
    21552143
    21562144        # Get VE context
     
    21662154        if (($vetype eq "chroot") || ($vetype eq "schroot")) {
    21672155            # Architecture consistency
    2168             if ($arch ne $darch) {
    2169                 die "Unable to launch a VE of architecture $darch on a $arch platform" if (($darch eq "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/));
    21702158            }
    21712159
     
    21752163
    21762164                # We have to rebuild the chroot
    2177                 if ($dtype eq "rpm") {
     2165                if ($pbos->{'type'} eq "rpm") {
    21782166
    21792167                    # Which tool is used
     
    21922180                    }
    21932181
    2194                     my $postinstall = pb_get_postinstall($ddir,$dver,$darch,$rbspi,$verpmstyle);
     2182                    my $postinstall = pb_get_postinstall($pbos,$rbspi,$verpmstyle);
    21952183                    if ($verpmstyle eq "rinse") {
    21962184                        # Need to reshape the mirrors generated with local before-post-install script
    21972185                        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);
    21992187                        if ($postparam eq "") {
    22002188                            $b4post = "";
     
    22062194                        my $addpkgs;
    22072195                        $postparam = "";
    2208                         $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep);
     2196                        $postparam .= pb_distro_get_param($pbos,$osmindep);
    22092197                        if ($postparam eq "") {
    22102198                            $addpkgs = "";
     
    22242212
    22252213                        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");
    22272215                    } elsif ($verpmstyle eq "rpmbootstrap") {
    22282216                        my $rbsverb = "";
     
    22322220                        my $addpkgs = "";
    22332221                        my $postparam = "";
    2234                         $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep);
     2222                        $postparam .= pb_distro_get_param($pbos,$osmindep);
    22352223                        if ($postparam eq "") {
    22362224                            $addpkgs = "";
     
    22392227                        }
    22402228                        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");
    22422230                    } elsif ($verpmstyle eq "mock") {
    22432231                        my ($rbsconf) = pb_conf_get("rbsconf");
    22442232                        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'})");
    22462234                        # Once setup we need to install some packages, the pb account, ...
    22472235                        pb_system("sudo $command --install --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v su","Configuring the mock VE");
     
    22492237                        die "Unknown verpmtype type $verpmstyle. Report to dev team";
    22502238                    }
    2251                 } elsif ($dtype eq "deb") {
     2239                } elsif ($pbos->{'type'} eq "deb") {
    22522240                    my $vedebstyle = $vedebtype->{$ENV{'PBPROJ'}};
    22532241
    2254                     my $codename = pb_distro_get_param($ddir,$dver,$darch,$oscodename);
     2242                    my $codename = pb_distro_get_param($pbos,$oscodename);
    22552243                    my $postparam = "";
    22562244                    my $addpkgs;
    2257                     $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep);
     2245                    $postparam .= pb_distro_get_param($pbos,$osmindep);
    22582246                    if ($postparam eq "") {
    22592247                        $addpkgs = "";
     
    22622250                    }
    22632251                    my $debmir = "";
    2264                     $debmir .= pb_distro_get_param($ddir,$dver,$darch,$rbsmirrorsrv);
     2252                    $debmir .= pb_distro_get_param($pbos,$rbsmirrorsrv);
    22652253
    22662254                    # Get potential rbs option
     
    22772265   
    22782266                    # debootstrap works with amd64 not x86_64
    2279                     my $debarch = $darch;
    2280                     $debarch = "amd64" if ($darch eq "x86_64");
     2267                    my $debarch = $pbos->{'arch'};
     2268                    $debarch = "amd64" if ($pbos->{'arch'} eq "x86_64");
    22812269                    if ($vedebstyle eq "debootstrap") {
    22822270                        my $dbsverb = "";
     
    22842272
    22852273                        # Some perl modules are in Universe on Ubuntu
    2286                         $rbsopt .= " --components=main,universe" if ($ddir eq "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");
    22892277                        # 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");
    22922280                        }
    22932281                    } else {
    22942282                        die "Unknown vedebtype type $vedebstyle. Report to dev team";
    22952283                    }
    2296                 } elsif ($dtype eq "ebuild") {
     2284                } elsif ($pbos->{'type'} eq "ebuild") {
    22972285                    die "Please teach the dev team how to build gentoo chroot";
    22982286                } else {
    2299                     die "Unknown distribution type $dtype. Report to dev team";
     2287                    die "Unknown distribution type $pbos->{'type'}. Report to dev team";
    23002288                }
    23012289            }
    23022290            # 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");
    23042292
    23052293            # Test if an existing snapshot exists and use it if appropriate
    23062294            # 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") &&
    23082296                (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) ||
    23092297                    ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i)) ||
    23102298                    ($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'}");
    23132301            }
    23142302            # Nothing more to do for VE. No real launch
     
    23192307        # RM here
    23202308        # 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);
    23242310
    23252311        # Get RM context
     
    26792665
    26802666    # 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);
    26842668   
    26852669    # Name of the account to deal with for VM/VE/RM
     
    28002784my $home = "/home";
    28012785# Solaris doesn't like that we use /home
    2802 $home = "/export/home" if ($dtype eq "pkg");
     2786$home = "/export/home" if ($pbos->{'type'} eq "pkg");
    28032787
    28042788    print SCRIPT << "EOF";
     
    28832867# pb has to be added to portage group on gentoo
    28842868
    2885 # We need to have that pb_distro_init function
     2869# We need to have that pb_distro_get_context function
    28862870# Get it from Project-Builder::Distribution
    28872871# And we now need the conf file required for this to work created above
    28882872
    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";
     2873my $pbos = pb_distro_get_context();
     2874print "distro tuple: ".Dumper($pbos)."\n";
    28912875
    28922876# Adapt sudoers
    28932877# sudo is not default on Solaris and needs to be installed first
    28942878# from http://www.sunfreeware.com/programlistsparc10.html#sudo
    2895 if ($dtype eq "pkg") {
     2879if ($pbos->{'type'} eq "pkg") {
    28962880    $file="/usr/local/etc/sudoers";
    28972881} else {
     
    29402924   
    29412925# Suse wants sudoers as 640
    2942 if ((($ddir eq "sles") && (($dver =~ /10/) || ($dver =~ /9/))) || (($ddir eq "opensuse") && ($dver =~ /10.[012]/))) {
     2926if ((($pbos->{'name'} eq "sles") && (($pbos->{'version'} =~ /10/) || ($pbos->{'version'} =~ /9/))) || (($pbos->{'name'} eq "opensuse") && ($pbos->{'version'} =~ /10.[012]/))) {
    29432927    chmod 0640,$file;
    29442928}
    29452929
    29462930# First install all required packages
    2947 pb_system("yum clean all","Cleaning yum env") if (($ddir eq "fedora") || ($ddir eq "asianux") || ($ddir eq "rhel"));
     2931pb_system("yum clean all","Cleaning yum env") if (($pbos->{'name'} eq "fedora") || ($pbos->{'name'} eq "asianux") || ($pbos->{'name'} eq "rhel"));
    29482932my ($ospkgdep) = pb_conf_get_if("ospkgdep");
    29492933   
    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);
     2934my $pkgdep = pb_distro_get_param($pbos,$ospkgdep);
     2935pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep))));
     2936
     2937EOF
     2938    my $itype = pb_distro_get_param($pbos,pb_conf_get("pbinstalltype"));
    29562939    # Install from sandbox mean a file base install
    29572940    $itype = "file" if (defined $sbx);
     
    29732956            if ($vtype eq "ve") {
    29742957                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");
    29772960            } else {
    29782961                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.");
     
    29862969my ($osperldep,$osperlver) = pb_conf_get_if("osperldep","osperlver");
    29872970   
    2988 my $perldep = pb_distro_get_param($ddir,$dver,$darch,$osperldep,$dfam,$dtype,$dos);
     2971my $perldep = pb_distro_get_param($pbos,$osperldep);
    29892972foreach my $m (split(/,/,$perldep)) {
    29902973    # Skip empty deps
     
    30022985        # pkg based install. We need to point to the project-builder.org repository
    30032986        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))));
     2987my $pkgforpb = pb_distro_get_param($pbos,pb_conf_get_if("ospkg"));
     2988pb_distro_setuposrepo($pbos);
     2989pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb))));
    30092990EOF
    30102991    } else {
     
    30243005
    30253006my $nf="/etc/sysconfig/network";
    3026 if ((! -f $nf) && ($dtype eq "rpm")) {
     3007if ((! -f $nf) && ($pbos->{'type'} eq "rpm")) {
    30273008    open(NF,"> $nf") || die "Unable to create $nf";
    30283009    print NF "NETWORKING=yes\n";
     
    30343015    }
    30353016
    3036     # Adds pb_distro_init and all functions needed from ProjectBuilder::Distribution, Conf and Base
     3017    # Adds pb_distro_get_context and all functions needed from ProjectBuilder::Distribution, Conf and Base
    30373018    foreach my $d (@INC) {
    30383019        my @f = ("$d/ProjectBuilder/Base.pm","$d/ProjectBuilder/Distribution.pm","$d/ProjectBuilder/Conf.pm");
     
    30933074    if ($vtype eq "ve") {
    30943075        # 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);
    30983077        my ($vepath) = pb_conf_get("vepath");
    30993078
    31003079        # 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");
    31043083        }
    31053084    }
     
    31353114foreach my $v (@$vm) {
    31363115    # 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);
    31403117
    31413118    # Prepare the script to be executed on the VM/VE/RM
     
    31513128        print SCRIPT "sudo mount -t proc /proc /proc\n";
    31523129    }
    3153     print SCRIPT "$pbupd\n";
     3130    print SCRIPT "$pbos->{'update'}\n";
    31543131    if ($vtype eq "ve") {
    31553132        print SCRIPT "sudo umount /proc\n";
     
    32083185        open(OUT,"> $ENV{'PBTMP'}/$pbpkg.ann") || die "Unable to create $ENV{'PBTMP'}/$pbpkg.ann: $!";
    32093186        my %pb;
    3210         $pb{'dtype'} = "announce";
    32113187        $pb{'realpkg'} = $pbpkg;
    32123188        $pb{'ver'} = $pbver;
    32133189        $pb{'tag'} = $pbtag;
    3214         $pb{'suf'} = "N/A";     # Should not be empty even if unused
    32153190        $pb{'date'} = $pbdate;
    32163191        $pb{'chglog'} = $chglog;
     
    35383513my $sdir = shift;
    35393514my $sources = shift;
    3540 my $dtype = shift;
    3541 my $dfam = shift;
    3542 my $ddir = shift;
    3543 my $dver = shift;
    3544 my $arch = shift;
     3515my $pbos = shift;
    35453516my $extdir = shift;
    35463517
     
    35483519# This function works for both patches and additional sources
    35493520foreach 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'}$/);
    35623533}
    35633534
    35643535# 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") {
     3536foreach my $p ("all","$pbos->{'type'}","$pbos->{'family'}","$pbos->{'name'}","$pbos->{'name'}-$pbos->{'version'}","$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}") {
    35663537    my $f = "$extdir.".".$p";
    35673538    next if (not -f $f);
     
    35723543    while (<PATCH>) {
    35733544        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'}"} .= "$_";
    35763547    }
    35773548    close(PATCH);
     
    36003571sub pb_get_postinstall {
    36013572
    3602 my $ddir = shift;
    3603 my $dver = shift;
    3604 my $darch = shift;
     3573my $pbos = shift;
    36053574my $rbspi = shift;
    36063575my $vestyle = shift;
     
    36143583}
    36153584
    3616 my $postparam = pb_distro_get_param($ddir,$dver,$darch,$rbspi);
     3585my $postparam = pb_distro_get_param($pbos,$rbspi);
    36173586if ($postparam eq "") {
    36183587    $post = "";
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r1156 r1177  
    5353
    5454The 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.
     55The second parameter is OS hash
    5956
    6057The function returns a pointer on a hash of filters.
     
    6865my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3);
    6966my $pbpkg = shift || die "No package specified";
    70 my $dtype = shift || "";
    71 my $dfam = shift || "";
    72 my $ddir = shift || "";
    73 my $dver = shift || "";
     67my $pbos = shift;
    7468my $ptr = undef; # returned value pointer on the hash of filters
    7569my %h;
     
    7872if (-d "$ENV{'PBROOTDIR'}/pbfilter") {
    7973    $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    }
    8480
    8581    push @ffiles,$mfile00 if (defined $mfile00);
     
    9288if (-d "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter") {
    9389    $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    }
    9996    push @ffiles,$ffile00 if (defined $ffile00);
    10097    push @ffiles,$ffile0 if (defined $ffile0);
  • devel/rpmbootstrap/bin/rpmbootstrap

    r1128 r1177  
    164164
    165165GetOptions("help|?|h" => \$opts{'h'},
    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'},
     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'},
    177177) || pb_syntax(-1,0);
    178178
     
    193193    $pbLOG = \*pbLOG;
    194194    $pbdebug = 0  if ($pbdebug == -1);
    195     }
     195}
    196196pb_log_init($pbdebug, $pbLOG);
    197197#pb_display_init("text","");
     
    214214#
    215215pb_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);
     216my $pbos = pb_distro_get_context($ENV{'PBV'});
    219217
    220218#
     
    233231if (not defined $vepath) {
    234232    my ($vestdpath) = pb_conf_get_if("vepath");
    235     $vepath = "$vestdpath->{'default'}/$ddir/$dver/$darch";
     233    $vepath = "$vestdpath->{'default'}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}";
    236234}
    237235
     
    243241# Get the package list to download, store them in a cache directory
    244242#
    245 my ($rbsmindep,$rbsmirrorsrv) = pb_conf_get("rbsmindep","rbsmirrorsrv");
    246243my ($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);
     244my ($pkgs,$mirror) = pb_distro_get_param($pbos->{'name'},$pbos->{'version'},$pbos->{'arch'},pb_conf_get("rbsmindep","rbsmirrorsrv"));
    249245
    250246my $cachedir = "/var/cache/rpmbootstrap";
     
    252248
    253249# Point to the right subdir and create it if needed
    254 $cachedir .= "/$ddir-$dver-$darch";
     250$cachedir .= "/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}";
    255251pb_mkdir_p($cachedir) if (! -d $cachedir);
    256252
     
    266262    if ($mirror =~ /i386/) {
    267263        # 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'}.";
    269265        $mirror =~ s|/i386/|/i586/|;
    270266        $response = $ua->get($mirror);
    271267        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'}";
    273269        }
    274270    }
     
    279275my $repo = $mirror;
    280276my $found = 0;
    281 if ($pbins =~ /yum/) {
     277if ($pbos->{'install'} =~ /yum/) {
    282278    my $response1;
    283279    while ($found == 0) {
     
    290286            my ($scheme, $account, $host, $port, $path) = pb_get_uri($repo);
    291287            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       
    293289            # / not reached, so looping
    294290            next;
     
    302298
    303299# Manages architectures specificities
    304 my $parch = $darch;
    305 $parch = "i[3456]86" if ($darch eq "i386");
     300my $parch = $pbos->{'arch'};
     301$parch = "i[3456]86" if ($pbos->{'arch'} eq "i386");
    306302
    307303# Get the list of packages and their URL in this hash
     
    331327my $osupdname = "";
    332328
    333 if ($pbins =~ /yum/) {
     329if ($pbos->{'install'} =~ /yum/) {
    334330    $oscachedir = "$vepath/var/cache/yum/core/packages/";
    335331    $osupdcachedir = "$vepath/var/cache/yum/updates-released/packages/";
    336332    $osupdname = "YUM";
    337333    # 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";
    341337        $osupdcachedir = "$vepath/var/cache/yum/updates-released/packages/";
    342338    }
    343 } elsif ($pbins =~ /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'}";
    345341    $osupdname = "Zypper";
    346 } elsif ($pbins =~ /urpmi/) {
     342} elsif ($pbos->{'install'} =~ /urpmi/) {
    347343    $oscachedir = "$vepath/var/cache/urpmi/rpms";
    348344    $osupdname = "URPMI";
     
    373369                pb_log(1,"Package $p1 already in cache\n");
    374370            }
    375            
     371       
    376372            # End if download only
    377373            if ($opts{'d'}) {
    378374                next;
    379375            }
    380 
     376   
    381377            #
    382378            # Copy the cached .RPM files into the oscachedir directory, so that os doesn't need to download them again.
    383379            #
    384380            pb_log(1,"Link package into $oscachedir\n");
    385             copy("$cachedir/$p1",$oscachedir) if (defined $oscachedir);
    386             symlink("$oscachedir/$p1","$osupdcachedir/p1") if (defined $osupdcachedir);
     381            copy("$cachedir/$p1",$oscachedir) if (defined $oscachedir);
     382            symlink("$oscachedir/$p1","$osupdcachedir/p1") if (defined $osupdcachedir);
    387383
    388384            # And extract it to the finale dir
    389385            pb_system("cd $vepath ; rpm2cpio $cachedir/$p1 | cpio -ivdum","Extracting package $p1 into $vepath");
    390 
     386       
    391387            # Remove cached package if not asked to keep
    392388            if (! $opts{'k'}) {
    393389                unlink("$cachedir/$p1");
    394390            }
    395 
     391   
    396392        }
    397393    } else {
     
    403399
    404400if ($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");
     401pb_log(0,"$warning WARNINGS found.\nMaybe you should review your package list for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}\nand remove$lwpkg\n");
    406402}
    407403
     
    415411
    416412# yum needs that distro-release package be installed, so force it
    417 if ($pbins =~ /yum/) {
     413if ($pbos->{'install'} =~ /yum/) {
     414    my $ddir = $pbos->{'name'};
    418415    foreach my $p1 (<$cachedir/($ddir|redhat)-release-*.rpm>) {
    419416        copy("$cachedir/$p1","$vepath/tmp");
     
    432429# BUGFIX:
    433430#
    434 if ((($ddir eq "centos") || ($ddir eq "rhel")) && ($dver eq "5")) {
     431if ((($pbos->{'name'} eq "centos") || ($pbos->{'name'} eq "rhel")) && ($pbos->{'version'} eq "5")) {
    435432    pb_log(1,"BUGFIX for centos-5\n");
    436433    pb_mkdir_p("$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx");
     
    458455
    459456pb_log(1,"Adapting $osupdname repository entries\n");
    460 if ($pbins =~ /yum/) {
     457if ($pbos->{'install'} =~ /yum/) {
    461458    #
    462459    # Force the architecture for yum
     
    468465    # yum.conf as well
    469466    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");
    472469        pb_system("sed -i -e 's/^mirrorlist/#mirrorlist/' $i","","quiet");
    473470        # rather use neutral separators here
     
    475472    }
    476473    $minipkglist = "ldconfig yum passwd vim-minimal dhclient authconfig";
    477 } elsif ($pbins =~ /zypper/) {
     474} elsif ($pbos->{'install'} =~ /zypper/) {
    478475    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";
    480477    my $baseurl = dirname(dirname($mirror));
    481478    # Setup the repo
    482479    print REPO << 'EOF';
    483480[opensuse]
    484 name=$ddir-$dver
     481name=$pbos->{'name'}-$pbos->{'version'}
    485482baseurl=$baseurl
    486483enabled=1
     
    491488    $minipkglist = "zypper vim-minimal dhclient";
    492489    # Bootstraping zypper
    493     if ($dver eq "10.2") {
    494         pb_system("chroot $vepath /bin/bash -c \"yes | /usr/bin/zypper sa $baseurl $ddir-$dver\"","Bootstrapping Zypper");
    495     }
    496 } elsif ($pbins =~ /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/) {
    497494    # Setup the repo
    498495    my $baseurl = dirname(dirname(dirname($mirror)));
     
    505502# No need for sudo here
    506503#
    507 $pbins =~ s/sudo//g;
    508 pb_system("chroot $vepath /bin/bash -c \"$pbins $minipkglist \"","Bootstrapping OS by running $pbins $minipkglist");
     504$pbos->{'install'} =~ s/sudo//g;
     505pb_system("chroot $vepath /bin/bash -c \"$pbos->{'install'} $minipkglist \"","Bootstrapping OS by running $pbos->{'install'} $minipkglist");
    509506
    510507#
     
    517514if (defined $opts{'a'}) {
    518515    $opts{'a'} =~ s/,/ /g;
    519     pb_system("chroot $vepath /bin/bash -c \"$pbins $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'}");
    520517}
    521518
     
    524521#
    525522pb_log(1,"Cleaning up\n");
    526 if ($pbins =~ /yum/) {
     523if ($pbos->{'install'} =~ /yum/) {
    527524    pb_system("chroot $vepath /usr/bin/yum clean all","Cleaning yum");
    528525}
Note: See TracChangeset for help on using the changeset viewer.