Index: virt-manager-0.10.0/virtinst/OSDistro.py =================================================================== --- virt-manager-0.10.0.orig/virtinst/OSDistro.py +++ virt-manager-0.10.0/virtinst/OSDistro.py @@ -70,8 +70,14 @@ def _storeForDistro(fetcher, baseuri, ty arch, typ, scratchdir) if dist: return dist + skip_treeinfo = True + dist = virtinst.OSDistro.distroFromContent(fetcher, progresscb, baseuri, + arch, typ, scratchdir) + if dist: + return dist + # FIXME: This 'distro ==' doesn't cut it. 'distro' is from our os # dictionary, so would look like 'fedora9' or 'rhel5', so this needs # to be a bit more intelligent @@ -236,6 +242,57 @@ def distroFromTreeinfo(fetcher, progress return ob +def distroFromContent(fetcher, progresscb, uri, arch, vmtype=None, + scratchdir=None): + # Parse content file for the 'LABEL' field containing the distribution name + # None if no content, GenericDistro if unknown label type. + if not fetcher.hasFile("content"): + return None + + distribution = None + distro_version = None + filename = fetcher.acquireFile("content", progresscb) + cbuf = f = None + try: + f = open(filename, "r") + cbuf = f.read() + except: + if f: + f.close() + os.unlink(filename) + return None + f.close() + os.unlink(filename) + + lines = cbuf.splitlines()[1:] + for line in lines: + if line.startswith("LABEL "): + distribution = line.split(' ', 1) + if distro_version: + break + if line.startswith("VERSION "): + distro_version = line.split(' ', 1) + if distribution: + break + if re.match(".*SUSE Linux Enterprise Server*", distribution[1]) or \ + re.match(".*SUSE SLES*", distribution[1]): + dclass = SLESDistro + elif re.match(".*SUSE Linux Enterprise Desktop*", distribution[1]): + dclass = SLEDDistro + elif re.match(".*openSUSE.*", distribution[1]): + dclass = OpensuseDistro + else: + dclass = GenericDistro + + ob = dclass(uri, arch, vmtype, scratchdir) + if dclass != GenericDistro: + ob.content = distro_version + + # Explictly call this, so we populate os_type/variant info + ob.isValidStore(fetcher, progresscb) + + return ob + # An image store is a base class for retrieving either a bootable # ISO image, or a kernel+initrd pair for a particular OS distribution @@ -689,6 +746,7 @@ class SuseDistro(Distro): _boot_iso_paths = ["boot/boot.iso"] def __init__(self, uri, arch, vmtype=None, scratchdir=None): + self.content = None Distro.__init__(self, uri, arch, vmtype, scratchdir) if re.match(r'i[4-9]86', arch): self.arch = 'i386' @@ -699,18 +757,32 @@ class SuseDistro(Distro): oldkern += "64" oldinit += "64" - # Tested with Opensuse >= 10.2, 11, and sles 10 - self._hvm_kernel_paths = [("boot/%s/loader/linux" % self.arch, - "boot/%s/loader/initrd" % self.arch)] - # Tested with Opensuse 10.0 - self._hvm_kernel_paths.append(("boot/loader/%s" % oldkern, - "boot/loader/%s" % oldinit)) - - # Matches Opensuse > 10.2 and sles 10 - self._xen_kernel_paths = [("boot/%s/vmlinuz-xen" % self.arch, - "boot/%s/initrd-xen" % self.arch)] + if self.arch == "s390x": + self._hvm_kernel_paths = [ ("boot/%s/vmrdr.ikr" % self.arch, + "boot/%s/initrd" % self.arch) ] + # No Xen on s390x + self._xen_kernel_paths = [] + else: + # Tested with Opensuse >= 10.2, 11, and sles 10 + self._hvm_kernel_paths = [ ("boot/%s/loader/linux" % self.arch, + "boot/%s/loader/initrd" % self.arch) ] + # Tested with Opensuse 10.0 + self._hvm_kernel_paths.append(("boot/loader/%s" % oldkern, + "boot/loader/%s" % oldinit)) + + # Matches Opensuse > 10.2 and sles 10 + self._xen_kernel_paths = [ ("boot/%s/vmlinuz-xen" % self.arch, + "boot/%s/initrd-xen" % self.arch) ] def isValidStore(self, fetcher, progresscb): + # self.content is the VERSION line from the contents file + distro_version = self.content[1] + version = distro_version.split('.', 1)[0].strip() + if int(version) >= 10: + self.os_variant += version + else: + self.os_variant += "9" + # Suse distros always have a 'directory.yast' file in the top # level of install tree, which we use as the magic check if fetcher.hasFile("directory.yast"): @@ -915,6 +987,19 @@ class SuseDistro(Distro): # pass os.system("rm -rf " + cpiodir) +class SLESDistro(SuseDistro): + + os_variant = "sles" + +class SLEDDistro(SuseDistro): + + os_variant = "sled" + +# Suse image store is harder - we fetch the kernel RPM and a helper +# RPM and then munge bits together to generate a initrd +class OpensuseDistro(SuseDistro): + + os_variant = "opensuse" class DebianDistro(Distro): # ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/