| 1 | #!/usr/bin/perl -w
|
|---|
| 2 | #
|
|---|
| 3 | # Project Builder Distribution Checker
|
|---|
| 4 | #
|
|---|
| 5 | # $Id$
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright B. Cornec 2007-2015
|
|---|
| 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::Distribution;
|
|---|
| 17 | use ProjectBuilder::Base;
|
|---|
| 18 |
|
|---|
| 19 | =pod
|
|---|
| 20 |
|
|---|
| 21 | =head1 NAME
|
|---|
| 22 |
|
|---|
| 23 | pb, aka project-builder.org - builds packages for your projects
|
|---|
| 24 |
|
|---|
| 25 | =head1 DESCRIPTION
|
|---|
| 26 |
|
|---|
| 27 | pb helps you build various packages directly from your project sources.
|
|---|
| 28 | pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
|
|---|
| 29 |
|
|---|
| 30 | =head1 SYNOPSIS
|
|---|
| 31 |
|
|---|
| 32 | pbdistrocheck [-h][-d][-v][-l [-c][-i][-r][-a]][-s] [distro-ver-arch]
|
|---|
| 33 |
|
|---|
| 34 | =head1 OPTIONS
|
|---|
| 35 |
|
|---|
| 36 | =over 4
|
|---|
| 37 |
|
|---|
| 38 | =item B<-h|--help>
|
|---|
| 39 |
|
|---|
| 40 | Prints this help
|
|---|
| 41 |
|
|---|
| 42 | =item B<-v|--verbose>
|
|---|
| 43 |
|
|---|
| 44 | Print a brief help message and exits.
|
|---|
| 45 |
|
|---|
| 46 | =item B<-a|--all>
|
|---|
| 47 |
|
|---|
| 48 | Print all parameters
|
|---|
| 49 |
|
|---|
| 50 | =item B<-s|--short>
|
|---|
| 51 |
|
|---|
| 52 | Generate a short format user friendly, comma separated allowing parsing
|
|---|
| 53 |
|
|---|
| 54 | =item B<-l|--lsb>
|
|---|
| 55 |
|
|---|
| 56 | Generate an LSB compliant output
|
|---|
| 57 |
|
|---|
| 58 | =item B<-d|--description>
|
|---|
| 59 |
|
|---|
| 60 | Print only description (LSB only)
|
|---|
| 61 |
|
|---|
| 62 | =item B<-r|--release>
|
|---|
| 63 |
|
|---|
| 64 | Print only release (LSB only)
|
|---|
| 65 |
|
|---|
| 66 | =item B<-c|--codename>
|
|---|
| 67 |
|
|---|
| 68 | Print only codename (LSB only)
|
|---|
| 69 |
|
|---|
| 70 | =item B<-i|--id>
|
|---|
| 71 |
|
|---|
| 72 | Print only distribution identificator (LSB only)
|
|---|
| 73 |
|
|---|
| 74 | =item B<-a|--all>
|
|---|
| 75 |
|
|---|
| 76 | Print all LSB fields
|
|---|
| 77 |
|
|---|
| 78 | =back
|
|---|
| 79 |
|
|---|
| 80 | =head1 ARGUMENTS
|
|---|
| 81 |
|
|---|
| 82 | Arguments are optional. If none given, analyzes the underlying operating system
|
|---|
| 83 | 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.
|
|---|
| 84 |
|
|---|
| 85 | =head1 WEB SITES
|
|---|
| 86 |
|
|---|
| 87 | 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/>.
|
|---|
| 88 |
|
|---|
| 89 | =head1 USER MAILING LIST
|
|---|
| 90 |
|
|---|
| 91 | 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.
|
|---|
| 92 |
|
|---|
| 93 | =head1 CONFIGURATION FILES
|
|---|
| 94 |
|
|---|
| 95 | Uses the main /etc/pb/pb.conf (or /usr/local/etc/pb/pb.conf if installed from files) configuration file to give its answers.
|
|---|
| 96 |
|
|---|
| 97 | =head1 AUTHORS
|
|---|
| 98 |
|
|---|
| 99 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
|---|
| 100 |
|
|---|
| 101 | =head1 COPYRIGHT
|
|---|
| 102 |
|
|---|
| 103 | Project-Builder.org is distributed under the GPL v2.0 license
|
|---|
| 104 | described in the file C<COPYING> included with the distribution.
|
|---|
| 105 |
|
|---|
| 106 | =cut
|
|---|
| 107 |
|
|---|
| 108 | my %opts; # CLI Options
|
|---|
| 109 |
|
|---|
| 110 | GetOptions(
|
|---|
| 111 | "verbose|v+" => \$opts{'v'},
|
|---|
| 112 | "short|s" => \$opts{'s'},
|
|---|
| 113 | "help|h" => \$opts{'h'},
|
|---|
| 114 | "description|d" => \$opts{'d'},
|
|---|
| 115 | "id|i" => \$opts{'i'},
|
|---|
| 116 | "release|r" => \$opts{'r'},
|
|---|
| 117 | "codename|c" => \$opts{'c'},
|
|---|
| 118 | "all|a" => \$opts{'a'},
|
|---|
| 119 | "lsb|l" => \$opts{'l'},
|
|---|
| 120 | );
|
|---|
| 121 | if (defined $opts{'v'}) {
|
|---|
| 122 | $pbdebug = $opts{'v'};
|
|---|
| 123 | }
|
|---|
| 124 | pb_log_init($pbdebug, \*STDOUT);
|
|---|
| 125 |
|
|---|
| 126 | my $dist = shift @ARGV || undef ;
|
|---|
| 127 | my $pbos = pb_distro_get_context($dist);
|
|---|
| 128 | my $sep = "\n";
|
|---|
| 129 | if (defined $opts{'l'}) {
|
|---|
| 130 | # Simulate lsb_release output
|
|---|
| 131 | my ($l,$i,$d,$r,$c) = pb_distro_getlsb($opts{'s'});
|
|---|
| 132 | $sep = " " if (defined $opts{'s'});
|
|---|
| 133 | print $l.$sep;
|
|---|
| 134 | print $i.$sep if (defined $opts{'i'} or defined $opts{'a'});
|
|---|
| 135 | print $d.$sep if (defined $opts{'d'} or defined $opts{'a'});
|
|---|
| 136 | print $r.$sep if (defined $opts{'r'} or defined $opts{'a'});
|
|---|
| 137 | $sep = "" if (defined $opts{'s'});
|
|---|
| 138 | print $c.$sep if (defined $opts{'c'} or defined $opts{'a'});
|
|---|
| 139 | print "\n" if (defined $opts{'s'});
|
|---|
| 140 | } else {
|
|---|
| 141 | $sep = "," if (defined $opts{'s'});
|
|---|
| 142 | if (not defined $opts{'s'}) {
|
|---|
| 143 | $pbos->{'os'} = "OS:\t$pbos->{'os'}";
|
|---|
| 144 | $pbos->{'name'} = "Name:\t$pbos->{'name'}";
|
|---|
| 145 | $pbos->{'version'} = "Ver:\t$pbos->{'version'}";
|
|---|
| 146 | $pbos->{'family'} = "Family:\t$pbos->{'family'}";
|
|---|
| 147 | $pbos->{'type'} = "Type:\t$pbos->{'type'}";
|
|---|
| 148 | $pbos->{'suffix'} = "Suffix:\t$pbos->{'suffix'}";
|
|---|
| 149 | $pbos->{'update'} = "Update:\t$pbos->{'update'}";
|
|---|
| 150 | $pbos->{'install'} = "Install:\t$pbos->{'install'}";
|
|---|
| 151 | $pbos->{'arch'} = "Arch:\t$pbos->{'arch'}";
|
|---|
| 152 | print "Project-Builder tuple:\n";
|
|---|
| 153 | }
|
|---|
| 154 | print join($sep,($pbos->{'os'}, $pbos->{'name'}, $pbos->{'version'}, $pbos->{'arch'}, $pbos->{'type'}, $pbos->{'family'}, $pbos->{'suffix'}, $pbos->{'update'}, $pbos->{'install'}))."\n";
|
|---|
| 155 | }
|
|---|