[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 |
|
---|
[969] | 116 | # Dig into the tuple to find the best answer
|
---|
[867] | 117 | $dfam = pb_distro_get_param($ddir,$dver,$darch,$osfamily);
|
---|
| 118 | $dtype = $ostype->{$dfam} if (defined $ostype->{$dfam});
|
---|
| 119 | $dupd = pb_distro_get_param($ddir,$dver,$darch,$osupd,$dfam,$dtype);
|
---|
| 120 | $dsuf = pb_distro_get_param($ddir,$dver,$darch,$ossuffix,$dfam,$dtype);
|
---|
| 121 | $dnover = pb_distro_get_param($ddir,$dver,$darch,$osnover,$dfam,$dtype);
|
---|
| 122 | $drmdot = pb_distro_get_param($ddir,$dver,$darch,$osremovedotinver,$dfam,$dtype);
|
---|
| 123 |
|
---|
| 124 | # Some OS have no interesting version
|
---|
| 125 | $dver = "nover" if ($dnover eq "true");
|
---|
| 126 |
|
---|
| 127 | # For some OS remove the . in version name
|
---|
[1050] | 128 | $dver =~ s/\.//g if ($drmdot eq "true");
|
---|
[867] | 129 |
|
---|
[969] | 130 | if ((not defined $dsuf) || ($dsuf eq "")) {
|
---|
[867] | 131 | # By default suffix is a concatenation of .ddir and dver
|
---|
| 132 | $dsuf = ".$ddir$dver"
|
---|
[11] | 133 | } else {
|
---|
[867] | 134 | # concat just the version to what has been found
|
---|
| 135 | $dsuf = ".$dsuf$dver";
|
---|
[11] | 136 | }
|
---|
| 137 |
|
---|
[867] | 138 | # if ($arch eq "x86_64") {
|
---|
| 139 | # $opt="--exclude=*.i?86";
|
---|
| 140 | # }
|
---|
[964] | 141 | pb_log(2,"DEBUG: pb_distro_init: $ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $darch\n");
|
---|
[867] | 142 |
|
---|
| 143 | return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd, $darch);
|
---|
[11] | 144 | }
|
---|
[23] | 145 |
|
---|
[756] | 146 | =item B<pb_distro_get>
|
---|
[395] | 147 |
|
---|
[756] | 148 | 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] | 149 |
|
---|
[756] | 150 | On my home machine it would currently report ("mandriva","2009.0").
|
---|
[395] | 151 |
|
---|
| 152 | =cut
|
---|
| 153 |
|
---|
[622] | 154 | sub pb_distro_get {
|
---|
[23] | 155 |
|
---|
[869] | 156 | # 1: List of files that unambiguously indicates what distro we have
|
---|
| 157 | # 2: List of files that ambiguously indicates what distro we have
|
---|
| 158 | # 3: Should have the same keys as the previous one. If ambiguity, which other distributions should be checked
|
---|
| 159 | # 4: Matching Rg. Expr to detect distribution and version
|
---|
| 160 | my ($single_rel_files, $ambiguous_rel_files,$distro_similar,$distro_match) = pb_conf_get("osrelfile","osrelambfile","osambiguous","osrelexpr");
|
---|
[23] | 161 |
|
---|
| 162 | my $release;
|
---|
| 163 | my $distro;
|
---|
| 164 |
|
---|
[391] | 165 | # Begin to test presence of non-ambiguous files
|
---|
[23] | 166 | # that way we reduce the choice
|
---|
[24] | 167 | my ($d,$r);
|
---|
[869] | 168 | while (($d,$r) = each %$single_rel_files) {
|
---|
[1027] | 169 | if (defined $ambiguous_rel_files->{$d}) {
|
---|
| 170 | print STDERR "The key $d is considered as both unambiguous and ambigous.\n";
|
---|
[1029] | 171 | print STDERR "Please fix your configuration file.\n"
|
---|
[1027] | 172 | }
|
---|
[869] | 173 | if (-f "$r" && ! -l "$r") {
|
---|
| 174 | my $tmp=pb_get_content("$r");
|
---|
[23] | 175 | # Found the only possibility.
|
---|
| 176 | # Try to get version and return
|
---|
[869] | 177 | if (defined ($distro_match->{$d})) {
|
---|
| 178 | ($release) = $tmp =~ m/$distro_match->{$d}/m;
|
---|
[23] | 179 | } else {
|
---|
[24] | 180 | print STDERR "Unable to find $d version in $r\n";
|
---|
[23] | 181 | print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
|
---|
| 182 | $release = "unknown";
|
---|
| 183 | }
|
---|
| 184 | return($d,$release);
|
---|
| 185 | }
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[423] | 188 | # Now look at ambiguous files
|
---|
[1027] | 189 | # Ubuntu before 10.04 includes a /etc/debian_version file that creates an ambiguity with debian
|
---|
[423] | 190 | # So we need to look at distros in reverse alphabetic order to treat ubuntu always first via lsb
|
---|
[869] | 191 | foreach $d (reverse keys %$ambiguous_rel_files) {
|
---|
| 192 | $r = $ambiguous_rel_files->{$d};
|
---|
| 193 | if (-f "$r" && !-l "$r") {
|
---|
[23] | 194 | # Found one possibility.
|
---|
| 195 | # Get all distros concerned by that file
|
---|
[869] | 196 | my $tmp=pb_get_content("$r");
|
---|
[24] | 197 | my $found = 0;
|
---|
[869] | 198 | my $ptr = $distro_similar->{$d};
|
---|
[423] | 199 | pb_log(2,"amb: ".Dumper($ptr)."\n");
|
---|
[24] | 200 | $release = "unknown";
|
---|
[869] | 201 | foreach my $dd (split(/,/,$ptr)) {
|
---|
[423] | 202 | pb_log(2,"check $dd\n");
|
---|
[23] | 203 | # Try to check pattern
|
---|
[869] | 204 | if (defined $distro_match->{$dd}) {
|
---|
| 205 | pb_log(2,"cmp: $distro_match->{$dd} - vs - $tmp\n");
|
---|
| 206 | ($release) = $tmp =~ m/$distro_match->{$dd}/m;
|
---|
[24] | 207 | if ((defined $release) && ($release ne "unknown")) {
|
---|
| 208 | $distro = $dd;
|
---|
| 209 | $found = 1;
|
---|
| 210 | last;
|
---|
| 211 | }
|
---|
[23] | 212 | }
|
---|
| 213 | }
|
---|
| 214 | if ($found == 0) {
|
---|
[24] | 215 | print STDERR "Unable to find $d version in $r\n";
|
---|
[23] | 216 | print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
|
---|
| 217 | $release = "unknown";
|
---|
| 218 | } else {
|
---|
| 219 | return($distro,$release);
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
| 223 | return("unknown","unknown");
|
---|
[24] | 224 | }
|
---|
[23] | 225 |
|
---|
[621] | 226 |
|
---|
| 227 | =item B<pb_distro_installdeps>
|
---|
| 228 |
|
---|
| 229 | This function install the dependencies required to build the package on an RPM based distro
|
---|
[756] | 230 | dependencies can be passed as a parameter in which case they are not computed
|
---|
[621] | 231 |
|
---|
| 232 | =cut
|
---|
| 233 |
|
---|
| 234 | sub pb_distro_installdeps {
|
---|
| 235 |
|
---|
| 236 | # SPEC file
|
---|
| 237 | my $f = shift || undef;
|
---|
| 238 | my $dtype = shift || undef;
|
---|
| 239 | my $dupd = shift || undef;
|
---|
| 240 | my $deps = shift || undef;
|
---|
| 241 |
|
---|
| 242 | # Protection
|
---|
| 243 | return if (not defined $dupd);
|
---|
| 244 |
|
---|
| 245 | # Get dependecies in the build file if not forced
|
---|
[899] | 246 | $deps = pb_distro_getdeps($f, $dtype) if (not defined $deps);
|
---|
[621] | 247 | pb_log(2,"deps: $deps\n");
|
---|
[623] | 248 | return if ((not defined $deps) || ($deps =~ /^\s*$/));
|
---|
[621] | 249 | if ($deps !~ /^[ ]*$/) {
|
---|
| 250 | pb_system("$dupd $deps","Installing dependencies ($deps)");
|
---|
| 251 | }
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | =item B<pb_distro_getdeps>
|
---|
| 255 |
|
---|
| 256 | This function computes the dependencies indicated in the build file and return them as a string of packages to install
|
---|
| 257 |
|
---|
| 258 | =cut
|
---|
| 259 |
|
---|
| 260 | sub pb_distro_getdeps {
|
---|
| 261 |
|
---|
| 262 | my $f = shift || undef;
|
---|
| 263 | my $dtype = shift || undef;
|
---|
| 264 |
|
---|
| 265 | my $regexp = "";
|
---|
| 266 | my $deps = "";
|
---|
| 267 | my $sep = $/;
|
---|
| 268 |
|
---|
| 269 | # Protection
|
---|
[622] | 270 | return("") if (not defined $dtype);
|
---|
[899] | 271 | return("") if (not defined $f);
|
---|
| 272 |
|
---|
| 273 | pb_log(3,"entering pb_distro_getdeps: $dtype - $f\n");
|
---|
[621] | 274 | if ($dtype eq "rpm") {
|
---|
| 275 | # In RPM this could include files, but we do not handle them atm.
|
---|
| 276 | $regexp = '^BuildRequires:(.*)$';
|
---|
[696] | 277 | } elsif ($dtype eq "deb") {
|
---|
[621] | 278 | $regexp = '^Build-Depends:(.*)$';
|
---|
| 279 | } elsif ($dtype eq "ebuild") {
|
---|
| 280 | $sep = '"'.$/;
|
---|
| 281 | $regexp = '^DEPEND="(.*)"\n'
|
---|
| 282 | } else {
|
---|
| 283 | # No idea
|
---|
[622] | 284 | return("");
|
---|
[621] | 285 | }
|
---|
| 286 | pb_log(2,"regexp: $regexp\n");
|
---|
| 287 |
|
---|
| 288 | # Preserve separator before using the one we need
|
---|
| 289 | my $oldsep = $/;
|
---|
| 290 | $/ = $sep;
|
---|
| 291 | open(DESC,"$f") || die "Unable to open $f";
|
---|
| 292 | while (<DESC>) {
|
---|
| 293 | pb_log(4,"read: $_\n");
|
---|
| 294 | next if (! /$regexp/);
|
---|
| 295 | chomp();
|
---|
| 296 | # What we found with the regexp is the list of deps.
|
---|
| 297 | pb_log(2,"found deps: $_\n");
|
---|
[681] | 298 | s/$regexp/$1/i;
|
---|
[698] | 299 | # Remove conditions in the middle and at the end for deb
|
---|
[931] | 300 | s/\(\s*[><=]+.*\)[^,]*,/,/g;
|
---|
[698] | 301 | s/\(\s*[><=]+.*$//g;
|
---|
| 302 | # Same for rpm
|
---|
[931] | 303 | s/[><=]+[^,]*,/,/g;
|
---|
[652] | 304 | s/[><=]+.*$//g;
|
---|
[621] | 305 | # Improve string format (remove , and spaces at start, end and in double
|
---|
[652] | 306 | s/,/ /g;
|
---|
[621] | 307 | s/^\s*//;
|
---|
| 308 | s/\s*$//;
|
---|
| 309 | s/\s+/ /g;
|
---|
| 310 | $deps .= " ".$_;
|
---|
| 311 | }
|
---|
| 312 | close(DESC);
|
---|
| 313 | $/ = $oldsep;
|
---|
| 314 | pb_log(2,"now deps: $deps\n");
|
---|
[622] | 315 | my $deps2 = pb_distro_only_deps_needed($dtype,$deps);
|
---|
| 316 | return($deps2);
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 |
|
---|
| 320 | =item B<pb_distro_only_deps_needed>
|
---|
| 321 |
|
---|
| 322 | This function returns only the dependencies not yet installed
|
---|
| 323 |
|
---|
| 324 | =cut
|
---|
| 325 |
|
---|
| 326 | sub pb_distro_only_deps_needed {
|
---|
| 327 |
|
---|
[623] | 328 | my $dtype = shift || undef;
|
---|
[622] | 329 | my $deps = shift || undef;
|
---|
| 330 |
|
---|
[623] | 331 | return("") if ((not defined $deps) || ($deps =~ /^\s*$/));
|
---|
[621] | 332 | my $deps2 = "";
|
---|
| 333 | # Avoid to install what is already there
|
---|
| 334 | foreach my $p (split(/ /,$deps)) {
|
---|
| 335 | if ($dtype eq "rpm") {
|
---|
| 336 | my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet");
|
---|
| 337 | next if ($res eq 0);
|
---|
[696] | 338 | } elsif ($dtype eq "deb") {
|
---|
[621] | 339 | my $res = pb_system("dpkg -L $p","","quiet");
|
---|
| 340 | next if ($res eq 0);
|
---|
| 341 | } elsif ($dtype eq "ebuild") {
|
---|
| 342 | } else {
|
---|
| 343 | # Not reached
|
---|
| 344 | }
|
---|
| 345 | pb_log(2,"found deps2: $p\n");
|
---|
| 346 | $deps2 .= " $p";
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | $deps2 =~ s/^\s*//;
|
---|
| 350 | pb_log(2,"now deps2: $deps2\n");
|
---|
| 351 | return($deps2);
|
---|
| 352 | }
|
---|
| 353 |
|
---|
[702] | 354 | =item B<pb_distro_setuprepo>
|
---|
| 355 |
|
---|
| 356 | This function sets up potential additional repository to the build environment
|
---|
| 357 |
|
---|
| 358 | =cut
|
---|
| 359 |
|
---|
| 360 | sub pb_distro_setuprepo {
|
---|
| 361 |
|
---|
| 362 | my $ddir = shift || undef;
|
---|
| 363 | my $dver = shift;
|
---|
| 364 | my $darch = shift;
|
---|
| 365 | my $dtype = shift || undef;
|
---|
| 366 |
|
---|
| 367 | my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","addrepo");
|
---|
| 368 | return if (not defined $addrepo);
|
---|
| 369 |
|
---|
| 370 | my $param = pb_distro_get_param($ddir,$dver,$darch,$addrepo);
|
---|
| 371 | return if ($param eq "");
|
---|
| 372 |
|
---|
| 373 | # Loop on the list of additional repo
|
---|
| 374 | foreach my $i (split(/,/,$param)) {
|
---|
| 375 |
|
---|
| 376 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($i);
|
---|
| 377 | my $bn = basename($i);
|
---|
| 378 |
|
---|
| 379 | # The repo file can be local or remote. download or copy at the right place
|
---|
| 380 | if (($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
| 381 | pb_system("wget -O $ENV{'PBTMP'}/$bn $i","Donwloading additional repository file $i");
|
---|
| 382 | } else {
|
---|
| 383 | copy($i,$ENV{'PBTMP'}/$bn);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | # The repo file can be a real file or a package
|
---|
| 387 | if ($dtype eq "rpm") {
|
---|
| 388 | if ($bn =~ /\.rpm$/) {
|
---|
[721] | 389 | my $pn = $bn;
|
---|
| 390 | $pn =~ s/\.rpm//;
|
---|
| 391 | if (pb_system("rpm -q --quiet $pn","","quiet") != 0) {
|
---|
| 392 | pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repository");
|
---|
| 393 | }
|
---|
| 394 | } elsif ($bn =~ /\.repo$/) {
|
---|
[702] | 395 | # Yum repo
|
---|
[721] | 396 | pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repos.d","Adding yum repository") if (not -f "/etc/yum.repos.d/$bn");
|
---|
[702] | 397 | } elsif ($bn =~ /\.addmedia/) {
|
---|
| 398 | # URPMI repo
|
---|
[721] | 399 | # We should test that it's not already a urpmi repo
|
---|
[702] | 400 | pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository");
|
---|
| 401 | } else {
|
---|
| 402 | pb_log(0,"Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
|
---|
| 403 | }
|
---|
| 404 | } elsif ($dtype eq "deb") {
|
---|
[721] | 405 | if (($bn =~ /\.sources.list$/) && (not -f "/etc/apt/sources.list.d/$bn")) {
|
---|
[711] | 406 | pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository");
|
---|
| 407 | pb_system("sudo apt-get update","Updating apt repository");
|
---|
[702] | 408 | } else {
|
---|
| 409 | pb_log(0,"Unable to deal with repository file $i on deb distro ! Please report to dev team\n");
|
---|
| 410 | }
|
---|
| 411 | } else {
|
---|
| 412 | pb_log(0,"Unable to deal with repository file $i on that distro ! Please report to dev team\n");
|
---|
| 413 | }
|
---|
| 414 | }
|
---|
| 415 | return;
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | =item B<pb_distro_get_param>
|
---|
| 419 |
|
---|
| 420 | This function gets the parameter in the conf file from the most precise tuple up to default
|
---|
| 421 |
|
---|
| 422 | =cut
|
---|
| 423 |
|
---|
| 424 | sub pb_distro_get_param {
|
---|
| 425 |
|
---|
| 426 | my $param = "";
|
---|
| 427 | my $ddir = shift;
|
---|
| 428 | my $dver = shift;
|
---|
| 429 | my $darch = shift;
|
---|
| 430 | my $opt = shift;
|
---|
[867] | 431 | my $dfam = shift || "unknown";
|
---|
| 432 | my $dtype = shift || "unknown";
|
---|
[702] | 433 |
|
---|
| 434 | if (defined $opt->{"$ddir-$dver-$darch"}) {
|
---|
| 435 | $param = $opt->{"$ddir-$dver-$darch"};
|
---|
| 436 | } elsif (defined $opt->{"$ddir-$dver"}) {
|
---|
| 437 | $param = $opt->{"$ddir-$dver"};
|
---|
| 438 | } elsif (defined $opt->{"$ddir"}) {
|
---|
| 439 | $param = $opt->{"$ddir"};
|
---|
[867] | 440 | } elsif (defined $opt->{$dfam}) {
|
---|
| 441 | $param = $opt->{$dfam};
|
---|
| 442 | } elsif (defined $opt->{$dtype}) {
|
---|
| 443 | $param = $opt->{$dtype};
|
---|
[702] | 444 | } elsif (defined $opt->{"default"}) {
|
---|
| 445 | $param = $opt->{"default"};
|
---|
| 446 | } else {
|
---|
[963] | 447 | $param = "";
|
---|
[702] | 448 | }
|
---|
[974] | 449 |
|
---|
[982] | 450 | # Allow replacement of variables inside the parameter such as ddir, dver, darch for rpmbootstrap
|
---|
[1029] | 451 | # but not shell variable which are backslashed
|
---|
[982] | 452 | if ($param =~ /[^\\]\$/) {
|
---|
| 453 | pb_log(3,"Expanding variable on $param\n");
|
---|
| 454 | eval { $param =~ s/(\$\w+)/$1/eeg };
|
---|
| 455 | }
|
---|
[974] | 456 |
|
---|
[982] | 457 | pb_log(2,"DEBUG: pb_distro_get_param on $ddir-$dver-$darch returns ==$param==\n");
|
---|
[702] | 458 | return($param);
|
---|
| 459 |
|
---|
| 460 | }
|
---|
[749] | 461 |
|
---|
| 462 |
|
---|
[395] | 463 | =back
|
---|
[23] | 464 |
|
---|
[395] | 465 | =head1 WEB SITES
|
---|
[23] | 466 |
|
---|
[395] | 467 | 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/>.
|
---|
| 468 |
|
---|
| 469 | =head1 USER MAILING LIST
|
---|
| 470 |
|
---|
| 471 | None exists for the moment.
|
---|
| 472 |
|
---|
| 473 | =head1 AUTHORS
|
---|
| 474 |
|
---|
| 475 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 476 |
|
---|
| 477 | =head1 COPYRIGHT
|
---|
| 478 |
|
---|
| 479 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 480 | described in the file C<COPYING> included with the distribution.
|
---|
| 481 |
|
---|
| 482 | =cut
|
---|
| 483 |
|
---|
| 484 |
|
---|
[11] | 485 | 1;
|
---|