source: ProjectBuilder/devel/pb-modules/bin/pbdistrocheck@ 2279

Last change on this file since 2279 was 2279, checked in by Bruno Cornec, 7 years ago

YAML support working for most distros

  • Fix rebase issues
  • Adds a pbsyncheck script for pre-commit check
  • Fix test deps for centos & fedora
  • update pbcl versions for deb build
File size: 4.5 KB
RevLine 
[176]1#!/usr/bin/perl -w
2#
3# Project Builder Distribution Checker
4#
5# $Id$
6#
[2032]7# Copyright B. Cornec 2007-2016
[1528]8# Eric Anderson's changes are (c) Copyright 2012 Hewlett Packard
[176]9# Provided under the GPL v2
10
11use strict 'vars';
[423]12use Getopt::Long qw(:config auto_abbrev no_ignore_case);
[176]13use Data::Dumper;
14use lib qw (lib);
[1551]15#use lib '/usr/share/perl5'; # mandatory for opensuse
[2175]16use ProjectBuilder::Version;
[423]17use ProjectBuilder::Distribution;
18use ProjectBuilder::Base;
[176]19
[969]20=pod
21
22=head1 NAME
23
24pb, aka project-builder.org - builds packages for your projects
25
26=head1 DESCRIPTION
27
28pb helps you build various packages directly from your project sources.
29pbdistrocheck is a command from the pb project providing the same type of services as lsb_release, but extended.
30
31=head1 SYNOPSIS
32
[1652]33pbdistrocheck [-h][-d][-v][-l [-c][-i][-r][-a]][-s] [distro-ver-arch]
[969]34
35=head1 OPTIONS
36
37=over 4
38
[1652]39=item B<-h|--help>
40
41Prints this help
42
[969]43=item B<-v|--verbose>
44
45Print a brief help message and exits.
46
[1071]47=item B<-a|--all>
48
[1652]49Print all parameters
[1071]50
51=item B<-s|--short>
52
[1652]53Generate a short format user friendly, comma separated allowing parsing
[1071]54
55=item B<-l|--lsb>
56
[1652]57Generate an LSB compliant output
[1071]58
[969]59=item B<-d|--description>
60
[1652]61Print only description (LSB only)
[969]62
[1071]63=item B<-r|--release>
64
[1652]65Print only release (LSB only)
[1071]66
67=item B<-c|--codename>
68
[1652]69Print only codename (LSB only)
[1071]70
71=item B<-i|--id>
72
[1652]73Print only distribution identificator (LSB only)
[1071]74
75=item B<-a|--all>
76
[1652]77Print all LSB fields
[1071]78
[969]79=back
80
81=head1 ARGUMENTS
82
[1652]83Arguments are optional. If none given, analyzes the underlying operating system
[969]84If 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
88The 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
92Cf: 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
[2279]96Uses the main /etc/pb/pb.yml (or /usr/local/etc/pb/pb.yml if installed from files) configuration file to give its answers.
[969]97
98=head1 AUTHORS
99
100The 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
104Project-Builder.org is distributed under the GPL v2.0 license
105described in the file C<COPYING> included with the distribution.
106
107=cut
108
[423]109my %opts; # CLI Options
110
[2175]111my ($projectver,$projectrev) = pb_version_init();
112my $appname = "pbgetparam";
113
114# Initialize the syntax string
115
116pb_syntax_init("$appname Version $projectver-$projectrev\n");
117
[839]118GetOptions(
119 "verbose|v+" => \$opts{'v'},
[2175]120 "version" => \$opts{'version'},
121 "man" => \$opts{'man'},
122 "help|h" => \$opts{'h'},
[1071]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'},
[839]130);
[2175]131if (defined $opts{'h'}) {
132 pb_syntax(0,1);
133}
134if (defined $opts{'version'}) {
135 pb_syntax(0,0);
136}
137if (defined $opts{'man'}) {
138 pb_syntax(0,2);
139}
[423]140if (defined $opts{'v'}) {
[495]141 $pbdebug = $opts{'v'};
[423]142}
[1071]143pb_log_init($pbdebug, \*STDOUT);
[423]144
[969]145my $dist = shift @ARGV || undef ;
[1177]146my $pbos = pb_distro_get_context($dist);
[1071]147my $sep = "\n";
148if (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'});
[839]159} else {
[1071]160 $sep = "," if (defined $opts{'s'});
161 if (not defined $opts{'s'}) {
[1177]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'}";
[1071]171 print "Project-Builder tuple:\n";
172 }
[1177]173 print join($sep,($pbos->{'os'}, $pbos->{'name'}, $pbos->{'version'}, $pbos->{'arch'}, $pbos->{'type'}, $pbos->{'family'}, $pbos->{'suffix'}, $pbos->{'update'}, $pbos->{'install'}))."\n";
[839]174}
Note: See TracBrowser for help on using the repository browser.