curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #01967
[Merge] ~dbungert/curtin:lp-1934513 into curtin:master
Dan Bungert has proposed merging ~dbungert/curtin:lp-1934513 into curtin:master.
Commit message:
distro: handle RockyLinux and ID_LIKE
Add an explicit entry for RockyLinux to the OS table.
Add support for ID_LIKE to simplify new variant handling.
Co-authored-by: Julian Andres Klode <julian.klode@xxxxxxxxxxxxx>
Requested reviews:
curtin developers (curtin-dev)
Related bugs:
Bug #1934513 in curtin: "support for rocky linux"
https://bugs.launchpad.net/curtin/+bug/1934513
For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/412653
--
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:lp-1934513 into curtin:master.
diff --git a/curtin/distro.py b/curtin/distro.py
index 82a4dd5..d96a174 100644
--- a/curtin/distro.py
+++ b/curtin/distro.py
@@ -23,7 +23,8 @@ from .log import LOG
DistroInfo = namedtuple('DistroInfo', ('variant', 'family'))
DISTRO_NAMES = ['arch', 'centos', 'debian', 'fedora', 'freebsd', 'gentoo',
- 'opensuse', 'redhat', 'rhel', 'sles', 'suse', 'ubuntu']
+ 'opensuse', 'redhat', 'rhel', 'rocky', 'sles', 'suse',
+ 'ubuntu']
# python2.7 lacks PEP 435, so we must make use an alternative for py2.7/3.x
@@ -37,7 +38,7 @@ DISTROS = distro_enum(*DISTRO_NAMES)
OS_FAMILIES = {
DISTROS.debian: [DISTROS.debian, DISTROS.ubuntu],
DISTROS.redhat: [DISTROS.centos, DISTROS.fedora, DISTROS.redhat,
- DISTROS.rhel],
+ DISTROS.rhel, DISTROS.rocky],
DISTROS.gentoo: [DISTROS.gentoo],
DISTROS.freebsd: [DISTROS.freebsd],
DISTROS.suse: [DISTROS.opensuse, DISTROS.sles, DISTROS.suse],
@@ -114,8 +115,19 @@ def _parse_redhat_release(release_file=None, target=None):
def get_distroinfo(target=None):
- variant_name = os_release(target=target)['ID']
- variant = name_to_distro(variant_name)
+ variant_os_release = os_release(target=target)
+ variant_name = variant_os_release['ID']
+ try:
+ variant = name_to_distro(variant_name)
+ except ValueError:
+ for variant_name in variant_os_release["ID_LIKE"].split():
+ try:
+ variant = name_to_distro(variant_name)
+ break
+ except ValueError:
+ pass
+ else:
+ raise ValueError("Unknown distro: %s" % variant_os_release['ID'])
family = DISTRO_TO_OSFAMILY.get(variant)
return DistroInfo(variant, family)
diff --git a/tests/unittests/test_distro.py b/tests/unittests/test_distro.py
index 380680c..7532126 100644
--- a/tests/unittests/test_distro.py
+++ b/tests/unittests/test_distro.py
@@ -210,6 +210,14 @@ class TestDistroInfo(CiTestCase):
distro_obj = distro.get_osfamily()
self.assertEqual(family, distro_obj)
+ def test_get_from_idlike(self):
+ name = 'NotADistro'
+ self.mock_os_release.return_value = {
+ 'ID': name,
+ 'ID_LIKE': "stuff things rhel"
+ }
+ self.assertEqual('rhel', distro.get_distro(name))
+
class TestDistroIdentity(CiTestCase):
Follow ups