def swap_monitor(self, num):
        def find_monitor_pixmaps():
            files = []

            pixmaps1 = glob.glob("/usr/share/anaconda/pixmaps/monitor_*")
            pixmaps2 = glob.glob("pixmaps/monitor_*")
            if len(pixmaps1) < len(pixmaps2):
                files = pixmaps2
            else:
                files = pixmaps1

            pixmaps = []
            for pixmap in files:
                pixmaps.append(pixmap[string.find(pixmap, "monitor_"):])

            pixmaps.sort()
            return pixmaps

        if self.monitor_pixmaps == None:
            self.monitor_pixmaps = find_monitor_pixmaps()

        try:
            self.load_monitor_preview_pixmap(self.monitor_pixmaps[num])
        except:
            log("Unable to load monitor preview #%s", num)
Beispiel #2
0
 def filesDone(self):
     # we're trying to unmount the CD here.  if it fails, oh well,
     # they'll reboot soon enough I guess :)
     try:
         isys.umount("/mnt/source")
     except Exception, e:
         log("unable to unmount source in filesDone: %s" %(e,))
Beispiel #3
0
    def setPackage(self, header):
        if len(self.pixmaps):
            # set to switch every N seconds
            if self.pixtimer is None or self.pixtimer.elapsed() > 30:
                if self.pixtimer is None:
                    self.pixtimer = timer.Timer()

                num = self.pixcurnum
                if num >= len(self.pixmaps):
                    num = 0
                pix = self.ics.readPixmapDithered(self.pixmaps[num], 425, 225)
                if pix:
                    if self.adpix:
                        self.adbox.remove(self.adpix)
                    pix.set_alignment(0.5, 0.5)
                    self.adbox.add(pix)
                    self.adpix = pix
                else:
                    log("couldn't get a pix")
                self.adbox.show_all()
                self.pixcurnum = num + 1
                self.pixtimer.reset()

        self.curPackage["package"].set_text(
            _("Installing %s-%s-%s.%s") %
            (header[rpm.RPMTAG_NAME], header[rpm.RPMTAG_VERSION],
             header[rpm.RPMTAG_RELEASE], header[rpm.RPMTAG_ARCH]))
        size = str(header[rpm.RPMTAG_SIZE] / 1024)
        if len(size) > 3:
            size = size[0:len(size) - 3] + ',' + size[len(size) - 3:]
        self.curPackage["size"].set_text(size)
        summary = header[rpm.RPMTAG_SUMMARY]
        if (summary == None):
            summary = "(none)"
        self.curPackage["summary"].set_text(summary)
Beispiel #4
0
    def getRPMFilename(self, h, timer, callback=None):
	if self.imageMounted != h[1000002]:
            log("switching from iso %s to %s for %s-%s-%s.%s" %(self.imageMounted, h[1000002], h['name'], h['version'], h['release'], h['arch']))
	    self.umountImage()
	    self.mountImage(h[1000002])

	return self.getFilename("/%s/RPMS/%s" % (productPath, h[1000000]))
Beispiel #5
0
    def setVideoCard(self, id, server=None, card=None, videoRam=None):
        # oh suck.  if on ppc, bail because nothing other than fbdev is
        # going to work all that well
        if iutil.getArch() == "ppc":
            return

        primary = id.videocard.primaryCard()

        if card:
            db = id.videocard.cardsDB()
            if db.has_key(card):
                vcdata = db[card]
                primary.setCardData(vcdata)
                primary.setDevID(vcdata["NAME"])
                primary.setDescription(vcdata["NAME"])

                id.xsetup.xhwstate.set_videocard_name(vcdata["NAME"])
                id.xsetup.xhwstate.set_videocard_card(vcdata["NAME"])
            else:
                raise RuntimeError, "Unknown videocard specified: %s" % (
                    card, )

        if videoRam:
            # FIXME: this required casting is ugly
            id.videocard.primaryCard().setVideoRam(str(videoRam))
            id.xsetup.xhwstate.set_videocard_ram(int(videoRam))

        if server is not None:
            log("unable to really do anything with server right now")
Beispiel #6
0
 def updateDependencyCountForAddition(self, p):
     pkgs = [ p ]
     checked = []
     while len(pkgs) > 0:
         tocheck = pkgs
         pkgs = []
         for pkg in tocheck:
             pkg = pkg.name
             # make sure the package is in the package list
             if not self.set.compsxml.packages.has_key(pkg):
                 log("Component %s contains non-existent package %s (this is probably not a problem)"
                     %(self.name, pkg))
                 continue
             deps = self.set.compsxml.packages[pkg].dependencies
             for dep in deps:
                 # really needs to be in the hdlist
                 if not self.set.packages.has_key(dep):
                     log("Package %s requires %s which we don't have"
                         %(tocheck, dep))
                     continue
                 # if we've already checked for this package, don't worry
                 if dep in checked:
                     continue
                 # up the refcount on the dependency
                 if dep in self.depsDict.keys():
                     self.depsDict[dep] = self.depsDict[dep] + 1
                 else:
                     self.depsDict[dep] = 1
                     # make sure it's registered in this component
                     self.set.packages[dep].registerComponent(self)
                     # and it also has to be in the pkgDict
                     self.pkgDict[self.set.packages[dep]] = None
                 pkgs.append(self.set.packages[dep])
                 checked.append(dep)
Beispiel #7
0
    def __call__(self, screen, defaultByLang, kbd):
        if flags.serial:
            return INSTALL_NOOP
        keyboards = kbd.modelDict.keys()
        keyboards.sort()

        if kbd.beenset:
            default = kbd.get()
        else:
            default = defaultByLang

        (button, choice) = \
            ListboxChoiceWindow(screen, _("Keyboard Selection"),
                                _("Which model keyboard is attached to this computer?"), keyboards,
                                buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON], width = 30, scroll = 1, height = 8,
                                default = default, help = "kybd")

        if button == TEXT_BACK_CHECK:
            return INSTALL_BACK

        kbd.set(keyboards[choice])
        kbd.beenset = 1

        kbd.activate()

        # FIXME: eventually, kbd.activate will do this
        try:
            isys.loadKeymap(keyboards[choice])
        except SystemError, (errno, msg):
            log("Could not install keymap %s: %s" % (keyboards[choice], msg))
Beispiel #8
0
 def filesDone(self):
     # we're trying to unmount the source image at the end.  if it
     # fails, we'll reboot soon enough anyway
     try:
         self.umountMedia()
     except:
         log("unable to unmount media")
Beispiel #9
0
 def stop(self):
     if self.pid == -1:
         raise RuntimeError, "syslogd not running"
     try:
         os.kill(self.pid, 15)
     except OSError, (num, msg):
         log("killing syslogd failed: %s %s" % (num, msg))
Beispiel #10
0
def vgactivate(volgroup=None):
    """Activate volume groups by running vgchange -ay.

    volgroup - optional single volume group to activate
    """
    global lvmDevicePresent
    if flags.test or lvmDevicePresent == 0:
        return

    args = ["lvm", "vgchange", "-ay"]
    if volgroup:
        args.append(volgroup)
    rc = iutil.execWithRedirect(args[0],
                                args,
                                stdout=output,
                                stderr=output,
                                searchPath=1)
    if rc:
        log("running vgchange failed: %s.  disabling lvm" % (rc, ))
        lvmDevicePresent = 0

    # now make the device nodes
    args = ["lvm", "vgmknodes"]
    if volgroup:
        args.append(volgroup)
    rc = iutil.execWithRedirect(args[0],
                                args,
                                stdout=output,
                                stderr=output,
                                searchPath=1)
    if rc:
        log("running vgmknodes failed: %s.  disabling lvm" % (rc, ))
        lvmDevicePresent = 0
Beispiel #11
0
    def unselect(self, forInclude=0):
        hdrlist = self.grpset.hdrlist

        # update the usecount.  if this is manual, change the state if needed
        # if we were already previously selected, we don't need to bump up
        # refcounts (which makes things faster)
        self.usecount = self.usecount - 1
        if not forInclude:
            self.manual_state = MANUAL_OFF
        if self.usecount < 0:
            log("WARNING: usecount for %s < 0 (%d)" % (self.id, self.usecount))

        for grpid in self.groupreqs:
            self.grpset.groups[grpid].unselect(forInclude=1)

        if self.usecount > 0:
            return

        selected = []
        for pkg in self.packages.values():
            pkgnevra = pkg["nevra"]
            if pkg["state"] not in ON_STATES:
                continue
            pkg["state"] = OFF
            if pkg["meta"] == 0:
                hdrlist[pkgnevra].unselect()
                selected.append(pkgnevra)
                self.unselectDeps([pkgnevra])
            else:
                self.grpset.groups[pkgnevra].unselect(forInclude=1)
Beispiel #12
0
def checkDasdFmt(disk, intf):
    if iutil.getArch() != "s390":
        return 0

    if disk.type.name != "dasd":
        return 0

    # FIXME: there has to be a better way to check LDL vs CDL
    # how do I test ldl vs cdl?
    if disk.max_primary_partition_count > 1:
        return 0

    if intf:
        try:
            devs = isys.getDasdDevPort()
            dev = "/dev/%s (%s" %(disk.dev.path[5:], devs[device])
        except Exception, e:
            log("exception getting dasd dev ports: %s" %(e,))
            dev = "/dev/%s" %(disk.dev.path[5:],)
        
        rc = intf.messageWindow(_("Warning"),
                       _("The device %s is LDL formatted instead of "
                         "CDL formatted.  LDL formatted DASDs are not "
                         "supported for usage during an install of %s.  "
                         "If you wish to use this disk for installation, "
                         "it must be re-initialized causing the loss of "
                         "ALL DATA on this drive.\n\n"
                         "Would you like to reformat this DASD using CDL "
                         "format?")
                        %(dev, productName), type = "yesno")
        if rc == 0:
            return 1
        else:
            return -1
Beispiel #13
0
 def readCompsViaMethod(self, hdlist):
     fname = self.findBestFileMatch(None, 'comps.xml')
     # if not local then assume its on host
     if fname is None:
         fname = '%s/%s/base/comps.xml' % (self.baseUrl, productPath)
         log("Comps not in update dirs, using %s", fname)
     return groupSetFromCompsFile(fname, hdlist)
Beispiel #14
0
def bootloaderSetupChoices(dispatch, bl, fsset, diskSet, dir):
    if dir == DISPATCH_BACK:
        return

    choices = fsset.bootloaderChoices(diskSet, bl)
    if not choices and iutil.getPPCMachine() != "iSeries":
	dispatch.skipStep("instbootloader")
    else:
	dispatch.skipStep("instbootloader", skip = 0)

    bl.images.setup(diskSet, fsset)

    if bl.defaultDevice != None and choices:
        keys = choices.keys()
        # there are only two possible things that can be in the keys
        # mbr and boot.  boot is ALWAYS present.  so if the dev isn't
        # listed, it was mbr and we should nicely fall back to boot
        if bl.defaultDevice not in keys:
            log("MBR not suitable as boot device; installing to partition")
            bl.defaultDevice = "boot"
        bl.setDevice(choices[bl.defaultDevice][0])
    elif choices and choices.has_key("mbr"):
        bl.setDevice(choices["mbr"][0])
    elif choices and choices.has_key("boot"):
        bl.setDevice(choices["boot"][0])
    

    bootDev = fsset.getEntryByMountPoint("/")
    if not bootDev:
        bootDev = fsset.getEntryByMountPoint("/boot")
    part = partedUtils.get_partition_by_name(diskSet.disks,
                                              bootDev.device.getDevice())
    if part and partedUtils.end_sector_to_cyl(part.geom.dev,
                                               part.geom.end) >= 1024:
        bl.above1024 = 1
Beispiel #15
0
 def filesDone(self):
     # if we can't unmount the cd image, we really don't care much
     # let them go along and don't complain
     try:
         self.umountImage()
     except Exception, e:
         log("unable to unmount image in filesDone: %s" %(e,))
         pass
Beispiel #16
0
    def getRPMFilename(self, h, timer, callback=None):
        if self.mediaIsMounted != h[1000002]:
            log("switching from iso %s to %s" %
                (self.mediaIsMounted, h[1000002]))
            self.umountMedia()
            self.mountMedia(h[1000002])

        return "%s/%s/RPMS/%s" % (self.tree, productPath, h[1000000])
Beispiel #17
0
    def includeMembers(self):
        for name in self.includes:
            if not self.set.has_key(name):
                log ("warning, unknown toplevel component %s "
                     "included by component %s", name, self.name)
            self.set[name].select(forInclude = 0, toplevel = 0)

        self.set.updateSelections()
Beispiel #18
0
def mountRootPartition(intf,
                       rootInfo,
                       oldfsset,
                       instPath,
                       allowDirty=0,
                       raiseErrors=0,
                       warnDirty=0,
                       readOnly=0):
    (root, rootFs) = rootInfo

    diskset = partedUtils.DiskSet()
    diskset.openDevices()
    diskset.startAllRaid()
    lvm.vgscan()
    lvm.vgactivate()

    log("going to mount %s on %s as %s" % (root, instPath, rootFs))
    isys.mount(root, instPath, rootFs)

    oldfsset.reset()
    newfsset = fsset.readFstab(instPath + '/etc/fstab', intf)
    for entry in newfsset.entries:
        oldfsset.add(entry)

    isys.umount(instPath)

    dirtyDevs = oldfsset.hasDirtyFilesystems(instPath)
    if not allowDirty and dirtyDevs != []:
        diskset.stopAllRaid()
        lvm.vgdeactivate()
        intf.messageWindow(
            _("Dirty File Systems"),
            _("The following file systems for your Linux system "
              "were not unmounted cleanly.  Please boot your "
              "Linux installation, let the file systems be "
              "checked and shut down cleanly to upgrade.\n"
              "%s" % (getDirtyDevString(dirtyDevs), )))
        sys.exit(0)
    elif warnDirty and dirtyDevs != []:
        rc = intf.messageWindow(_("Dirty File Systems"),
                                _("The following file systems for your Linux "
                                  "system were not unmounted cleanly.  Would "
                                  "you like to mount them anyway?\n"
                                  "%s" % (getDirtyDevString(dirtyDevs, ))),
                                type="yesno")
        if rc == 0:
            return -1

    if flags.setupFilesystems:
        oldfsset.mountFilesystems(instPath, readOnly=readOnly)

    # XXX we should properly support 'auto' at some point
    if (not oldfsset.getEntryByMountPoint("/")
            or not oldfsset.getEntryByMountPoint("/").fsystem
            or not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()):
        raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support"
Beispiel #19
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
Beispiel #20
0
    def __init__(self, compsxml, hdrlist):
        self.hdrlist = hdrlist
        self.compsxml = compsxml
        self.groups = {}

        for xmlgrp in compsxml.groups.values():
            group = Group(self, xmlgrp)
            self.groups[xmlgrp.id] = group

        # build up an Everything group
        everything = rhpl.comps.Group(self.compsxml)
        everything.name = N_("Everything")
        everything.id = "everything"
        everything.description = EVERYTHING_DESCRIPTION

        multiarch = rhpl.arch.getMultiArchInfo()
        if multiarch is not None:
            (comp, best, biarch) = multiarch
        for pkgname in hdrlist.pkgnames.keys():
            if EverythingExclude.has_key(pkgname):
                continue

            mainnevra = hdrlist.getBestNevra(pkgname, prefArch=None)
            if mainnevra is None:
                continue

            everything.packages[mainnevra] = (u"mandatory", mainnevra)
            if multiarch is not None:
                # get the main and the biarch version of this package
                # for everything group
                secnevra = hdrlist.getBestNevra(pkgname, prefArch=biarch)
                if mainnevra != secnevra and secnevra is not None:
                    everything.packages[secnevra] = (u"mandatory", secnevra)

        self.compsxml.groups["Everything"] = everything
        self.groups["everything"] = Group(self, everything)

        # have to do includes and metagroups in a second pass so that
        # we can make sure the group is defined.
        for xmlgrp in compsxml.groups.values():
            group = self.groups[xmlgrp.id]
            for id in xmlgrp.groups.keys():
                if not self.groups.has_key(id):
                    log("%s references component %s which doesn't exist" %
                        (xmlgrp.id, id))
                    continue
                group.addGroupRequires(id)

            for id in xmlgrp.metapkgs.keys():
                if not self.groups.has_key(id):
                    log("%s references component %s which doesn't exist" %
                        (xmlgrp.id, id))
                    continue
                group.addMetaPkg(xmlgrp.metapkgs[id])
Beispiel #21
0
def groupSetFromCompsFile(filename, hdrlist, doSelect=1):
    import urllib2

    tries = 0
    while tries < 5:
        try:
            file = urllib2.urlopen(filename)
        except urllib2.HTTPError, e:
            log("HTTPError: %s occurred getting %s", filename, e)
        except urllib2.URLError, e:
            log("URLError: %s occurred getting %s", filename, e)
Beispiel #22
0
    def readHeaders(self):
        tries = 0

        while tries < 5:
            hdurl = "%s/%s/base/hdlist" % (self.baseUrl, productPath)
            try:
                url = urllib2.urlopen(hdurl)
            except urllib2.HTTPError, e:
                log("HTTPError: %s occurred getting %s", hdurl, e)
            except urllib2.URLError, e:
                log("URLError: %s occurred getting %s", hdurl, e)
Beispiel #23
0
    def write(self, instPath):
        # dont do this in test mode!
        if flags.test:
            return

        fromFile = instPath + "/usr/share/zoneinfo/" + self.tz

        try:
            iutil.copyFile(fromFile, instPath + "/etc/localtime")
        except OSError, (errno, msg):
            log("Error copying timezone (from %s): %s" % (fromFile, msg))
Beispiel #24
0
 def setProtected(self, dispatch):
     """Set any partitions which should be protected to be so."""
     protected = dispatch.method.protectedPartitions()
     if protected:
         for device in protected:
             log("%s is a protected partition" % (device))
             request = self.getRequestByDeviceName(device)
             if request is not None:
                 request.setProtected(1)
             else:
                 log("no request, probably a removable drive")
Beispiel #25
0
    def unselect(self, isManual=0):
        self.usecount = self.usecount - 1
        if isManual:
            if self.manual_state == MANUAL_NONE:
                self.manual_state = MANUAL_OFF
            elif self.manual_state == MANUAL_ON:
                self.manual_state = MANUAL_NONE

        # DEBUG
        if self.usecount < 0:
            log("WARNING: usecount for %s dropped below 0 (%d)" %
                (nevra(self.hdr), self.usecount))
Beispiel #26
0
    def readCompsFile(self, filename, packages):
	#
	# ugly - urlopen can return a variety of errors which
	#        do not have same form.
	#
        connected = 0
        while not connected:
            try:
		file = urllib2.urlopen(filename)
	    except urllib2.HTTPError, e:
		log("HTTPError: %s occurred getting %s", filename, e)
	    except urllib2.URLError, e:
		log("URLError: %s occurred getting %s", filename, e)
    def getDevice(self, partitions):
        """Return a device which can be solidified."""
        if self.dev:
            # FIXME: this warning can probably be removed post-beta
            log("WARNING: getting self.dev more than once for %s" % (self, ))
            return self.dev

        vg = partitions.getRequestByID(self.volumeGroup)
        vgname = vg.volumeGroupName
        self.dev = fsset.LogicalVolumeDevice(vgname,
                                             self.size,
                                             self.logicalVolumeName,
                                             existing=self.preexist)
        return self.dev
Beispiel #28
0
    def write (self, instPath):
        args = [ "/usr/sbin/authconfig", "--kickstart", "--nostart" ]
	args = args + self.getArgList()

        try:
            if flags.setupFilesystems:
                iutil.execWithRedirect(args[0], args,
                                       stdout = None, stderr = None,
                                       searchPath = 1,
                                       root = instPath)
            else:
                log("Would have run %s", args)
        except RuntimeError, msg:
            log ("Error running %s: %s", args, msg)
Beispiel #29
0
def vgscan():
    """Runs vgscan."""
    global lvmDevicePresent

    if flags.test or lvmDevicePresent == 0:
        return

    rc = iutil.execWithRedirect("lvm", ["lvm", "vgscan", "-v"],
                                stdout=output,
                                stderr=output,
                                searchPath=1)
    if rc:
        log("running vgscan failed: %s.  disabling lvm" % (rc, ))
        lvmDevicePresent = 0
Beispiel #30
0
    def __call__(self, screen, intf, network, firewall, security):
        if flags.selinux == 0:
            log("selinux disabled, not showing selinux config screen")
            return INSTALL_OK

        self.intf = intf

        toplevel = GridFormHelp(screen, _("Security Enhanced Linux"),
                                "selinux", 1, 5)
        text = _("Security Enhanced Linux (SELinux) provides stricter access "
                 "controls to improve the security of your system.  How would "
                 "you like this support enabled?")

        toplevel.add(TextboxReflowed(50, text), 0, 0, (0, 0, 0, 1))

        grid = Grid(3, 1)
        disable = SingleRadioButton(_("Disable SELinux"), None,
                                    (security.getSELinux() == 0))
        toplevel.add(disable, 0, 1, (0, 0, 0, 0))
        warn = SingleRadioButton(_("Warn on violations"), disable,
                                 (security.getSELinux() == 1))
        toplevel.add(warn, 0, 2, (0, 0, 0, 0))
        enable = SingleRadioButton(_("Active"), warn,
                                   (security.getSELinux() == 2))
        toplevel.add(enable, 0, 3, (0, 0, 0, 1))

        bb = ButtonBar(screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON))
        toplevel.add(bb, 0, 4, (0, 0, 0, 0), growx=1)

        while 1:
            result = toplevel.run()

            rc = bb.buttonPressed(result)

            if rc == TEXT_BACK_CHECK:
                screen.popWindow()
                return INSTALL_BACK

            break

        if enable.selected():
            security.setSELinux(2)
        elif warn.selected():
            security.setSELinux(1)
        elif disable.selected():
            security.setSELinux(0)

        screen.popWindow()
        return INSTALL_OK