[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 |
|
---|
| 11 | use strict 'vars';
|
---|
[423] | 12 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
[176] | 13 | use Data::Dumper;
|
---|
| 14 | use lib qw (lib);
|
---|
[1551] | 15 | #use lib '/usr/share/perl5'; # mandatory for opensuse
|
---|
[2175] | 16 | use ProjectBuilder::Version;
|
---|
[423] | 17 | use ProjectBuilder::Distribution;
|
---|
| 18 | use ProjectBuilder::Base;
|
---|
[2496] | 19 | use ProjectBuilder::Conf;
|
---|
[176] | 20 |
|
---|
[969] | 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 | pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
|
---|
| 31 |
|
---|
| 32 | =head1 SYNOPSIS
|
---|
| 33 |
|
---|
[1652] | 34 | pbdistrocheck [-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 |
|
---|
| 42 | Prints this help
|
---|
| 43 |
|
---|
[969] | 44 | =item B<-v|--verbose>
|
---|
| 45 |
|
---|
| 46 | Print a brief help message and exits.
|
---|
| 47 |
|
---|
[1071] | 48 | =item B<-a|--all>
|
---|
| 49 |
|
---|
[1652] | 50 | Print all parameters
|
---|
[1071] | 51 |
|
---|
| 52 | =item B<-s|--short>
|
---|
| 53 |
|
---|
[1652] | 54 | Generate a short format user friendly, comma separated allowing parsing
|
---|
[1071] | 55 |
|
---|
| 56 | =item B<-l|--lsb>
|
---|
| 57 |
|
---|
[1652] | 58 | Generate an LSB compliant output
|
---|
[1071] | 59 |
|
---|
[969] | 60 | =item B<-d|--description>
|
---|
| 61 |
|
---|
[1652] | 62 | Print only description (LSB only)
|
---|
[969] | 63 |
|
---|
[1071] | 64 | =item B<-r|--release>
|
---|
| 65 |
|
---|
[1652] | 66 | Print only release (LSB only)
|
---|
[1071] | 67 |
|
---|
| 68 | =item B<-c|--codename>
|
---|
| 69 |
|
---|
[1652] | 70 | Print only codename (LSB only)
|
---|
[1071] | 71 |
|
---|
| 72 | =item B<-i|--id>
|
---|
| 73 |
|
---|
[1652] | 74 | Print only distribution identificator (LSB only)
|
---|
[1071] | 75 |
|
---|
| 76 | =item B<-a|--all>
|
---|
| 77 |
|
---|
[1652] | 78 | Print all LSB fields
|
---|
[1071] | 79 |
|
---|
[969] | 80 | =back
|
---|
| 81 |
|
---|
| 82 | =head1 ARGUMENTS
|
---|
| 83 |
|
---|
[1652] | 84 | Arguments are optional. If none given, analyzes the underlying operating system
|
---|
[969] | 85 | 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.
|
---|
| 86 |
|
---|
| 87 | =head1 WEB SITES
|
---|
| 88 |
|
---|
| 89 | 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/>.
|
---|
| 90 |
|
---|
| 91 | =head1 USER MAILING LIST
|
---|
| 92 |
|
---|
| 93 | 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.
|
---|
| 94 |
|
---|
| 95 | =head1 CONFIGURATION FILES
|
---|
| 96 |
|
---|
[2279] | 97 | Uses 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 |
|
---|
| 101 | The 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 |
|
---|
| 105 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 106 | described in the file C<COPYING> included with the distribution.
|
---|
| 107 |
|
---|
| 108 | =cut
|
---|
| 109 |
|
---|
[423] | 110 | my %opts; # CLI Options
|
---|
| 111 |
|
---|
[2496] | 112 | my ($projectbuilderver,$projectbuilderrev,$projectbuilderconfver) = pb_version_init();
|
---|
| 113 | my $appname = "pbdistrocheck";
|
---|
[2175] | 114 |
|
---|
| 115 | # Initialize the syntax string
|
---|
| 116 |
|
---|
[2496] | 117 | pb_syntax_init("$appname Version $projectbuilderver-$projectbuilderrev\n");
|
---|
| 118 | pb_temp_init();
|
---|
| 119 | pb_conf_init($appname);
|
---|
[2175] | 120 |
|
---|
[839] | 121 | GetOptions(
|
---|
| 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] | 134 | if (defined $opts{'h'}) {
|
---|
| 135 | pb_syntax(0,1);
|
---|
| 136 | }
|
---|
| 137 | if (defined $opts{'version'}) {
|
---|
| 138 | pb_syntax(0,0);
|
---|
| 139 | }
|
---|
| 140 | if (defined $opts{'man'}) {
|
---|
| 141 | pb_syntax(0,2);
|
---|
| 142 | }
|
---|
[423] | 143 | if (defined $opts{'v'}) {
|
---|
[495] | 144 | $pbdebug = $opts{'v'};
|
---|
[423] | 145 | }
|
---|
[1071] | 146 | pb_log_init($pbdebug, \*STDOUT);
|
---|
[423] | 147 |
|
---|
[969] | 148 | my $dist = shift @ARGV || undef ;
|
---|
[1177] | 149 | my $pbos = pb_distro_get_context($dist);
|
---|
[1071] | 150 | my $sep = "\n";
|
---|
| 151 | if (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 | }
|
---|