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

Last change on this file was 2496, checked in by Bruno Cornec, 4 years ago

call pb_conf_init before using conf files

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