Esempio n. 1
0
def get_release_string():
    """Identify the installation of a Linux distribution.

    Attempt to identify the installation of a Linux distribution by checking
    a previously mounted filesystem for several files.  The filesystem must
    be mounted under the target physical root.

    :returns: The machine's arch, distribution name, and distribution version
    or None for any parts that cannot be determined
    :rtype: (string, string, string)
    """
    rel_name = None
    rel_ver = None
    sysroot = util.getSysroot()

    try:
        rel_arch = blivet_util.capture_output(["arch"], root=sysroot).strip()
    except OSError:
        rel_arch = None

    filename = "%s/etc/redhat-release" % sysroot
    if os.access(filename, os.R_OK):
        (rel_name, rel_ver) = _release_from_redhat_release(filename)
    else:
        filename = "%s/etc/os-release" % sysroot
        if os.access(filename, os.R_OK):
            (rel_name, rel_ver) = _release_from_os_release(filename)

    return rel_arch, rel_name, rel_ver
Esempio n. 2
0
def get_release_string(chroot):
    """Identify the installation of a Linux distribution.

    Attempt to identify the installation of a Linux distribution by checking
    a previously mounted filesystem for several files.  The filesystem must
    be mounted under the target physical root.

    :returns: The machine's arch, distribution name, and distribution version
    or None for any parts that cannot be determined
    :rtype: (string, string, string)
    """
    rel_name = None
    rel_ver = None
    sysroot = chroot

    try:
        rel_arch = blivet_util.capture_output(["arch"], root=sysroot).strip()
    except OSError:
        rel_arch = None

    try:
        filename = "%s/etc/redhat-release" % sysroot
        if os.access(filename, os.R_OK):
            (rel_name, rel_ver) = _release_from_redhat_release(filename)
        else:
            filename = "%s/etc/os-release" % sysroot
            if os.access(filename, os.R_OK):
                (rel_name, rel_ver) = _release_from_os_release(filename)
    except ValueError:
        pass

    return rel_arch, rel_name, rel_ver
Esempio n. 3
0
    def test_set_uuid(self):
        """Create the filesystem with a valid UUID."""
        an_fs = self._fs_class(device=self.loop_devices[0],
                               uuid=self._valid_uuid)
        self.assertIsNone(an_fs.create())

        out = capture_output(["blkid", "-sUUID", "-ovalue", self.loop_devices[0]])
        self.assertEqual(out.strip(), self._valid_uuid)
Esempio n. 4
0
    def test_reset_uuid(self):
        """Create the filesystem with random UUID and reset it later."""
        an_fs = self._fs_class(device=self.loop_devices[0])
        if an_fs._writeuuid.availability_errors:
            self.skipTest("can not write UUID for filesystem %s" % an_fs.name)
        self.assertIsNone(an_fs.create())

        self.assertIsNone(an_fs.reset_uuid())

        out = capture_output(["blkid", "-sUUID", "-ovalue", self.loop_devices[0]])
        self.assertEqual(out.strip(), an_fs.uuid)