mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
urldetect: Use libosinfo for tree detection too
Ask libosinfo for tree detection, but still fall back to our own implementation if libosinfo fails
This commit is contained in:
parent
e7cdb695c3
commit
97a5af1e43
@ -57,11 +57,11 @@ distro = centos6.10
|
||||
# Latest scientific 6, detected as centos
|
||||
[centos-sl6-latest]
|
||||
url = http://ftp.scientificlinux.org/linux/scientific/6/x86_64/os
|
||||
distro = centos6.10
|
||||
distro = scientificlinux6.10
|
||||
# Latest scientific 7, detected as centos
|
||||
[centos-sl7-latest]
|
||||
url = http://ftp.scientificlinux.org/linux/scientific/7/x86_64/os
|
||||
distro = centos7.0
|
||||
distro = scientificlinux7.6
|
||||
|
||||
# centos7 with exotic archs (i686 is dead)
|
||||
[centos-7-latest]
|
||||
|
@ -229,6 +229,20 @@ class _OSDB(object):
|
||||
return None
|
||||
return media.get_os().get_short_id(), media
|
||||
|
||||
def guess_os_by_tree(self, location):
|
||||
if location.startswith("/"):
|
||||
location = "file://" + location
|
||||
try:
|
||||
tree = Libosinfo.Tree.create_from_location(location, None)
|
||||
except Exception as e:
|
||||
logging.debug("Error creating libosinfo tree object: %s", str(e))
|
||||
return None
|
||||
|
||||
osobj, treeobj = self._os_loader.get_db().guess_os_from_tree(tree)
|
||||
if not osobj:
|
||||
return None
|
||||
return osobj.get_short_id(), treeobj
|
||||
|
||||
def list_os(self):
|
||||
"""
|
||||
List all OSes in the DB
|
||||
|
@ -162,7 +162,14 @@ class _DistroCache(object):
|
||||
"path for detected os_variant=%s",
|
||||
self.libosinfo_mediaobj)
|
||||
return False
|
||||
return True
|
||||
|
||||
def guess_os_from_tree(self):
|
||||
ret = OSDB.guess_os_by_tree(self._fetcher.location)
|
||||
if not ret:
|
||||
return False
|
||||
self.libosinfo_os_variant = ret[0]
|
||||
self.treeinfo_matched = True
|
||||
return True
|
||||
|
||||
|
||||
@ -821,7 +828,7 @@ class _LibosinfoDistro(_DistroTree):
|
||||
def is_valid(cls, cache):
|
||||
if cache.fetcher_is_iso():
|
||||
return cache.guess_os_from_iso()
|
||||
return False
|
||||
return cache.guess_os_from_tree()
|
||||
|
||||
def _set_manual_kernel_paths(self):
|
||||
self._kernel_paths += [
|
||||
|
Loading…
Reference in New Issue
Block a user