source: ProjectBuilder/devel/pb-modules/bin/pbdistrocheck@ 1520

Last change on this file since 1520 was 1520, checked in by Bruno Cornec, 12 years ago
  • Fix an error introduced when isolating the new pb_distro_compare_repo function (Bruno Cornec)
  • pbdistrocheck: hack so that we can have one pb package that just works everywhere (Need a special use lib for opensuse) (Eric Anderson)
File size: 4.0 KB
RevLine 
[176]1#!/usr/bin/perl -w
2#
3# Project Builder Distribution Checker
4#
5# $Id$
6#
7# Copyright B. Cornec 2007
8# Provided under the GPL v2
9
10use strict 'vars';
[423]11use Getopt::Long qw(:config auto_abbrev no_ignore_case);
[176]12use Data::Dumper;
13use lib qw (lib);
[1520]14use lib '/usr/share/perl5'; # mandatory for opensuse
[423]15use ProjectBuilder::Distribution;
16use ProjectBuilder::Base;
[176]17
[969]18=pod
19
20=head1 NAME
21
22pb, aka project-builder.org - builds packages for your projects
23
24=head1 DESCRIPTION
25
26pb helps you build various packages directly from your project sources.
27pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
28
29=head1 SYNOPSIS
30
[1071]31pbdistrocheck [-d][-v][-l [-c][-i][-r][-a]][-s] [distro-ver-arch]
[969]32
33=head1 OPTIONS
34
35=over 4
36
37=item B<-v|--verbose>
38
39Print a brief help message and exits.
40
[1071]41=item B<-a|--all>
42
43print all parameters
44
45=item B<-s|--short>
46
47generate a short format user friendly, comma separated allowing parsing
48
49=item B<-l|--lsb>
50
51generate an LSB compliant output
52
[969]53=item B<-d|--description>
54
[1071]55print only description (LSB only)
[969]56
[1071]57=item B<-r|--release>
58
59print only release (LSB only)
60
61=item B<-c|--codename>
62
63print only codename (LSB only)
64
65=item B<-i|--id>
66
67print only distribution identificator (LSB only)
68
69=item B<-a|--all>
70
71print all LSB fields
72
[969]73=back
74
75=head1 ARGUMENTS
76
77arguments are optional. If none given, analyzes the underlying operating system
78If one is given, it should have the format osname-version-architecture, and in that case pbdistrocheck will provide all the information related to that OS needed by pb.
79
80=head1 WEB SITES
81
82The 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/>.
83
84=head1 USER MAILING LIST
85
86Cf: L<http://www.mondorescue.org/sympa/info/pb-announce> for announces and L<http://www.mondorescue.org/sympa/info/pb-devel> for the development of the pb project.
87
88=head1 CONFIGURATION FILES
89
90Uses the main /etc/pb/pb.conf (or /usr/local/etc/pb/pb.conf if installed from files) configuration file to give its answers.
91
92=head1 AUTHORS
93
94The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
95
96=head1 COPYRIGHT
97
98Project-Builder.org is distributed under the GPL v2.0 license
99described in the file C<COPYING> included with the distribution.
100
101=cut
102
[423]103my %opts; # CLI Options
104
[839]105GetOptions(
106 "verbose|v+" => \$opts{'v'},
[1071]107 "short|s" => \$opts{'s'},
108 "description|d" => \$opts{'d'},
109 "id|i" => \$opts{'i'},
110 "release|r" => \$opts{'r'},
111 "codename|c" => \$opts{'c'},
112 "all|a" => \$opts{'a'},
113 "lsb|l" => \$opts{'l'},
[839]114);
[423]115if (defined $opts{'v'}) {
[495]116 $pbdebug = $opts{'v'};
[423]117}
[1071]118pb_log_init($pbdebug, \*STDOUT);
[423]119
[969]120my $dist = shift @ARGV || undef ;
[1177]121my $pbos = pb_distro_get_context($dist);
[1071]122my $sep = "\n";
123if (defined $opts{'l'}) {
124 # Simulate lsb_release output
125 my ($l,$i,$d,$r,$c) = pb_distro_getlsb($opts{'s'});
126 $sep = " " if (defined $opts{'s'});
127 print $l.$sep;
128 print $i.$sep if (defined $opts{'i'} or defined $opts{'a'});
129 print $d.$sep if (defined $opts{'d'} or defined $opts{'a'});
130 print $r.$sep if (defined $opts{'r'} or defined $opts{'a'});
131 $sep = "" if (defined $opts{'s'});
132 print $c.$sep if (defined $opts{'c'} or defined $opts{'a'});
133 print "\n" if (defined $opts{'s'});
[839]134} else {
[1071]135 $sep = "," if (defined $opts{'s'});
136 if (not defined $opts{'s'}) {
[1177]137 $pbos->{'os'} = "OS:\t$pbos->{'os'}";
138 $pbos->{'name'} = "Name:\t$pbos->{'name'}";
139 $pbos->{'version'} = "Ver:\t$pbos->{'version'}";
140 $pbos->{'family'} = "Family:\t$pbos->{'family'}";
141 $pbos->{'type'} = "Type:\t$pbos->{'type'}";
142 $pbos->{'suffix'} = "Suffix:\t$pbos->{'suffix'}";
143 $pbos->{'update'} = "Update:\t$pbos->{'update'}";
144 $pbos->{'install'} = "Install:\t$pbos->{'install'}";
145 $pbos->{'arch'} = "Arch:\t$pbos->{'arch'}";
[1071]146 print "Project-Builder tuple:\n";
147 }
[1177]148 print join($sep,($pbos->{'os'}, $pbos->{'name'}, $pbos->{'version'}, $pbos->{'arch'}, $pbos->{'type'}, $pbos->{'family'}, $pbos->{'suffix'}, $pbos->{'update'}, $pbos->{'install'}))."\n";
[839]149}
Note: See TracBrowser for help on using the repository browser.