1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Project Builder Distribution Checker
|
---|
4 | #
|
---|
5 | # $Id$
|
---|
6 | #
|
---|
7 | # Copyright B. Cornec 2007-today
|
---|
8 | # Eric Anderson's changes are (c) Copyright 2012 Hewlett Packard
|
---|
9 | # Provided under the GPL v2
|
---|
10 |
|
---|
11 | use strict 'vars';
|
---|
12 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
13 | use Data::Dumper;
|
---|
14 | use lib qw (lib);
|
---|
15 | #use lib '/usr/share/perl5'; # mandatory for opensuse
|
---|
16 | use ProjectBuilder::Version;
|
---|
17 | use ProjectBuilder::Distribution;
|
---|
18 | use ProjectBuilder::Base;
|
---|
19 | use ProjectBuilder::Conf;
|
---|
20 |
|
---|
21 | =pod
|
---|
22 |
|
---|
23 | =head1 NAME
|
---|
24 |
|
---|
25 | pb, aka project-builder.org - builds packages for your projects
|
---|
26 |
|
---|
27 | =head1 DESCRIPTION
|
---|
28 |
|
---|
29 | pb helps you build various packages directly from your project sources.
|
---|
30 | pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
|
---|
31 |
|
---|
32 | =head1 SYNOPSIS
|
---|
33 |
|
---|
34 | pbdistrocheck [-h][-d][-v][-l [-c][-i][-r][-a]][-s] [distro-ver-arch]
|
---|
35 |
|
---|
36 | =head1 OPTIONS
|
---|
37 |
|
---|
38 | =over 4
|
---|
39 |
|
---|
40 | =item B<-h|--help>
|
---|
41 |
|
---|
42 | Prints this help
|
---|
43 |
|
---|
44 | =item B<-v|--verbose>
|
---|
45 |
|
---|
46 | Print a brief help message and exits.
|
---|
47 |
|
---|
48 | =item B<-a|--all>
|
---|
49 |
|
---|
50 | Print all parameters
|
---|
51 |
|
---|
52 | =item B<-s|--short>
|
---|
53 |
|
---|
54 | Generate a short format user friendly, comma separated allowing parsing
|
---|
55 |
|
---|
56 | =item B<-l|--lsb>
|
---|
57 |
|
---|
58 | Generate an LSB compliant output
|
---|
59 |
|
---|
60 | =item B<-d|--description>
|
---|
61 |
|
---|
62 | Print only description (LSB only)
|
---|
63 |
|
---|
64 | =item B<-r|--release>
|
---|
65 |
|
---|
66 | Print only release (LSB only)
|
---|
67 |
|
---|
68 | =item B<-c|--codename>
|
---|
69 |
|
---|
70 | Print only codename (LSB only)
|
---|
71 |
|
---|
72 | =item B<-i|--id>
|
---|
73 |
|
---|
74 | Print only distribution identificator (LSB only)
|
---|
75 |
|
---|
76 | =item B<-a|--all>
|
---|
77 |
|
---|
78 | Print all LSB fields
|
---|
79 |
|
---|
80 | =back
|
---|
81 |
|
---|
82 | =head1 ARGUMENTS
|
---|
83 |
|
---|
84 | Arguments are optional. If none given, analyzes the underlying operating system
|
---|
85 | If 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.
|
---|
86 |
|
---|
87 | =head1 WEB SITES
|
---|
88 |
|
---|
89 | 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/>.
|
---|
90 |
|
---|
91 | =head1 USER MAILING LIST
|
---|
92 |
|
---|
93 | Cf: 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.
|
---|
94 |
|
---|
95 | =head1 CONFIGURATION FILES
|
---|
96 |
|
---|
97 | Uses the main /etc/pb/pb.yml (or /usr/local/etc/pb/pb.yml if installed from files) configuration file to give its answers.
|
---|
98 |
|
---|
99 | =head1 AUTHORS
|
---|
100 |
|
---|
101 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
102 |
|
---|
103 | =head1 COPYRIGHT
|
---|
104 |
|
---|
105 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
106 | described in the file C<COPYING> included with the distribution.
|
---|
107 |
|
---|
108 | =cut
|
---|
109 |
|
---|
110 | my %opts; # CLI Options
|
---|
111 |
|
---|
112 | my ($projectbuilderver,$projectbuilderrev,$projectbuilderconfver) = pb_version_init();
|
---|
113 | my $appname = "pbdistrocheck";
|
---|
114 |
|
---|
115 | # Initialize the syntax string
|
---|
116 |
|
---|
117 | pb_syntax_init("$appname Version $projectbuilderver-$projectbuilderrev\n");
|
---|
118 | pb_temp_init();
|
---|
119 | pb_conf_init($appname);
|
---|
120 |
|
---|
121 | GetOptions(
|
---|
122 | "verbose|v+" => \$opts{'v'},
|
---|
123 | "version" => \$opts{'version'},
|
---|
124 | "man" => \$opts{'man'},
|
---|
125 | "help|h" => \$opts{'h'},
|
---|
126 | "short|s" => \$opts{'s'},
|
---|
127 | "description|d" => \$opts{'d'},
|
---|
128 | "id|i" => \$opts{'i'},
|
---|
129 | "release|r" => \$opts{'r'},
|
---|
130 | "codename|c" => \$opts{'c'},
|
---|
131 | "all|a" => \$opts{'a'},
|
---|
132 | "lsb|l" => \$opts{'l'},
|
---|
133 | );
|
---|
134 | if (defined $opts{'h'}) {
|
---|
135 | pb_syntax(0,1);
|
---|
136 | }
|
---|
137 | if (defined $opts{'version'}) {
|
---|
138 | pb_syntax(0,0);
|
---|
139 | }
|
---|
140 | if (defined $opts{'man'}) {
|
---|
141 | pb_syntax(0,2);
|
---|
142 | }
|
---|
143 | if (defined $opts{'v'}) {
|
---|
144 | $pbdebug = $opts{'v'};
|
---|
145 | }
|
---|
146 | pb_log_init($pbdebug, \*STDOUT);
|
---|
147 |
|
---|
148 | my $dist = shift @ARGV || undef ;
|
---|
149 | my $pbos = pb_distro_get_context($dist);
|
---|
150 | my $sep = "\n";
|
---|
151 | if (defined $opts{'l'}) {
|
---|
152 | # Simulate lsb_release output
|
---|
153 | my ($l,$i,$d,$r,$c) = pb_distro_getlsb($opts{'s'});
|
---|
154 | $sep = " " if (defined $opts{'s'});
|
---|
155 | print $l.$sep;
|
---|
156 | print $i.$sep if (defined $opts{'i'} or defined $opts{'a'});
|
---|
157 | print $d.$sep if (defined $opts{'d'} or defined $opts{'a'});
|
---|
158 | print $r.$sep if (defined $opts{'r'} or defined $opts{'a'});
|
---|
159 | $sep = "" if (defined $opts{'s'});
|
---|
160 | print $c.$sep if (defined $opts{'c'} or defined $opts{'a'});
|
---|
161 | print "\n" if (defined $opts{'s'});
|
---|
162 | } else {
|
---|
163 | $sep = "," if (defined $opts{'s'});
|
---|
164 | if (not defined $opts{'s'}) {
|
---|
165 | $pbos->{'os'} = "OS:\t$pbos->{'os'}";
|
---|
166 | $pbos->{'name'} = "Name:\t$pbos->{'name'}";
|
---|
167 | $pbos->{'version'} = "Ver:\t$pbos->{'version'}";
|
---|
168 | $pbos->{'family'} = "Family:\t$pbos->{'family'}";
|
---|
169 | $pbos->{'type'} = "Type:\t$pbos->{'type'}";
|
---|
170 | $pbos->{'suffix'} = "Suffix:\t$pbos->{'suffix'}";
|
---|
171 | $pbos->{'update'} = "Update:\t$pbos->{'update'}";
|
---|
172 | $pbos->{'install'} = "Install:\t$pbos->{'install'}";
|
---|
173 | $pbos->{'arch'} = "Arch:\t$pbos->{'arch'}";
|
---|
174 | print "Project-Builder tuple:\n";
|
---|
175 | }
|
---|
176 | print join($sep,($pbos->{'os'}, $pbos->{'name'}, $pbos->{'version'}, $pbos->{'arch'}, $pbos->{'type'}, $pbos->{'family'}, $pbos->{'suffix'}, $pbos->{'update'}, $pbos->{'install'}))."\n";
|
---|
177 | }
|
---|