urlfetcher: Fix ubuntu url detection with latest libosinfo

This commit is contained in:
Cole Robinson 2015-11-24 21:52:06 -05:00
parent e13f81a7c5
commit 8700fda757
2 changed files with 9 additions and 6 deletions

View File

@ -284,6 +284,7 @@ class _OsVariant(object):
self.name = self._os and self._os.get_short_id() or "generic"
self.label = self._os and self._os.get_name() or "Generic"
self.codename = self._os and self._os.get_codename() or ""
self.sortby = self._get_sortby()
self.urldistro = self._get_urldistro()

View File

@ -1120,14 +1120,16 @@ class DebianDistro(Distro):
"debian OS")
return oses[0].name
# We grab the distro code name from the libosinfo label, and
# see if we can find that in the URL
for osobj in oses:
# name looks like 'Debian Sarge' or 'Ubuntu Vivid Varvet'
if " " not in osobj.label:
continue
if osobj.codename:
# Ubuntu codenames look like 'Warty Warthog'
codename = osobj.codename.split()[0].lower()
else:
if " " not in osobj.label:
continue
# Debian labels look like 'Debian Sarge'
codename = osobj.label.split()[1].lower()
codename = osobj.label.lower().split()[1]
if ("/%s/" % codename) in self.uri:
logging.debug("Found codename=%s in the URL string", codename)
return osobj.name