[1690] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Project Builder Distribution Parameter extractor
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
[2032] | 7 | # Copyright B. Cornec 2007-2016
|
---|
[1690] | 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
|
---|
[2175] | 15 | use ProjectBuilder::Version;
|
---|
[1690] | 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.
|
---|
[2223] | 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
|
---|
[1690] | 31 | It is a CLI version of the pb_distro_get_param function
|
---|
| 32 |
|
---|
| 33 | =head1 SYNOPSIS
|
---|
| 34 |
|
---|
[2223] | 35 | pbgetparam [-h][-v][-p project][-d distro-ver-arch] [param|-a]
|
---|
[1690] | 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 |
|
---|
[1694] | 57 | =item B<-a|--all>
|
---|
| 58 |
|
---|
| 59 | Process all configuration parameters
|
---|
| 60 |
|
---|
[1690] | 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 |
|
---|
[2279] | 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.
|
---|
[1690] | 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 |
|
---|
[2175] | 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 |
|
---|
[1690] | 99 | GetOptions(
|
---|
| 100 | "verbose|v+" => \$opts{'v'},
|
---|
[2175] | 101 | "version" => \$opts{'version'},
|
---|
| 102 | "man" => \$opts{'man'},
|
---|
[1690] | 103 | "help|h" => \$opts{'h'},
|
---|
[1694] | 104 | "all|a" => \$opts{'a'},
|
---|
[1690] | 105 | "project|p=s" => \$opts{'p'},
|
---|
[1694] | 106 | "distribution|d=s" => \$opts{'d'},
|
---|
[1690] | 107 | );
|
---|
[1694] | 108 | if (defined $opts{'h'}) {
|
---|
[2175] | 109 | pb_syntax(0,1);
|
---|
[1694] | 110 | }
|
---|
[2175] | 111 | if (defined $opts{'version'}) {
|
---|
| 112 | pb_syntax(0,0);
|
---|
| 113 | }
|
---|
[1694] | 114 | if (defined $opts{'man'}) {
|
---|
| 115 | pb_syntax(0,2);
|
---|
| 116 | }
|
---|
[1690] | 117 | if (defined $opts{'v'}) {
|
---|
| 118 | $pbdebug = $opts{'v'};
|
---|
| 119 | }
|
---|
| 120 | pb_log_init($pbdebug, \*STDOUT);
|
---|
| 121 |
|
---|
| 122 | my $dist = $opts{'d'};
|
---|
[2153] | 123 | my $pbos = pb_distro_get_context($dist);
|
---|
[2151] | 124 | pb_env_init($opts{'p'},0,"getconf",0);
|
---|
[1694] | 125 |
|
---|
| 126 | my @tab = @ARGV;
|
---|
| 127 | @tab = pb_conf_get_all() if (defined $opts{'a'});
|
---|
| 128 |
|
---|
[2153] | 129 | pb_distro_conf_print($pbos,@tab);
|
---|