Пример #1
0
def findFirstIsoImage(path, messageWindow):
    """
    Find the first iso image in path
    This also supports specifying a specific .iso image

    Returns the full path to the image
    """
    flush = os.stat(path)
    arch = _arch

    if os.path.isfile(path) and path.endswith(".iso"):
        files = [os.path.basename(path)]
        path = os.path.dirname(path)
    else:
        files = os.listdir(path)

    for fn in files:
        what = path + '/' + fn
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        log.debug("mounting %s on /mnt/install/cdimage", what)
        try:
            isys.mount(what, "/mnt/install/cdimage", fstype="iso9660", readOnly=True)
        except SystemError:
            continue

        if not os.access("/mnt/install/cdimage/.discinfo", os.R_OK):
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        log.debug("Reading .discinfo")
        f = open("/mnt/install/cdimage/.discinfo")
        f.readline() # skip timestamp
        f.readline() # skip release description
        discArch = f.readline().strip() # read architecture
        f.close()

        log.debug("discArch = %s" % discArch)
        if discArch != arch:
            log.warning("findFirstIsoImage: architectures mismatch: %s, %s" %
                        (discArch, arch))
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        # If there's no repodata, there's no point in trying to
        # install from it.
        if not os.access("/mnt/install/cdimage/repodata", os.R_OK):
            log.warning("%s doesn't have repodata, skipping" %(what,))
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        # warn user if images appears to be wrong size
        if os.stat(what)[stat.ST_SIZE] % 2048:
            rc = messageWindow(_("Warning"),
                 _("The ISO image %s has a size which is not "
                   "a multiple of 2048 bytes.  This may mean "
                   "it was corrupted on transfer to this computer."
                   "\n\n"
                   "It is recommended that you exit and abort your "
                   "installation, but you can choose to continue if "
                   "you think this is in error.") % (fn,),
                   type="custom", custom_icon="warning",
                   custom_buttons= [_("_Exit installer"),
                                    _("_Continue")])
            if rc == 0:
                sys.exit(0)

        log.info("Found disc at %s" % fn)
        isys.umount("/mnt/install/cdimage", removeDir=False)
        return what

    return None
Пример #2
0
def findIsoImages(path, messageWindow):
    flush = os.stat(path)
    files = os.listdir(path)
    arch = _arch
    discImages = {}

    for file in files:
        what = path + '/' + file
        if not isys.isIsoImage(what):
            continue

        try:
            isys.losetup("/dev/loop2", what, readOnly = 1)
        except SystemError:
            continue

        try:
            isys.mount("/dev/loop2", "/mnt/cdimage", fstype = "iso9660",
                       readOnly = True)
            for num in range(1, 10):
                if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                    f = open("/mnt/cdimage/.discinfo")
                    try:
                        f.readline() # skip timestamp
                        f.readline() # skip release description
                        discArch = string.strip(f.readline()) # read architecture
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discArch = None
                        discNum = [ 0 ]

                    f.close()

                    if num not in discNum or discArch != arch:
                        continue

                    # if it's disc1, it needs to have images/install.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/images/install.img", os.R_OK)):
                        log.warning("%s doesn't have a install.img, skipping" %(what,))
                        continue
                    # we only install binary packages, so let's look for a
                    # product/ dir and hope that this avoids getting
                    # discs from the src.rpm set
                    if not os.path.isdir("/mnt/cdimage/%s" %(productPath,)):
                        log.warning("%s doesn't have binary RPMS, skipping" %(what,))
                        continue

                    # warn user if images appears to be wrong size
                    if os.stat(what)[stat.ST_SIZE] % 2048:
                        rc = messageWindow(_("Warning"),
                             _("The ISO image %s has a size which is not "
                               "a multiple of 2048 bytes.  This may mean "
                               "it was corrupted on transfer to this computer."
                               "\n\n"
                               "It is recommended that you exit and abort your "
                               "installation, but you can choose to continue if "
                               "you think this is in error.") % (file,),
                               type="custom", custom_icon="warning",
                               custom_buttons= [_("_Exit installer"),
                                                _("_Continue")])
                        if rc == 0:
                            sys.exit(0)

                    discImages[num] = file

            isys.umount("/mnt/cdimage", removeDir=False)
        except SystemError:
            pass

        isys.unlosetup("/dev/loop2")

    return discImages
def findFirstIsoImage(path, messageWindow):
    flush = os.stat(path)
    files = os.listdir(path)
    arch = _arch

    for file in files:
        what = path + '/' + file
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        try:
            log.debug("mounting %s on /mnt/cdimage", what)
            isys.mount(what, "/mnt/cdimage", fstype = "iso9660", readOnly = True)

            if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                log.debug("Reading .discinfo")
                f = open("/mnt/cdimage/.discinfo")
                try:
                    f.readline() # skip timestamp
                    f.readline() # skip release description
                    discArch = string.strip(f.readline()) # read architecture
                except:
                    discArch = None

                f.close()

                log.debug("discArch = %s" % discArch)
                if discArch != arch:
                    isys.umount("/mnt/cdimage", removeDir=False)
                    continue

                # If there's no repodata, there's no point in trying to
                # install from it.
                if not os.access("/mnt/cdimage/repodata", os.R_OK):
                    log.warning("%s doesn't have repodata, skipping" %(what,))
                    isys.umount("/mnt/cdimage", removeDir=False)
                    continue

                # warn user if images appears to be wrong size
                if os.stat(what)[stat.ST_SIZE] % 2048:
                    rc = messageWindow(_("Warning"),
                         _("The ISO image %s has a size which is not "
                           "a multiple of 2048 bytes.  This may mean "
                           "it was corrupted on transfer to this computer."
                           "\n\n"
                           "It is recommended that you exit and abort your "
                           "installation, but you can choose to continue if "
                           "you think this is in error.") % (file,),
                           type="custom", custom_icon="warning",
                           custom_buttons= [_("_Exit installer"),
                                            _("_Continue")])
                    if rc == 0:
                        sys.exit(0)

                log.info("Found disc at %s" % file)
                isys.umount("/mnt/cdimage", removeDir=False)
                return file
        except SystemError:
            pass

    return None
Пример #4
0
def findFirstIsoImage(path):
    """
    Find the first iso image in path
    This also supports specifying a specific .iso image

    Returns the basename of the image
    """
    try:
        flush = os.stat(path)
    except OSError:
        return None

    arch = _arch

    if os.path.isfile(path) and path.endswith(".iso"):
        files = [os.path.basename(path)]
        path = os.path.dirname(path)
    else:
        files = os.listdir(path)

    for fn in files:
        what = path + '/' + fn
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        log.debug("mounting %s on /mnt/install/cdimage", what)
        try:
            blivet.util.mount(what, "/mnt/install/cdimage", fstype="iso9660", options="ro")
        except OSError:
            continue

        if not os.access("/mnt/install/cdimage/.discinfo", os.R_OK):
            blivet.util.umount("/mnt/install/cdimage")
            continue

        log.debug("Reading .discinfo")
        f = open("/mnt/install/cdimage/.discinfo")
        f.readline() # skip timestamp
        f.readline() # skip release description
        discArch = f.readline().strip() # read architecture
        f.close()

        log.debug("discArch = %s" % discArch)
        if discArch != arch:
            log.warning("findFirstIsoImage: architectures mismatch: %s, %s" %
                        (discArch, arch))
            blivet.util.umount("/mnt/install/cdimage")
            continue

        # If there's no repodata, there's no point in trying to
        # install from it.
        if not os.access("/mnt/install/cdimage/repodata", os.R_OK):
            log.warning("%s doesn't have repodata, skipping" %(what,))
            blivet.util.umount("/mnt/install/cdimage")
            continue

        # warn user if images appears to be wrong size
        if os.stat(what)[stat.ST_SIZE] % 2048:
            log.warning("%s appears to be corrupted" % what)
            exn = InvalidImageSizeError("size is not a multiple of 2048 bytes")
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        log.info("Found disc at %s" % fn)
        blivet.util.umount("/mnt/install/cdimage")
        return fn

    return None
Пример #5
0
def findFirstIsoImage(path):
    """
    Find the first iso image in path
    This also supports specifying a specific .iso image

    Returns the basename of the image
    """
    try:
        flush = os.stat(path)
    except OSError:
        return None

    arch = _arch

    if os.path.isfile(path) and path.endswith(".iso"):
        files = [os.path.basename(path)]
        path = os.path.dirname(path)
    else:
        files = os.listdir(path)

    for fn in files:
        what = path + '/' + fn
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        log.debug("mounting %s on /mnt/install/cdimage", what)
        try:
            blivet.util.mount(what, "/mnt/install/cdimage", fstype="iso9660", options="ro")
        except OSError:
            continue

        if not os.access("/mnt/install/cdimage/.discinfo", os.R_OK):
            blivet.util.umount("/mnt/install/cdimage")
            continue

        log.debug("Reading .discinfo")
        f = open("/mnt/install/cdimage/.discinfo")
        f.readline() # skip timestamp
        f.readline() # skip release description
        discArch = f.readline().strip() # read architecture
        f.close()

        log.debug("discArch = %s" % discArch)
        if discArch != arch:
            log.warning("findFirstIsoImage: architectures mismatch: %s, %s" %
                        (discArch, arch))
            blivet.util.umount("/mnt/install/cdimage")
            continue

        # If there's no repodata, there's no point in trying to
        # install from it.
        if not os.access("/mnt/install/cdimage/repodata", os.R_OK):
            log.warning("%s doesn't have repodata, skipping" %(what,))
            blivet.util.umount("/mnt/install/cdimage")
            continue

        # warn user if images appears to be wrong size
        if os.stat(what)[stat.ST_SIZE] % 2048:
            log.warning("%s appears to be corrupted" % what)
            exn = InvalidImageSizeError("size is not a multiple of 2048 bytes")
            if errorHandler.cb(exn) == ERROR_RAISE:
                raise exn

        log.info("Found disc at %s" % fn)
        blivet.util.umount("/mnt/install/cdimage")
        return fn

    return None
Пример #6
0
def findIsoImages(path, messageWindow):
    files = os.listdir(path)
    arch = _arch
    discImages = {}

    for file in files:
	what = path + '/' + file
	if not isys.isIsoImage(what):
            continue

	isys.makeDevInode("loop2", "/tmp/loop2")

	try:
	    isys.losetup("/tmp/loop2", what, readOnly = 1)
	except SystemError:
	    continue

	try:
	    isys.mount("loop2", "/mnt/cdimage", fstype = "iso9660",
		       readOnly = 1)
	    for num in range(1, 10):
		if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                    f = open("/mnt/cdimage/.discinfo")
                    try:
                        f.readline() # skip timestamp
                        f.readline() # skip release description
                        discArch = string.strip(f.readline()) # read architecture
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discArch = None
                        discNum = [ 0 ]

                    f.close()

                    if num not in discNum or discArch != arch:
                        continue

                    # if it's disc1, it needs to have RedHat/base/stage2.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/%s/base/stage2.img" % (productPath,),
                                  os.R_OK)):
                        continue
                    
		    # warn user if images appears to be wrong size
		    if os.stat(what)[stat.ST_SIZE] % 2048:
			rc = messageWindow(_("Warning"),
	       "The ISO image %s has a size which is not "
	       "a multiple of 2048 bytes.  This may mean "
	       "it was corrupted on transfer to this computer."
	       "\n\n"
               "It is recommended that you reboot and abort your "
               "installation, but you can choose to continue if "
               "you think this is in error." % (file,),
                                           type="custom",
                                           custom_icon="warning",
                                           custom_buttons= [_("_Reboot"),
                                                            _("_Continue")])
                        if rc == 0:
			    sys.exit(0)

		    discImages[num] = file

	    isys.umount("/mnt/cdimage")
	except SystemError:
	    pass

	isys.makeDevInode("loop2", '/tmp/' + "loop2")
	isys.unlosetup("/tmp/loop2")

    return discImages