summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lsb_release.py9
-rw-r--r--test/test_lsb_release.py9
2 files changed, 14 insertions, 4 deletions
diff --git a/lsb_release.py b/lsb_release.py
index d36eeb6..ecf46e3 100644
--- a/lsb_release.py
+++ b/lsb_release.py
@@ -41,8 +41,8 @@ RELEASE_CODENAME_LOOKUP = {
'4.0' : 'etch',
'5.0' : 'lenny',
'6.0' : 'squeeze',
- '7.0' : 'wheezy',
- '8.0' : 'jessie',
+ '7' : 'wheezy',
+ '8' : 'jessie',
}
TESTING_CODENAME = 'unknown.new.testing'
@@ -57,7 +57,10 @@ def lookup_codename(release, unknown=None):
if not m:
return unknown
- shortrelease = '%s.%s' % m.group(1,2)
+ if int(m.group(1)) < 7:
+ shortrelease = '%s.%s' % m.group(1,2)
+ else:
+ shortrelease = '%s' % m.group(1)
return RELEASE_CODENAME_LOOKUP.get(shortrelease, unknown)
# LSB compliance packages... may grow eventually
diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py
index d100c21..c449a4b 100644
--- a/test/test_lsb_release.py
+++ b/test/test_lsb_release.py
@@ -40,6 +40,9 @@ class TestLSBRelease(unittest.TestCase):
cdn = lr.RELEASE_CODENAME_LOOKUP[rno]
# Test that 1.1, 1.1r0 and 1.1.8 lead to buzz. Default is picked randomly and is not supposed to go trough
badDefault = rnd_string(0,9)
+ # From Wheezy on, the codename is defined by the first number but a dot-revision is mandatory
+ if float(rno) >= 7:
+ rno = rno + '.' + str(random.randint(0,9))
self.assertEqual(lr.lookup_codename(rno,badDefault),cdn,'Release name `' + rno + '` is not recognized.')
self.assertEqual(lr.lookup_codename(rno + 'r' + str(random.randint(0,9)),badDefault),cdn,'Release name `' + rno + 'r*` is not recognized.')
self.assertEqual(lr.lookup_codename(rno + '.' + str(random.randint(0,9)),badDefault),cdn,'Release name `' + rno + '.*` is not recognized.')
@@ -241,7 +244,11 @@ class TestLSBRelease(unittest.TestCase):
# Test "stable releases" with numeric debian_versions
for rno in lr.RELEASE_CODENAME_LOOKUP:
- distinfo['RELEASE'] = rno + random.choice('.r') + str(random.randint(0,9))
+ # From Wheezy on, the codename is defined by the first number but a dot-revision is mandatory
+ if float(rno) >= 7:
+ distinfo['RELEASE'] = rno + '.' + str(random.randint(0,9))
+ else:
+ distinfo['RELEASE'] = rno + random.choice('.r') + str(random.randint(0,9))
distinfo['CODENAME'] = lr.RELEASE_CODENAME_LOOKUP[rno]
distinfo['DESCRIPTION'] = '%(ID)s %(OS)s %(RELEASE)s (%(CODENAME)s)' % distinfo
fn = 'test/debian_version_' + rnd_string(5,5)