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

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