Commit 006a4925 authored by Thomas Gambier's avatar Thomas Gambier

grid: fix comparison of OS to keep compatibility

parent 49c80882
Pipeline #20328 failed with stage
in 0 seconds
...@@ -42,18 +42,22 @@ import distro ...@@ -42,18 +42,22 @@ import distro
def _debianize(os_): def _debianize(os_):
""" """
* keep only the major release number in case of debian, otherwise
minor releases would be seen as not compatible to each other.
* consider raspbian as debian * consider raspbian as debian
* don't use codename * in case of Debian:
+ keep only the major release number, otherwise minor releases would be
seen as not compatible to each other.
+ don't use codename as it was always empty with platform.linux_distribution
and we want to keep compatibility with what was already pushed in shacache
""" """
distname, version, codename_ = os_ distname, version, codename = os_
distname = distname.lower() distname = distname.lower()
if distname == 'raspbian': if distname == 'raspbian':
distname = 'debian' distname = 'debian'
if distname == 'debian' and '.' in version: if distname == 'debian':
version = version.split('.')[0] if '.' in version:
return distname, version, '' version = version.split('.')[0]
codename = ''
return distname, version, codename
def os_matches(os1, os2): def os_matches(os1, os2):
......
...@@ -45,6 +45,7 @@ class TestDebianize(unittest.TestCase): ...@@ -45,6 +45,7 @@ class TestDebianize(unittest.TestCase):
(('debian', '6.0.6', ''), ('debian', '6', '')), (('debian', '6.0.6', ''), ('debian', '6', '')),
(('debian', '7.0', ''), ('debian', '7', '')), (('debian', '7.0', ''), ('debian', '7', '')),
(('Debian', '8.11', ''), ('debian', '8', '')), (('Debian', '8.11', ''), ('debian', '8', '')),
(('debian', '10.9', 'buster'), ('debian', '10', '')),
]: ]:
self.assertEqual(distribution._debianize(provided), expected) self.assertEqual(distribution._debianize(provided), expected)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment