lsb 3.0-8 Debian release.
authorChris Lawrence <lawrencc@debian.org>
Thu, 22 Sep 2005 00:53:37 +0000 (20:53 -0400)
committerDidier Raboud <odyx@debian.org>
Thu, 22 Sep 2005 00:53:37 +0000 (20:53 -0400)
debian/changelog
debian/control
debian/lsb-base.README.Debian
debian/lsb-release.README.Debian [new file with mode: 0644]
debian/lsb-release.dirs [new file with mode: 0644]
debian/lsb-release.manpages [new file with mode: 0644]
debian/rules
lsb_release [new file with mode: 0755]
lsb_release.1 [new file with mode: 0644]

index be05f23ce39e0df070152b5f058a4725b7bfc35d..42155d664d164e2db903e06f6980e342eb7cf51f 100644 (file)
@@ -1,3 +1,13 @@
+lsb (3.0-8) unstable; urgency=low
+
+  * Bring in lsb-release (binary) package; rewritten to handle -v properly
+    for LSB 2.x and beyond.
+  * /etc/lsb-release is no longer provided by the lsb-release package;
+    it is probably best managed in base-files (which derived distros are
+    probably branding anyway).
+
+ -- Chris Lawrence <lawrencc@debian.org>  Wed, 21 Sep 2005 20:53:37 -0400
+
 lsb (3.0-7) unstable; urgency=low
 
   * Update lsb-core dependencies to include:
index 4312cab3f4e80ce5b54c8b642f5a0591a48c1d40..cb5907d693c218bea7fb77741067df352c641a80 100644 (file)
@@ -96,7 +96,7 @@ Architecture: all
 Depends: sed, ncurses-bin
 Replaces: lsb (<< 2.0-6)
 Conflicts: lsb (<< 2.0-6)
-Priority: important
+Priority: required
 Description: Linux Standard Base 3.0 init script functionality
  The Linux Standard Base (http://www.linuxbase.org/) is a standard
  core system that third-party applications written for Linux can
@@ -105,3 +105,21 @@ Description: Linux Standard Base 3.0 init script functionality
  This package only includes the init-functions shell library, which
  may be used by other packages' initialization scripts for console
  logging and other purposes.
+
+Package: lsb-release
+Architecture: all
+Depends: python (>> 2.3), python (<< 2.5)
+Recommends: lsb
+Description: Linux Standard Base version reporting utility
+ The Linux Standard Base (http://www.linuxbase.org/) is a standard
+ core system that third-party applications written for Linux can
+ depend upon.
+ .
+ The lsb-release command is a simple tool to help identify the Linux
+ distribution being used and its compliance with the Linux Standard Base.
+ LSB conformance will not be reported unless the required metapackages are
+ installed.
+ .
+ While it is intended for use by LSB packages, this command may also
+ be useful for programmatically distinguishing between a pure Debian
+ installation and derived distributions.
index 415a6fb61cc0312d4b837c9a367723cbfada7afc..d06ccce31320f2ca578d6afe5eb1c8de596c4809 100644 (file)
@@ -1,3 +1,6 @@
+lsb-base for Debian
+-------------------
+
 The Debian lsb-base package provides a series of logging functions to
 permit simplified logging of init script actions.
 
@@ -87,4 +90,4 @@ If supplied, this script fragment should be compatible with any Debian
 /bin/sh, as init scripts sourcing this file may be running under any
 Bourne-style shell permitted by Debian policy (i.e. not just bash).
 
- -- Chris Lawrence <lawrencc@debian.org>, Fri Sep 16 19:20:32 2005
+ -- Chris Lawrence <lawrencc@debian.org>, Wed Sep 21 20:21:36 2005
diff --git a/debian/lsb-release.README.Debian b/debian/lsb-release.README.Debian
new file mode 100644 (file)
index 0000000..437136d
--- /dev/null
@@ -0,0 +1,38 @@
+lsb-release for Debian
+----------------------
+
+NB: These notes are intended for anyone building a derived
+distribution using this package.  They are not likely to be helpful to
+end-users.
+
+This is a reimplementation of the classic lsb_release command; its
+main new feature is support for the new output for the -v option in
+LSB 2.x/3.x.  This version of lsb_release is also designed to only report
+that a system is LSB compliant if the correct LSB metapackages are available,
+and to properly support situations where only certain LSB metapackages
+(i.e. lsb-core only) are installed.
+
+Distribution-specific information should be *separately provided* in
+/etc/lsb-release; it is no longer provided in this package.  It is my
+hope that in Debian, this will be managed by the base-files
+maintainer (who already maintains the debian_version file).
+
+The file should be formatted as a series of shell variable
+assignments.  Multiword strings should be quoted in double quotes.
+You should not assume this file is actually parsed by a Bourne shell
+(i.e., no fancy stuff).  Example:
+
+DISTRIB_ID=(Distributor ID)
+DISTRIB_DESCRIPTION=(A human-readable description of the release)
+DISTRIB_RELEASE=(The release number)
+DISTRIB_CODENAME=(The codename for the release)
+
+Any other variable assignments will be silently ignored.  For Debian
+3.1 (sarge), it might have read:
+
+DISTRIB_ID=Debian
+DISTRIB_DESCRIPTION="Debian GNU/Linux 3.1 (sarge)"
+DISTRIB_RELEASE=3.1
+DISTRIB_CODENAME=sarge
+
+ -- Chris Lawrence <lawrencc@debian.org>, Wed Sep 21 20:40:25 2005
diff --git a/debian/lsb-release.dirs b/debian/lsb-release.dirs
new file mode 100644 (file)
index 0000000..5e56e04
--- /dev/null
@@ -0,0 +1 @@
+/bin
diff --git a/debian/lsb-release.manpages b/debian/lsb-release.manpages
new file mode 100644 (file)
index 0000000..c610296
--- /dev/null
@@ -0,0 +1 @@
+lsb_release.1
index 54a1b4a0ebfe19c67ac7a7b527cc0250e666d14b..cbecbf7f44bc709aa99dea81699d36dc279c17b9 100755 (executable)
@@ -74,8 +74,9 @@ install: build
 
        # Add here commands to install the package into debian/lsb.
        #$(MAKE) install DESTDIR=$(CURDIR)/debian/lsb
-       cp initdutils.py install_initd remove_initd lsbinstall debian/lsb-core/usr/lib/lsb
-       cp init-functions debian/lsb-base/lib/lsb
+       cp -p initdutils.py install_initd remove_initd lsbinstall debian/lsb-core/usr/lib/lsb
+       cp -p init-functions debian/lsb-base/lib/lsb
+       cp -p lsb_release debian/lsb-release/bin
 
 # Build architecture-independent files here.
 binary-indep: build install
diff --git a/lsb_release b/lsb_release
new file mode 100755 (executable)
index 0000000..d639d60
--- /dev/null
@@ -0,0 +1,186 @@
+#!/usr/bin/python
+
+# lsb_release command for Debian
+# (C) 2005 Chris Lawrence <lawrencc@debian.org>
+
+#    This package 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; version 2 dated June, 1991.
+
+#    This package 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 package; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+#    02111-1307, USA.
+
+from optparse import OptionParser
+import sys
+import commands
+import os
+import re
+
+# LSB compliance packages... may grow eventually
+PACKAGES = 'lsb-core lsb-cxx lsb-graphics'
+
+modnamere = re.compile(r'lsb-(?P<module>[a-z]+)-(?P<arch>[^ ]+)(?: \(= (?P<version>[0-9.]+)\))?')
+
+def valid_lsb_versions(version, module):
+    # If a module is ever released that only appears in >= version, deal
+    # with that here
+    if version == '3.0':
+        return ['2.0', '3.0']
+
+    return [version]
+
+def check_modules_installed():
+    # Find which LSB modules are installed on this system
+    output = commands.getoutput("dpkg-query -f '${Version} ${Provides}\n' -W %s 2>/dev/null" % PACKAGES)
+    if not output:
+        return []
+
+    modules = []
+    for line in output.split(os.linesep):
+        version, provides = line.split(' ', 1)
+        version = version.split('-', 1)[0]
+        for pkg in provides.split(','):
+            mob = modnamere.search(pkg)
+            if not mob:
+                continue
+
+            mgroups = mob.groupdict()
+            # If no versioned provides...
+            if mgroups.get('version'):
+                module = '%(module)s-%(version)s-%(arch)s' % mgroups
+                modules += [module]
+            else:
+                module = mgroups['module']
+                for v in valid_lsb_versions(version, module):
+                    mgroups['version'] = v
+                    module = '%(module)s-%(version)s-%(arch)s' % mgroups
+                    modules += [module]
+                    
+    return modules
+
+RELEASE_CODENAME_LOOKUP = {
+    '1.1' : 'buzz',
+    '1.2' : 'rex',
+    '1.3' : 'bo',
+    '2.0' : 'hamm',
+    '2.1' : 'slink',
+    '2.2' : 'potato',
+    '3.0' : 'woody',
+    '3.1' : 'sarge',
+    '3.2' : 'etch', # XXX - may not end up as 3.2
+    }
+
+def guess_debian_release():
+    distinfo = {'ID' : 'Debian'}
+
+    kern = os.uname()[0]
+    if kern in ('Linux', 'Hurd', 'NetBSD'):
+        distinfo['OS'] = 'GNU/'+kern
+    elif kern == 'FreeBSD':
+        distinfo['OS'] = 'GNU/k'+kern
+
+    if os.path.exists('/etc/debian_version'):
+        release = open('/etc/debian_version').read().strip()
+        if not release[0:1].isalpha():
+            # /etc/debian_version should be numeric
+            codename = RELEASE_CODENAME_LOOKUP.get(release, 'n/a')
+            distinfo.update({ 'RELEASE' : release, 'CODENAME' : codename })
+        else:
+            # Guess with apt policy before being this stupid?
+            distinfo.update({ 'RELEASE' : release, 'CODENAME' : 'sid'} )
+
+    distinfo['DESCRIPTION'] = '%(ID)s %(OS)s %(RELEASE)s (%(CODENAME)s)' % distinfo
+    return distinfo
+
+def get_distro_information():
+    distinfo = {}
+    if os.path.exists('/etc/lsb-release'):
+        for line in open('/etc/lsb-release'):
+            line = line.strip()
+            if not line:
+                continue
+            var, arg = line.split('=', 1)
+            if var.startswith('DISTRIB_'):
+                var = var[8:]
+                if arg.startswith('"') and arg.endswith('"'):
+                    arg = arg[1:-1]
+                distinfo[var] = arg
+    else:
+        distinfo = guess_debian_release()
+
+    return distinfo
+    
+def main():
+    parser = OptionParser()
+    parser.add_option('-v', '--version', dest='output', action='store_const',
+                      const='version', default='version',
+                      help="show LSB modules this system supports")
+    parser.add_option('-i', '--id', dest='output', action='store_const',
+                      const='id', help="show distributor ID")
+    parser.add_option('-d', '--description', dest='output',
+                      action='store_const', const='description',
+                      help="show description of this distribution")
+    parser.add_option('-r', '--release', dest='output',
+                      action='store_const', const='release',
+                      help="show release number of this distribution")
+    parser.add_option('-c', '--codename', dest='output',
+                      action='store_const', const='codename',
+                      help="show code name of this distribution")
+    parser.add_option('-a', '--all', dest='output',
+                      action='store_const', const='all',
+                      help="show all of the above information")
+    parser.add_option('-s', '--short', dest='short',
+                      action='store_true', default=False,
+                      help="show all of the above information in short format")
+    
+    (options, args) = parser.parse_args()
+    if args:
+        parser.error("No arguments are permitted")
+
+    short = (options.short)
+    all = (options.output=='all')
+
+    distinfo = get_distro_information()
+
+    if options.output == 'version' or all:
+        verinfo = check_modules_installed()
+        if not verinfo:
+            print >> sys.stderr, "No LSB modules are available."
+        elif short:
+            print ':'.join(verinfo)
+        else:
+            print 'LSB Version:\t' + ':'.join(verinfo)
+
+    if options.output == 'id' or all:
+        if short:
+            print distinfo.get('ID', 'n/a')
+        else:
+            print 'Distributor ID:\t%s' % distinfo.get('ID', 'n/a')
+
+    if options.output == 'description' or all:
+        if short:
+            print distinfo.get('DESCRIPTION', 'n/a')
+        else:
+            print 'Description:\t%s' % distinfo.get('DESCRIPTION', 'n/a')
+
+    if options.output == 'release' or all:
+        if short:
+            print distinfo.get('RELEASE', 'n/a')
+        else:
+            print 'Release:\t%s' % distinfo.get('RELEASE', 'n/a')
+
+    if options.output == 'codename' or all:
+        if short:
+            print distinfo.get('CODENAME', 'n/a')
+        else:
+            print 'Codename:\t%s' % distinfo.get('CODENAME', 'n/a')
+
+if __name__ == '__main__':
+    main()
diff --git a/lsb_release.1 b/lsb_release.1
new file mode 100644 (file)
index 0000000..faaedcf
--- /dev/null
@@ -0,0 +1,52 @@
+.TH lsb_release 1
+.SH NAME
+lsb_release \- print distribution-specific information
+.SH SYNOPSIS
+.B lsb_release
+.I "[options]"
+.SH DESCRIPTION
+The
+.B lsb_release
+command provides certain LSB (Linux Standard Base) and
+distribution-specific information.
+.PP
+If no options are given, the \fI\-v\fP option is assumed.
+.SH OPTIONS
+The program follows the usual GNU command line syntax, with long
+options starting with two dashes (`\-\-').
+A summary of options are included below.
+.TP
+.B \-v, \-\-version
+Show the version of the LSB against which your current installation is
+compliant.  The version is expressed as a colon separated list of LSB
+module descriptions.
+.TP
+.B \-i, \-\-id
+Display the distributor's ID.
+.TP
+.B \-d, \-\-description
+Display a description of the currently installed distribution.
+.TP
+.B \-r, \-\-release
+Display the release number of the currently installed distribution.
+.TP
+.B \-c, \-\-codename
+Display the code name of the currently installed distribution.
+.TP
+.B \-a, \-\-all
+Display all of the above information.
+.B \-s, \-\-short
+Use the short output format for any information displayed.  This
+format omits the leading header(s).
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.SH NOTES
+This is a reimplementation of the 
+.B lsb_release
+command provided by the Free Standards Group.  Any bugs are solely the
+responsibility of the author below.
+.SH "SEE ALSO"
+lsb(8)
+.SH AUTHOR
+Chris Lawrence <lawrencc@debian.org>.