[virt-manager PATCH 2/3] urldetect: add version detection for Mageia

Pino Toscano ptoscano at redhat.com
Wed Aug 26 10:44:55 UTC 2020


Use the VERSION file not only to detect whether the tree is a Mageia
tree, but also to detect the version.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 virtinst/install/urldetect.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/virtinst/install/urldetect.py b/virtinst/install/urldetect.py
index 7878a1a5..908781e6 100644
--- a/virtinst/install/urldetect.py
+++ b/virtinst/install/urldetect.py
@@ -30,6 +30,7 @@ class _DistroCache(object):
         self.suse_content = None
         self.checked_for_suse_content = False
         self.debian_media_type = None
+        self.mageia_version = None
 
         self.libosinfo_os_variant = None
         self.libosinfo_mediaobj = None
@@ -790,13 +791,30 @@ class _MageiaDistro(_DistroTree):
 
     @classmethod
     def is_valid(cls, cache):
-        return cache.content_regex("VERSION", ".*Mageia.*")
+        if not cache.mageia_version:
+            content = cache.acquire_file_content("VERSION")
+            if not content:
+                return False
+
+            m = re.match("^Mageia (\d+) .*", content)
+            if not m:
+                return False
+
+            cache.mageia_version = m.group(1)
+
+        return bool(cache.mageia_version)
 
     def _set_manual_kernel_paths(self):
         self._kernel_paths += [
             ("isolinux/%s/vmlinuz" % self.arch,
              "isolinux/%s/all.rdz" % self.arch)]
 
+    def _detect_version(self):
+        # version is just an integer
+        variant = "mageia" + self.cache.mageia_version
+        if OSDB.lookup_os(variant):
+            return variant
+
 
 class _GenericTreeinfoDistro(_DistroTree):
     """
-- 
2.26.2




More information about the virt-tools-list mailing list