source: devel/pb-modules/bin/pbgetparam @ 2175

Last change on this file since 2175 was 2175, checked in by bruno, 18 months ago

Adds man, help and versions options to pbdistrocheck and pbgetparam

File size: 3.1 KB
Line 
1#!/usr/bin/perl -w
2#
3# Project Builder Distribution Parameter extractor
4#
5# $Id$
6#
7# Copyright B. Cornec 2007-2016
8# Provided under the GPL v2
9
10use strict 'vars';
11use Getopt::Long qw(:config auto_abbrev no_ignore_case);
12use Data::Dumper;
13use lib qw (lib);
14#use lib '/usr/share/perl5'; # mandatory for opensuse
15use ProjectBuilder::Version;
16use ProjectBuilder::Base;
17use ProjectBuilder::Env;
18use ProjectBuilder::Distribution;
19use ProjectBuilder::Conf;
20
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.
30pbdistrogetparam is a command from the pb project providing the value of the parameter for the running distribution based on the most precise tuple
31It is a CLI version of the pb_distro_get_param function
32
33=head1 SYNOPSIS
34
35pbdistrogetparam [-h][-v][-p project][-d distro-ver-arch] [param|-a]
36
37=head1 OPTIONS
38
39=over 4
40
41=item B<-h|--help>
42
43Prints this help
44
45=item B<-v|--verbose>
46
47Print a brief help message and exits.
48
49=item B<-d|--distribution>
50
51The tuple for which to print the parameter value considered (by default current distribution)
52
53=item B<-p|--project project_name>
54
55Name of the project you're working on (or use the env variable PBPROJ)
56
57=item B<-a|--all>
58
59Process all configuration parameters
60
61=back
62
63=head1 ARGUMENTS
64
65Arguments is mandatory and corresponds to the parameter whose value is requested for the related distribution tuple.
66
67=head1 WEB SITES
68
69The 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/>.
70
71=head1 USER MAILING LIST
72
73Cf: 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.
74
75=head1 CONFIGURATION FILES
76
77Uses the main /etc/pb/pb.conf (or /usr/local/etc/pb/pb.conf if installed from files) configuration file to give its answers.
78
79=head1 AUTHORS
80
81The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
82
83=head1 COPYRIGHT
84
85Project-Builder.org is distributed under the GPL v2.0 license
86described in the file C<COPYING> included with the distribution.
87
88=cut
89
90my %opts;                   # CLI Options
91
92my ($projectver,$projectrev) = pb_version_init();
93my $appname = "pbgetparam";
94
95# Initialize the syntax string
96
97pb_syntax_init("$appname Version $projectver-$projectrev\n");
98
99GetOptions(
100        "verbose|v+" => \$opts{'v'},
101        "version" => \$opts{'version'},
102        "man" => \$opts{'man'},
103        "help|h" => \$opts{'h'},
104        "all|a" => \$opts{'a'},
105        "project|p=s" => \$opts{'p'},
106        "distribution|d=s" => \$opts{'d'},
107);
108if (defined $opts{'h'}) {
109    pb_syntax(0,1);
110}
111if (defined $opts{'version'}) {
112    pb_syntax(0,0);
113}
114if (defined $opts{'man'}) {
115    pb_syntax(0,2);
116}
117if (defined $opts{'v'}) {
118    $pbdebug = $opts{'v'};
119}
120pb_log_init($pbdebug, \*STDOUT);
121
122my $dist = $opts{'d'};
123my $pbos = pb_distro_get_context($dist);
124pb_env_init($opts{'p'},0,"getconf",0);
125
126my @tab = @ARGV;
127@tab = pb_conf_get_all() if (defined $opts{'a'});
128
129pb_distro_conf_print($pbos,@tab);
Note: See TracBrowser for help on using the repository browser.