Initial lsb-release-2.0 sources
This commit is contained in:
commit
e3d3e103e4
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -0,0 +1,36 @@
|
|||
2004-05-13 Mats Wichmann <mats@freestandards.org>
|
||||
|
||||
* lsb_release: now version 2.0 to match LSB 2.0. Added module
|
||||
support code, /etc/lsb-release.d will be searched for added modules
|
||||
|
||||
* lsb_release.examples: documented module support behavior.
|
||||
|
||||
* README: added note that this is an example, an implementation
|
||||
doesn't need to choose this approach.
|
||||
|
||||
* COPYING (new): since this is GPL code, include the license here
|
||||
|
||||
2000-12-15 Christopher Yeoh <cyeoh@linuxcare.com.au>
|
||||
|
||||
* lsb_release: Replace source with '.' to make
|
||||
script more portable. Now tested to work with bash (2.04),
|
||||
ash (0.3.7) and pdksh (5.2.14)
|
||||
|
||||
2000-12-13 Christopher Yeoh <cyeoh@linuxcare.com.au>
|
||||
|
||||
* lsb_release.examples: Fix mistakes in documentation
|
||||
|
||||
2000-12-11 Christopher Yeoh <cyeoh@linuxcare.com.au>
|
||||
|
||||
* lsb_release.examples: Update documentation. Explicitly state
|
||||
that LSB_VERSION should not be set if the distribution is not LSB
|
||||
compliant.
|
||||
|
||||
* lsb_release: Various fixes to run with less featured shells
|
||||
and removal of dependency on awk (Dominique Massonie et al).
|
||||
|
||||
2000-11-06 Christopher Yeoh <cyeoh@linuxcare.com.au>
|
||||
|
||||
* Makefile (lsb_release.1.gz): Compress with -9
|
||||
|
||||
* ChangeLog: Add changelog file
|
|
@ -0,0 +1,18 @@
|
|||
This dir contains the lsb_release script and the required
|
||||
programs to build the associated man pages.
|
||||
|
||||
README
|
||||
lsb_release : version 2.0
|
||||
help2man : the GNU script to build Man from --help output
|
||||
Makefile : Makefile for creating the man page
|
||||
lsb_release.examples : the Man style add-on for the pages
|
||||
lsb-release.template : the sample "/etc/lsb-release" file.
|
||||
INSTALL : this file
|
||||
|
||||
To create the man page do a 'make'.
|
||||
To install the lsb_release program and associated man page do a
|
||||
'make install'.
|
||||
|
||||
Regards,
|
||||
|
||||
-- Dominique
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Makefile for lsb_release program
|
||||
#
|
||||
# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc
|
||||
#
|
||||
# Christopher Yeoh <cyeoh@samba.org>
|
||||
#
|
||||
# This is $Revision: 1.7 $
|
||||
|
||||
# Config
|
||||
|
||||
ifndef INSTALL_ROOT
|
||||
prefix=/usr/local
|
||||
else
|
||||
prefix=$(INSTALL_ROOT)
|
||||
endif
|
||||
mandir=${prefix}/man
|
||||
|
||||
all: man
|
||||
|
||||
man: lsb_release.1.gz
|
||||
|
||||
lsb_release.1.gz: lsb_release
|
||||
@./help2man -N --include ./lsb_release.examples --alt_version_key=program_version ./lsb_release >lsb_release.1
|
||||
@gzip -9f lsb_release.1
|
||||
|
||||
install: all
|
||||
install -D -m 644 lsb_release.1.gz ${mandir}/man1/lsb_release.1.gz
|
||||
install -D -m 755 lsb_release ${prefix}/bin/lsb_release
|
|
@ -0,0 +1,23 @@
|
|||
LSB version query program (lsb_release) by Dominique Massonie
|
||||
(mdomi@users.sourceforge.net)
|
||||
|
||||
This program forms part of the required functionality of the LSB
|
||||
(Linux Standard Base) specification.
|
||||
|
||||
The program queries the installed state of the distribution to display
|
||||
certain properties such as the version of the LSB against which the
|
||||
distribution claims compliance as well. It can also attempt to display
|
||||
the name and release of the distribution along with an identifier of
|
||||
who produces the distribution.
|
||||
|
||||
======================================================================
|
||||
|
||||
Note that this is an \example/ implementation.
|
||||
|
||||
The specification requires only an lsb_release command to exist, and to
|
||||
return the information in the format described. The fact that the manual
|
||||
page generated from this software describes implementation details of this
|
||||
example should not be construed as placing any additional requirements
|
||||
on implementors beyond those just noted. In particular, the existance and
|
||||
format of the /etc/lsb-release file and the /etc/lsb-release.d directory
|
||||
are not part of the LSB specification
|
|
@ -0,0 +1,520 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright © 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# Written by Brendan O'Dea <bod@compusol.com.au>
|
||||
# Available from ftp://ftp.gnu.org/gnu/help2man/
|
||||
|
||||
# This has been modified by Chris Yeoh <cyeoh@linuxcare.com.au> to
|
||||
# handle FSG programs and those which don't support --version
|
||||
# to display the version
|
||||
|
||||
use 5.004;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use Text::Tabs qw(expand);
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.022';
|
||||
my $version_info = <<EOT;
|
||||
GNU $this_program $this_version
|
||||
|
||||
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Written by Brendan O'Dea <bod\@compusol.com.au>
|
||||
EOT
|
||||
|
||||
my $help_info = <<EOT;
|
||||
`$this_program' generates a man page out of `--help' and `--version' output.
|
||||
|
||||
Usage: $this_program [OPTION]... EXECUTABLE
|
||||
|
||||
-n, --name=STRING use `STRING' as the description for the NAME paragraph
|
||||
-s, --section=SECTION use `SECTION' as the section for the man page
|
||||
-i, --include=FILE include material from `FILE'
|
||||
-I, --opt-include=FILE include material from `FILE' if it exists
|
||||
-o, --output=FILE send output to `FILE'
|
||||
-N, --no-info suppress pointer to Texinfo manual
|
||||
--alt_version_key=KEY use specified flag instead of --version
|
||||
--help print this help, then exit
|
||||
--version print version number, then exit
|
||||
|
||||
EXECUTABLE should accept `--help' and `--version' options.
|
||||
|
||||
Report bugs to <bug-help2man\@gnu.org>.
|
||||
EOT
|
||||
|
||||
my $section = 1;
|
||||
my ($opt_name, @opt_include, $opt_output, $opt_no_info);
|
||||
my($opt_version_key) = "version";
|
||||
|
||||
# Parse options.
|
||||
Getopt::Long::config('bundling');
|
||||
GetOptions (
|
||||
'n|name=s' => \$opt_name,
|
||||
's|section=s' => \$section,
|
||||
'i|include=s' => sub { push @opt_include, [ pop, 1 ] },
|
||||
'I|opt-include=s' => sub { push @opt_include, [ pop, 0 ] },
|
||||
'o|output=s' => \$opt_output,
|
||||
'N|no-info' => \$opt_no_info,
|
||||
'alt_version_key=s' => \$opt_version_key,
|
||||
help => sub { print $help_info; exit },
|
||||
version => sub { print $version_info; exit },
|
||||
) or die $help_info;
|
||||
|
||||
die $help_info unless @ARGV == 1;
|
||||
|
||||
my %include = ();
|
||||
my %append = ();
|
||||
my @include = (); # retain order given in include file
|
||||
|
||||
# Provide replacement `quote-regex' operator for pre-5.005.
|
||||
BEGIN { eval q(sub qr { '' =~ $_[0]; $_[0] }) if $] < 5.005 }
|
||||
|
||||
# Process include file (if given). Format is:
|
||||
#
|
||||
# [section name]
|
||||
# verbatim text
|
||||
#
|
||||
# or
|
||||
#
|
||||
# /pattern/
|
||||
# verbatim text
|
||||
#
|
||||
|
||||
for (@opt_include)
|
||||
{
|
||||
my ($inc, $required) = @$_;
|
||||
|
||||
next unless -f $inc or $required;
|
||||
die "$this_program: can't open `$inc' ($!)\n"
|
||||
unless open INC, $inc;
|
||||
|
||||
my $key;
|
||||
my $hash = \%include;
|
||||
|
||||
while (<INC>)
|
||||
{
|
||||
# [section]
|
||||
if (/^\[([^]]+)\]/)
|
||||
{
|
||||
$key = uc $1;
|
||||
$key =~ s/^\s+//;
|
||||
$key =~ s/\s+$//;
|
||||
$hash = \%include;
|
||||
push @include, $key unless $include{$key};
|
||||
next;
|
||||
}
|
||||
|
||||
# /pattern/
|
||||
if (m!^/(.*)/([ims]*)!)
|
||||
{
|
||||
my $pat = $2 ? "(?$2)$1" : $1;
|
||||
|
||||
# Check pattern.
|
||||
eval { $key = qr($pat) };
|
||||
if ($@)
|
||||
{
|
||||
$@ =~ s/ at .*? line \d.*//;
|
||||
die "$inc:$.:$@";
|
||||
}
|
||||
|
||||
$hash = \%append;
|
||||
next;
|
||||
}
|
||||
|
||||
# Silently ignore anything before the first
|
||||
# section--allows for comments and revision info.
|
||||
next unless $key;
|
||||
|
||||
$hash->{$key} ||= '';
|
||||
$hash->{$key} .= $_;
|
||||
}
|
||||
|
||||
close INC;
|
||||
|
||||
die "$this_program: no valid information found in `$inc'\n"
|
||||
unless $key;
|
||||
}
|
||||
|
||||
# Compress trailing blank lines.
|
||||
for my $hash (\(%include, %append))
|
||||
{
|
||||
for (keys %$hash) { $hash->{$_} =~ s/\n+$/\n/ }
|
||||
}
|
||||
|
||||
# Turn off localisation of executable's ouput.
|
||||
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
|
||||
|
||||
# Turn off localisation of date (for strftime).
|
||||
setlocale LC_TIME, 'C';
|
||||
|
||||
# Grab help and version info from executable.
|
||||
my ($help_text, $version_text) = map {
|
||||
join '', map { s/ +$//; expand $_ } `$ARGV[0] --$_ 2>/dev/null`
|
||||
or die "$this_program: can't get `--$_' info from $ARGV[0]\n"
|
||||
} qw(help), $opt_version_key;
|
||||
|
||||
my $date = strftime "%B %Y", localtime;
|
||||
(my $program = $ARGV[0]) =~ s!.*/!!;
|
||||
my $package = $program;
|
||||
my $version;
|
||||
|
||||
if ($opt_output)
|
||||
{
|
||||
unlink $opt_output
|
||||
or die "$this_program: can't unlink $opt_output ($!)\n"
|
||||
if -e $opt_output;
|
||||
|
||||
open STDOUT, ">$opt_output"
|
||||
or die "$this_program: can't create $opt_output ($!)\n";
|
||||
}
|
||||
|
||||
# The first line of the --version information is assumed to be in one
|
||||
# of the following formats:
|
||||
#
|
||||
# <version>
|
||||
# <program> <version>
|
||||
# {GNU,Free} <program> <version>
|
||||
# <program> ({GNU,Free} <package>) <version>
|
||||
# <program> - {GNU,Free} <package> <version>
|
||||
#
|
||||
# and seperated from any copyright/author details by a blank line.
|
||||
|
||||
($_, $version_text) = split /\n+/, $version_text, 2;
|
||||
|
||||
if (/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or
|
||||
/^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/)
|
||||
{
|
||||
$program = $1;
|
||||
$package = $2;
|
||||
$version = $3;
|
||||
}
|
||||
elsif (/^((?:GNU|Free) +)?(\S+) +(.*)/)
|
||||
{
|
||||
$program = $2;
|
||||
$package = $1 ? "$1$2" : $2;
|
||||
$version = $3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = $_;
|
||||
}
|
||||
|
||||
$program =~ s!.*/!!;
|
||||
|
||||
# No info for `info' itself.
|
||||
$opt_no_info = 1 if $program eq 'info';
|
||||
|
||||
# --name overrides --include contents.
|
||||
$include{NAME} = "$program \\- $opt_name\n" if $opt_name;
|
||||
|
||||
# Default (useless) NAME paragraph.
|
||||
$include{NAME} ||= "$program \\- manual page for $program $version\n";
|
||||
|
||||
# Man pages traditionally have the page title in caps.
|
||||
my $PROGRAM = uc $program;
|
||||
|
||||
# Extract usage clause(s) [if any] for SYNOPSIS.
|
||||
if ($help_text =~ s/^Usage:( +(\S+))(.*)((?:\n(?: {6}\1| *or: +\S).*)*)//m)
|
||||
{
|
||||
my @syn = $2 . $3;
|
||||
|
||||
if ($_ = $4)
|
||||
{
|
||||
s/^\n//;
|
||||
for (split /\n/) { s/^ *(or: +)?//; push @syn, $_ }
|
||||
}
|
||||
|
||||
my $synopsis = '';
|
||||
for (@syn)
|
||||
{
|
||||
$synopsis .= ".br\n" if $synopsis;
|
||||
s!^\S*/!!;
|
||||
s/^(\S+) *//;
|
||||
$synopsis .= ".B $1\n";
|
||||
s/\s+$//;
|
||||
s/(([][]|\.\.+)+)/\\fR$1\\fI/g;
|
||||
s/^/\\fI/ unless s/^\\fR//;
|
||||
$_ .= '\fR';
|
||||
s/(\\fI)( *)/$2$1/g;
|
||||
s/\\fI\\fR//g;
|
||||
s/^\\fR//;
|
||||
s/\\fI$//;
|
||||
s/^\./\\&./;
|
||||
|
||||
$synopsis .= "$_\n";
|
||||
}
|
||||
|
||||
$include{SYNOPSIS} ||= $synopsis;
|
||||
}
|
||||
|
||||
# Process text, initial section is DESCRIPTION.
|
||||
my $sect = 'DESCRIPTION';
|
||||
$_ = "$help_text\n\n$version_text";
|
||||
|
||||
# Normalise paragraph breaks.
|
||||
s/^\n+//;
|
||||
s/\n*$/\n/;
|
||||
s/\n\n+/\n\n/g;
|
||||
|
||||
# Temporarily exchange leading dots and backslashes for tokens.
|
||||
s/^\./\x80/mg;
|
||||
s/\\/\x81/g;
|
||||
|
||||
# Start a new paragraph (if required) for these.
|
||||
s/([^\n])\n(Report +bugs|Email +bug +reports +to|Written +by)/$1\n\n$2/g;
|
||||
|
||||
sub convert_option;
|
||||
|
||||
while (length)
|
||||
{
|
||||
# Convert some standard paragraph names.
|
||||
if (s/^(Options|Examples): *\n//)
|
||||
{
|
||||
$sect = uc $1;
|
||||
next;
|
||||
}
|
||||
|
||||
# Copyright section
|
||||
if (/^Copyright +[(\xa9]/)
|
||||
{
|
||||
$sect = 'COPYRIGHT';
|
||||
$include{$sect} ||= '';
|
||||
$include{$sect} .= ".PP\n" if $include{$sect};
|
||||
|
||||
my $copy;
|
||||
($copy, $_) = split /\n\n/, $_, 2;
|
||||
|
||||
for ($copy)
|
||||
{
|
||||
# Add back newline
|
||||
s/\n*$/\n/;
|
||||
|
||||
# Convert iso9959-1 copyright symbol or (c) to nroff
|
||||
# character.
|
||||
s/^Copyright +(?:\xa9|\([Cc]\))/Copyright \\(co/mg;
|
||||
|
||||
# Insert line breaks before additional copyright messages
|
||||
# and the disclaimer.
|
||||
s/(.)\n(Copyright |This +is +free +software)/$1\n.br\n$2/g;
|
||||
|
||||
# Join hyphenated lines.
|
||||
s/([A-Za-z])-\n */$1/g;
|
||||
}
|
||||
|
||||
$include{$sect} .= $copy;
|
||||
$_ ||= '';
|
||||
next;
|
||||
}
|
||||
|
||||
# Catch bug report text.
|
||||
if (/^(Report +bugs|Email +bug +reports +to) /)
|
||||
{
|
||||
$sect = 'REPORTING BUGS';
|
||||
}
|
||||
|
||||
# Author section.
|
||||
elsif (/^Written +by/)
|
||||
{
|
||||
$sect = 'AUTHOR';
|
||||
}
|
||||
|
||||
# Examples, indicated by an indented leading $, % or > are
|
||||
# rendered in a constant width font.
|
||||
if (/^( +)([\$\%>] )\S/)
|
||||
{
|
||||
my $indent = $1;
|
||||
my $prefix = $2;
|
||||
my $break = '.IP';
|
||||
$include{$sect} ||= '';
|
||||
while (s/^$indent\Q$prefix\E(\S.*)\n*//)
|
||||
{
|
||||
$include{$sect} .= "$break\n\\f(CW$prefix$1\\fR\n";
|
||||
$break = '.br';
|
||||
}
|
||||
|
||||
next;
|
||||
}
|
||||
|
||||
my $matched = '';
|
||||
$include{$sect} ||= '';
|
||||
|
||||
# Sub-sections have a trailing colon and the second line indented.
|
||||
if (s/^(\S.*:) *\n / /)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$include{$sect} .= qq(.SS "$1"\n);
|
||||
}
|
||||
|
||||
my $indent = 0;
|
||||
my $content = '';
|
||||
|
||||
# Option with description.
|
||||
if (s/^( {1,10}([+-]\S.*?))(?:( +)|\n( {20,}))(\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length ($4 || "$1$3");
|
||||
$content = ".TP\n\x82$2\n\x82$5\n";
|
||||
unless ($4)
|
||||
{
|
||||
# Indent may be different on second line.
|
||||
$indent = length $& if /^ {20,}/;
|
||||
}
|
||||
}
|
||||
|
||||
# Option without description.
|
||||
elsif (s/^ {1,10}([+-]\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$content = ".HP\n\x82$1\n";
|
||||
$indent = 80; # not continued
|
||||
}
|
||||
|
||||
# Indented paragraph with tag.
|
||||
elsif (s/^( +(\S.*?) +)(\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length $1;
|
||||
$content = ".TP\n\x82$2\n\x82$3\n";
|
||||
}
|
||||
|
||||
# Indented paragraph.
|
||||
elsif (s/^( +)(\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length $1;
|
||||
$content = ".IP\n\x82$2\n";
|
||||
}
|
||||
|
||||
# Left justified paragraph.
|
||||
else
|
||||
{
|
||||
s/(.*)\n//;
|
||||
$matched .= $& if %append;
|
||||
$content = ".PP\n" if $include{$sect};
|
||||
$content .= "$1\n";
|
||||
}
|
||||
|
||||
# Append continuations.
|
||||
while (s/^ {$indent}(\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$content .= "\x82$1\n"
|
||||
}
|
||||
|
||||
# Move to next paragraph.
|
||||
s/^\n+//;
|
||||
|
||||
for ($content)
|
||||
{
|
||||
# Leading dot protection.
|
||||
s/\x82\./\x80/g;
|
||||
s/\x82//g;
|
||||
|
||||
# Convert options.
|
||||
s/(^| )(-[][\w=-]+)/$1 . convert_option $2/mge;
|
||||
}
|
||||
|
||||
# Check if matched paragraph contains /pat/.
|
||||
if (%append)
|
||||
{
|
||||
for my $pat (keys %append)
|
||||
{
|
||||
if ($matched =~ $pat)
|
||||
{
|
||||
$content .= ".PP\n" unless $append{$pat} =~ /^\./;
|
||||
$content .= $append{$pat};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$include{$sect} .= $content;
|
||||
}
|
||||
|
||||
# Refer to the real documentation.
|
||||
unless ($opt_no_info)
|
||||
{
|
||||
$sect = 'SEE ALSO';
|
||||
$include{$sect} ||= '';
|
||||
$include{$sect} .= ".PP\n" if $include{$sect};
|
||||
$include{$sect} .= <<EOT;
|
||||
The full documentation for
|
||||
.B $program
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B $program
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info $program
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
EOT
|
||||
}
|
||||
|
||||
# Output header.
|
||||
print <<EOT;
|
||||
.\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
|
||||
.TH $PROGRAM "$section" "$date" "$package $version" FSG
|
||||
EOT
|
||||
|
||||
# Section ordering.
|
||||
my @pre = qw(NAME SYNOPSIS DESCRIPTION OPTIONS FILES EXAMPLES);
|
||||
my @post = ('AUTHOR', 'REPORTING BUGS', 'COPYRIGHT', 'SEE ALSO');
|
||||
my $filter = join '|', @pre, @post;
|
||||
|
||||
# Output content.
|
||||
for (@pre, (grep ! /^($filter)$/o, @include), @post)
|
||||
{
|
||||
if ($include{$_})
|
||||
{
|
||||
my $quote = /\W/ ? '"' : '';
|
||||
print ".SH $quote$_$quote\n";
|
||||
|
||||
for ($include{$_})
|
||||
{
|
||||
# Replace leading dot an backslash tokens.
|
||||
s/\x80/\\&./g;
|
||||
s/\x81/\\e/g;
|
||||
print;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
# Convert option dashes to \- to stop nroff from hyphenating 'em, and
|
||||
# embolden. Option arguments get italicised.
|
||||
sub convert_option
|
||||
{
|
||||
local $_ = '\fB' . shift;
|
||||
|
||||
s/-/\\-/g;
|
||||
unless (s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/)
|
||||
{
|
||||
s/=(.)/\\fR=\\fI$1/;
|
||||
s/ (.)/ \\fI$1/;
|
||||
$_ .= '\fR';
|
||||
}
|
||||
|
||||
$_;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# FSG lsb_release configuration file template
|
||||
# If the distribution is LSB compliant, uncomment the following line
|
||||
# and set the version appropriately
|
||||
# LSB_VERSION=""
|
||||
DISTRIB_ID=""
|
||||
DISTRIB_RELEASE=""
|
||||
DISTRIB_CODENAME=""
|
||||
DISTRIB_DESCRIPTION=""
|
|
@ -0,0 +1,425 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# lsb_release - collect LSB conformance status about a system
|
||||
#
|
||||
# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc.
|
||||
# Originally by Dominique MASSONIE <mdomi@users.sourceforge.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# * Changes in 2.0
|
||||
# - Support LSB 2.0 module layout (Mats Wichmann)
|
||||
# The LSB_VERSION is now a colon-separated field of supported module versions
|
||||
# An /etc/lsb-release.d is searched for modules beyond the core.
|
||||
# Only the filenames in this directory is looked at, those names are added
|
||||
# to LSB_VERSION. This allows module support to be handled easily by
|
||||
# package install/removal without a need to edit lsb-release on the fly.
|
||||
# - Correct license: FSG == Free Standards Group, Inc.
|
||||
#
|
||||
# * Changes in 1.4
|
||||
# - "awk" not needed anymore (Loic Lefort)
|
||||
# - fixed bug #121879 reported by Chris D. Faulhaber,
|
||||
# some shells doesn't support local variables
|
||||
# - fixed a bug when single parameter sets many args including -s
|
||||
# - function DisplayProgramVersion (undocumented) now exits script like Usage
|
||||
# - cosmetic changes in comments/outputs
|
||||
#
|
||||
# * Changes in 1.3
|
||||
# - No changes in script, only in build infrastructure
|
||||
#
|
||||
# * Changes in 1.2
|
||||
# - Fixed more bash'isms
|
||||
# - LSB_VERSION is no longer required in /etc/lsb-release file
|
||||
#
|
||||
# * Changes in 1.1
|
||||
# - removed some bash-ism and typos
|
||||
# Notice: script remains broken with ash because of awk issues
|
||||
# - changed licence to FSG - "Free Software Group, Inc"
|
||||
# - fixed problem with --short single arg call
|
||||
# - changed Debian specifics, codename anticipates release num
|
||||
#
|
||||
# Description:
|
||||
# Collect information from sourceable /etc/lsb-release file (present on
|
||||
# LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE,
|
||||
# DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional)
|
||||
# Then (if needed) find and add names from /etc/lsb-release.d
|
||||
# Then (if needed) find and parse the /etc/[distro]-release file
|
||||
|
||||
|
||||
###############################################################################
|
||||
# DECLARATIONS
|
||||
###############################################################################
|
||||
|
||||
# This script version
|
||||
SCRIPTVERSION="2.0"
|
||||
|
||||
# Defines the data files
|
||||
INFO_ROOT="/etc" # directory of config files
|
||||
INFO_LSB_FILE="lsb-release" # where to get LSB version
|
||||
INFO_LSB_DIR="lsb-release.d" # where to get LSB addon modules
|
||||
INFO_DISTRIB_SUFFIX="release" # <distrib>-<suffix>
|
||||
ALTERNATE_DISTRIB_FILE="/etc/debian_version" # for Debian [based distrib]
|
||||
ALTERNATE_DISTRIB_NAME="Debian" # "
|
||||
CHECKFIRST="/etc/redhat-release" # check it before file search
|
||||
|
||||
# Defines our exit codes
|
||||
EXIT_STATUS="0" # default = Ok :)
|
||||
ERROR_UNKNOWN="10" # unknown error
|
||||
ERROR_USER="1" # program misuse
|
||||
ERROR_PROGRAM="2" # internal error
|
||||
ERROR_NOANSWER="3" # all required info not available
|
||||
# typically non LSB compliant distro!
|
||||
|
||||
# Defines our messages
|
||||
MSG_LSBVER="LSB Version:\t"
|
||||
MSG_DISTID="Distributor ID:\t"
|
||||
MSG_DISTDESC="Description:\t"
|
||||
MSG_DISTREL="Release:\t"
|
||||
MSG_DISTCODE="Codename:\t"
|
||||
MSG_NA="n/a"
|
||||
MSG_NONE="(none)"
|
||||
MSG_RESULT="" # contains the result in case short output selected
|
||||
|
||||
# Description string delimiter
|
||||
DESCSTR_DELI="release"
|
||||
|
||||
|
||||
###############################################################################
|
||||
# FUNCTIONS
|
||||
###############################################################################
|
||||
|
||||
# Display Program Version for internal use (needed by help2man)
|
||||
DisplayProgramVersion() {
|
||||
echo "FSG `basename $0` v$SCRIPTVERSION"
|
||||
echo
|
||||
echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc."
|
||||
echo "This is free software; see the source for copying conditions. There\
|
||||
is NO"
|
||||
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR\
|
||||
PURPOSE."
|
||||
echo
|
||||
echo "Originally written by Dominique MASSONIE."
|
||||
|
||||
exit $EXIT_STATUS
|
||||
}
|
||||
|
||||
# defines the Usage for lsb_release
|
||||
Usage() {
|
||||
echo "FSG `basename $0` v$SCRIPTVERSION prints certain LSB (Linux\
|
||||
Standard Base) and"
|
||||
echo "Distribution information."
|
||||
echo
|
||||
echo "Usage: `basename $0` [OPTION]..."
|
||||
echo "With no OPTION specified defaults to -v."
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -v, --version"
|
||||
echo " Display the version of the LSB specification against which the distribution is compliant."
|
||||
echo " -i, --id"
|
||||
echo " Display the string id of the distributor."
|
||||
echo " -d, --description"
|
||||
echo " Display the single line text description of the distribution."
|
||||
echo " -r, --release"
|
||||
echo " Display the release number of the distribution."
|
||||
echo " -c, --codename"
|
||||
echo " Display the codename according to the distribution release."
|
||||
echo " -a, --all"
|
||||
echo " Display all of the above information."
|
||||
echo " -s, --short"
|
||||
echo " Use short output format for information requested by other options (or version if none)."
|
||||
echo " -h, --help"
|
||||
echo " Display this message."
|
||||
|
||||
exit $EXIT_STATUS
|
||||
}
|
||||
|
||||
# Handles the enhanced args (i.e. --something)
|
||||
EnhancedGetopt() {
|
||||
getopt -T >/dev/null 2>&1 # is getopt the enhanced one ?
|
||||
if [ $? = 4 ]
|
||||
then # Yes, advanced args ALLOWED
|
||||
OPT=$(getopt -o acdhirsvp \
|
||||
--long all,codename,description,help,id,release,short,version,program_version \
|
||||
-n 'lsb_release' \
|
||||
-- "$@")
|
||||
else # No, advanced args NOT allowed
|
||||
# convert (if needed) the enhanced options into basic ones
|
||||
MYARGS=$(echo "$@" | sed -e "/--/s/-\(-[[:alnum:]]\)[[:alnum:]]*/\1/g")
|
||||
OPT=$(getopt -o acdhirsvp \
|
||||
-n 'lsb_release' \
|
||||
-- "$MYARGS")
|
||||
fi
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
exit $ERROR_PROGRAM
|
||||
fi
|
||||
|
||||
NB_ARG="" # enabled if many args set in one parameter (i.e. -dris)
|
||||
eval set -- "$OPT"
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-a|--all) ARG_A="y"; NB_ARG="y"; shift;;
|
||||
-c|--codename) ARG_C="y"; NB_ARG="y"; shift;;
|
||||
-d|--description) ARG_D="y"; NB_ARG="y"; shift;;
|
||||
-i|--id) ARG_I="y"; NB_ARG="y"; shift;;
|
||||
-r|--release) ARG_R="y"; NB_ARG="y"; shift;;
|
||||
-s|--short) ARG_S="y"; shift;;
|
||||
-v|--version) ARG_V="y"; NB_ARG="y"; shift;;
|
||||
-p|--program_version) DisplayProgramVersion;;
|
||||
-h|--help) Usage;;
|
||||
--) shift; break;;
|
||||
*) EXIT_STATUS=$ERROR_USER
|
||||
Usage;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Get/Init LSB infos (maybe Distrib infos too)
|
||||
GetLSBInfo() {
|
||||
if [ -f "$INFO_ROOT/$INFO_LSB_FILE" ]
|
||||
then
|
||||
# should init at least LSB_VERSION
|
||||
. "$INFO_ROOT/$INFO_LSB_FILE"
|
||||
fi
|
||||
if [ -z "$LSB_VERSION" ]
|
||||
then
|
||||
LSB_VERSION=$MSG_NA
|
||||
else
|
||||
# if we found LSB_VERSION, continue to look in directory
|
||||
if [ -d "$INFO_ROOT/$INFO_LSB_DIR" ]
|
||||
then
|
||||
for tag in "$INFO_ROOT/$INFO_LSB_DIR/"*
|
||||
do
|
||||
LSB_VERSION=$LSB_VERSION:`basename $tag`
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the whole distrib information string (from ARG $1 file)
|
||||
InitDistribInfo() {
|
||||
## Notice: Debian has a debian_version file
|
||||
## (at least) Mandrake has two files, a mandrake and a redhat one
|
||||
FILENAME=$1 # CHECKFIRST or finds' result in GetDistribInfo() or ""
|
||||
|
||||
if [ -z "$FILENAME" ]
|
||||
then
|
||||
if [ -f "$ALTERNATE_DISTRIB_FILE" ]
|
||||
then # For Debian only
|
||||
[ -z "$DISTRIB_ID" ] && DISTRIB_ID="$ALTERNATE_DISTRIB_NAME"
|
||||
[ -z "$DISTRIB_RELEASE" ] \
|
||||
&& DISTRIB_RELEASE=$(cat $ALTERNATE_DISTRIB_FILE)
|
||||
[ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.1" ] \
|
||||
&& DISTRIB_CODENAME="Slink"
|
||||
[ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.2" ] \
|
||||
&& DISTRIB_CODENAME="Potato"
|
||||
# [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.3" ] \
|
||||
# && DISTRIB_CODENAME="Woody"
|
||||
[ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$DISTRIB_RELEASE
|
||||
# build the DISTRIB_DESCRIPTION string (never need to be parsed)
|
||||
[ -z "$DISTRIB_DESCRIPTION" ] \
|
||||
&& DISTRIB_DESCRIPTION="$DISTRIB_ID $DESCSTR_DELI $DISTRIB_REL\
|
||||
EASE ($DISTRIB_CODENAME)"
|
||||
else # Only for nothing known compliant distrib :(
|
||||
[ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA
|
||||
[ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
|
||||
[ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA
|
||||
[ -z "$DISTRIB_DESCRIPTION" ] && DISTRIB_DESCRIPTION=$MSG_NONE
|
||||
|
||||
EXIT_STATUS=$ERROR_NOANSWER
|
||||
fi
|
||||
else
|
||||
NO="" # is Description string syntax correct ?
|
||||
if [ -z "$DISTRIB_DESCRIPTION" ] \
|
||||
|| [ -n "$(echo $DISTRIB_DESCRIPTION | \
|
||||
sed -e "s/.*$DESCSTR_DELI.*//")" ]
|
||||
then
|
||||
TMP_DISTRIB_DESC=$(head -n 1 $FILENAME 2>/dev/null)
|
||||
[ -z "$DISTRIB_DESCRIPTION" ] \
|
||||
&& DISTRIB_DESCRIPTION=$TMP_DISTRIB_DESC
|
||||
else
|
||||
TMP_DISTRIB_DESC=$DISTRIB_DESCRIPTION
|
||||
fi
|
||||
|
||||
if [ -z "$TMP_DISTRIB_DESC" ] # head or lsb-release init
|
||||
then # file contains no data
|
||||
DISTRIB_DESCRIPTION=$MSG_NONE
|
||||
NO="y"
|
||||
else # Do simple check
|
||||
[ -n "$(echo $TMP_DISTRIB_DESC | \
|
||||
sed -e "s/.*$DESCSTR_DELI.*//")" ] \
|
||||
&& NO="y"
|
||||
fi
|
||||
|
||||
if [ -n "$NO" ]
|
||||
then # does not contain "release" delimiter
|
||||
[ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA
|
||||
[ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
|
||||
[ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check missing and requested infos, then find the file and get infos
|
||||
GetDistribInfo() {
|
||||
NO="" # /etc/lsb-release data are enough to reply what is requested?
|
||||
[ -n "$ARG_D" ] && [ -z "$DISTRIB_DESCRIPTION" ] && NO="y"
|
||||
[ -z "$NO" ] && [ -n "$ARG_I" ] && [ -z "$DISTRIB_ID" ] && NO="y"
|
||||
[ -z "$NO" ] && [ -n "$ARG_R" ] && [ -z "$DISTRIB_RELEASE" ] && NO="y"
|
||||
[ -z "$NO" ] && [ -n "$ARG_C" ] && [ -z "$DISTRIB_CODENAME" ] && NO="y"
|
||||
|
||||
if [ -n "$NO" ]
|
||||
then
|
||||
if [ ! -f "$CHECKFIRST" ]
|
||||
then
|
||||
CHECKFIRST=$(find $INFO_ROOT/ -maxdepth 1 \
|
||||
-name \*$INFO_DISTRIB_SUFFIX \
|
||||
-and ! -name $INFO_LSB_FILE \
|
||||
-and -type f \
|
||||
2>/dev/null \
|
||||
| head -n 1 ) # keep one of the files found (if many)
|
||||
fi
|
||||
InitDistribInfo $CHECKFIRST
|
||||
fi
|
||||
}
|
||||
|
||||
# Display version of LSB against which distribution is compliant
|
||||
DisplayVersion() {
|
||||
if [ -z "$ARG_S" ]
|
||||
then
|
||||
echo -e "$MSG_LSBVER$LSB_VERSION" # at least "n/a"
|
||||
else
|
||||
MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$LSB_VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
# Display string id of distributor ( i.e. a single word! )
|
||||
DisplayID() {
|
||||
if [ -z "$DISTRIB_ID" ]
|
||||
then
|
||||
## Linux could be part of the distro name (i.e. Turbolinux) or a separate word
|
||||
## set before, after...
|
||||
## also expect a delimiter ( i.e. "release" )
|
||||
if [ -n "$(echo $TMP_DISTRIB_DESC | sed "s/.*$DESCSTR_DELI.*//")" ]
|
||||
then
|
||||
DISTRIB_ID=$MSG_NA
|
||||
else
|
||||
DISTRIB_ID=$(echo " $TMP_DISTRIB_DESC" \
|
||||
| sed -e "s/[[:blank:]][Ll][Ii][Nn][Uu][Xx][[:blank:]]/ /g" \
|
||||
-e "s/\(.*\)[[:blank:]]$DESCSTR_DELI.*/\1/" -e "s/[[:blank:]]//g")
|
||||
fi
|
||||
fi
|
||||
if [ -z "$ARG_S" ]
|
||||
then
|
||||
echo -e "$MSG_DISTID$DISTRIB_ID"
|
||||
else
|
||||
MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_ID"
|
||||
fi
|
||||
}
|
||||
|
||||
# Diplay single line text description of distribution
|
||||
DisplayDescription() {
|
||||
if [ -z "$DISTRIB_DESCRIPTION" ]
|
||||
then
|
||||
# should not be empty since GetDistribInfo called on Initialization !
|
||||
EXIT_STATUS=$ERROR_PROGRAM
|
||||
fi
|
||||
if [ -z "$ARG_S" ]
|
||||
then
|
||||
echo -e "$MSG_DISTDESC$DISTRIB_DESCRIPTION"
|
||||
else
|
||||
MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }\"$DISTRIB_DESCRIPTION\""
|
||||
fi
|
||||
}
|
||||
|
||||
# Display release number of distribution.
|
||||
DisplayRelease() {
|
||||
if [ -z "$DISTRIB_RELEASE" ]
|
||||
then # parse the "$DISTRIB_DESCRIPTION" string
|
||||
DISTRIB_RELEASE=$(echo "$TMP_DISTRIB_DESC" | \
|
||||
sed -e "s/.*$DESCSTR_DELI[[:blank:]]*\([[:digit:]][[:graph:]]*\).*/\1/" )
|
||||
[ "$DISTRIB_RELEASE" = "$TMP_DISTRIB_DESC" ] \
|
||||
|| [ -z "$DISTRIB_RELEASE" ] \
|
||||
&& DISTRIB_RELEASE=$MSG_NA
|
||||
fi
|
||||
if [ -z "$ARG_S" ]
|
||||
then
|
||||
echo -e "$MSG_DISTREL$DISTRIB_RELEASE"
|
||||
else
|
||||
MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_RELEASE"
|
||||
fi
|
||||
}
|
||||
|
||||
# Display codename according to distribution version.
|
||||
DisplayCodename() {
|
||||
if [ -z "$DISTRIB_CODENAME" ]
|
||||
then # parse the "$DISTRIB_DESCRIPTION" string
|
||||
DISTRIB_CODENAME=$(echo "$TMP_DISTRIB_DESC" | \
|
||||
sed -e "s/.*$DESCSTR_DELI.*(\(.*\)).*/\1/")
|
||||
[ "$DISTRIB_CODENAME" = "$TMP_DISTRIB_DESC" ] \
|
||||
|| [ -z "$DISTRIB_CODENAME" ] \
|
||||
&& DISTRIB_CODENAME=$MSG_NA
|
||||
fi
|
||||
if [ -z "$ARG_S" ]
|
||||
then
|
||||
echo -e "$MSG_DISTCODE$(echo "$DISTRIB_CODENAME" | \
|
||||
tr -d "[:blank:]")" # Remove blanks
|
||||
else
|
||||
MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$(echo "$DISTRIB_CODENAME" | \
|
||||
tr -d "[:blank:]")"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# MAIN
|
||||
###############################################################################
|
||||
|
||||
# Check if any prog argument
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
ARG_V="y" # default set to Display LSB Version (not Usage)
|
||||
else
|
||||
EnhancedGetopt "$@" # Parse program args
|
||||
if [ -n "$ARG_S" ] && [ -z "$NB_ARG" ]
|
||||
then
|
||||
ARG_V="y" # set also default for --short when single arg
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update args to All if requested
|
||||
if [ -n "$ARG_A" ]
|
||||
then
|
||||
[ -z "$ARG_C" ] && ARG_C="y"
|
||||
[ -z "$ARG_D" ] && ARG_D="y"
|
||||
[ -z "$ARG_I" ] && ARG_I="y"
|
||||
[ -z "$ARG_R" ] && ARG_R="y"
|
||||
[ -z "$ARG_V" ] && ARG_V="y"
|
||||
fi
|
||||
|
||||
# Initialization
|
||||
GetLSBInfo
|
||||
GetDistribInfo
|
||||
|
||||
# Display requested infos (order as follow)
|
||||
[ -n "$ARG_V" ] && DisplayVersion
|
||||
[ -n "$ARG_I" ] && DisplayID
|
||||
[ -n "$ARG_D" ] && DisplayDescription
|
||||
[ -n "$ARG_R" ] && DisplayRelease
|
||||
[ -n "$ARG_C" ] && DisplayCodename
|
||||
|
||||
[ -n "$ARG_S" ] && echo "$MSG_RESULT"
|
||||
|
||||
exit $EXIT_STATUS
|
|
@ -0,0 +1,93 @@
|
|||
[FILES]
|
||||
|
||||
If the installation is LSB compliant, the \fB"/etc/lsb-release"\fR
|
||||
file should contain the \fBLSB_VERSION\fR field.
|
||||
The value of the field should be a colon separated list of
|
||||
supported module versions indicating the LSB specification
|
||||
modules to which the installation is compliant. If the installation is not
|
||||
compliant, the above field should
|
||||
.B not
|
||||
be present.
|
||||
|
||||
Optional fields are \fBDISTRIB_ID\fR, \fBDISTRIB_RELEASE\fR,
|
||||
\fBDISTRIB_CODENAME\fR, \fBDISTRIB_DESCRIPTION\fR and can be used to
|
||||
override information which is parsed from the
|
||||
\fB"/etc/\fIdistrib\fB-release"\fR file.
|
||||
|
||||
If the \fB"/etc/lsb-release.d"\fR directory exists, it is
|
||||
searched for filenames which are taken as additional module-version
|
||||
strings to add to \fBLSB_VERSION\fR.
|
||||
|
||||
The \fB"/etc/\fIdistrib\fB-release"\fR file contains a description line
|
||||
which is parsed to get information (especially on currently non-LSB
|
||||
compliant systems).
|
||||
|
||||
The required line style is:
|
||||
.br
|
||||
"\fIDistributor\fR \fBrelease\fR \fIx.x\fR \fB(\fR\fICodename\fR\fB)\fR"
|
||||
|
||||
Where \fIDistributor\fR can be a couple of words, but then concatenated
|
||||
(i.e. Linux Foo BarLinux Linux -> FooBarLinux),
|
||||
.br
|
||||
\fIx.x\fR starts with a digit followed by any non-blank characters,
|
||||
\fICodename\fR will also be concatenated (blanks cleanup only).
|
||||
|
||||
\fBrelease\fR may not be used as a keyword in \fBDISTRIB_DESCRIPTION\fR
|
||||
if you don't want to override \fB"/etc/\fIdistrib\fB-release"\fR data.
|
||||
|
||||
\fBNotice:\fR To support the \fBDebian\fR distributions' lack of
|
||||
information (see "/etc/debian_version" file) some have been directly
|
||||
added into the \fBlsb_release\fR script.
|
||||
|
||||
[EXAMPLES]
|
||||
If the "\fB/etc/lsb-release\fR" file contains:
|
||||
|
||||
LSB_VERSION="core-2.0-ia64:core-2.0-noarch"
|
||||
.br
|
||||
DISTRIB_DESCRIPTION="I enjoy using my distrib"
|
||||
|
||||
and the "\fB/etc/lsb-release.d\fR" directory contains:
|
||||
|
||||
graphics-2.0-ia64 graphics-2.0-noarch
|
||||
|
||||
and the "\fB/etc/foobar-release\fP" file contains:
|
||||
|
||||
My Linux Distrib release 1.0RC4 (TryIt)
|
||||
|
||||
Then the results of various options will be:
|
||||
|
||||
.B $ ./lsb_release --all
|
||||
.br
|
||||
LSB Version: core-2.0-ia64:core-2.0-noarch:graphics-2.0-ia64:graphics-2.0-noarch
|
||||
.br
|
||||
Distributor ID: MyDistrib
|
||||
.br
|
||||
Description: I enjoy using my distrib
|
||||
.br
|
||||
Release: 1.0RC4
|
||||
.br
|
||||
Codename: TryIt
|
||||
|
||||
.B $ ./lsb_release -a -s
|
||||
.br
|
||||
1.0 MyDistrib "I enjoy using my distrib" 1.0RC4 TryIt
|
||||
|
||||
If the "/etc/lsb-release" file is absent (indicating this is
|
||||
not an LSB compliant distribution), the result will be:
|
||||
|
||||
.B $ ./lsb_release -a
|
||||
.br
|
||||
LSB Version: n/a
|
||||
.br
|
||||
Distributor ID: MyDistrib
|
||||
.br
|
||||
Description: My Linux Distrib release 1.0RC4 (TryIt)
|
||||
.br
|
||||
Release: 1.0RC4
|
||||
.br
|
||||
Codename: TryIt
|
||||
|
||||
[REPORTING BUGS]
|
||||
Report bugs at http://bugs.linuxbase.org.
|
||||
Please include a complete, self contained example that will allow the
|
||||
bug to be reproduced, and say which version of lsb_release you are using.
|
Loading…
Reference in New Issue