osdict: expand the "unknown" check for any distro
Currently osinfo-db has "unknown" entries for fedora, opensuse and asianux. Considering this list may grow even more at some point, let's just make the check more generic and use it for all of them instead of keeping it for fedora only. Changes have also been done in urldetect and tests_url, as those also used latest_fedora_version(). Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
5f5b49f289
commit
7612c5bdcd
|
@ -126,7 +126,7 @@ def _sanitize_osdict_name(detectdistro):
|
|||
if detectdistro == "testsuite-fedora-rawhide":
|
||||
# Special value we use in the test suite to always return the latest
|
||||
# fedora when checking rawhide URL
|
||||
return OSDB.latest_fedora_version()
|
||||
return OSDB.latest_os_version("fedora")
|
||||
|
||||
return detectdistro
|
||||
|
||||
|
|
|
@ -208,11 +208,15 @@ class _OSDB(object):
|
|||
return None
|
||||
|
||||
osname = ret[0].get_short_id()
|
||||
if osname == "fedora-unknown":
|
||||
osname = self.latest_fedora_version()
|
||||
logging.debug("Detected location=%s as os=fedora-unknown. "
|
||||
"Converting that to the latest fedora OS version=%s",
|
||||
location, osname)
|
||||
if osname.endswith("-unknown"):
|
||||
# We want to get whatever the name is apart from unknown, instead
|
||||
# of getting the distro, as some enterprise distros may have more
|
||||
# than one "unknown" entry and we'd like to match the correct one.
|
||||
osdistro = osname.split("-unknown")[0]
|
||||
osname = self.latest_os_version(osdistro)
|
||||
logging.debug("Detected location=%s as os=%s-unknown. "
|
||||
"Converting that to the latest %s OS version=%s",
|
||||
location, osdistro, osdistro, osname)
|
||||
|
||||
return osname
|
||||
|
||||
|
@ -236,8 +240,9 @@ class _OSDB(object):
|
|||
return None
|
||||
return oses[0]
|
||||
|
||||
def latest_fedora_version(self):
|
||||
return self.latest_regex("fedora[0-9]+")
|
||||
def latest_os_version(self, osdistro):
|
||||
version = r"\.[0-9]+" if osdistro[-1].isdigit() else "[0-9]+"
|
||||
return self.latest_regex(osdistro + version)
|
||||
|
||||
|
||||
#####################
|
||||
|
|
|
@ -415,7 +415,7 @@ class FedoraDistro(RedHatDistro):
|
|||
return cache.treeinfo_family_regex(famregex)
|
||||
|
||||
def _detect_version(self):
|
||||
latest_variant = OSDB.latest_fedora_version()
|
||||
latest_variant = OSDB.latest_os_version("fedora")
|
||||
|
||||
verstr = self.cache.treeinfo_version
|
||||
if not verstr:
|
||||
|
|
Loading…
Reference in New Issue