urlfetcher: Detect debian, ubuntu, and opensuse variant from URL
This commit is contained in:
parent
a78235c8bf
commit
7aa24be31a
|
@ -143,31 +143,30 @@ _add(OPENSUSE10, i686=OPENSUSE10, hasxen=False, hasbootiso=False,
|
|||
# Latest 10 series
|
||||
_add(OLD_OPENSUSE_URL % ("10.3"), hasbootiso=False, name="opensuse-10.3")
|
||||
# Latest 11 series
|
||||
_add(OLD_OPENSUSE_URL % ("11.4"), hasbootiso=False, name="opensuse-11.4")
|
||||
_add(OLD_OPENSUSE_URL % ("11.4"), "opensuse11", hasbootiso=False)
|
||||
# Latest 12 series
|
||||
# Only keep i686 for the latest opensuse
|
||||
_add(OPENSUSE_URL % ("12.3"), i686=OPENSUSE_URL % ("12.3"), hasbootiso=False,
|
||||
name="opensuse-12.3")
|
||||
_add(OPENSUSE_URL % ("12.3"), "opensuse12",
|
||||
i686=OPENSUSE_URL % ("12.3"), hasbootiso=False)
|
||||
|
||||
|
||||
_set_distro(DebianDistro)
|
||||
# Debian releases rarely enough that we can just do every release since lenny
|
||||
_add(OLD_DEBIAN_URL % ("lenny", "amd64"), hasxen=False, name="debian-lenny")
|
||||
_add(DEBIAN_URL % ("squeeze", "amd64"), name="debian-squeeze")
|
||||
_add(DEBIAN_URL % ("wheezy", "amd64"), name="debian-wheezy")
|
||||
_add(OLD_DEBIAN_URL % ("lenny", "amd64"), "debianlenny", hasxen=False)
|
||||
_add(DEBIAN_URL % ("squeeze", "amd64"), "debiansqueeze")
|
||||
_add(DEBIAN_URL % ("wheezy", "amd64"), "debianwheezy")
|
||||
# And daily builds, since we specially handle that URL
|
||||
_add(DAILY_DEBIAN_URL % ("amd64"), name="debian-daily")
|
||||
_add(DAILY_DEBIAN_URL % ("amd64"), "debianwheezy", name="debiandaily")
|
||||
|
||||
|
||||
_set_distro(UbuntuDistro)
|
||||
# One old ubuntu
|
||||
_add(OLD_UBUNTU_URL % ("hardy", "amd64"),
|
||||
i686=OLD_UBUNTU_URL % ("hardy", "i386"),
|
||||
hasxen=False, name="ubuntu-hardy")
|
||||
_add(OLD_UBUNTU_URL % ("hardy", "amd64"), "ubuntuhardy",
|
||||
i686=OLD_UBUNTU_URL % ("hardy", "i386"), hasxen=False)
|
||||
# Latest LTS
|
||||
_add(UBUNTU_URL % ("precise", "amd64"), name="ubuntu-precise")
|
||||
_add(UBUNTU_URL % ("precise", "amd64"), "ubuntuprecise")
|
||||
# Latest release
|
||||
_add(UBUNTU_URL % ("raring", "amd64"), name="ubuntu-raring")
|
||||
_add(UBUNTU_URL % ("raring", "amd64"), "ubunturaring")
|
||||
|
||||
|
||||
_set_distro(MandrivaDistro)
|
||||
|
|
|
@ -670,6 +670,11 @@ class RHELDistro(RedHatDistro):
|
|||
return True
|
||||
return self.fetcher.hasFile("RedHat")
|
||||
|
||||
|
||||
################################
|
||||
# osdict autodetection helpers #
|
||||
################################
|
||||
|
||||
def _parseTreeinfoVersion(self, verstr):
|
||||
def _safeint(c):
|
||||
try:
|
||||
|
@ -790,7 +795,27 @@ class SuseDistro(Distro):
|
|||
"boot/%s/initrd-xen" % self.arch)]
|
||||
|
||||
def isValidStore(self):
|
||||
return self.fetcher.hasFile("directory.yast")
|
||||
if not self.fetcher.hasFile("directory.yast"):
|
||||
return False
|
||||
|
||||
self.os_variant = self._detect_osdict_from_url()
|
||||
return True
|
||||
|
||||
|
||||
################################
|
||||
# osdict autodetection helpers #
|
||||
################################
|
||||
|
||||
def _detect_osdict_from_url(self):
|
||||
root = "opensuse"
|
||||
our_os_vals = [n.name for n in osdict.list_os() if
|
||||
n.name.startswith(root)]
|
||||
|
||||
for name in our_os_vals:
|
||||
codename = name[len(root):]
|
||||
if re.search("/%s\.[1-9]/" % codename, self.uri):
|
||||
return name
|
||||
return self.os_variant
|
||||
|
||||
|
||||
class DebianDistro(Distro):
|
||||
|
@ -839,16 +864,36 @@ class DebianDistro(Distro):
|
|||
|
||||
filename = "%s/MANIFEST" % self._prefix
|
||||
regex = ".*%s.*" % self._installer_name
|
||||
if self._fetchAndMatchRegex(filename, regex):
|
||||
return True
|
||||
if not self._fetchAndMatchRegex(filename, regex):
|
||||
logging.debug("Regex didn't match, not a %s distro", self.name)
|
||||
return False
|
||||
|
||||
logging.debug("Regex didn't match, not a %s distro", self.name)
|
||||
return False
|
||||
self.os_variant = self._detect_osdict_from_url()
|
||||
return True
|
||||
|
||||
|
||||
################################
|
||||
# osdict autodetection helpers #
|
||||
################################
|
||||
|
||||
def _detect_osdict_from_url(self):
|
||||
root = self.name.lower()
|
||||
our_os_vals = [n.name for n in osdict.list_os() if
|
||||
n.name.startswith(root)]
|
||||
|
||||
if self._prefix == "daily":
|
||||
return our_os_vals[0]
|
||||
for name in our_os_vals:
|
||||
codename = name[len(root):]
|
||||
if ("/%s/" % codename) in self.uri:
|
||||
return name
|
||||
return self.os_variant
|
||||
|
||||
|
||||
class UbuntuDistro(DebianDistro):
|
||||
# http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/
|
||||
name = "Ubuntu"
|
||||
urldistro = "ubuntu"
|
||||
|
||||
def isValidStore(self):
|
||||
if self.fetcher.hasFile("%s/MANIFEST" % self._prefix):
|
||||
|
@ -864,11 +909,12 @@ class UbuntuDistro(DebianDistro):
|
|||
else:
|
||||
return False
|
||||
|
||||
if self._fetchAndMatchRegex(filename, regex):
|
||||
return True
|
||||
if not self._fetchAndMatchRegex(filename, regex):
|
||||
logging.debug("Regex didn't match, not a %s distro", self.name)
|
||||
return False
|
||||
|
||||
logging.debug("Regex didn't match, not a %s distro", self.name)
|
||||
return False
|
||||
self.os_variant = self._detect_osdict_from_url()
|
||||
return True
|
||||
|
||||
|
||||
class MandrivaDistro(Distro):
|
||||
|
|
Loading…
Reference in New Issue