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

Last change on this file since 2241 was 2241, checked in by Bruno Cornec, 7 years ago

revert last commit as this is not ready yet for integration in that tree !

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