[11] | 1 | #!/usr/bin/perl -w
|
---|
[2] | 2 | #
|
---|
[11] | 3 | # Creates common environment for distributions
|
---|
[2] | 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 |
|
---|
[329] | 8 | package ProjectBuilder::Distribution;
|
---|
| 9 |
|
---|
[11] | 10 | use strict;
|
---|
[423] | 11 | use Data::Dumper;
|
---|
[395] | 12 | use ProjectBuilder::Base;
|
---|
[702] | 13 | use ProjectBuilder::Conf;
|
---|
| 14 | use File::Basename;
|
---|
| 15 | use File::Copy;
|
---|
[2] | 16 |
|
---|
[329] | 17 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 18 |
|
---|
| 19 | use Exporter;
|
---|
| 20 |
|
---|
| 21 | # Export, by default, all the functions into the namespace of
|
---|
| 22 | # any code which uses this module.
|
---|
| 23 |
|
---|
| 24 | our @ISA = qw(Exporter);
|
---|
[891] | 25 | our @EXPORT = qw(pb_distro_conffile pb_distro_init pb_distro_get pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_get_param);
|
---|
[329] | 26 |
|
---|
[391] | 27 | =pod
|
---|
| 28 |
|
---|
| 29 | =head1 NAME
|
---|
| 30 |
|
---|
| 31 | ProjectBuilder::Distribution, part of the project-builder.org - module dealing with distribution detection
|
---|
| 32 |
|
---|
| 33 | =head1 DESCRIPTION
|
---|
| 34 |
|
---|
| 35 | This modules provides functions to allow detection of Linux distributions, and giving back some attributes concerning them.
|
---|
| 36 |
|
---|
| 37 | =head1 SYNOPSIS
|
---|
| 38 |
|
---|
| 39 | use ProjectBuilder::Distribution;
|
---|
| 40 |
|
---|
| 41 | #
|
---|
| 42 | # Return information on the running distro
|
---|
| 43 | #
|
---|
[756] | 44 | my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch) = pb_distro_init();
|
---|
| 45 | print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch)."\n";
|
---|
[391] | 46 | #
|
---|
| 47 | # Return information on the requested distro
|
---|
| 48 | #
|
---|
[756] | 49 | my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch) = pb_distro_init("ubuntu","7.10","x86_64");
|
---|
| 50 | print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch)."\n";
|
---|
[391] | 51 | #
|
---|
| 52 | # Return information on the running distro
|
---|
| 53 | #
|
---|
[622] | 54 | my ($ddir,$dver) = pb_distro_get();
|
---|
[756] | 55 | my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch) = pb_distro_init($ddir,$dver);
|
---|
| 56 | print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch)."\n";
|
---|
[391] | 57 |
|
---|
| 58 | =head1 USAGE
|
---|
| 59 |
|
---|
| 60 | =over 4
|
---|
| 61 |
|
---|
[891] | 62 | =item B<pb_distro_conffile>
|
---|
| 63 |
|
---|
| 64 | This function returns the mandatory configuration file used for distribution/OS detection
|
---|
| 65 |
|
---|
| 66 | =cut
|
---|
| 67 |
|
---|
| 68 | sub pb_distro_conffile {
|
---|
| 69 |
|
---|
| 70 | return("CCCC/pb.conf");
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 |
|
---|
[756] | 74 | =item B<pb_distro_init>
|
---|
[395] | 75 |
|
---|
[756] | 76 | This function returns a list of 7 parameters indicating the distribution name, version, family, type of build system, suffix of packages, update command line and architecture of the underlying Linux distribution. The value of the 7 fields may be "unknown" in case the function was unable to recognize on which distribution it is running.
|
---|
[391] | 77 |
|
---|
[756] | 78 | As an example, Ubuntu and Debian are in the same "du" family. As well as RedHat, RHEL, CentOS, fedora are on the same "rh" family.
|
---|
| 79 | 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.
|
---|
| 80 | And "fc" is the extension generated for all Fedora packages (Version will be added by pb).
|
---|
[869] | 81 | All these information are stored in an external configuration file typically at /etc/pb/pb.conf
|
---|
[391] | 82 |
|
---|
[756] | 83 | When passing the distribution name and version as parameters, the B<pb_distro_init> function returns the parameter of that distribution instead of the underlying one.
|
---|
[391] | 84 |
|
---|
[756] | 85 | Cf: http://linuxmafia.com/faq/Admin/release-files.html
|
---|
| 86 | Ideas taken from http://search.cpan.org/~kerberus/Linux-Distribution-0.14/lib/Linux/Distribution.pm
|
---|
| 87 |
|
---|
[391] | 88 | =cut
|
---|
| 89 |
|
---|
[756] | 90 |
|
---|
[74] | 91 | sub pb_distro_init {
|
---|
[2] | 92 |
|
---|
[23] | 93 | my $ddir = shift || undef;
|
---|
| 94 | my $dver = shift || undef;
|
---|
[11] | 95 | my $dfam = "unknown";
|
---|
| 96 | my $dtype = "unknown";
|
---|
| 97 | my $dsuf = "unknown";
|
---|
[620] | 98 | my $dupd = "unknown";
|
---|
[867] | 99 | my $darch = shift || undef;
|
---|
| 100 | my $dnover = "false";
|
---|
| 101 | my $drmdot = "false";
|
---|
[2] | 102 |
|
---|
[869] | 103 | # Adds conf file for distribution description
|
---|
| 104 | # the location of the conf file is finalyzed at install time
|
---|
| 105 | # depending whether we deal with package install or tar file install
|
---|
[891] | 106 | pb_conf_add(pb_distro_conffile());
|
---|
[869] | 107 |
|
---|
[11] | 108 | # If we don't know which distribution we're on, then guess it
|
---|
[622] | 109 | ($ddir,$dver) = pb_distro_get() if ((not defined $ddir) || (not defined $dver));
|
---|
[2] | 110 |
|
---|
[757] | 111 | # Initialize arch
|
---|
[867] | 112 | $darch=pb_get_arch() if (not defined $darch);
|
---|
[757] | 113 |
|
---|
[867] | 114 | my ($osfamily,$ostype,$osupd,$ossuffix,$osnover,$osremovedotinver) = pb_conf_get("osfamily","ostype","osupd","ossuffix","osnover","osremovedotinver");
|
---|
[620] | 115 |
|
---|
[867] | 116 | $dfam = pb_distro_get_param($ddir,$dver,$darch,$osfamily);
|
---|
| 117 | $dtype = $ostype->{$dfam} if (defined $ostype->{$dfam});
|
---|
| 118 | $dupd = pb_distro_get_param($ddir,$dver,$darch,$osupd,$dfam,$dtype);
|
---|
| 119 | $dsuf = pb_distro_get_param($ddir,$dver,$darch,$ossuffix,$dfam,$dtype);
|
---|
| 120 | $dnover = pb_distro_get_param($ddir,$dver,$darch,$osnover,$dfam,$dtype);
|
---|
| 121 | $drmdot = pb_distro_get_param($ddir,$dver,$darch,$osremovedotinver,$dfam,$dtype);
|
---|
| 122 |
|
---|
| 123 | # Some OS have no interesting version
|
---|
| 124 | $dver = "nover" if ($dnover eq "true");
|
---|
| 125 |
|
---|
| 126 | # For some OS remove the . in version name
|
---|
| 127 | $dver =~ s/\.// if ($drmdot eq "true");
|
---|
| 128 |
|
---|
| 129 | if ((not defined $dsuf) || ($dsuf eq "unknown")) {
|
---|
| 130 | # By default suffix is a concatenation of .ddir and dver
|
---|
| 131 | $dsuf = ".$ddir$dver"
|
---|
[11] | 132 | } else {
|
---|
[867] | 133 | # concat just the version to what has been found
|
---|
| 134 | $dsuf = ".$dsuf$dver";
|
---|
[11] | 135 | }
|
---|
| 136 |
|
---|
[867] | 137 | # if ($arch eq "x86_64") {
|
---|
| 138 | # $opt="--exclude=*.i?86";
|
---|
| 139 | # }
|
---|
| 140 |
|
---|
| 141 | return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $darch);
|
---|
[11] | 142 | }
|
---|
[23] | 143 |
|
---|
[756] | 144 | =item B<pb_distro_get>
|
---|
[395] | 145 |
|
---|
[756] | 146 | This function returns a list of 2 parameters indicating the distribution name and version of the underlying Linux distribution. The value of those 2 fields may be "unknown" in case the function was unable to recognize on which distribution it is running.
|
---|
[395] | 147 |
|
---|
[756] | 148 | On my home machine it would currently report ("mandriva","2009.0").
|
---|
[395] | 149 |
|
---|
| 150 | =cut
|
---|
| 151 |
|
---|
[622] | 152 | sub pb_distro_get {
|
---|
[23] | 153 |
|
---|
[869] | 154 | # 1: List of files that unambiguously indicates what distro we have
|
---|
| 155 | # 2: List of files that ambiguously indicates what distro we have
|
---|
| 156 | # 3: Should have the same keys as the previous one. If ambiguity, which other distributions should be checked
|
---|
| 157 | # 4: Matching Rg. Expr to detect distribution and version
|
---|
| 158 | my ($single_rel_files, $ambiguous_rel_files,$distro_similar,$distro_match) = pb_conf_get("osrelfile","osrelambfile","osambiguous","osrelexpr");
|
---|
[23] | 159 |
|
---|
| 160 | my $release;
|
---|
| 161 | my $distro;
|
---|
| 162 |
|
---|
[391] | 163 | # Begin to test presence of non-ambiguous files
|
---|
[23] | 164 | # that way we reduce the choice
|
---|
[24] | 165 | my ($d,$r);
|
---|
[869] | 166 | while (($d,$r) = each %$single_rel_files) {
|
---|
| 167 | if (-f "$r" && ! -l "$r") {
|
---|
| 168 | my $tmp=pb_get_content("$r");
|
---|
[23] | 169 | # Found the only possibility.
|
---|
| 170 | # Try to get version and return
|
---|
[869] | 171 | if (defined ($distro_match->{$d})) {
|
---|
| 172 | ($release) = $tmp =~ m/$distro_match->{$d}/m;
|
---|
[23] | 173 | } else {
|
---|
[24] | 174 | print STDERR "Unable to find $d version in $r\n";
|
---|
[23] | 175 | print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
|
---|
| 176 | $release = "unknown";
|
---|
| 177 | }
|
---|
| 178 | return($d,$release);
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[423] | 182 | # Now look at ambiguous files
|
---|
| 183 | # Ubuntu includes a /etc/debian_version file that creates an ambiguity with debian
|
---|
| 184 | # So we need to look at distros in reverse alphabetic order to treat ubuntu always first via lsb
|
---|
[869] | 185 | foreach $d (reverse keys %$ambiguous_rel_files) {
|
---|
| 186 | $r = $ambiguous_rel_files->{$d};
|
---|
| 187 | if (-f "$r" && !-l "$r") {
|
---|
[23] | 188 | # Found one possibility.
|
---|
| 189 | # Get all distros concerned by that file
|
---|
[869] | 190 | my $tmp=pb_get_content("$r");
|
---|
[24] | 191 | my $found = 0;
|
---|
[869] | 192 | my $ptr = $distro_similar->{$d};
|
---|
[423] | 193 | pb_log(2,"amb: ".Dumper($ptr)."\n");
|
---|
[24] | 194 | $release = "unknown";
|
---|
[869] | 195 | foreach my $dd (split(/,/,$ptr)) {
|
---|
[423] | 196 | pb_log(2,"check $dd\n");
|
---|
[23] | 197 | # Try to check pattern
|
---|
[869] | 198 | if (defined $distro_match->{$dd}) {
|
---|
| 199 | pb_log(2,"cmp: $distro_match->{$dd} - vs - $tmp\n");
|
---|
| 200 | ($release) = $tmp =~ m/$distro_match->{$dd}/m;
|
---|
[24] | 201 | if ((defined $release) && ($release ne "unknown")) {
|
---|
| 202 | $distro = $dd;
|
---|
| 203 | $found = 1;
|
---|
| 204 | last;
|
---|
| 205 | }
|
---|
[23] | 206 | }
|
---|
| 207 | }
|
---|
| 208 | if ($found == 0) {
|
---|
[24] | 209 | print STDERR "Unable to find $d version in $r\n";
|
---|
[23] | 210 | print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
|
---|
| 211 | $release = "unknown";
|
---|
| 212 | } else {
|
---|
| 213 | return($distro,$release);
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 | }
|
---|
| 217 | return("unknown","unknown");
|
---|
[24] | 218 | }
|
---|
[23] | 219 |
|
---|
[621] | 220 |
|
---|
| 221 | =item B<pb_distro_installdeps>
|
---|
| 222 |
|
---|
| 223 | This function install the dependencies required to build the package on an RPM based distro
|
---|
[756] | 224 | dependencies can be passed as a parameter in which case they are not computed
|
---|
[621] | 225 |
|
---|
| 226 | =cut
|
---|
| 227 |
|
---|
| 228 | sub pb_distro_installdeps {
|
---|
| 229 |
|
---|
| 230 | # SPEC file
|
---|
| 231 | my $f = shift || undef;
|
---|
| 232 | my $dtype = shift || undef;
|
---|
| 233 | my $dupd = shift || undef;
|
---|
| 234 | my $deps = shift || undef;
|
---|
| 235 |
|
---|
| 236 | # Protection
|
---|
| 237 | return if (not defined $dupd);
|
---|
| 238 |
|
---|
| 239 | # Get dependecies in the build file if not forced
|
---|
[899] | 240 | $deps = pb_distro_getdeps($f, $dtype) if (not defined $deps);
|
---|
[621] | 241 | pb_log(2,"deps: $deps\n");
|
---|
[623] | 242 | return if ((not defined $deps) || ($deps =~ /^\s*$/));
|
---|
[621] | 243 | if ($deps !~ /^[ ]*$/) {
|
---|
| 244 | pb_system("$dupd $deps","Installing dependencies ($deps)");
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | =item B<pb_distro_getdeps>
|
---|
| 249 |
|
---|
| 250 | This function computes the dependencies indicated in the build file and return them as a string of packages to install
|
---|
| 251 |
|
---|
| 252 | =cut
|
---|
| 253 |
|
---|
| 254 | sub pb_distro_getdeps {
|
---|
| 255 |
|
---|
| 256 | my $f = shift || undef;
|
---|
| 257 | my $dtype = shift || undef;
|
---|
| 258 |
|
---|
| 259 | my $regexp = "";
|
---|
| 260 | my $deps = "";
|
---|
| 261 | my $sep = $/;
|
---|
| 262 |
|
---|
| 263 | # Protection
|
---|
[622] | 264 | return("") if (not defined $dtype);
|
---|
[899] | 265 | return("") if (not defined $f);
|
---|
| 266 |
|
---|
| 267 | pb_log(3,"entering pb_distro_getdeps: $dtype - $f\n");
|
---|
[621] | 268 | if ($dtype eq "rpm") {
|
---|
| 269 | # In RPM this could include files, but we do not handle them atm.
|
---|
| 270 | $regexp = '^BuildRequires:(.*)$';
|
---|
[696] | 271 | } elsif ($dtype eq "deb") {
|
---|
[621] | 272 | $regexp = '^Build-Depends:(.*)$';
|
---|
| 273 | } elsif ($dtype eq "ebuild") {
|
---|
| 274 | $sep = '"'.$/;
|
---|
| 275 | $regexp = '^DEPEND="(.*)"\n'
|
---|
| 276 | } else {
|
---|
| 277 | # No idea
|
---|
[622] | 278 | return("");
|
---|
[621] | 279 | }
|
---|
| 280 | pb_log(2,"regexp: $regexp\n");
|
---|
| 281 |
|
---|
| 282 | # Preserve separator before using the one we need
|
---|
| 283 | my $oldsep = $/;
|
---|
| 284 | $/ = $sep;
|
---|
| 285 | open(DESC,"$f") || die "Unable to open $f";
|
---|
| 286 | while (<DESC>) {
|
---|
| 287 | pb_log(4,"read: $_\n");
|
---|
| 288 | next if (! /$regexp/);
|
---|
| 289 | chomp();
|
---|
| 290 | # What we found with the regexp is the list of deps.
|
---|
| 291 | pb_log(2,"found deps: $_\n");
|
---|
[681] | 292 | s/$regexp/$1/i;
|
---|
[698] | 293 | # Remove conditions in the middle and at the end for deb
|
---|
[931] | 294 | s/\(\s*[><=]+.*\)[^,]*,/,/g;
|
---|
[698] | 295 | s/\(\s*[><=]+.*$//g;
|
---|
| 296 | # Same for rpm
|
---|
[931] | 297 | s/[><=]+[^,]*,/,/g;
|
---|
[652] | 298 | s/[><=]+.*$//g;
|
---|
[621] | 299 | # Improve string format (remove , and spaces at start, end and in double
|
---|
[652] | 300 | s/,/ /g;
|
---|
[621] | 301 | s/^\s*//;
|
---|
| 302 | s/\s*$//;
|
---|
| 303 | s/\s+/ /g;
|
---|
| 304 | $deps .= " ".$_;
|
---|
| 305 | }
|
---|
| 306 | close(DESC);
|
---|
| 307 | $/ = $oldsep;
|
---|
| 308 | pb_log(2,"now deps: $deps\n");
|
---|
[622] | 309 | my $deps2 = pb_distro_only_deps_needed($dtype,$deps);
|
---|
| 310 | return($deps2);
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 |
|
---|
| 314 | =item B<pb_distro_only_deps_needed>
|
---|
| 315 |
|
---|
| 316 | This function returns only the dependencies not yet installed
|
---|
| 317 |
|
---|
| 318 | =cut
|
---|
| 319 |
|
---|
| 320 | sub pb_distro_only_deps_needed {
|
---|
| 321 |
|
---|
[623] | 322 | my $dtype = shift || undef;
|
---|
[622] | 323 | my $deps = shift || undef;
|
---|
| 324 |
|
---|
[623] | 325 | return("") if ((not defined $deps) || ($deps =~ /^\s*$/));
|
---|
[621] | 326 | my $deps2 = "";
|
---|
| 327 | # Avoid to install what is already there
|
---|
| 328 | foreach my $p (split(/ /,$deps)) {
|
---|
| 329 | if ($dtype eq "rpm") {
|
---|
| 330 | my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet");
|
---|
| 331 | next if ($res eq 0);
|
---|
[696] | 332 | } elsif ($dtype eq "deb") {
|
---|
[621] | 333 | my $res = pb_system("dpkg -L $p","","quiet");
|
---|
| 334 | next if ($res eq 0);
|
---|
| 335 | } elsif ($dtype eq "ebuild") {
|
---|
| 336 | } else {
|
---|
| 337 | # Not reached
|
---|
| 338 | }
|
---|
| 339 | pb_log(2,"found deps2: $p\n");
|
---|
| 340 | $deps2 .= " $p";
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | $deps2 =~ s/^\s*//;
|
---|
| 344 | pb_log(2,"now deps2: $deps2\n");
|
---|
| 345 | return($deps2);
|
---|
| 346 | }
|
---|
| 347 |
|
---|
[702] | 348 | =item B<pb_distro_setuprepo>
|
---|
| 349 |
|
---|
| 350 | This function sets up potential additional repository to the build environment
|
---|
| 351 |
|
---|
| 352 | =cut
|
---|
| 353 |
|
---|
| 354 | sub pb_distro_setuprepo {
|
---|
| 355 |
|
---|
| 356 | my $ddir = shift || undef;
|
---|
| 357 | my $dver = shift;
|
---|
| 358 | my $darch = shift;
|
---|
| 359 | my $dtype = shift || undef;
|
---|
| 360 |
|
---|
| 361 | my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","addrepo");
|
---|
| 362 | return if (not defined $addrepo);
|
---|
| 363 |
|
---|
| 364 | my $param = pb_distro_get_param($ddir,$dver,$darch,$addrepo);
|
---|
| 365 | return if ($param eq "");
|
---|
| 366 |
|
---|
| 367 | # Loop on the list of additional repo
|
---|
| 368 | foreach my $i (split(/,/,$param)) {
|
---|
| 369 |
|
---|
| 370 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($i);
|
---|
| 371 | my $bn = basename($i);
|
---|
| 372 |
|
---|
| 373 | # The repo file can be local or remote. download or copy at the right place
|
---|
| 374 | if (($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
| 375 | pb_system("wget -O $ENV{'PBTMP'}/$bn $i","Donwloading additional repository file $i");
|
---|
| 376 | } else {
|
---|
| 377 | copy($i,$ENV{'PBTMP'}/$bn);
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | # The repo file can be a real file or a package
|
---|
| 381 | if ($dtype eq "rpm") {
|
---|
| 382 | if ($bn =~ /\.rpm$/) {
|
---|
[721] | 383 | my $pn = $bn;
|
---|
| 384 | $pn =~ s/\.rpm//;
|
---|
| 385 | if (pb_system("rpm -q --quiet $pn","","quiet") != 0) {
|
---|
| 386 | pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repository");
|
---|
| 387 | }
|
---|
| 388 | } elsif ($bn =~ /\.repo$/) {
|
---|
[702] | 389 | # Yum repo
|
---|
[721] | 390 | pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repos.d","Adding yum repository") if (not -f "/etc/yum.repos.d/$bn");
|
---|
[702] | 391 | } elsif ($bn =~ /\.addmedia/) {
|
---|
| 392 | # URPMI repo
|
---|
[721] | 393 | # We should test that it's not already a urpmi repo
|
---|
[702] | 394 | pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository");
|
---|
| 395 | } else {
|
---|
| 396 | pb_log(0,"Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
|
---|
| 397 | }
|
---|
| 398 | } elsif ($dtype eq "deb") {
|
---|
[721] | 399 | if (($bn =~ /\.sources.list$/) && (not -f "/etc/apt/sources.list.d/$bn")) {
|
---|
[711] | 400 | pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository");
|
---|
| 401 | pb_system("sudo apt-get update","Updating apt repository");
|
---|
[702] | 402 | } else {
|
---|
| 403 | pb_log(0,"Unable to deal with repository file $i on deb distro ! Please report to dev team\n");
|
---|
| 404 | }
|
---|
| 405 | } else {
|
---|
| 406 | pb_log(0,"Unable to deal with repository file $i on that distro ! Please report to dev team\n");
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 | return;
|
---|
| 410 | }
|
---|
| 411 |
|
---|
| 412 | =item B<pb_distro_get_param>
|
---|
| 413 |
|
---|
| 414 | This function gets the parameter in the conf file from the most precise tuple up to default
|
---|
| 415 |
|
---|
| 416 | =cut
|
---|
| 417 |
|
---|
| 418 | sub pb_distro_get_param {
|
---|
| 419 |
|
---|
| 420 | my $param = "";
|
---|
| 421 | my $ddir = shift;
|
---|
| 422 | my $dver = shift;
|
---|
| 423 | my $darch = shift;
|
---|
| 424 | my $opt = shift;
|
---|
[867] | 425 | my $dfam = shift || "unknown";
|
---|
| 426 | my $dtype = shift || "unknown";
|
---|
[702] | 427 |
|
---|
| 428 | if (defined $opt->{"$ddir-$dver-$darch"}) {
|
---|
| 429 | $param = $opt->{"$ddir-$dver-$darch"};
|
---|
| 430 | } elsif (defined $opt->{"$ddir-$dver"}) {
|
---|
| 431 | $param = $opt->{"$ddir-$dver"};
|
---|
| 432 | } elsif (defined $opt->{"$ddir"}) {
|
---|
| 433 | $param = $opt->{"$ddir"};
|
---|
[867] | 434 | } elsif (defined $opt->{$dfam}) {
|
---|
| 435 | $param = $opt->{$dfam};
|
---|
| 436 | } elsif (defined $opt->{$dtype}) {
|
---|
| 437 | $param = $opt->{$dtype};
|
---|
[702] | 438 | } elsif (defined $opt->{"default"}) {
|
---|
| 439 | $param = $opt->{"default"};
|
---|
| 440 | } else {
|
---|
[867] | 441 | $param = "unknown";
|
---|
[702] | 442 | }
|
---|
| 443 | return($param);
|
---|
| 444 |
|
---|
| 445 | }
|
---|
[749] | 446 |
|
---|
| 447 |
|
---|
[395] | 448 | =back
|
---|
[23] | 449 |
|
---|
[395] | 450 | =head1 WEB SITES
|
---|
[23] | 451 |
|
---|
[395] | 452 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 453 |
|
---|
| 454 | =head1 USER MAILING LIST
|
---|
| 455 |
|
---|
| 456 | None exists for the moment.
|
---|
| 457 |
|
---|
| 458 | =head1 AUTHORS
|
---|
| 459 |
|
---|
| 460 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 461 |
|
---|
| 462 | =head1 COPYRIGHT
|
---|
| 463 |
|
---|
| 464 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 465 | described in the file C<COPYING> included with the distribution.
|
---|
| 466 |
|
---|
| 467 | =cut
|
---|
| 468 |
|
---|
| 469 |
|
---|
[11] | 470 | 1;
|
---|