Пример #1
0
    def _setup_device(device, mountpoint):
        """Prepare an install CD/DVD for use as a package source."""
        log.info("setting up device %s and mounting on %s", device.name,
                 mountpoint)
        # Is there a symlink involved?  If so, let's get the actual path.
        # This is to catch /run/install/isodir vs. /mnt/install/isodir, for
        # instance.
        real_mountpoint = os.path.realpath(mountpoint)
        mount_device_path = payload_utils.get_mount_device_path(
            real_mountpoint)

        if mount_device_path:
            log.warning("%s is already mounted on %s", mount_device_path,
                        mountpoint)

            if mount_device_path == device.path:
                return
            else:
                payload_utils.unmount(real_mountpoint)

        try:
            payload_utils.setup_device(device)
            payload_utils.mount_device(device, mountpoint)
        except StorageError as e:
            log.error("mount failed: %s", e)
            payload_utils.teardown_device(device)
            raise PayloadSetupError(str(e))
Пример #2
0
def find_optical_install_media(storage):
    """Find a device with a valid optical install media.

    Return the first device containing a valid optical install
    media for this product.

    :param storage: an instance of Blivet's storage
    :return: a device or None
    """
    for dev in find_optical_media(storage.devicetree):
        mountpoint = tempfile.mkdtemp()

        try:
            try:
                payload_utils.mount_device(dev, mountpoint)
            except FSError:
                continue
            try:
                if not verifyMedia(mountpoint):
                    continue
            finally:
                payload_utils.unmount_device(dev, mountpoint)
        finally:
            os.rmdir(mountpoint)

        return dev

    return None
Пример #3
0
def find_optical_install_media():
    """Find a device with a valid optical install media.

    Return the first device containing a valid optical install
    media for this product.

    FIXME: This is duplicated in SetUpCdromSourceTask.run

    :return: a device name or None
    """
    device_tree = STORAGE.get_proxy(DEVICE_TREE)

    for dev in device_tree.FindOpticalMedia():
        mountpoint = tempfile.mkdtemp()

        try:
            try:
                payload_utils.mount_device(dev, mountpoint)
            except MountFilesystemError:
                continue
            try:
                if not is_valid_install_disk(mountpoint):
                    continue
            finally:
                payload_utils.unmount_device(dev, mountpoint)
        finally:
            os.rmdir(mountpoint)

        return dev

    return None
    def run(self, device_name):
        retval = None
        device_path = payload_utils.get_device_path(device_name)

        # FIXME: Use a unique mount point.
        mounts = payload_utils.get_mount_paths(device_path)
        mountpoint = None
        # We have to check both ISO_DIR and the DRACUT_ISODIR because we
        # still reference both, even though /mnt/install is a symlink to
        # /run/install.  Finding mount points doesn't handle the symlink
        if constants.ISO_DIR not in mounts and constants.DRACUT_ISODIR not in mounts:
            # We're not mounted to either location, so do the mount
            mountpoint = constants.ISO_DIR
            payload_utils.mount_device(device_name, mountpoint)

        # If any directory was chosen, return that.  Otherwise, return None.
        rc = self.window.run()
        if rc == Gtk.ResponseType.OK:
            f = self._chooser.get_filename()
            if f:
                retval = f.replace(constants.ISO_DIR, "")

        if not mounts:
            payload_utils.unmount_device(device_name, mountpoint)

        self.window.destroy()
        return retval
Пример #5
0
 def _mount_device(self):
     """ Mount the device so we can search it for ISOs. """
     mounts = payload_utils.get_mount_paths(self._device.path)
     # We have to check both ISO_DIR and the DRACUT_ISODIR because we
     # still reference both, even though /mnt/install is a symlink to
     # /run/install.  Finding mount points doesn't handle the symlink
     if ISO_DIR not in mounts and DRACUT_ISODIR not in mounts:
         # We're not mounted to either location, so do the mount
         payload_utils.mount_device(self._device, ISO_DIR)
Пример #6
0
    def _setup_media(self, device):
        method = self.data.method
        if method.method == "harddrive":
            try:
                method.dir = self._find_and_mount_iso(device, ISO_DIR,
                                                      method.dir, INSTALL_TREE)
            except PayloadSetupError as ex:
                log.warning(str(ex))

                try:
                    self._setup_install_tree(device, method.dir, INSTALL_TREE)
                except PayloadSetupError as ex:
                    log.error(str(ex))
                    raise PayloadSetupError(
                        "failed to setup installation tree or ISO from HDD")
        elif not (method.method == "cdrom"
                  and self._device_is_mounted_as_source(device)):
            payload_utils.mount_device(device, INSTALL_TREE)
Пример #7
0
    def _setup_media(self, device):
        method = self.data.method
        if method.method == "harddrive":
            try:
                method.dir = self._find_and_mount_iso(device, ISO_DIR, method.dir, INSTALL_TREE)
            except PayloadSetupError as ex:
                log.warning(str(ex))

                try:
                    self._setup_install_tree(device, method.dir, INSTALL_TREE)
                except PayloadSetupError as ex:
                    log.error(str(ex))
                    raise PayloadSetupError("failed to setup installation tree or ISO from HDD")

        # Check to see if the device is already mounted, in which case
        # we don't need to mount it again
        elif method.method == "cdrom" and payload_utils.get_mount_paths(device.path):
            return
        else:
            payload_utils.mount_device(device, INSTALL_TREE)