Update lsb_release.py to cope with the new Debian Ports' release label
authorHelge Deller <deller@gmx.de>
Wed, 29 Jun 2016 16:12:43 +0000 (18:12 +0200)
committerDidier Raboud <odyx@debian.org>
Wed, 29 Jun 2016 16:12:43 +0000 (18:12 +0200)
Closes: #827137
Changed-by: Didier Raboud <odyx@debian.org> to have tests for both the old and the new versions
lsb_release.py
test/apt-cache
test/test_lsb_release.py

index ce5c93dd05f2df1eb8a4ad0e4407d97721481448..0c4b0783bc3366d48b98e4127ed8911364ac6ad7 100644 (file)
@@ -184,7 +184,7 @@ def parse_apt_policy():
 def guess_release_from_apt(origin='Debian', component='main',
                            ignoresuites=('experimental'),
                            label='Debian',
-                           alternate_olabels={'Debian Ports':'ftp.debian-ports.org'}):
+                           alternate_olabels={'Debian Ports': ('ftp.ports.debian.org', 'ftp.debian-ports.org')}):
     releases = parse_apt_policy()
 
     if not releases:
@@ -197,7 +197,7 @@ def guess_release_from_apt(origin='Debian', component='main',
         x[1].get('component', '') == component and
         x[1].get('label', '') == label) or (
         x[1].get('origin', '') in alternate_olabels and
-        x[1].get('label', '') == alternate_olabels.get(x[1].get('origin', '')))]
+        x[1].get('label', '') in alternate_olabels.get(x[1].get('origin', '')))]
 
     # Check again to make sure we didn't wipe out all of the releases
     if not releases:
@@ -285,7 +285,7 @@ def guess_debian_release():
         release = rinfo.get('version')
 
         # Special case Debian-Ports as their Release file has 'version': '1.0'
-        if release == '1.0' and rinfo.get('origin') == 'Debian Ports' and rinfo.get('label') == 'ftp.debian-ports.org':
+        if release == '1.0' and rinfo.get('origin') == 'Debian Ports' and rinfo.get('label') in ('ftp.ports.debian.org', 'ftp.debian-ports.org'):
             release = None
             rinfo.update({'suite': 'unstable'})
 
index 7492dc07010774385465de1ce8433e2d02e20e05..eb503a5b8d20dd5fb9c0ca891b01129dc2b5568e 100755 (executable)
@@ -46,9 +46,14 @@ if os.environ.get('TEST_APT_CACHE_UNSTABLE') == '500':
        print('     release o=Debian,a=unstable,n=sid,l=Debian,c=main')
        print('     origin MirRor-is-not-read')
 
-if os.environ.get('TEST_APT_CACHE_UNSTABLE_PORTS') == '500':
+if os.environ.get('TEST_APT_CACHE_UNSTABLE_PORTS_OLD') == '500':
        print(' 500 http://MirRor_is_not_read/folder-either-debian-ports/ sid/main arch Packages')
        print('     release o=Debian Ports,a=unstable,n=sid,l=ftp.debian-ports.org,c=main,v=1.0')
        print('     origin MirRor-is-not-read')
 
+if os.environ.get('TEST_APT_CACHE_UNSTABLE_PORTS') == '500':
+       print(' 500 http://MirRor_is_not_read/folder-either-debian-ports/ sid/main arch Packages')
+       print('     release o=Debian Ports,a=unstable,n=sid,l=ftp.ports.debian.org,c=main,v=1.0')
+       print('     origin MirRor-is-not-read')
+
 print('Pinned packages:')
index 10b969a759f9215c2fde94d8084a08a021809101..936af904e0d0622747b676282637c1fdee613ae5 100644 (file)
@@ -163,7 +163,7 @@ class TestLSBRelease(unittest.TestCase):
                                label='l8bel',
                                component='c0mp0nent',
                                ignoresuites=('c0mp0nentIgn'),
-                               alternate_olabels={'P-or1g1n':'P-l8bel'}),
+                               alternate_olabels={'P-or1g1n': ('P-l8bel', 'P-l9bel')}),
                        supposed_output)
                os.environ.pop('TEST_APT_CACHE1')
                os.environ.pop('TEST_APT_CACHE2')
@@ -255,21 +255,23 @@ class TestLSBRelease(unittest.TestCase):
                        os.remove(fn)
                os.environ.pop('LSB_ETC_DEBIAN_VERSION')
 
-               # Test "unstable releases with Debian Ports" that end in /sid, go read valid apt-cache policy
-               os.environ['TEST_APT_CACHE_UNSTABLE_PORTS'] = '500'
                distinfo['CODENAME'] = 'sid'
                distinfo['RELEASE'] = 'unstable'
                distinfo['DESCRIPTION'] = '%(ID)s %(OS)s %(RELEASE)s (%(CODENAME)s)' % distinfo
-               for rno in lr.RELEASE_CODENAME_LOOKUP:
-                       fn = 'test/debian_version_' + rnd_string(5,12)
-                       f = open(fn,'w')
-                       f.write(lr.RELEASE_CODENAME_LOOKUP[rno] + '/sid')
-                       f.close()
-                       os.environ['LSB_ETC_DEBIAN_VERSION'] = fn
-                       self.assertEqual(lr.guess_debian_release(),distinfo)
-                       os.remove(fn)
+
+               for CODE in ('PORTS', 'PORTS_OLD'):
+                       # Test "unstable releases with Debian Ports" that end in /sid, go read valid apt-cache policy
+                       os.environ['TEST_APT_CACHE_UNSTABLE_' + CODE] = '500'
+                       for rno in lr.RELEASE_CODENAME_LOOKUP:
+                               fn = 'test/debian_version_' + rnd_string(5,12)
+                               f = open(fn,'w')
+                               f.write(lr.RELEASE_CODENAME_LOOKUP[rno] + '/sid')
+                               f.close()
+                               os.environ['LSB_ETC_DEBIAN_VERSION'] = fn
+                               self.assertEqual(lr.guess_debian_release(),distinfo)
+                               os.remove(fn)
+                       os.environ.pop('TEST_APT_CACHE_UNSTABLE_' + CODE)
                os.environ.pop('LSB_ETC_DEBIAN_VERSION')
-               os.environ.pop('TEST_APT_CACHE_UNSTABLE_PORTS')
                os.environ.pop('TEST_APT_CACHE_UNSTABLE')
 
        def test_get_lsb_information(self):