mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
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
|
# Latest 10 series
|
||||||
_add(OLD_OPENSUSE_URL % ("10.3"), hasbootiso=False, name="opensuse-10.3")
|
_add(OLD_OPENSUSE_URL % ("10.3"), hasbootiso=False, name="opensuse-10.3")
|
||||||
# Latest 11 series
|
# 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
|
# Latest 12 series
|
||||||
# Only keep i686 for the latest opensuse
|
# Only keep i686 for the latest opensuse
|
||||||
_add(OPENSUSE_URL % ("12.3"), i686=OPENSUSE_URL % ("12.3"), hasbootiso=False,
|
_add(OPENSUSE_URL % ("12.3"), "opensuse12",
|
||||||
name="opensuse-12.3")
|
i686=OPENSUSE_URL % ("12.3"), hasbootiso=False)
|
||||||
|
|
||||||
|
|
||||||
_set_distro(DebianDistro)
|
_set_distro(DebianDistro)
|
||||||
# Debian releases rarely enough that we can just do every release since lenny
|
# 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(OLD_DEBIAN_URL % ("lenny", "amd64"), "debianlenny", hasxen=False)
|
||||||
_add(DEBIAN_URL % ("squeeze", "amd64"), name="debian-squeeze")
|
_add(DEBIAN_URL % ("squeeze", "amd64"), "debiansqueeze")
|
||||||
_add(DEBIAN_URL % ("wheezy", "amd64"), name="debian-wheezy")
|
_add(DEBIAN_URL % ("wheezy", "amd64"), "debianwheezy")
|
||||||
# And daily builds, since we specially handle that URL
|
# 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)
|
_set_distro(UbuntuDistro)
|
||||||
# One old ubuntu
|
# One old ubuntu
|
||||||
_add(OLD_UBUNTU_URL % ("hardy", "amd64"),
|
_add(OLD_UBUNTU_URL % ("hardy", "amd64"), "ubuntuhardy",
|
||||||
i686=OLD_UBUNTU_URL % ("hardy", "i386"),
|
i686=OLD_UBUNTU_URL % ("hardy", "i386"), hasxen=False)
|
||||||
hasxen=False, name="ubuntu-hardy")
|
|
||||||
# Latest LTS
|
# Latest LTS
|
||||||
_add(UBUNTU_URL % ("precise", "amd64"), name="ubuntu-precise")
|
_add(UBUNTU_URL % ("precise", "amd64"), "ubuntuprecise")
|
||||||
# Latest release
|
# Latest release
|
||||||
_add(UBUNTU_URL % ("raring", "amd64"), name="ubuntu-raring")
|
_add(UBUNTU_URL % ("raring", "amd64"), "ubunturaring")
|
||||||
|
|
||||||
|
|
||||||
_set_distro(MandrivaDistro)
|
_set_distro(MandrivaDistro)
|
||||||
|
@ -670,6 +670,11 @@ class RHELDistro(RedHatDistro):
|
|||||||
return True
|
return True
|
||||||
return self.fetcher.hasFile("RedHat")
|
return self.fetcher.hasFile("RedHat")
|
||||||
|
|
||||||
|
|
||||||
|
################################
|
||||||
|
# osdict autodetection helpers #
|
||||||
|
################################
|
||||||
|
|
||||||
def _parseTreeinfoVersion(self, verstr):
|
def _parseTreeinfoVersion(self, verstr):
|
||||||
def _safeint(c):
|
def _safeint(c):
|
||||||
try:
|
try:
|
||||||
@ -790,7 +795,27 @@ class SuseDistro(Distro):
|
|||||||
"boot/%s/initrd-xen" % self.arch)]
|
"boot/%s/initrd-xen" % self.arch)]
|
||||||
|
|
||||||
def isValidStore(self):
|
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):
|
class DebianDistro(Distro):
|
||||||
@ -839,16 +864,36 @@ class DebianDistro(Distro):
|
|||||||
|
|
||||||
filename = "%s/MANIFEST" % self._prefix
|
filename = "%s/MANIFEST" % self._prefix
|
||||||
regex = ".*%s.*" % self._installer_name
|
regex = ".*%s.*" % self._installer_name
|
||||||
if self._fetchAndMatchRegex(filename, regex):
|
if not self._fetchAndMatchRegex(filename, regex):
|
||||||
return True
|
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)
|
self.os_variant = self._detect_osdict_from_url()
|
||||||
return False
|
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):
|
class UbuntuDistro(DebianDistro):
|
||||||
# http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/
|
# http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/
|
||||||
name = "Ubuntu"
|
name = "Ubuntu"
|
||||||
|
urldistro = "ubuntu"
|
||||||
|
|
||||||
def isValidStore(self):
|
def isValidStore(self):
|
||||||
if self.fetcher.hasFile("%s/MANIFEST" % self._prefix):
|
if self.fetcher.hasFile("%s/MANIFEST" % self._prefix):
|
||||||
@ -864,11 +909,12 @@ class UbuntuDistro(DebianDistro):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self._fetchAndMatchRegex(filename, regex):
|
if not self._fetchAndMatchRegex(filename, regex):
|
||||||
return True
|
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)
|
self.os_variant = self._detect_osdict_from_url()
|
||||||
return False
|
return True
|
||||||
|
|
||||||
|
|
||||||
class MandrivaDistro(Distro):
|
class MandrivaDistro(Distro):
|
||||||
|
Loading…
Reference in New Issue
Block a user