Exemplo n.º 1
0
    def umountImage(self):
	if self.currentMedia:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.currentMedia = []
Exemplo n.º 2
0
    def mountImage(self, cdNum):
	if (self.currentMedia):
	    raise SystemError, "trying to mount already-mounted iso image!"

	retrymount = True
	while retrymount:
	    try:
	        isoImage = self.isoPath + '/' + self.discImages[cdNum]

	        isys.makeDevInode("loop3", "/tmp/loop3")
	        isys.losetup("/tmp/loop3", isoImage, readOnly = 1)
	
	        isys.mount("loop3", "/tmp/isomedia", fstype = 'iso9660', readOnly = 1);
	        self.mntPoint = "/tmp/isomedia/"
	        self.currentMedia = [ cdNum ]

	        retrymount = False
	    except:
	        ans = self.messageWindow( _("Missing ISO 9660 Image"),
	                                  _("The installer has tried to mount "
	                                    "image #%s, but cannot find it on "
	                                    "the server.\n\n"
	                                    "Please copy this image to the "
	                                    "remote server's share path and "
	                                    "click Retry. Click Reboot to "
	                                    "abort the installation.")
	                                    % (cdNum,), type="custom",
	                                    custom_icon="warning",
	                                    custom_buttons=[_("_Reboot"),
	                                                    _("Re_try")])
	        if ans == 0:
	            sys.exit(0)
	        elif ans == 1:
	            self.discImages = findIsoImages(self.isoPath, self.messageWindow)
Exemplo n.º 3
0
    def umountMedia(self):
	if self.mediaIsMounted:
	    isys.umount(self.tree)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.umountDirectory()
	    self.mediaIsMounted = 0
Exemplo n.º 4
0
    def mountMedia(self, cdNum):
        if self.mediaIsMounted:
            raise SystemError, "trying to mount already-mounted iso image!"

        self.mountDirectory()

        retry = True
        while retry:
            try:
                isoImage = self.isoDir + '/' + self.path + '/' + self.discImages[cdNum]

                isys.makeDevInode("loop3", "/tmp/loop3")
                isys.losetup("/tmp/loop3", isoImage, readOnly = 1)

                isys.mount("loop3", self.tree, fstype = 'iso9660', readOnly = 1);
                self.mediaIsMounted = cdNum

                retry = False
            except:
                ans = self.messageWindow( _("Missing ISO 9660 Image"),
                                          _("The installer has tried to mount "
                                            "image #%s, but cannot find it on "
                                            "the hard drive.\n\n"
                                            "Please copy this image to the "
                                            "drive and click Retry. Click Reboot "
                                            " to abort the installation.")
                                            % (cdNum,), type="custom",
	                                    custom_icon="warning",
                                            custom_buttons=[_("_Reboot"),
	                                                    _("Re_try")])
                if ans == 0:
                    sys.exit(0)
                elif ans == 1:
                    self.discImages = findIsoImages(self.isoPath, self.messageWindow)
    def mountImage(self, cdNum):
	if (self.currentMedia):
	    raise SystemError, "trying to mount already-mounted iso image!"

	retrymount = True
	while retrymount:
	    try:
	        isoImage = self.isoPath + '/' + self.discImages[cdNum]

	        isys.makeDevInode("loop3", "/tmp/loop3")
	        isys.losetup("/tmp/loop3", isoImage, readOnly = 1)
	
	        isys.mount("loop3", "/tmp/isomedia", fstype = 'iso9660', readOnly = 1);
	        self.mntPoint = "/tmp/isomedia/"
	        self.currentMedia = [ cdNum ]

	        retrymount = False
	    except:
	        ans = self.messageWindow( _("Missing ISO 9660 Image"),
	                                  _("The installer has tried to mount "
	                                    "image #%s, but cannot find it on "
	                                    "the server.\n\n"
	                                    "Please copy this image to the "
	                                    "remote server's share path and "
	                                    "click Retry. Click Reboot to "
	                                    "abort the installation.")
	                                    % (cdNum,), type="custom",
	                                    custom_icon="warning",
	                                    custom_buttons=[_("_Reboot"),
	                                                    _("Re_try")])
	        if ans == 0:
	            sys.exit(0)
	        elif ans == 1:
	            self.discImages = findIsoImages(self.isoPath, self.messageWindow)
    def umountImage(self):
	if self.currentMedia:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.currentMedia = []
Exemplo n.º 7
0
    def umountImage(self):
	if self.imageMounted:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.imageMounted = 0
Exemplo n.º 8
0
def scanForMPath(drives):
    log.debug("scanning for multipath on drives %s" % (drives,))
    mpaths = []

    probeDrives = []
    for d in drives:
        dp = "/dev/" + d
        isys.makeDevInode(d, dp)
        probeDrives.append(dp)
        dp = "/tmp/" + d
        isys.makeDevInode(d, dp)

    import block as _block
    _block.setBdevidPath(_block.getBdevidPath() + _bdModulePath)

    _block.load("scsi")
    mpaths = _block.getMPaths(probeDrives)
    log.debug("mpaths: %s" % (mpaths,))
    
    def updateName(mp):
        if dmNameUpdates.has_key(mp.name):
            mp.set_name(dmNameUpdates[mp.name])
        cacheDrives.add(mp)
        return mp
    
    return reduce(lambda x,y: x + [updateName(y),], mpaths, [])
Exemplo n.º 9
0
    def fdasd_button_clicked(self, widget):
        if self.drive == None:
            return
        zvt = ZvtTerm(80, 24)
        zvt.set_del_key_swap(TRUE)
        zvt.connect("child_died", self.child_died, widget)

        # free our fd's to the hard drive -- we have to
        # fstab.rescanDrives() after this or bad things happen!
        if os.access("/sbin/fdasd", os.X_OK):
            path = "/sbin/fdasd"
        else:
            path = "/usr/sbin/fdasd"

        isys.makeDevInode(self.drive, '/tmp/' + self.drive)

        if zvt.forkpty() == 0:
            env = os.environ
            os.execve(path, (path, '/tmp/' + self.drive), env)
        zvt.show()

        self.windowContainer.remove(self.buttonBox)
        self.windowContainer.pack_start(zvt)

        self.ics.readHTML("usefdasd-s390")
        self.ics.setPrevEnabled(0)
        self.ics.setNextEnabled(0)
Exemplo n.º 10
0
    def button_clicked(self, widget, drive):
        term = vte.Terminal()
        term.set_encoding("UTF-8")
        term.set_font_from_string("monospace 10")
        term.set_color_background(gtk.gdk.color_parse('white'))
        term.set_color_foreground(gtk.gdk.color_parse('black'))
        term.connect("child_exited", self.child_died, widget)
        term.reset(gtk.TRUE, gtk.TRUE)

        self.drive = drive

        # free our fd's to the hard drive -- we have to
        # fstab.rescanDrives() after this or bad things happen!
        if os.access("/sbin/fdisk", os.X_OK):
            path = "/sbin/fdisk"
        else:
            path = "/usr/sbin/fdisk"

        isys.makeDevInode(drive, '/tmp/' + drive)

        term.fork_command(path, (path, '/tmp/' + drive))
        term.show()

        self.windowContainer.remove(self.buttonBox)
        self.windowContainer.pack_start(term)

        self.ics.readHTML("fdiskpart")
        cw = self.ics.getICW()
        if cw.displayHelp:
            cw.refreshHelp()

        self.ics.setPrevEnabled(0)
        self.ics.setNextEnabled(0)
Exemplo n.º 11
0
 def umountMedia(self):
     if self.mediaIsMounted:
         isys.umount(self.tree)
         isys.makeDevInode("loop3", "/tmp/loop3")
         isys.unlosetup("/tmp/loop3")
         self.umountDirectory()
         self.tree = None
         self.mediaIsMounted = 0
Exemplo n.º 12
0
def copyExceptionToFloppy(anaconda):
    # in test mode have save to floppy option just copy to new name
    if not flags.setupFilesystems:
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/test-anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to /tmp/test-anacdump.txt")
            pass

        anaconda.intf.__del__()
        return 2

    while 1:
        # Bail if they hit the cancel button.
        rc = anaconda.intf.dumpWindow()
        if rc:
            return 1

        device = anaconda.id.floppyDevice
        file = "/tmp/floppy"
        try:
            isys.makeDevInode(device, file)
        except SystemError:
            pass

        try:
            fd = os.open(file, os.O_RDONLY)
        except:
            continue

        os.close(fd)

        if rhpl.getArch() != "ia64":
            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect(cmd, ["/tmp/floppy"],
                                   stdout='/dev/tty5',
                                   stderr='/dev/tty5')

        try:
            isys.mount(device, "/tmp/crash", fstype="vfat")
        except SystemError:
            continue

        # copy trace dump we wrote to local storage to floppy
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/crash/anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to floppy")
            return 2

        isys.umount("/tmp/crash")
        return 0
Exemplo n.º 13
0
def copyExceptionToFloppy (anaconda):
    # in test mode have save to floppy option just copy to new name
    if not flags.setupFilesystems:
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/test-anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to /tmp/test-anacdump.txt")
            pass

        anaconda.intf.__del__ ()
        return 2

    while 1:
        # Bail if they hit the cancel button.
        rc = anaconda.intf.dumpWindow()
        if rc:
            return 1

        device = anaconda.id.floppyDevice
        file = "/tmp/floppy"
        try:
            isys.makeDevInode(device, file)
        except SystemError:
            pass
        
        try:
            fd = os.open(file, os.O_RDONLY)
        except:
            continue

        os.close(fd)

        if rhpl.getArch() != "ia64":
            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect (cmd, ["/tmp/floppy"], stdout = '/dev/tty5',
                                    stderr = '/dev/tty5')

        try:
            isys.mount(device, "/tmp/crash", fstype = "vfat")
        except SystemError:
            continue

        # copy trace dump we wrote to local storage to floppy
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/crash/anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to floppy")
            return 2

        isys.umount("/tmp/crash")
        return 0
Exemplo n.º 14
0
    def ejectCD(self):
	log("ejecting CD")

	# make /tmp/cdrom again so cd gets ejected
	isys.makeDevInode(self.device, "/tmp/cdrom")
	    
        try:
            isys.ejectCdrom("/tmp/cdrom", makeDevice = 0)
        except Exception, e:
	    log("eject failed %s" % (e,))
            pass
Exemplo n.º 15
0
    def mountImage(self, cdNum):
	if (self.imageMounted):
	    raise SystemError, "trying to mount already-mounted iso image!"

	isoImage = self.isoPath + '/' + self.discImages[cdNum]

	isys.makeDevInode("loop3", "/tmp/loop3")
	isys.losetup("/tmp/loop3", isoImage, readOnly = 1)
	
	isys.mount("loop3", "/tmp/isomedia", fstype = 'iso9660', readOnly = 1);
	self.mntPoint = "/tmp/isomedia/"
	self.imageMounted = cdNum
Exemplo n.º 16
0
    def mountMedia(self, cdNum):
        if (self.mediaIsMounted):
            raise SystemError, "trying to mount already-mounted iso image!"

        self.mountDirectory()

        isoImage = self.isoDir + '/' + self.path + '/' + self.discImages[cdNum]

        isys.makeDevInode("loop3", "/tmp/loop3")
        isys.losetup("/tmp/loop3", isoImage, readOnly=1)

        isys.mount("loop3", "/tmp/isomedia", fstype='iso9660', readOnly=1)
        self.tree = "/tmp/isomedia/"
        self.mediaIsMounted = cdNum
Exemplo n.º 17
0
    def __call__(self, screen, diskset, partrequests, intf):
        choices = []
        drives = diskset.disks.keys()
        drives.sort()
        for drive in drives:
            choices.append("%s" %(drive))

        # close all references we had to the diskset
        diskset.closeDevices()

        button = None
        while button != "done" and button != "back":
            (button, choice) = \
                     ListboxChoiceWindow(screen, _("Disk Setup"),
                     _("Choose a disk to run fdisk on"), choices,
                     [ (_("OK"), "done"), (_("Edit"), "edit"),
                       TEXT_BACK_BUTTON ], width = 50, help = "fdisk")

            if button != "done" and button != TEXT_BACK_CHECK:
                device = choices[choice]
                
                if os.access("/sbin/fdisk", os.X_OK):
                    path = "/sbin/fdisk"
                else:
                    path = "/usr/sbin/fdisk"

                try:
                    isys.makeDevInode(device, '/tmp/' + device)
                except:
                    pass

                screen.suspend()
                iutil.execWithRedirect (path, [ path, "/tmp/" + device ],
                                        ignoreTermSigs = 1)
                screen.resume()

                try:
                    os.remove('/tmp/' + device)
                except:
                    pass


        diskset.refreshDevices(intf)
        diskset.checkNoDisks(intf)
        partrequests.setFromDisk(diskset)

        if button == TEXT_BACK_CHECK:
            return INSTALL_BACK

        return INSTALL_OK
Exemplo n.º 18
0
def makeDriveDeviceNodes():
    hardDrives = isys.hardDriveDict()
    for drive in hardDrives.keys():
        if drive.startswith("mapper"):
            continue
        isys.makeDevInode(drive, "/dev/%s" % (drive, ))

        if drive.startswith("hd"):
            num = 32
        elif drive.startswith("dasd"):
            num = 4
        else:
            num = 15

        if (drive.startswith("cciss") or drive.startswith("ida")
                or drive.startswith("rd") or drive.startswith("sx8")):
            sep = "p"
        else:
            sep = ""

        for i in range(1, num):
            dev = "%s%s%d" % (drive, sep, i)
            isys.makeDevInode(dev, "/dev/%s" % (dev, ))

    cdroms = isys.cdromList()
    for drive in cdroms:
        isys.makeDevInode(drive, "/dev/%s" % (drive, ))

    tapeDrives = isys.tapeDriveList()
    for drive in tapeDrives:
        # make all tape device variants (stX,stXl,stXm,stXa,nstX,nstXl,nstXm,nstXa)
        for prefix in ("", "n"):
            for postfix in ("", "l", "m", "a"):
                device = "%s%s%s" % (prefix, drive, postfix)
                isys.makeDevInode(device, "/dev/%s" % (device, ))

    for mdMinor in range(0, 32):
        md = "md%d" % (mdMinor, )
        isys.makeDevInode(md, "/dev/%s" % (md, ))

    # make the node for the device mapper
    makeDMNode()
Exemplo n.º 19
0
Arquivo: iutil.py Projeto: Sudoka/base
def makeDriveDeviceNodes():
    hardDrives = isys.hardDriveDict()
    for drive in hardDrives.keys():
        if drive.startswith("mapper"):
            continue
        isys.makeDevInode(drive, "/dev/%s" % (drive,))

        if drive.startswith("hd"):
            num = 32
        elif drive.startswith("dasd"):
            num = 4
        else:
            num = 15

        if (drive.startswith("cciss") or drive.startswith("ida") or
            drive.startswith("rd") or drive.startswith("sx8")):
            sep = "p"
        else:
            sep = ""

        for i in range(1, num):
            dev = "%s%s%d" % (drive, sep, i)
            isys.makeDevInode(dev, "/dev/%s" % (dev,))

    cdroms = isys.cdromList()
    for drive in cdroms:
        isys.makeDevInode(drive, "/dev/%s" % (drive,))

    tapeDrives = isys.tapeDriveList()
    for drive in tapeDrives:
        # make all tape device variants (stX,stXl,stXm,stXa,nstX,nstXl,nstXm,nstXa)
        for prefix in ("", "n"):
            for postfix in ("", "l", "m", "a"):
                device = "%s%s%s" % (prefix, drive, postfix)
                isys.makeDevInode(device, "/dev/%s" % (device,))

    for mdMinor in range(0, 32):
        md = "md%d" %(mdMinor,)
        isys.makeDevInode(md, "/dev/%s" %(md,))

    # make the node for the device mapper
    makeDMNode()
Exemplo n.º 20
0
 def openDevices (self, intf = None, initAll = 0,
                  zeroMbr = 0, clearDevs = []):
     """Open the disks on the system and skip unopenable devices."""
     if self.disks:
         return
     for drive in self.driveList ():
         if drive in DiskSet.skippedDisks and not initAll:
             continue
         deviceFile = isys.makeDevInode(drive)
         if isys.driveIsRemovable(drive) and not flags.expert:
             DiskSet.skippedDisks.append(drive)
             continue
         # FIXME: need the right fix for z/VM formatted dasd
         if 0 and iutil.getArch() == "s390":
             rc = intf.messageWindow(_("Warning"),
                     _("The partition table on device %s was unreadable. "
                       "To create new partitions it must be initialized, "
                       "causing the loss of ALL DATA on this drive.\n\n"
                       "This operation will override any previous "
                       "installation choices about which drives to "
                       "ignore.\n\n"
                       "Would you like to initialize this drive, "
                       "erasing ALL DATA?")
                                     % (drive,), type = "yesno")
             if rc == 0:
                 DiskSet.skippedDisks.append(drive)
                 continue
             else:
                 if (self.dasdFmt(intf, drive)):
                     DiskSet.skippedDisks.append(drive)
                     continue
             
         try:
             dev = parted.PedDevice.get (deviceFile)
         except parted.error, msg:
             DiskSet.skippedDisks.append(drive)
             continue
         
         if (initAll and ((clearDevs is None) or (len(clearDevs) == 0)
                          or drive in clearDevs) and not flags.test):
             if iutil.getArch() == "s390":
                 if (self.dasdFmt(intf, drive)):
                     DiskSet.skippedDisks.append(drive)
                     continue                    
             else:
                 try:
                     disk = dev.disk_new_fresh(getDefaultDiskType())
                     disk.commit()
                     self.disks[drive] = disk
                 except parted.error, msg:
                     DiskSet.skippedDisks.append(drive)
                     continue
Exemplo n.º 21
0
def scanForRaid(drives, degradedOk=False):
    """Scans for dmraid devices on drives.

    drives is a list of device names.
    Returns a list of (raidSet, parentRaidSet, devices, level, totalDisks)
      tuples.
    """

    log.debug("scanning for dmraid on drives %s" % (drives,))

    probeDrives = []
    for d in drives:
        dp = "/dev/" + d
        isys.makeDevInode(d, dp)
        probeDrives.append(dp)
        dp = "/tmp/" + d
        isys.makeDevInode(d, dp)
    
    dmsets = []
    def nonDegraded(rs):
        log.debug("got raidset %s (%s)" % (rs, string.join(rs.member_devpaths)))
        log.debug("  valid: %s found_devs: %s total_devs: %s" % (rs.valid, rs.rs.found_devs, rs.rs.total_devs))

        if not rs.valid and not degradedOk:
            log.warning("raid %s (%s) is degraded" % (rs, rs.name))
            #raise DegradedRaidWarning, rs
            return False
        return True

    raidsets = filter(nonDegraded, block.getRaidSets(probeDrives) or [])
    def updateName(rs):
        if dmNameUpdates.has_key(rs.name):
            rs.set_name(dmNameUpdates[rs.name])
        cacheDrives.add(rs)
        return rs
        
    return reduce(lambda x,y: x + [updateName(y),], raidsets, [])
Exemplo n.º 22
0
class UrlInstallMethod(InstallMethod):
    def badPackageError(self, pkgname):
        return _(
            "The file %s cannot be opened.  This is due to a missing "
            "file or perhaps a corrupt package.  Please verify your "
            "mirror contains all required packages, and try using a "
            "different one.\n\n"
            "If you reboot, your system will be left in an inconsistent "
            "state that will likely require reinstallation.\n\n") % pkgname

    def systemUnmounted(self):
        if self.loopbackFile:
            isys.makeDevInode("loop0", "/tmp/loop")
            isys.lochangefd("/tmp/loop",
                            "%s/images/stage2.img" % (self.tree, ))
            self.loopbackFile = None

    def systemMounted(self, fsset, chroot):
        if self.tree is None:
            return

        self.loopbackFile = "%s%s%s" % (chroot,
                                        fsset.filesystemSpace(chroot)[0][0],
                                        "/rhinstall-stage2.img")

        try:
            win = self.waitWindow(
                _("Copying File"),
                _("Transferring install image to hard drive..."))
            shutil.copyfile("%s/images/stage2.img" % (self.tree, ),
                            self.loopbackFile)
            win.pop()
        except Exception, e:
            if win:
                win.pop()

            log.critical("error transferring stage2.img: %s" % (e, ))
            self.messageWindow(
                _("Error"),
                _("An error occurred transferring the install image "
                  "to your hard drive. You are probably out of disk "
                  "space."))
            os.unlink(self.loopbackFile)
            return 1

        isys.makeDevInode("loop0", "/tmp/loop")
        isys.lochangefd("/tmp/loop", self.loopbackFile)
Exemplo n.º 23
0
def scanForRaid(drives):
    """Scans for raid devices on drives.

    drives is a list of device names.
    Returns a list of (mdMinor, devices, level, totalDisks) tuples.
    """
    
    raidSets = {}
    raidDevices = {}

    for d in drives:
        parts = []
	isys.makeDevInode(d, "/tmp/" + d)
        try:
            dev = parted.PedDevice.get("/tmp/" + d)
            disk = parted.PedDisk.new(dev)

            raidParts = partedUtils.get_raid_partitions(disk)
            for part in raidParts:
                parts.append(partedUtils.get_partition_name(part))
        except:
            pass

	os.remove("/tmp/" + d)
        for dev in parts:
            try:
                (major, minor, raidSet, level, nrDisks, totalDisks, mdMinor) =\
                        isys.raidsb(dev)
            except ValueError:
                # bad magic, this can't be part of our raid set
                log("reading raid sb failed for %s",dev)
                continue

	    if raidSets.has_key(raidSet):
	    	(knownLevel, knownDisks, knownMinor, knownDevices) = \
			raidSets[raidSet]
		if knownLevel != level or knownDisks != totalDisks or \
		   knownMinor != mdMinor:
                    # Raise hell
		    log("raid set inconsistency for md%d: "
                        "all drives in this raid set do not "
                        "agree on raid parameters.  Skipping raid device",
                        mdMinor)
                    continue
		knownDevices.append(dev)
		raidSets[raidSet] = (knownLevel, knownDisks, knownMinor,
				     knownDevices)
	    else:
		raidSets[raidSet] = (level, totalDisks, mdMinor, [dev,])

	    if raidDevices.has_key(mdMinor):
	    	if (raidDevices[mdMinor] != raidSet):
		    log("raid set inconsistency for md%d: "
                        "found members of multiple raid sets "
                        "that claim to be md%d.  Using only the first "
                        "array found.", mdMinor, mdMinor)
                    continue
	    else:
	    	raidDevices[mdMinor] = raidSet

    raidList = []
    for key in raidSets.keys():
	(level, totalDisks, mdMinor, devices) = raidSets[key]
	if len(devices) < totalDisks:
            log("missing components of raid device md%d.  The "
                "raid device needs %d drive(s) and only %d (was/were) found. "
                "This raid device will not be started.", mdMinor,
                totalDisks, len(devices))
	    continue
	raidList.append((mdMinor, devices, level, totalDisks))

    return raidList
Exemplo n.º 24
0
    def __call__(self, screen, diskset, partrequests, intf):
        choices = []

        fdisk_name = "fdasd"
        listboxtext = _("Choose a disk to run fdasd or dasdfmt on")
        buttons = [(_("Next"), "done"), (_("Edit Partitions"), "edit"),
                   (_("Format DASD"), "dasdfmt"), TEXT_BACK_BUTTON]
        drives = diskset.driveList()

        drives.sort()

        for drive in drives:
            choices.append("%s" % (drive))

        # close all references we had to the diskset
        diskset.closeDevices()

        button = None

        while button != "done" and button != TEXT_BACK_CHECK:

            (button, choice) = \
                     ListboxChoiceWindow(screen, _("Disk Setup"),
                     listboxtext, choices,
                     buttons, width = 50, help = "fdasd-s390")

            if button == "edit":
                device = choices[choice]

                if os.access("/sbin/fdasd", os.X_OK):
                    path = "/sbin/fdasd"
                else:
                    path = "/usr/sbin/fdasd"

                try:
                    isys.makeDevInode(device, '/tmp/' + device)
                except:
                    pass

                screen.suspend()
                rc = iutil.execWithRedirect(path, [path, "/tmp/" + device],
                                            ignoreTermSigs=1)
                screen.resume()

                if rc:
                    intf.messageWindow(
                        _("Error"),
                        _("An error occurred while running %s on drive %s.") %
                        (path, device))

                try:
                    os.remove('/tmp/' + device)
                except:
                    pass

            elif button == "dasdfmt":
                device = choices[choice]

                rc = intf.messageWindow(
                    _("Warning"),
                    _("Running dasdfmt means the loss of \n"
                      "ALL DATA on drive %s.\n\n"
                      "Do you really want this?") % (device, ),
                    type="yesno")
                if rc == 0:
                    continue

                diskset.dasdFmt(intf, device)

            elif button == "done" or button == TEXT_BACK_CHECK:
                diskset.refreshDevices(intf)
                diskset.checkNoDisks(intf)
                partrequests.setFromDisk(diskset)

                if len(diskset.disks.keys()) == 0:
                    rc = intf.messageWindow(
                        _("No Drives Found"),
                        _("An error has occurred - no valid devices were "
                          "found on which to create new filesystems. "
                          "Please check your hardware for the cause "
                          "of this problem or use dasdfmt.\n\n"
                          "Back to the fdasd screen?"),
                        type="yesno")

                    if rc:
                        button = ""

        if button == TEXT_BACK_CHECK:
            return INSTALL_BACK

        diskset.checkNoDisks(intf)
        partrequests.setFromDisk(diskset)

        return INSTALL_OK
Exemplo n.º 25
0
def runRescue(anaconda):
    for file in [ "services", "protocols", "group", "joe", "man.config",
                  "nsswitch.conf", "selinux", "mke2fs.conf" ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except:
            pass

    # see if they would like networking enabled
    if not methodUsesNetworking(anaconda.id.methodstr):
	screen = SnackScreen()

	while 1:
	    rc = ButtonChoiceWindow(screen, _("Setup Networking"),
		_("Do you want to start the network interfaces on "
		  "this system?"), [_("Yes"), _("No")])

	    if rc != string.lower(_("No")):
		anaconda.intf = RescueInterface(screen)

		# need to call sequence of screens, have to look in text.py
		#
		# this code is based on main loop in text.py, and if it
		# or the network step in dispatch.py change significantly
		# then this will certainly break
		#
                pyfile = "network_text"
		classNames = ("NetworkDeviceWindow", "NetworkGlobalWindow")

		lastrc = INSTALL_OK
		step = 0
		anaconda.dir = 1

		while 1:
		    s = "from %s import %s; nextWindow = %s" % \
			(pyfile, classNames[step], classNames[step])
		    exec s

		    win = nextWindow()

                    rc = win(screen, anaconda, showonboot = 0)

		    if rc == INSTALL_NOOP:
			rc = lastrc
			
		    if rc == INSTALL_BACK:
			step = step - 1
			anaconda.dir = - 1
		    elif rc == INSTALL_OK:
			step = step + 1
			anaconda.dir = 1

		    lastrc = rc

		    if step == -1:
			ButtonChoiceWindow(screen, _("Cancelled"),
					   _("I can't go to the previous step "
					     "from here. You will have to try "
					     "again."),
					   buttons=[_("OK")])
                        anaconda.dir = 1
                        step = 0
		    elif step >= len(classNames):
			break

		startNetworking(anaconda.id.network, anaconda.intf, anaconda)
		break
	    else:
		break

	screen.finish()

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
	runShell()
	sys.exit(0)

    # need loopback devices too
    for lpminor in range(8):
	dev = "loop%s" % (lpminor,)
	isys.makeDevInode(dev, "/dev/" + dev)

    screen = SnackScreen()
    anaconda.intf = RescueInterface(screen)
    anaconda.setMethod()

    # prompt to see if we should try and find root filesystem and mount
    # everything in /etc/fstab on that root
    rc = ButtonChoiceWindow(screen, _("Rescue"),
        _("The rescue environment will now attempt to find your "
          "Linux installation and mount it under the directory "
          "%s.  You can then make any changes required to your "
          "system.  If you want to proceed with this step choose "
          "'Continue'.  You can also choose to mount your file systems "
          "read-only instead of read-write by choosing 'Read-Only'."
          "\n\n"
          "If for some reason this process fails you can choose 'Skip' "
          "and this step will be skipped and you will go directly to a "
          "command shell.\n\n") % (anaconda.rootPath,),
          [_("Continue"), _("Read-Only"), _("Skip")] )

    if rc == string.lower(_("Skip")):
        runShell(screen)
        sys.exit(0)
    elif rc == string.lower(_("Read-Only")):
        readOnly = 1
    else:
        readOnly = 0

    disks = upgrade.findExistingRoots(anaconda, upgradeany = 1)

    if not disks:
	root = None
    elif len(disks) == 1:
	root = disks[0]
    else:
	height = min (len (disks), 12)
	if height == 12:
	    scroll = 1
	else:
	    scroll = 0

	partList = []
	for (drive, fs, relstr, label) in disks:
            if label:
	        partList.append("%s (%s)" % (drive, label))
            else:
                partList.append(drive)

	(button, choice) = \
	    ListboxChoiceWindow(screen, _("System to Rescue"),
				_("What partition holds the root partition "
				  "of your installation?"), partList, 
				[ _("OK"), _("Exit") ], width = 30,
				scroll = scroll, height = height,
				help = "multipleroot")

	if button == string.lower (_("Exit")):
	    root = None
	else:
	    root = disks[choice]

    rootmounted = 0

    if root:
	try:
	    fs = fsset.FileSystemSet(anaconda)

	    # only pass first two parts of tuple for root, since third
	    # element is a comment we dont want
	    rc = upgrade.mountRootPartition(anaconda, root[:2], fs,
                                            allowDirty = 1, warnDirty = 1,
                                            readOnly = readOnly)

            if rc == -1:
                ButtonChoiceWindow(screen, _("Rescue"),
                    _("Your system had dirty file systems which you chose not "
                      "to mount.  Press return to get a shell from which "
                      "you can fsck and mount your partitions.  The system "
                      "will reboot automatically when you exit from the "
                      "shell."), [_("OK")], width = 50)
                rootmounted = 0
            else:
                ButtonChoiceWindow(screen, _("Rescue"),
		   _("Your system has been mounted under %s.\n\n"
                     "Press <return> to get a shell. If you would like to "
                     "make your system the root environment, run the command:\n\n"
                     "\tchroot %s\n\nThe system will reboot "
                     "automatically when you exit from the shell.") %
                                   (anaconda.rootPath, anaconda.rootPath),
                                   [_("OK")] )
                rootmounted = 1

		# now turn on swap
		if not readOnly:
		    try:
			fs.turnOnSwap("/")
		    except:
			log.error("Error enabling swap")

                # now that dev is udev, bind mount the installer dev there
                isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = 1)

                # and /dev/pts
                isys.mount("/dev/pts", "%s/dev/pts" %(anaconda.rootPath,), bindMount = 1)

                # and /selinux too
                if flags.selinux and os.path.isdir("%s/selinux" %(anaconda.rootPath,)):
                    try:
                        isys.mount("/selinux", "%s/selinux" %(anaconda.rootPath,),
                                   "selinuxfs")
                    except Exception, e:
                        log.error("error mounting selinuxfs: %s" %(e,))

		# set a library path to use mounted fs
		os.environ["LD_LIBRARY_PATH"] =  "/lib:/usr/lib:/usr/X11R6/lib:/lib:/mnt/usr/lib:/mnt/sysimage/lib:/mnt/sysimage/usr/lib:/mnt/sysimage/usr/X11R6/lib"

		# get man pages to work
                os.environ["MANPATH"] = "/mnt/sysimage/usr/share/man:/mnt/sysimage/usr/local/share/man:/usr/share/man:/usr/local/share/man"

		# find groff data dir
		try:
		    glst = os.listdir("/mnt/sysimage/usr/share/groff")

		    # find a directory which is a numeral, its where
		    # data files are
		    gversion = None
		    for gdir in glst:
			try:
			    isone = 1
			    for idx in range(0, len(gdir)):
				if string.find(string.digits + '.', gdir[idx]) == -1:
				    isone = 0
				    break
			    if isone:
				gversion = gdir
				break
				
			except:
			    gversion = None
			    continue
			
		except:
		    gversion = None

		if gversion is not None:
		    gpath = "/mnt/sysimage/usr/share/groff/"+gversion
		    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
		    os.environ["GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (gpath + '/tmac',)
		    

		# do we have bash?
		try:
		    if os.access("/usr/bin/bash", os.R_OK):
			os.symlink ("/usr/bin/bash", "/bin/bash")
		except:
		    pass
		    
			
	except:
	    # This looks horrible, but all it does is catch every exception,
	    # and reraise those in the tuple check. This lets programming
	    # errors raise exceptions, while any runtime error will
	    # still result in a shell. 
	    (exc, val) = sys.exc_info()[0:2]
            log.error(val)
	    if exc in (IndexError, ValueError, SyntaxError):
		raise exc, val, sys.exc_info()[2]

	    ButtonChoiceWindow(screen, _("Rescue"),
		_("An error occurred trying to mount some or all of your "
		  "system. Some of it may be mounted under %s.\n\n"
		  "Press <return> to get a shell. The system will reboot "
		  "automatically when you exit from the shell.") % (anaconda.rootPath,),
		  [_("OK")] )
    else:
	ButtonChoiceWindow(screen, _("Rescue Mode"),
			   _("You don't have any Linux partitions. Press "
			     "return to get a shell. The system will reboot "
			     "automatically when you exit from the shell."),
			   [ _("OK") ], width = 50)

    msgStr = ""

    if rootmounted and not readOnly:
        makeMtab(anaconda.rootPath, fs)
        try:
            makeResolvConf(anaconda.rootPath)
        except Exception, e:
            log.error("error making a resolv.conf: %s" %(e,))
        msgStr = _("Your system is mounted under the %s directory.") % (anaconda.rootPath,)
Exemplo n.º 26
0
def makeCharDeviceNodes():
    for dev in [
            "input/event0", "input/event1", "input/event2", "input/event3"
    ]:
        isys.makeDevInode(dev, "/dev/%s" % (dev, ))
Exemplo n.º 27
0
def runRescue(anaconda):
    for file in [
            "services", "protocols", "group", "joe", "man.config",
            "nsswitch.conf", "selinux", "mke2fs.conf"
    ]:
        try:
            os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
        except:
            pass

    # see if they would like networking enabled
    if not methodUsesNetworking(anaconda.id.methodstr):
        screen = SnackScreen()

        while 1:
            rc = ButtonChoiceWindow(
                screen, _("Setup Networking"),
                _("Do you want to start the network interfaces on "
                  "this system?"), [_("Yes"), _("No")])

            if rc != string.lower(_("No")):
                anaconda.intf = RescueInterface(screen)

                # need to call sequence of screens, have to look in text.py
                #
                # this code is based on main loop in text.py, and if it
                # or the network step in dispatch.py change significantly
                # then this will certainly break
                #
                pyfile = "network_text"
                classNames = ("NetworkDeviceWindow", "NetworkGlobalWindow")

                lastrc = INSTALL_OK
                step = 0
                anaconda.dir = 1

                while 1:
                    s = "from %s import %s; nextWindow = %s" % \
                 (pyfile, classNames[step], classNames[step])
                    exec s

                    win = nextWindow()

                    rc = win(screen, anaconda, showonboot=0)

                    if rc == INSTALL_NOOP:
                        rc = lastrc

                    if rc == INSTALL_BACK:
                        step = step - 1
                        anaconda.dir = -1
                    elif rc == INSTALL_OK:
                        step = step + 1
                        anaconda.dir = 1

                    lastrc = rc

                    if step == -1:
                        ButtonChoiceWindow(screen,
                                           _("Cancelled"),
                                           _("I can't go to the previous step "
                                             "from here. You will have to try "
                                             "again."),
                                           buttons=[_("OK")])
                        anaconda.dir = 1
                        step = 0
                    elif step >= len(classNames):
                        break

                startNetworking(anaconda.id.network, anaconda.intf, anaconda)
                break
            else:
                break

        screen.finish()

    # Early shell access with no disk access attempts
    if not anaconda.rescue_mount:
        runShell()
        sys.exit(0)

    # need loopback devices too
    for lpminor in range(8):
        dev = "loop%s" % (lpminor, )
        isys.makeDevInode(dev, "/dev/" + dev)

    screen = SnackScreen()
    anaconda.intf = RescueInterface(screen)
    anaconda.setMethod()

    # prompt to see if we should try and find root filesystem and mount
    # everything in /etc/fstab on that root
    rc = ButtonChoiceWindow(
        screen, _("Rescue"),
        _("The rescue environment will now attempt to find your "
          "Linux installation and mount it under the directory "
          "%s.  You can then make any changes required to your "
          "system.  If you want to proceed with this step choose "
          "'Continue'.  You can also choose to mount your file systems "
          "read-only instead of read-write by choosing 'Read-Only'."
          "\n\n"
          "If for some reason this process fails you can choose 'Skip' "
          "and this step will be skipped and you will go directly to a "
          "command shell.\n\n") % (anaconda.rootPath, ),
        [_("Continue"), _("Read-Only"),
         _("Skip")])

    if rc == string.lower(_("Skip")):
        runShell(screen)
        sys.exit(0)
    elif rc == string.lower(_("Read-Only")):
        readOnly = 1
    else:
        readOnly = 0

    disks = upgrade.findExistingRoots(anaconda, upgradeany=1)

    if not disks:
        root = None
    elif len(disks) == 1:
        root = disks[0]
    else:
        height = min(len(disks), 12)
        if height == 12:
            scroll = 1
        else:
            scroll = 0

        partList = []
        for (drive, fs, relstr, label) in disks:
            if label:
                partList.append("%s (%s)" % (drive, label))
            else:
                partList.append(drive)

        (button, choice) = \
            ListboxChoiceWindow(screen, _("System to Rescue"),
           _("What partition holds the root partition "
             "of your installation?"), partList,
           [ _("OK"), _("Exit") ], width = 30,
           scroll = scroll, height = height,
           help = "multipleroot")

        if button == string.lower(_("Exit")):
            root = None
        else:
            root = disks[choice]

    rootmounted = 0

    if root:
        try:
            fs = fsset.FileSystemSet(anaconda)

            # only pass first two parts of tuple for root, since third
            # element is a comment we dont want
            rc = upgrade.mountRootPartition(anaconda,
                                            root[:2],
                                            fs,
                                            allowDirty=1,
                                            warnDirty=1,
                                            readOnly=readOnly)

            if rc == -1:
                ButtonChoiceWindow(
                    screen,
                    _("Rescue"),
                    _("Your system had dirty file systems which you chose not "
                      "to mount.  Press return to get a shell from which "
                      "you can fsck and mount your partitions.  The system "
                      "will reboot automatically when you exit from the "
                      "shell."), [_("OK")],
                    width=50)
                rootmounted = 0
            else:
                ButtonChoiceWindow(
                    screen, _("Rescue"),
                    _("Your system has been mounted under %s.\n\n"
                      "Press <return> to get a shell. If you would like to "
                      "make your system the root environment, run the command:\n\n"
                      "\tchroot %s\n\nThe system will reboot "
                      "automatically when you exit from the shell.") %
                    (anaconda.rootPath, anaconda.rootPath), [_("OK")])
                rootmounted = 1

                # now turn on swap
                if not readOnly:
                    try:
                        fs.turnOnSwap("/")
                    except:
                        log.error("Error enabling swap")

                # now that dev is udev, bind mount the installer dev there
                isys.mount("/dev",
                           "%s/dev" % (anaconda.rootPath, ),
                           bindMount=1)

                # and /dev/pts
                isys.mount("/dev/pts",
                           "%s/dev/pts" % (anaconda.rootPath, ),
                           bindMount=1)

                # and /selinux too
                if flags.selinux and os.path.isdir("%s/selinux" %
                                                   (anaconda.rootPath, )):
                    try:
                        isys.mount("/selinux",
                                   "%s/selinux" % (anaconda.rootPath, ),
                                   "selinuxfs")
                    except Exception, e:
                        log.error("error mounting selinuxfs: %s" % (e, ))

        # set a library path to use mounted fs
                os.environ[
                    "LD_LIBRARY_PATH"] = "/lib:/usr/lib:/usr/X11R6/lib:/lib:/mnt/usr/lib:/mnt/sysimage/lib:/mnt/sysimage/usr/lib:/mnt/sysimage/usr/X11R6/lib"

                # get man pages to work
                os.environ[
                    "MANPATH"] = "/mnt/sysimage/usr/share/man:/mnt/sysimage/usr/local/share/man:/usr/share/man:/usr/local/share/man"

                # find groff data dir
                try:
                    glst = os.listdir("/mnt/sysimage/usr/share/groff")

                    # find a directory which is a numeral, its where
                    # data files are
                    gversion = None
                    for gdir in glst:
                        try:
                            isone = 1
                            for idx in range(0, len(gdir)):
                                if string.find(string.digits + '.',
                                               gdir[idx]) == -1:
                                    isone = 0
                                    break
                            if isone:
                                gversion = gdir
                                break

                        except:
                            gversion = None
                            continue

                except:
                    gversion = None

                if gversion is not None:
                    gpath = "/mnt/sysimage/usr/share/groff/" + gversion
                    os.environ["GROFF_FONT_PATH"] = gpath + '/font'
                    os.environ[
                        "GROFF_TMAC_PATH"] = "%s:/mnt/sysimage/usr/share/groff/site-tmac" % (
                            gpath + '/tmac', )

        # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink("/usr/bin/bash", "/bin/bash")
                except:
                    pass

        except:
            # This looks horrible, but all it does is catch every exception,
            # and reraise those in the tuple check. This lets programming
            # errors raise exceptions, while any runtime error will
            # still result in a shell.
            (exc, val) = sys.exc_info()[0:2]
            log.error(val)
            if exc in (IndexError, ValueError, SyntaxError):
                raise exc, val, sys.exc_info()[2]

            ButtonChoiceWindow(
                screen, _("Rescue"),
                _("An error occurred trying to mount some or all of your "
                  "system. Some of it may be mounted under %s.\n\n"
                  "Press <return> to get a shell. The system will reboot "
                  "automatically when you exit from the shell.") %
                (anaconda.rootPath, ), [_("OK")])
    else:
        ButtonChoiceWindow(screen,
                           _("Rescue Mode"),
                           _("You don't have any Linux partitions. Press "
                             "return to get a shell. The system will reboot "
                             "automatically when you exit from the shell."),
                           [_("OK")],
                           width=50)

    msgStr = ""

    if rootmounted and not readOnly:
        makeMtab(anaconda.rootPath, fs)
        try:
            makeResolvConf(anaconda.rootPath)
        except Exception, e:
            log.error("error making a resolv.conf: %s" % (e, ))
        msgStr = _("Your system is mounted under the %s directory.") % (
            anaconda.rootPath, )
Exemplo n.º 28
0
    def dasdFmt (self, intf = None, drive = None):
        """Format dasd devices (s390)."""

        if self.disks.has_key(drive):
            del self.disks[drive]

        w = intf.progressWindow (_("Initializing"),
                             _("Please wait while formatting drive %s...\n"
                               ) % (drive,), 100)
        try:
            isys.makeDevInode(drive, '/tmp/' + drive)
        except:
            pass

        argList = [ "/sbin/dasdfmt",
                    "-y",
                    "-b", "4096",
                    "-d", "cdl",
                    "-P",
                    "-F",
                    "-f",
                    "/tmp/%s" % drive]
        
        fd = os.open("/dev/null", os.O_RDWR | os.O_CREAT | os.O_APPEND)
        p = os.pipe()
        childpid = os.fork()
        if not childpid:
            os.close(p[0])
            os.dup2(p[1], 1)
            os.dup2(fd, 2)
            os.close(p[1])
            os.close(fd)
            os.execv(argList[0], argList)
            log("failed to exec %s", argList)
            sys.exit(1)
			    
        os.close(p[1])

        num = ''
        sync = 0
        s = 'a'
        while s:
            try:
                s = os.read(p[0], 1)
                os.write(fd, s)

                if s != '\n':
                    try:
                        num = num + s
                    except:
                        pass
                else:
                    if num:
                        val = string.split(num)
                        if (val[0] == 'cyl'):
                            # printf("cyl %5d of %5d |  %3d%%\n",
                            val = int(val[5][:-1])
                            w and w.set(val)
                            # sync every 10%
                            if sync + 10 <= val:
                                isys.sync()
                                sync = val
                    num = ''
            except OSError, args:
                (errno, str) = args
                if (errno != 4):
                    raise IOError, args
Exemplo n.º 29
0
def scanForRaid(drives):
    """Scans for raid devices on drives.

    drives is a list of device names.
    Returns a list of (mdMinor, devices, level, totalDisks) tuples.
    """
    
    raidSets = {}
    raidDevices = {}
    encryptedDevices = partitions.Partitions.encryptedDevices

    for d in drives:
        parts = []
	isys.makeDevInode(d, "/tmp/" + d)
        try:
            dev = parted.PedDevice.get("/tmp/" + d)
            disk = parted.PedDisk.new(dev)

            raidParts = partedUtils.get_raid_partitions(disk)
            for part in raidParts:
                # if the part is encrypted, add the mapped dev instead
                pname = partedUtils.get_partition_name(part)
                cryptoDev = encryptedDevices.get(pname)
                if cryptoDev and not cryptoDev.openDevice():
                    dev = cryptoDev.getDevice()
                else:
                    dev = pname
                parts.append(dev)
        except:
            pass

	os.remove("/tmp/" + d)
        for dev in parts:
            try:
                (major, minor, raidSet, level, nrDisks, totalDisks, mdMinor) =\
                        isys.raidsb(dev)
            except ValueError:
                # bad magic, this can't be part of our raid set
                log.error("reading raid sb failed for %s",dev)
                continue

	    if raidSets.has_key(raidSet):
	    	(knownLevel, knownDisks, knownMinor, knownDevices) = \
			raidSets[raidSet]
		if knownLevel != level or knownDisks != totalDisks or \
		   knownMinor != mdMinor:
                    # Raise hell
		    log.error("raid set inconsistency for md%d: "
                              "all drives in this raid set do not "
                              "agree on raid parameters.  Skipping raid device",
                              mdMinor)
                    continue
		knownDevices.append(dev)
		raidSets[raidSet] = (knownLevel, knownDisks, knownMinor,
				     knownDevices)
	    else:
		raidSets[raidSet] = (level, totalDisks, mdMinor, [dev,])

	    if raidDevices.has_key(mdMinor):
	    	if (raidDevices[mdMinor] != raidSet):
		    log.error("raid set inconsistency for md%d: "
                              "found members of multiple raid sets "
                              "that claim to be md%d.  Using only the first "
                              "array found.", mdMinor, mdMinor)
                    continue
	    else:
	    	raidDevices[mdMinor] = raidSet

    raidList = []
    for key in raidSets.keys():
	(level, totalDisks, mdMinor, devices) = raidSets[key]
	if len(devices) < totalDisks:
            log.warning("missing components of raid device md%d.  The "
                        "raid device needs %d drive(s) and only %d (was/were) "
                        "found. This raid device will not be started.", mdMinor,
                        totalDisks, len(devices))
	    continue
	raidList.append((mdMinor, devices, level, totalDisks))

    return raidList
Exemplo n.º 30
0
    def getRPMFilename(self, h, timer, callback=None):
        if h[1000002] == None or 1000002 not in h.keys():
            log ("header for %s has no disc location tag, assuming it's"
                 "on the current CD" %(h[1000000],))
        elif h[1000002] not in self.currentDisc:
	    timer.stop()
            log("switching from iso %s to %s for %s-%s-%s.%s" %(self.currentDisc, h[1000002], h['name'], h['version'], h['release'], h['arch']))

            if os.access("/mnt/source/.discinfo", os.R_OK):
                f = open("/mnt/source/.discinfo")
                timestamp = f.readline().strip()
                f.close()
            else:
                timestamp = self.timestamp

            if self.timestamp is None:
                self.timestamp = timestamp

	    needed = h[1000002]

            # if self.currentDisc is empty, then we shouldn't have anything
            # mounted.  double-check by trying to unmount, but we don't want
            # to get into a loop of trying to unmount forever.  if
            # self.currentDisc is set, then it should still be mounted and
            # we want to loop until it unmounts successfully
            if not self.currentDisc:
                try:
                    isys.umount("/mnt/source")
                except:
                    pass
            else:
                self.unmountCD()

	    done = 0

	    cdlist = []
	    for (dev, something, descript) in \
		    kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
                cdlist.append(dev)

	    for dev in cdlist:
		try:
		    if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
			       readOnly = 1):
			if os.access("/mnt/source/.discinfo", os.R_OK):
			    f = open("/mnt/source/.discinfo")
			    newStamp = f.readline().strip()
                            try:
                                descr = f.readline().strip()
                            except:
                                descr = None
                            try:
                                arch = f.readline().strip()
                            except:
                                arch = None
                            try:
                                discNum = getDiscNums(f.readline().strip())
                            except:
                                discNum = [ 0 ]
			    f.close()
			    if (newStamp == timestamp and
                                arch == _arch and
                                needed in discNum):
				done = 1
                                self.currentDisc = discNum

			if not done:
			    isys.umount("/mnt/source")
		except:
		    pass

		if done:
		    break

	    if not done:
		isys.ejectCdrom(self.device)

	    while not done:
		self.messageWindow(_("Change CDROM"), 
		    _("Please insert disc %d to continue.") % needed)

		try:
		    if isys.mount(self.device, "/mnt/source", 
				  fstype = "iso9660", readOnly = 1):
			time.sleep(3)
			isys.mount(self.device, "/mnt/source", 
				   fstype = "iso9660", readOnly = 1)
		    

                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
			newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
			f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
			    done = 1
                            self.currentDisc = discNum
                            # make /tmp/cdrom again so cd gets ejected
                            isys.makeDevInode(self.device, "/tmp/cdrom")

		    if not done:
			self.messageWindow(_("Wrong CDROM"),
				_("That's not the correct %s CDROM.")
                                           % (productName,))
			isys.umount("/mnt/source")
			isys.ejectCdrom(self.device)
		except:
		    self.messageWindow(_("Error"), 
			    _("The CDROM could not be mounted."))

	    timer.start()

        # if we haven't read a timestamp yet, let's try to get one
        if (self.timestamp is None and
            os.access("/mnt/source/.discinfo", os.R_OK)):
            try:
                f = open("/mnt/source/.discinfo")
                self.timestamp = f.readline().strip()
                f.close()
            except:
                pass

        tmppath = self.getTempPath()
        tries = 0
        # FIXME: should retry a few times then prompt for new cd
        while tries < 5:
            try:
                shutil.copy("%s/%s/RPMS/%s" % (self.tree, productPath,
                                               h[1000000]),
                            tmppath + h[1000000])
            except IOError, (errnum, msg):
                log("IOError %s occurred copying %s: %s",
                    errnum, h[1000000], str(msg))
                time.sleep(5)
            else:
                break
            tries = tries + 1
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

	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 images/stage2.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/images/stage2.img", os.R_OK)):
                        log.warning("%s doesn't have a stage2.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 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
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
	    shutil.copyfile("%s/images/stage2.img" % (self.tree,), 
			    self.loopbackFile)
            win.pop()
	except Exception, e:
            if win:
                win.pop()

            log.critical("error transferring stage2.img: %s" %(e,))
	    self.messageWindow(_("Error"),
		    _("An error occurred transferring the install image "
		      "to your hard drive. You are probably out of disk "
		      "space."))
	    os.unlink(self.loopbackFile)
	    return 1

	isys.makeDevInode("loop0", "/tmp/loop")
	isys.lochangefd("/tmp/loop", self.loopbackFile)

    def getFilename(self, filename, callback=None, destdir=None, retry=1):
	return self.tree + "/" + filename

    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp
Exemplo n.º 34
0
import isys
from sys import argv


def usage():
    print "usage: losetup [-d] /dev/loopN [image]"
    sys.exit(1)


if len(argv) < 3:
    usage()

if argv[1] == "-d" and len(argv[2]) > 4 and argv[2][-5:-1] == "loop":
    try:
        isys.makeDevInode(argv[2][-5:], argv[2])
        isys.unlosetup(argv[2])
    except SystemError, (errno, msg):
        print msg
        sys.exit(1)
    sys.exit(0)

if len(argv[1]) > 4 and argv[1][-5:-1] == "loop":
    try:
        isys.makeDevInode(argv[1][-5:], argv[1])
        isys.losetup(argv[1], argv[2])
    except SystemError, (errno, msg):
        print msg
        sys.exit(1)
    sys.exit(0)
Exemplo n.º 35
0
            log("Failed to copy anacdump.txt to /tmp/test-anacdump.txt")
            pass

        intf.__del__()
        os.kill(os.getpid(), signal.SIGKILL)

    while 1:
        rc = intf.dumpWindow()
        if rc:
            intf.__del__()
            os.kill(os.getpid(), signal.SIGKILL)

        device = dispatch.id.floppyDevice
        file = "/tmp/floppy"
        try:
            isys.makeDevInode(device, file)
        except SystemError:
            pass
        try:
            fd = os.open(file, os.O_RDONLY)
        except:
            continue

        os.close(fd)

        if iutil.getArch() != "ia64":
            args = ['mkdosfs', '/tmp/floppy']

            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
Exemplo n.º 36
0
def sniffFilesystemType(device):
    """Sniff to determine the type of fs on device.  

    device - name of device to sniff.  we try to create it if it doesn't exist.
    """

    if os.access(device, os.O_RDONLY):
        dev = device
    else:
        dev = "/tmp/" + device
        if not os.access(dev, os.O_RDONLY):
            try:
                isys.makeDevInode(device, dev)
            except:
                pass

    pagesize = isys.getpagesize()
    if pagesize > 2048:
        num = pagesize
    else:
        num = 2048
    try:
        fd = os.open(dev, os.O_RDONLY)
        buf = os.read(fd, num)
        os.close(fd)
    except:
        return None

    if len(buf) < pagesize:
	try:
	    log("Tried to read pagesize for %s in sniffFilesystemType and only read %s", dev, len(buf))
	except:
	    pass
	return None

    # ext2 check
    if struct.unpack("<H", buf[1080:1082]) == (0xef53,):
        if isys.ext2HasJournal(dev, makeDevNode = 0):
            return "ext3"
        else:
            return "ext2"

    # physical volumes start with HM (see linux/lvm.h
    # and LVM/ver/tools/lib/pv_copy.c)
    if buf.startswith("HM"):
        return "physical volume (LVM)"
    # xfs signature
    if buf.startswith("XFSB"):
        return "xfs"

    if (buf[pagesize - 10:] == "SWAP-SPACE" or
        buf[pagesize - 10:] == "SWAPSPACE2"):
        return "swap"

    try:
        isys.raidsbFromDevice(dev)
        return "software RAID"
    except:
        pass

    if fsset.isValidReiserFS(dev):
        return "reiserfs"

    if fsset.isValidJFS(dev):
        return "jfs"

    # FIXME:  we don't look for vfat

    return None
Exemplo n.º 37
0
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
Exemplo n.º 38
0
    def systemUnmounted(self):
	if self.loopbackFile:
	    isys.makeDevInode("loop0", "/tmp/loop")
	    isys.lochangefd("/tmp/loop", 
			"%s/%s/base/stage2.img" % (self.tree, productPath))
	    self.loopbackFile = None
Exemplo n.º 39
0
	    shutil.copyfile("%s/images/stage2.img" % (self.tree,), 
			    self.loopbackFile)
            win.pop()
	except Exception, e:
            if win:
                win.pop()

            log.critical("error transferring stage2.img: %s" %(e,))
	    self.messageWindow(_("Error"),
		    _("An error occurred transferring the install image "
		      "to your hard drive. You are probably out of disk "
		      "space."))
	    os.unlink(self.loopbackFile)
	    return 1

	isys.makeDevInode("loop0", "/tmp/loop")
	isys.lochangefd("/tmp/loop", self.loopbackFile)

    def getFilename(self, filename, callback=None, destdir=None, retry=1):
	return self.tree + "/" + filename

    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp
Exemplo n.º 40
0
 def systemUnmounted(self):
     if self.loopbackFile:
         isys.makeDevInode("loop0", "/tmp/loop")
         isys.lochangefd("/tmp/loop",
                         "%s/images/stage2.img" % (self.tree, ))
         self.loopbackFile = None
Exemplo n.º 41
0
    def systemUnmounted(self):
	if self.loopbackFile:
	    isys.makeDevInode("loop0", "/tmp/loop")
	    isys.lochangefd("/tmp/loop", 
			"%s/images/stage2.img" % (self.tree,))
	    self.loopbackFile = None
def makeCharDeviceNodes():
    for dev in ["input/event0", "input/event1", "input/event2", "input/event3"]:
        isys.makeDevInode(dev, "/dev/%s" % (dev,))
Exemplo n.º 43
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

	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 images/stage2.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/images/stage2.img", os.R_OK)):
                        log.warning("%s doesn't have a stage2.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 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