From: Chris Lawrence Date: Sat, 28 Jan 2006 23:24:49 +0000 (-0500) Subject: lsb 3.0-15 Debian release. X-Git-Tag: archive/raspbian/10.2018112800+rpi1^2~251 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a820113a75f4bac412d60a6d25b8d487fe66ff2d;p=lsb.git lsb 3.0-15 Debian release. --- diff --git a/debian/changelog b/debian/changelog index 9094c99..17cdeaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +lsb (3.0-15) unstable; urgency=low + + * Test $TERM in log_use_fancy_output; if it is "dumb" we don't have a + fancy TTY. (Closes: #350291) + * Better heuristics in lsb_release to guess whether we're running on + testing or unstable. (Closes: #95824, #341231) + Note that /etc/lsb-release, if present, will override these results, + and /etc/debian_version has priority. + * Fix lsb_release to allow multiple fields to be displayed (i.e. + lsb_release --id --codename). + + -- Chris Lawrence Sat, 28 Jan 2006 18:24:49 -0500 + lsb (3.0-14) unstable; urgency=low * Allow lsb-base to be built on sarge. (Closes: #345984) diff --git a/init-functions b/init-functions index f788b7e..8bd7c84 100644 --- a/init-functions +++ b/init-functions @@ -127,7 +127,7 @@ killproc () { log_use_fancy_output () { TPUT=/usr/bin/tput EXPR=/usr/bin/expr - if [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; then + if [ "x$TERM" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; then FANCYTTY=1 true else diff --git a/lsb_release b/lsb_release index 408aa0b..3501aed 100755 --- a/lsb_release +++ b/lsb_release @@ -23,6 +23,21 @@ import commands import os import re +# XXX: Update as needed +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 + } + +TESTING_CODENAME = 'etch' + # LSB compliance packages... may grow eventually PACKAGES = 'lsb-core lsb-cxx lsb-graphics' @@ -65,17 +80,38 @@ def check_modules_installed(): 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 - } +priorityre = re.compile(r'\s+(\d+)\s+') +versionre = re.compile(r'release v=([\d.+]+),o=Debian,a=([^,]+).*c=main') +releasere = re.compile(r'release o=Debian,a=([^,]+).*c=main') + +def guess_release_from_apt(): + releases = [] + + priority = None + policy = commands.getoutput('apt-cache policy 2>/dev/null') + for line in policy.split('\n'): + m = priorityre.match(line) + if m: + priority = int(m.group(1)) + + m = versionre.search(line) + if m and priority is not None: + releases.append((priority, m.group(1))) + + m = releasere.search(line) + if m and priority is not None: + releases.append((priority, m.group(1))) + + if not releases: + return None + + releases.sort() + releases.reverse() + for (pri, release) in releases: + if release != 'experimental': + return release + + return None def guess_debian_release(): distinfo = {'ID' : 'Debian'} @@ -97,8 +133,17 @@ def guess_debian_release(): 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'}) + release = guess_release_from_apt() + if release: + codename = RELEASE_CODENAME_LOOKUP.get(release) + if not codename: + if release == 'testing': + codename = TESTING_CODENAME + else: + codename = 'sid' + distinfo.update({ 'RELEASE' : release, 'CODENAME' : codename}) + else: + distinfo.update({ 'RELEASE' : release, 'CODENAME' : 'sid'}) distinfo['DESCRIPTION'] += ' %(RELEASE)s (%(CODENAME)s)' % distinfo return distinfo @@ -123,22 +168,23 @@ def get_distro_information(): def main(): parser = OptionParser() - parser.add_option('-v', '--version', dest='output', action='store_const', - const='version', default='version', + parser.add_option('-v', '--version', dest='version', action='store_true', + default=False, 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', + parser.add_option('-i', '--id', dest='id', action='store_true', + default=False, + help="show distributor ID") + parser.add_option('-d', '--description', dest='description', + default=False, action='store_true', help="show description of this distribution") - parser.add_option('-r', '--release', dest='output', - action='store_const', const='release', + parser.add_option('-r', '--release', dest='release', + default=False, action='store_true', help="show release number of this distribution") - parser.add_option('-c', '--codename', dest='output', - action='store_const', const='codename', + parser.add_option('-c', '--codename', dest='codename', + default=False, action='store_true', help="show code name of this distribution") - parser.add_option('-a', '--all', dest='output', - action='store_const', const='all', + parser.add_option('-a', '--all', dest='all', + default=False, action='store_true', help="show all of the above information") parser.add_option('-s', '--short', dest='short', action='store_true', default=False, @@ -149,11 +195,13 @@ def main(): parser.error("No arguments are permitted") short = (options.short) - all = (options.output=='all') + all = (options.all) + none = not (options.all or options.version or options.id or + options.description or options.codename or options.release) distinfo = get_distro_information() - if options.output == 'version' or all: + if none or all or options.version: verinfo = check_modules_installed() if not verinfo: print >> sys.stderr, "No LSB modules are available." @@ -162,25 +210,25 @@ def main(): else: print 'LSB Version:\t' + ':'.join(verinfo) - if options.output == 'id' or all: + if options.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 options.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 options.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 options.codename or all: if short: print distinfo.get('CODENAME', 'n/a') else: