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

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

r4764@localhost: bruno | 2012-05-10 15:13:10 +0200

  • Distribution.pm: Fix the code to check to see if a package is installed. dpkg -L <package> can succeed on an installed but not configured package, however, dpkg-buildpackage will later fail. Fix is to check that the package is in the ii state. (Eric Anderson)
File size: 19.5 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 open(CMD,"dpkg -l $p |") or die "Unable to run dpkg -l $p: $!";
435 my $ok = 0;
436 while (<CMD>) {
437 $ok = 1 if /^ii\s+$p/;
438 }
439 next if $ok;
440 } elsif ($pbos->{'type'} eq "ebuild") {
441 } else {
442 # Not reached
443 }
444 pb_log(2,"found deps2: $p\n");
445 $deps2 .= " $p";
446}
447
448$deps2 =~ s/^\s*//;
449pb_log(2,"now deps2: $deps2\n");
450return($deps2);
451}
452
453=item B<pb_distro_setuposrepo>
454
455This function sets up potential additional repository for the setup phase
456
457=cut
458
459sub pb_distro_setuposrepo {
460
461my $pbos = shift;
462
463pb_distro_setuprepo_gen($pbos,pb_distro_conffile(),"osrepo");
464}
465
466=item B<pb_distro_setuprepo>
467
468This function sets up potential additional repository to the build environment
469
470=cut
471
472sub pb_distro_setuprepo {
473
474my $pbos = shift;
475
476pb_distro_setuprepo_gen($pbos,"$ENV{'PBDESTDIR'}/pbrc","addrepo");
477}
478
479# Internal
480sub pb_distro_compare_repo {
481
482my $src = shift;
483my $dest = shift;
484
485if (not -f $dest) {
486 pb_log(1, "Creating new file $dest");
487} elsif (-f $dest && -s $dest == 0) {
488 pb_log(1, "Overwriting empty file $dest");
489} elsif (-f $dest && compare("$src", $dest) == 0) {
490 pb_log(1, "Overwriting identical file $dest");
491} else {
492 pb_log(0, "ERROR: destination file $dest exists and is different than source $src\n");
493 pb_system("cat $dest","Dest...");
494 pb_system("cat $ENV{PBTMP}/$bn","New...");
495 pb_log("Returning...\n");
496 return(0);
497}
498# TRUE
499return(1);
500}
501
502=item B<pb_distro_setuprepo_gen>
503
504This function sets up in a generic way potential additional repository
505
506=cut
507
508sub pb_distro_setuprepo_gen {
509
510my $pbos = shift;
511my $pbconf = shift || undef;
512my $pbkey = shift || undef;
513
514return if (not defined $pbconf);
515return if (not defined $pbkey);
516my ($addrepo) = pb_conf_read($pbconf,$pbkey);
517return if (not defined $addrepo);
518
519my $param = pb_distro_get_param($pbos,$addrepo);
520return if ($param eq "");
521
522# Loop on the list of additional repo
523foreach my $i (split(/,/,$param)) {
524
525 my ($scheme, $account, $host, $port, $path) = pb_get_uri($i);
526 my $bn = basename($i);
527
528 # The repo file can be local or remote. download or copy at the right place
529 if (($scheme eq "ftp") || ($scheme eq "http")) {
530 pb_system("wget -O $ENV{'PBTMP'}/$bn $i","Downloading additional repository file $i");
531 } else {
532 copy($i,$ENV{'PBTMP'}/$bn);
533 }
534
535 # The repo file can be a real file or a package
536 if ($pbos->{'type'} eq "rpm") {
537 if ($bn =~ /\.rpm$/) {
538 my $pn = $bn;
539 $pn =~ s/\.rpm//;
540 if (pb_system("rpm -q --quiet $pn","","quiet") != 0) {
541 pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repository");
542 }
543 } elsif ($bn =~ /\.repo$/) {
544 # Yum repo
545 my $dest = "/etc/yum.repos.d/$bn";
546 return if (pb_distro_compare_repo($ENV{'PBTMP'}/$bn,$dest));
547 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repos.d","Adding yum repository") if (not -f "/etc/yum.repos.d/$bn");
548 } elsif ($bn =~ /\.addmedia/) {
549 # URPMI repo
550 # We should test that it's not already a urpmi repo
551 pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository");
552 } else {
553 pb_log(0,"ERROR: Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
554 }
555 } elsif ($pbos->{'type'} eq "deb") {
556 if ($bn =~ /\.sources.list$/) {
557 my $dest = "/etc/apt/sources.list.d/$bn";
558 return if (pb_distro_compare_repo($ENV{'PBTMP'}/$bn,$dest));
559 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository");
560 pb_system("sudo apt-get update","Updating apt repository");
561 } else {
562 pb_log(0,"ERROR: Unable to deal with repository file $i on deb distro ! Please report to dev team\n");
563 }
564 } else {
565 pb_log(0,"ERROR: Unable to deal with repository file $i on that distro ! Please report to dev team\n");
566 }
567}
568return;
569}
570
571=item B<pb_distro_get_param>
572
573This function gets the parameter in the conf file from the most precise tuple up to default
574
575=cut
576
577sub pb_distro_get_param {
578
579my @param;
580my $param;
581my $pbos = shift;
582
583pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n");
584foreach my $opt (@_) {
585 if (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) {
586 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"};
587 } elsif (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}"}) {
588 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}"};
589 } elsif (defined $opt->{"$pbos->{'name'}"}) {
590 $param = $opt->{"$pbos->{'name'}"};
591 } elsif (defined $opt->{$pbos->{'family'}}) {
592 $param = $opt->{$pbos->{'family'}};
593 } elsif (defined $opt->{$pbos->{'type'}}) {
594 $param = $opt->{$pbos->{'type'}};
595 } elsif (defined $opt->{$pbos->{'os'}}) {
596 $param = $opt->{$pbos->{'os'}};
597 } elsif (defined $opt->{"default"}) {
598 $param = $opt->{"default"};
599 } else {
600 $param = "";
601 }
602
603 # Allow replacement of variables inside the parameter such as name, version, arch for rpmbootstrap
604 # but not shell variable which are backslashed
605 if ($param =~ /[^\\]\$/) {
606 pb_log(3,"Expanding variable on $param\n");
607 eval { $param =~ s/(\$\w+->{\'\w+\'})/$1/eeg };
608 }
609 push @param,$param;
610}
611
612pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} returns ==".Dumper(@param)."==\n");
613
614# Return one param in scalar context, an array if not.
615my $nb = @param;
616if ($nb eq 1) {
617 return($param);
618} else {
619 return(@param);
620}
621}
622
623=item B<pb_distro_get_context>
624
625This function gets the OS context passed as parameter and return the corresponding distribution hash
626If passed undef or "" then auto-detects
627
628=cut
629
630
631sub pb_distro_get_context {
632
633my $os = shift;
634my $pbos;
635
636if ((defined $os) && ($os ne "")) {
637 my ($name,$ver,$darch) = split(/-/,$os);
638 pb_log(0,"Bad format for $os") if ((not defined $name) || (not defined $ver) || (not defined $darch)) ;
639 chomp($darch);
640 $pbos = pb_distro_init($name,$ver,$darch);
641} else {
642 $pbos = pb_distro_init();
643}
644return($pbos);
645}
646
647=back
648
649=head1 WEB SITES
650
651The 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/>.
652
653=head1 USER MAILING LIST
654
655None exists for the moment.
656
657=head1 AUTHORS
658
659The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
660
661=head1 COPYRIGHT
662
663Project-Builder.org is distributed under the GPL v2.0 license
664described in the file C<COPYING> included with the distribution.
665
666=cut
667
668
6691;
Note: See TracBrowser for help on using the repository browser.