source: ProjectBuilder/devel/pb-modules/lib/ProjectBuilder/Distribution.pm@ 1515

Last change on this file since 1515 was 1515, checked in by Bruno Cornec, 12 years ago

r4760@localhost: bruno | 2012-05-10 11:48:21 +0200

  • pb.conf: sudo does not pass through the DEBIAN_FRONTEND variable; use env to make sure it is set. Also change from --force-yes to --allow-unauthenticated (Eric Anderson)
  • Base.pm: Provide a better error message for failures of pb_mkdir_p (Eric Anderson)
  • Distribution.pm: Make sure to apply the ftp/http proxy when installing dependencies. Also add hack to try the install twice if it fails the first time. That may be unnecessary with the DEBIAN_FRONTEND fix, but doesn't hurt. (Eric Anderson)
File size: 19.3 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates common environment for distributions
4#
5# $Id$
6#
7
8package ProjectBuilder::Distribution;
9
10use strict;
11use Data::Dumper;
12use Carp 'confess';
13use ProjectBuilder::Version;
14use ProjectBuilder::Base;
15use ProjectBuilder::Conf;
16use File::Basename;
17use File::Copy;
18# requires perl 5.004 minimum in VM/VE
19use File::Compare;
20
21# Global vars
22# Inherit from the "Exporter" module which handles exporting functions.
23
24use vars qw($VERSION $REVISION @ISA @EXPORT);
25use Exporter;
26
27# Export, by default, all the functions into the namespace of
28# any code which uses this module.
29
30our @ISA = qw(Exporter);
31our @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);
32($VERSION,$REVISION) = pb_version_init();
33
34=pod
35
36=head1 NAME
37
38ProjectBuilder::Distribution, part of the project-builder.org - module dealing with distribution detection
39
40=head1 DESCRIPTION
41
42This modules provides functions to allow detection of Linux distributions, and giving back some attributes concerning them.
43
44=head1 SYNOPSIS
45
46 use ProjectBuilder::Distribution;
47
48 #
49 # Return information on the running distro
50 #
51 my $pbos = pb_distro_get_context();
52 print "distro tuple: ".Dumper($pbos->name, $pbos->ver, $pbos->fam, $pbos->type, $pbos->pbsuf, $pbos->pbupd, $pbos->pbins, $pbos->arch)."\n";
53 #
54 # Return information on the requested distro
55 #
56 my $pbos = pb_distro_get_context("ubuntu-7.10-x86_64");
57 print "distro tuple: ".Dumper($pbos->name, $pbos->ver, $pbos->fam, $pbos->type, $pbos->pbsuf, $pbos->pbupd, $pbos->pbins, $pbos->arch)."\n";
58 #
59 # Return information on the running distro
60 #
61 my ($ddir,$dver) = pb_distro_get();
62
63=head1 USAGE
64
65=over 4
66
67=item B<pb_distro_conffile>
68
69This function returns the mandatory configuration file used for distribution/OS detection
70
71=cut
72
73sub pb_distro_conffile {
74
75return("CCCC/pb.conf");
76}
77
78
79=item B<pb_distro_init>
80
81This 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.
82
83As an example, Ubuntu and Debian are in the same "du" family. As well as RedHat, RHEL, CentOS, fedora are on the same "rh" family.
84Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu and Debian have the same "deb" type of build system.
85And "fc" is the extension generated for all Fedora packages (Version will be added by pb).
86All this information is stored in an external configuration file typically at /etc/pb/pb.conf
87
88When 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.
89
90Cf: http://linuxmafia.com/faq/Admin/release-files.html
91Ideas taken from http://search.cpan.org/~kerberus/Linux-Distribution-0.14/lib/Linux/Distribution.pm
92
93=cut
94
95
96sub pb_distro_init {
97
98my $pbos = {
99 'name' => undef,
100 'version' => undef,
101 'arch' => undef,
102 'family' => "unknown",
103 'suffix' => "unknown",
104 'update' => "unknown",
105 'install' => "unknown",
106 'type' => "unknown",
107 'os' => "unknown",
108 'nover' => "false",
109 'rmdot' => "false",
110 };
111$pbos->{'name'} = shift;
112$pbos->{'version'} = shift;
113$pbos->{'arch'} = shift;
114
115# Adds conf file for distribution description
116# the location of the conf file is finalyzed at install time
117# depending whether we deal with package install or tar file install
118pb_conf_add(pb_distro_conffile());
119
120# If we don't know which distribution we're on, then guess it
121($pbos->{'name'},$pbos->{'version'}) = pb_distro_get() if ((not defined $pbos->{'name'}) || (not defined $pbos->{'version'}));
122
123# For some rare cases, typically nover ones
124$pbos->{'name'} = "unknown" if (not defined $pbos->{'name'});
125$pbos->{'version'} = "unknown" if (not defined $pbos->{'version'});
126
127# Initialize arch
128$pbos->{'arch'} = pb_get_arch() if (not defined $pbos->{'arch'});
129
130# Dig into the tuple to find the best answer
131# Do NOT factorize here, as it won't work as of now for hash creation
132$pbos->{'family'} = pb_distro_get_param($pbos,pb_conf_get("osfamily"));
133$pbos->{'type'} = pb_distro_get_param($pbos,pb_conf_get("ostype"));
134($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"));
135#($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"));
136
137# Some OS have no interesting version
138$pbos->{'version'} = "nover" if ((defined $pbos->{'nover'}) && ($pbos->{'nover'} eq "true"));
139
140# For some OS remove the . in version name for extension
141my $dver2 = $pbos->{'version'};
142$dver2 =~ s/\.//g if ((defined $pbos->{'rmdot'}) && ($pbos->{'rmdot'} eq "true"));
143
144if ((not defined $pbos->{'suffix'}) || ($pbos->{'suffix'} eq "")) {
145 # By default suffix is a concatenation of name and version
146 $pbos->{'suffix'} = ".$pbos->{'name'}$dver2"
147} else {
148 # concat just the version to what has been found
149 $pbos->{'suffix'} = ".$pbos->{'suffix'}$dver2";
150}
151
152# if ($arch eq "x86_64") {
153# $opt="--exclude=*.i?86";
154# }
155pb_log(2,"DEBUG: pb_distro_init: ".Dumper($pbos)."\n");
156
157return($pbos);
158}
159
160=item B<pb_distro_get>
161
162This 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.
163
164On my home machine it would currently report ("mandriva","2010.2").
165
166=cut
167
168sub pb_distro_get {
169
170# 1: List of files that unambiguously indicates what distro we have
171# 2: List of files that ambiguously indicates what distro we have
172# 3: Should have the same keys as the previous one. If ambiguity, which other distributions should be checked
173# 4: Matching Rg. Expr to detect distribution and version
174my ($single_rel_files, $ambiguous_rel_files,$distro_similar,$distro_match) = pb_conf_get("osrelfile","osrelambfile","osambiguous","osrelexpr");
175
176my $release;
177my $distro;
178
179# Begin to test presence of non-ambiguous files
180# that way we reduce the choice
181my ($d,$r);
182while (($d,$r) = each %$single_rel_files) {
183 if (defined $ambiguous_rel_files->{$d}) {
184 print STDERR "The key $d is considered as both unambiguous and ambigous.\n";
185 print STDERR "Please fix your configuration file.\n"
186 }
187 if (-f "$r" && ! -l "$r") {
188 my $tmp=pb_get_content("$r");
189 # Found the only possibility.
190 # Try to get version and return
191 if (defined ($distro_match->{$d})) {
192 ($release) = $tmp =~ m/$distro_match->{$d}/m;
193 } else {
194 print STDERR "Unable to find $d version in $r (non-ambiguous)\n";
195 print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
196 $release = "unknown";
197 }
198 return($d,$release);
199 }
200}
201
202# Now look at ambiguous files
203# Ubuntu before 10.04 includes a /etc/debian_version file that creates an ambiguity with debian
204# So we need to look at distros in reverse alphabetic order to treat ubuntu always first via lsb
205foreach $d (reverse keys %$ambiguous_rel_files) {
206 $r = $ambiguous_rel_files->{$d};
207 if (-f "$r" && !-l "$r") {
208 # Found one possibility.
209 # Get all distros concerned by that file
210 my $tmp=pb_get_content("$r");
211 my $found = 0;
212 my $ptr = $distro_similar->{$d};
213 pb_log(2,"amb: ".Dumper($ptr)."\n");
214 $release = "unknown";
215 foreach my $dd (split(/,/,$ptr)) {
216 pb_log(2,"check $dd\n");
217 # Try to check pattern
218 if (defined $distro_match->{$dd}) {
219 pb_log(2,"cmp: $distro_match->{$dd} - vs - $tmp\n");
220 ($release) = $tmp =~ m/$distro_match->{$dd}/m;
221 if ((defined $release) && ($release ne "unknown")) {
222 $distro = $dd;
223 $found = 1;
224 last;
225 }
226 }
227 }
228 if ($found == 0) {
229 print STDERR "Unable to find $d version in $r (ambiguous)\n";
230 print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
231 $release = "unknown";
232 } else {
233 return($distro,$release);
234 }
235 }
236}
237return("unknown","unknown");
238}
239
240=item B<pb_distro_getlsb>
241
242This function returns the 5 lsb values LSB version, distribution ID, Description, release and codename.
243As entry it takes an optional parameter to specify whether the output is short or not.
244
245=cut
246
247sub pb_distro_getlsb {
248
249my $s = shift;
250pb_log(3,"Entering pb_distro_getlsb\n");
251
252my ($ambiguous_rel_files) = pb_conf_get("osrelambfile");
253my $lsbf = $ambiguous_rel_files->{"lsb"};
254
255# LSB has not been configured.
256if (not defined $lsbf) {
257 print STDERR "no lsb entry defined for osrelambfile\n";
258 die "You modified upstream delivery and lost !\n";
259}
260
261if (-r $lsbf) {
262 my $rep = pb_get_content($lsbf);
263 # Create elementary fields
264 my ($c, $r, $d, $i, $l) = ("", "", "", "", "");
265 for my $f (split(/\n/,$rep)) {
266 pb_log(3,"Reading file part ***$f***\n");
267 $c = $f if ($f =~ /^DISTRIB_CODENAME/);
268 $c =~ s/DISTRIB_CODENAME=/Codename:\t/;
269 $r = $f if ($f =~ /^DISTRIB_RELEASE/);
270 $r =~ s/DISTRIB_RELEASE=/Release:\t/;
271 $d = $f if ($f =~ /^DISTRIB_DESCRIPTION/);
272 $d =~ s/DISTRIB_DESCRIPTION=/Description:\t/;
273 $d =~ s/"//g;
274 $i = $f if ($f =~ /^DISTRIB_ID/);
275 $i =~ s/DISTRIB_ID=/Distributor ID:\t/;
276 $l = $f if ($f =~ /^LSB_VERSION/);
277 $l =~ s/LSB_VERSION=/LSB Version:\t/;
278 }
279 my $regexp = "^[A-z ]*:[\t ]*";
280 $c =~ s/$regexp// if (defined $s);
281 $r =~ s/$regexp// if (defined $s);
282 $d =~ s/$regexp// if (defined $s);
283 $i =~ s/$regexp// if (defined $s);
284 $l =~ s/$regexp// if (defined $s);
285 return($l, $i, $d, $r, $c);
286} else {
287 print STDERR "Unable to read $lsbf file\n";
288 die "Please report to the maintainer bruno_at_project-builder.org\n";
289}
290}
291
292=item B<pb_distro_installdeps>
293
294This function install the dependencies required to build the package on a distro.
295Dependencies can be passed as a parameter in which case they are not computed
296
297=cut
298
299sub pb_distro_installdeps {
300
301# SPEC file
302my $f = shift || undef;
303my $pbos = shift;
304my $deps = shift || undef;
305
306my $ftp_proxy = pb_distro_get_param($pbos,pb_conf_get_if("ftp_proxy"));
307my $http_proxy = pb_distro_get_param($pbos,pb_conf_get_if("http_proxy"));
308
309# We do not overwrite shell settings
310$ENV{ftp_proxy} ||= $ftp_proxy;
311$ENV{http_proxy} ||= $http_proxy;
312
313# Protection
314return if (not defined $pbos->{'install'});
315
316# Get dependencies in the build file if not forced
317$deps = pb_distro_getdeps($f,$pbos) if (not defined $deps);
318pb_log(2,"deps: $deps\n");
319return if ((not defined $deps) || ($deps =~ /^\s*$/));
320
321# This may not be // proof. We should test for availability of repo and sleep if not
322my $cmd = "$pbos->{'install'} $deps";
323my $ret = pb_system($cmd, "Installing dependencies ($cmd)", undef, 1);
324# Try to accomodate deficient proxies
325if ($ret != 0) {
326 pb_system($cmd, "Re-trying installing dependencies ($cmd)");
327}
328}
329
330=item B<pb_distro_getdeps>
331
332This function computes the dependencies indicated in the build file and return them as a string of packages to install
333
334=cut
335
336sub pb_distro_getdeps {
337
338my $f = shift || undef;
339my $pbos = shift;
340
341my $regexp = "";
342my $deps = "";
343my $sep = $/;
344
345# Protection
346return("") if (not defined $pbos->{'type'});
347return("") if (not defined $f);
348
349pb_log(3,"entering pb_distro_getdeps: $pbos->{'type'} - $f\n");
350if ($pbos->{'type'} eq "rpm") {
351 # In RPM this could include files, but we do not handle them atm.
352 $regexp = '^BuildRequires:(.*)$';
353} elsif ($pbos->{'type'} eq "deb") {
354 $regexp = '^Build-Depends:(.*)$';
355} elsif ($pbos->{'type'} eq "ebuild") {
356 $sep = '"'.$/;
357 $regexp = '^DEPEND="(.*)"\n'
358} else {
359 # No idea
360 return("");
361}
362pb_log(2,"regexp: $regexp\n");
363
364# Preserve separator before using the one we need
365my $oldsep = $/;
366$/ = $sep;
367open(DESC,"$f") || die "Unable to open $f";
368while (<DESC>) {
369 pb_log(4,"read: $_\n");
370 next if (! /$regexp/);
371 chomp();
372
373 my $nextline;
374 # Support multi-lines deps for .deb
375 if ($pbos->{type} eq 'deb') {
376 while ($nextline = <DESC>) {
377 last unless $nextline =~ /^\s+(.+)$/o;
378 $_ .= $1;
379 }
380 }
381
382 # What we found with the regexp is the list of deps.
383 pb_log(2,"found deps: $_\n");
384 s/$regexp/$1/i;
385 # Remove conditions in the middle and at the end for deb
386 s/\(\s*[><=]+.*\)[^,]*,/,/g;
387 s/\(\s*[><=]+.*$//g;
388 # Same for rpm
389 s/[><=]+[^,]*,/,/g;
390 s/[><=]+.*$//g;
391 # Improve string format (remove , and spaces at start, end and in double
392 s/,/ /g;
393 s/^\s*//;
394 s/\s*$//;
395 s/\s+/ /g;
396 $deps .= " ".$_;
397
398 # Support multi-lines deps for .deb (fwup)
399 if (defined $nextline) {
400 $_ = $nextline;
401 redo;
402 }
403}
404close(DESC);
405$/ = $oldsep;
406pb_log(2,"now deps: $deps\n");
407my $deps2 = pb_distro_only_deps_needed($pbos,$deps);
408return($deps2);
409}
410
411
412=item B<pb_distro_only_deps_needed>
413
414This function returns only the dependencies not yet installed
415
416=cut
417
418sub pb_distro_only_deps_needed {
419
420my $pbos = shift;
421my $deps = shift || undef;
422
423return("") if ((not defined $deps) || ($deps =~ /^\s*$/));
424my $deps2 = "";
425# Avoid to install what is already there
426foreach my $p (split(/\s+/,$deps)) {
427 next if $p =~ /^\s*$/o;
428 if ($pbos->{'type'} eq "rpm") {
429 my $res = pb_system("rpm -q --whatprovides --quiet $p","","quiet", 1);
430 next if ($res eq 0);
431 } elsif ($pbos->{'type'} eq "deb") {
432 my $res = pb_system("dpkg -L $p","","quiet", 1);
433 next if ($res eq 0);
434 } elsif ($pbos->{'type'} eq "ebuild") {
435 } else {
436 # Not reached
437 }
438 pb_log(2,"found deps2: $p\n");
439 $deps2 .= " $p";
440}
441
442$deps2 =~ s/^\s*//;
443pb_log(2,"now deps2: $deps2\n");
444return($deps2);
445}
446
447=item B<pb_distro_setuposrepo>
448
449This function sets up potential additional repository for the setup phase
450
451=cut
452
453sub pb_distro_setuposrepo {
454
455my $pbos = shift;
456
457pb_distro_setuprepo_gen($pbos,pb_distro_conffile(),"osrepo");
458}
459
460=item B<pb_distro_setuprepo>
461
462This function sets up potential additional repository to the build environment
463
464=cut
465
466sub pb_distro_setuprepo {
467
468my $pbos = shift;
469
470pb_distro_setuprepo_gen($pbos,"$ENV{'PBDESTDIR'}/pbrc","addrepo");
471}
472
473# Internal
474sub pb_distro_compare_repo {
475
476my $src = shift;
477my $dest = shift;
478
479if (not -f $dest) {
480 pb_log(1, "Creating new file $dest");
481} elsif (-f $dest && -s $dest == 0) {
482 pb_log(1, "Overwriting empty file $dest");
483} elsif (-f $dest && compare("$src", $dest) == 0) {
484 pb_log(1, "Overwriting identical file $dest");
485} else {
486 pb_log(0, "ERROR: destination file $dest exists and is different than source $src\n");
487 pb_system("cat $dest","Dest...");
488 pb_system("cat $ENV{PBTMP}/$bn","New...");
489 pb_log("Returning...\n");
490 return(0);
491}
492# TRUE
493return(1);
494}
495
496=item B<pb_distro_setuprepo_gen>
497
498This function sets up in a generic way potential additional repository
499
500=cut
501
502sub pb_distro_setuprepo_gen {
503
504my $pbos = shift;
505my $pbconf = shift || undef;
506my $pbkey = shift || undef;
507
508return if (not defined $pbconf);
509return if (not defined $pbkey);
510my ($addrepo) = pb_conf_read($pbconf,$pbkey);
511return if (not defined $addrepo);
512
513my $param = pb_distro_get_param($pbos,$addrepo);
514return if ($param eq "");
515
516# Loop on the list of additional repo
517foreach my $i (split(/,/,$param)) {
518
519 my ($scheme, $account, $host, $port, $path) = pb_get_uri($i);
520 my $bn = basename($i);
521
522 # The repo file can be local or remote. download or copy at the right place
523 if (($scheme eq "ftp") || ($scheme eq "http")) {
524 pb_system("wget -O $ENV{'PBTMP'}/$bn $i","Downloading additional repository file $i");
525 } else {
526 copy($i,$ENV{'PBTMP'}/$bn);
527 }
528
529 # The repo file can be a real file or a package
530 if ($pbos->{'type'} eq "rpm") {
531 if ($bn =~ /\.rpm$/) {
532 my $pn = $bn;
533 $pn =~ s/\.rpm//;
534 if (pb_system("rpm -q --quiet $pn","","quiet") != 0) {
535 pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repository");
536 }
537 } elsif ($bn =~ /\.repo$/) {
538 # Yum repo
539 my $dest = "/etc/yum.repos.d/$bn";
540 return if (pb_distro_compare_repo($ENV{'PBTMP'}/$bn,$dest));
541 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repos.d","Adding yum repository") if (not -f "/etc/yum.repos.d/$bn");
542 } elsif ($bn =~ /\.addmedia/) {
543 # URPMI repo
544 # We should test that it's not already a urpmi repo
545 pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository");
546 } else {
547 pb_log(0,"ERROR: Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
548 }
549 } elsif ($pbos->{'type'} eq "deb") {
550 if ($bn =~ /\.sources.list$/) {
551 my $dest = "/etc/apt/sources.list.d/$bn";
552 return if (pb_distro_compare_repo($ENV{'PBTMP'}/$bn,$dest));
553 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository");
554 pb_system("sudo apt-get update","Updating apt repository");
555 } else {
556 pb_log(0,"ERROR: Unable to deal with repository file $i on deb distro ! Please report to dev team\n");
557 }
558 } else {
559 pb_log(0,"ERROR: Unable to deal with repository file $i on that distro ! Please report to dev team\n");
560 }
561}
562return;
563}
564
565=item B<pb_distro_get_param>
566
567This function gets the parameter in the conf file from the most precise tuple up to default
568
569=cut
570
571sub pb_distro_get_param {
572
573my @param;
574my $param;
575my $pbos = shift;
576
577pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n");
578foreach my $opt (@_) {
579 if (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) {
580 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"};
581 } elsif (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}"}) {
582 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}"};
583 } elsif (defined $opt->{"$pbos->{'name'}"}) {
584 $param = $opt->{"$pbos->{'name'}"};
585 } elsif (defined $opt->{$pbos->{'family'}}) {
586 $param = $opt->{$pbos->{'family'}};
587 } elsif (defined $opt->{$pbos->{'type'}}) {
588 $param = $opt->{$pbos->{'type'}};
589 } elsif (defined $opt->{$pbos->{'os'}}) {
590 $param = $opt->{$pbos->{'os'}};
591 } elsif (defined $opt->{"default"}) {
592 $param = $opt->{"default"};
593 } else {
594 $param = "";
595 }
596
597 # Allow replacement of variables inside the parameter such as name, version, arch for rpmbootstrap
598 # but not shell variable which are backslashed
599 if ($param =~ /[^\\]\$/) {
600 pb_log(3,"Expanding variable on $param\n");
601 eval { $param =~ s/(\$\w+->{\'\w+\'})/$1/eeg };
602 }
603 push @param,$param;
604}
605
606pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} returns ==".Dumper(@param)."==\n");
607
608# Return one param in scalar context, an array if not.
609my $nb = @param;
610if ($nb eq 1) {
611 return($param);
612} else {
613 return(@param);
614}
615}
616
617=item B<pb_distro_get_context>
618
619This function gets the OS context passed as parameter and return the corresponding distribution hash
620If passed undef or "" then auto-detects
621
622=cut
623
624
625sub pb_distro_get_context {
626
627my $os = shift;
628my $pbos;
629
630if ((defined $os) && ($os ne "")) {
631 my ($name,$ver,$darch) = split(/-/,$os);
632 pb_log(0,"Bad format for $os") if ((not defined $name) || (not defined $ver) || (not defined $darch)) ;
633 chomp($darch);
634 $pbos = pb_distro_init($name,$ver,$darch);
635} else {
636 $pbos = pb_distro_init();
637}
638return($pbos);
639}
640
641=back
642
643=head1 WEB SITES
644
645The 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/>.
646
647=head1 USER MAILING LIST
648
649None exists for the moment.
650
651=head1 AUTHORS
652
653The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
654
655=head1 COPYRIGHT
656
657Project-Builder.org is distributed under the GPL v2.0 license
658described in the file C<COPYING> included with the distribution.
659
660=cut
661
662
6631;
Note: See TracBrowser for help on using the repository browser.