Changeset 1071 in ProjectBuilder


Ignore:
Timestamp:
Jul 12, 2010, 7:59:19 PM (14 years ago)
Author:
Bruno Cornec
Message:

r3947@sge91-1-82-234-15-218: bruno | 2010-07-10 18:40:35 +0200

  • Adds function pb_distro_getlsb and make pbdistrocheck fully lsb_release compatible
Location:
devel/pb-modules
Files:
2 edited

Legend:

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

    r1064 r1071  
    2828=head1 SYNOPSIS
    2929
    30 pbdistrocheck [-d][-v] [distro-ver-arch]
     30pbdistrocheck [-d][-v][-l [-c][-i][-r][-a]][-s] [distro-ver-arch]
    3131
    3232=head1 OPTIONS
     
    3838Print a brief help message and exits.
    3939
     40=item B<-a|--all>
     41
     42print all parameters
     43
     44=item B<-s|--short>
     45
     46generate a short format user friendly, comma separated allowing parsing
     47
     48=item B<-l|--lsb>
     49
     50generate an LSB compliant output
     51
    4052=item B<-d|--description>
    4153
    42 generate a short format user friendly
    43 (by default, generate a longer format, comma separated allowing parsing)
     54print only description (LSB only)
     55
     56=item B<-r|--release>
     57
     58print only release (LSB only)
     59
     60=item B<-c|--codename>
     61
     62print only codename (LSB only)
     63
     64=item B<-i|--id>
     65
     66print only distribution identificator (LSB only)
     67
     68=item B<-a|--all>
     69
     70print all LSB fields
    4471
    4572=back
     
    77104GetOptions(
    78105        "verbose|v+" => \$opts{'v'},
    79         "description|d" => \$opts{'d'}
     106        "short|s" => \$opts{'s'},
     107        "description|d" => \$opts{'d'},
     108        "id|i" => \$opts{'i'},
     109        "release|r" => \$opts{'r'},
     110        "codename|c" => \$opts{'c'},
     111        "all|a" => \$opts{'a'},
     112        "lsb|l" => \$opts{'l'},
    80113);
    81114if (defined $opts{'v'}) {
    82115    $pbdebug = $opts{'v'};
    83116}
    84 if (defined $opts{'l'}) {
    85     open(pbLOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
    86     $pbLOG = \*pbLOG;
    87     $pbdebug = 0  if ($pbdebug == -1);
    88     }
    89 pb_log_init($pbdebug, $pbLOG);
     117pb_log_init($pbdebug, \*STDOUT);
    90118
    91119my $dist = shift @ARGV || undef ;
     
    94122
    95123my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $arch) = pb_distro_init(@param);
    96 if (defined $opts{'d'}) {
    97     print "\u$ddir $dver $arch\n";
     124my $sep = "\n";
     125if (defined $opts{'l'}) {
     126    # Simulate lsb_release output
     127    my ($l,$i,$d,$r,$c) = pb_distro_getlsb($opts{'s'});
     128    $sep = " " if (defined $opts{'s'});
     129    print $l.$sep;
     130    print $i.$sep if (defined $opts{'i'} or defined $opts{'a'});
     131    print $d.$sep if (defined $opts{'d'} or defined $opts{'a'});
     132    print $r.$sep if (defined $opts{'r'} or defined $opts{'a'});
     133    $sep = "" if (defined $opts{'s'});
     134    print $c.$sep if (defined $opts{'c'} or defined $opts{'a'});
     135    print "\n" if (defined $opts{'s'});
    98136} else {
    99     print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch))."\n";
     137    $sep = "," if (defined $opts{'s'});
     138    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        $arch = "Arch:\t$arch";
     147        print "Project-Builder tuple:\n";
     148    }
     149    print join($sep,($dos, $ddir, $dver, $arch, $dtype, $dfam, $pbsuf, $pbupd))."\n";
    100150}
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1067 r1071  
    2323 
    2424our @ISA = qw(Exporter);
    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);
     25our @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_get_param);
    2626
    2727=pod
     
    226226}
    227227
     228=item B<pb_distro_getlsb>
     229
     230This function returns the 5 lsb values LSB version, distribution ID, Description, release and codename.
     231As entry it takes an optional parameter to specify whether the output is short or not.
     232
     233=cut
     234
     235sub pb_distro_getlsb {
     236
     237my $s = shift;
     238pb_log(3,"Entering pb_distro_getlsb\n");
     239
     240my ($ambiguous_rel_files) = pb_conf_get("osrelambfile");
     241my $lsbf = $ambiguous_rel_files->{"lsb"};
     242
     243# LSB has not been configured.
     244if (not defined $lsbf) {
     245    print STDERR "no lsb entry defined for osrelambfile\n";
     246    die "You modified upstream delivery and lost !\n";
     247}
     248
     249if (-r $lsbf) {
     250    my $rep = pb_get_content($lsbf);
     251    # Create elementary fields
     252    my ($c, $r, $d, $i, $l) = ("", "", "", "", "");
     253    for my $f (split(/\n/,$rep)) {
     254        pb_log(3,"Reading file part ***$f***\n");
     255        $c = $f if ($f =~ /^DISTRIB_CODENAME/);
     256        $c =~ s/DISTRIB_CODENAME=/Codename:\t/;
     257        $r = $f if ($f =~ /^DISTRIB_RELEASE/);
     258        $r =~ s/DISTRIB_RELEASE=/Release:\t/;
     259        $d = $f if ($f =~ /^DISTRIB_DESCRIPTION/);
     260        $d =~ s/DISTRIB_DESCRIPTION=/Description:\t/;
     261        $d =~ s/"//g;
     262        $i = $f if ($f =~ /^DISTRIB_ID/);
     263        $i =~ s/DISTRIB_ID=/Distributor ID:\t/;
     264        $l = $f if ($f =~ /^LSB_VERSION/);
     265        $l =~ s/LSB_VERSION=/LSB Version:\t/;
     266    }
     267    $c =~ s/^[A-z ]*:[\t ]*// if (defined $s);
     268    $r =~ s/^[A-z ]*:[\t ]*// if (defined $s);
     269    $d =~ s/^[A-z ]*:[\t ]*// if (defined $s);
     270    $i =~ s/^[A-z ]*:[\t ]*// if (defined $s);
     271    $l =~ s/^[A-z ]*:[\t ]*// if (defined $s);
     272    return($l, $i, $d, $r, $c);
     273} else {
     274    print STDERR "Unable to read $lsbf file\n";
     275    die "Please report to the maintainer bruno_at_project-builder.org\n";
     276}
     277}
    228278
    229279=item B<pb_distro_installdeps>
Note: See TracChangeset for help on using the changeset viewer.