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 |
|
---|
10 | use strict 'vars';
|
---|
11 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
12 | use Data::Dumper;
|
---|
13 | use lib qw (lib);
|
---|
14 | #use lib '/usr/share/perl5'; # mandatory for opensuse
|
---|
15 | use ProjectBuilder::Version;
|
---|
16 | use ProjectBuilder::Base;
|
---|
17 | use ProjectBuilder::Env;
|
---|
18 | use ProjectBuilder::Distribution;
|
---|
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 | pbgetparam is a command from the pb project providing the value of the parameter for the running distribution based on the most precise tuple
|
---|
31 | It is a CLI version of the pb_distro_get_param function
|
---|
32 |
|
---|
33 | =head1 SYNOPSIS
|
---|
34 |
|
---|
35 | pbgetparam [-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 |
|
---|
43 | Prints this help
|
---|
44 |
|
---|
45 | =item B<-v|--verbose>
|
---|
46 |
|
---|
47 | Print a brief help message and exits.
|
---|
48 |
|
---|
49 | =item B<-d|--distribution>
|
---|
50 |
|
---|
51 | The tuple for which to print the parameter value considered (by default current distribution)
|
---|
52 |
|
---|
53 | =item B<-p|--project project_name>
|
---|
54 |
|
---|
55 | Name of the project you're working on (or use the env variable PBPROJ)
|
---|
56 |
|
---|
57 | =item B<-a|--all>
|
---|
58 |
|
---|
59 | Process all configuration parameters
|
---|
60 |
|
---|
61 | =back
|
---|
62 |
|
---|
63 | =head1 ARGUMENTS
|
---|
64 |
|
---|
65 | Arguments is mandatory and corresponds to the parameter whose value is requested for the related distribution tuple.
|
---|
66 |
|
---|
67 | =head1 WEB SITES
|
---|
68 |
|
---|
69 | 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/>.
|
---|
70 |
|
---|
71 | =head1 USER MAILING LIST
|
---|
72 |
|
---|
73 | 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.
|
---|
74 |
|
---|
75 | =head1 CONFIGURATION FILES
|
---|
76 |
|
---|
77 | Uses the main /etc/pb/pb.yml (or /usr/local/etc/pb/pb.yml if installed from files) configuration file to give its answers.
|
---|
78 |
|
---|
79 | =head1 AUTHORS
|
---|
80 |
|
---|
81 | The 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 |
|
---|
85 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
86 | described in the file C<COPYING> included with the distribution.
|
---|
87 |
|
---|
88 | =cut
|
---|
89 |
|
---|
90 | my %opts; # CLI Options
|
---|
91 |
|
---|
92 | my ($projectver,$projectrev) = pb_version_init();
|
---|
93 | my $appname = "pbgetparam";
|
---|
94 |
|
---|
95 | # Initialize the syntax string
|
---|
96 |
|
---|
97 | pb_syntax_init("$appname Version $projectver-$projectrev\n");
|
---|
98 |
|
---|
99 | GetOptions(
|
---|
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 | );
|
---|
108 | if (defined $opts{'h'}) {
|
---|
109 | pb_syntax(0,1);
|
---|
110 | }
|
---|
111 | if (defined $opts{'version'}) {
|
---|
112 | pb_syntax(0,0);
|
---|
113 | }
|
---|
114 | if (defined $opts{'man'}) {
|
---|
115 | pb_syntax(0,2);
|
---|
116 | }
|
---|
117 | if (defined $opts{'v'}) {
|
---|
118 | $pbdebug = $opts{'v'};
|
---|
119 | }
|
---|
120 | pb_log_init($pbdebug, \*STDOUT);
|
---|
121 |
|
---|
122 | my $dist = $opts{'d'};
|
---|
123 | my $pbos = pb_distro_get_context($dist);
|
---|
124 | pb_env_init($opts{'p'},0,"getconf",0);
|
---|
125 |
|
---|
126 | my @tab = @ARGV;
|
---|
127 | @tab = pb_conf_get_all() if (defined $opts{'a'});
|
---|
128 |
|
---|
129 | pb_distro_conf_print($pbos,@tab);
|
---|