| 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 |
|
|---|
| 11 | use strict 'vars';
|
|---|
| 12 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
|---|
| 13 | use Data::Dumper;
|
|---|
| 14 | use lib qw (lib);
|
|---|
| 15 | #use lib '/usr/share/perl5'; # mandatory for opensuse
|
|---|
| 16 | use ProjectBuilder::Version;
|
|---|
| 17 | use ProjectBuilder::Distribution;
|
|---|
| 18 | use ProjectBuilder::Base;
|
|---|
| 19 |
|
|---|
| 20 | =pod
|
|---|
| 21 |
|
|---|
| 22 | =head1 NAME
|
|---|
| 23 |
|
|---|
| 24 | pb, aka project-builder.org - builds packages for your projects
|
|---|
| 25 |
|
|---|
| 26 | =head1 DESCRIPTION
|
|---|
| 27 |
|
|---|
| 28 | pb helps you build various packages directly from your project sources.
|
|---|
| 29 | pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
|
|---|
| 30 |
|
|---|
| 31 | =head1 SYNOPSIS
|
|---|
| 32 |
|
|---|
| 33 | pbdistrocheck [-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 |
|
|---|
| 41 | Prints this help
|
|---|
| 42 |
|
|---|
| 43 | =item B<-v|--verbose>
|
|---|
| 44 |
|
|---|
| 45 | Print a brief help message and exits.
|
|---|
| 46 |
|
|---|
| 47 | =item B<-a|--all>
|
|---|
| 48 |
|
|---|
| 49 | Print all parameters
|
|---|
| 50 |
|
|---|
| 51 | =item B<-s|--short>
|
|---|
| 52 |
|
|---|
| 53 | Generate a short format user friendly, comma separated allowing parsing
|
|---|
| 54 |
|
|---|
| 55 | =item B<-l|--lsb>
|
|---|
| 56 |
|
|---|
| 57 | Generate an LSB compliant output
|
|---|
| 58 |
|
|---|
| 59 | =item B<-d|--description>
|
|---|
| 60 |
|
|---|
| 61 | Print only description (LSB only)
|
|---|
| 62 |
|
|---|
| 63 | =item B<-r|--release>
|
|---|
| 64 |
|
|---|
| 65 | Print only release (LSB only)
|
|---|
| 66 |
|
|---|
| 67 | =item B<-c|--codename>
|
|---|
| 68 |
|
|---|
| 69 | Print only codename (LSB only)
|
|---|
| 70 |
|
|---|
| 71 | =item B<-i|--id>
|
|---|
| 72 |
|
|---|
| 73 | Print only distribution identificator (LSB only)
|
|---|
| 74 |
|
|---|
| 75 | =item B<-a|--all>
|
|---|
| 76 |
|
|---|
| 77 | Print all LSB fields
|
|---|
| 78 |
|
|---|
| 79 | =back
|
|---|
| 80 |
|
|---|
| 81 | =head1 ARGUMENTS
|
|---|
| 82 |
|
|---|
| 83 | Arguments are optional. If none given, analyzes the underlying operating system
|
|---|
| 84 | If 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 |
|
|---|
| 88 | 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/>.
|
|---|
| 89 |
|
|---|
| 90 | =head1 USER MAILING LIST
|
|---|
| 91 |
|
|---|
| 92 | 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.
|
|---|
| 93 |
|
|---|
| 94 | =head1 CONFIGURATION FILES
|
|---|
| 95 |
|
|---|
| 96 | Uses the main /etc/pb/pb.yml (or /usr/local/etc/pb/pb.yml if installed from files) configuration file to give its answers.
|
|---|
| 97 |
|
|---|
| 98 | =head1 AUTHORS
|
|---|
| 99 |
|
|---|
| 100 | The 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 |
|
|---|
| 104 | Project-Builder.org is distributed under the GPL v2.0 license
|
|---|
| 105 | described in the file C<COPYING> included with the distribution.
|
|---|
| 106 |
|
|---|
| 107 | =cut
|
|---|
| 108 |
|
|---|
| 109 | my %opts; # CLI Options
|
|---|
| 110 |
|
|---|
| 111 | my ($projectver,$projectrev) = pb_version_init();
|
|---|
| 112 | my $appname = "pbgetparam";
|
|---|
| 113 |
|
|---|
| 114 | # Initialize the syntax string
|
|---|
| 115 |
|
|---|
| 116 | pb_syntax_init("$appname Version $projectver-$projectrev\n");
|
|---|
| 117 |
|
|---|
| 118 | GetOptions(
|
|---|
| 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 | );
|
|---|
| 131 | if (defined $opts{'h'}) {
|
|---|
| 132 | pb_syntax(0,1);
|
|---|
| 133 | }
|
|---|
| 134 | if (defined $opts{'version'}) {
|
|---|
| 135 | pb_syntax(0,0);
|
|---|
| 136 | }
|
|---|
| 137 | if (defined $opts{'man'}) {
|
|---|
| 138 | pb_syntax(0,2);
|
|---|
| 139 | }
|
|---|
| 140 | if (defined $opts{'v'}) {
|
|---|
| 141 | $pbdebug = $opts{'v'};
|
|---|
| 142 | }
|
|---|
| 143 | pb_log_init($pbdebug, \*STDOUT);
|
|---|
| 144 |
|
|---|
| 145 | my $dist = shift @ARGV || undef ;
|
|---|
| 146 | my $pbos = pb_distro_get_context($dist);
|
|---|
| 147 | my $sep = "\n";
|
|---|
| 148 | if (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 | }
|
|---|