Here's a set of patches to stop using rhpl in anaconda for everything *except* for keyboard models. We need to figure out what to do there, still. But this is a step in the right direction
Jeremy
Use python's gettext module instead of rhpl.translate --- booty/bootloaderInfo.py | 5 ++++- iutil.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py index 8e09c50..0cee1f6 100644 --- a/booty/bootloaderInfo.py +++ b/booty/bootloaderInfo.py @@ -24,9 +24,12 @@ import string import struct from copy import copy
+import gettext +_ = lambda x: gettext.ldgettext("anaconda", x) +N_ = lambda x: x + from lilo import LiloConfigFile import rhpl -from rhpl.translate import _, N_
from flags import flags import iutil diff --git a/iutil.py b/iutil.py index ba1d0b4..f80d4a5 100644 --- a/iutil.py +++ b/iutil.py @@ -31,9 +31,11 @@ import warnings import subprocess from flags import flags from constants import * -from rhpl.translate import _ import re
+import gettext +_ = lambda x: gettext.ldgettext("anaconda", x) + import logging log = logging.getLogger("anaconda")
--- isys/isys.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/isys/isys.py b/isys/isys.py index 0ea19f2..48909c7 100755 --- a/isys/isys.py +++ b/isys/isys.py @@ -36,7 +36,6 @@ import resource import re import struct import block -import rhpl import dbus
import logging @@ -483,7 +482,7 @@ def driveUsesModule(device, modules): return rc
def vtActivate (num): - if rhpl.getArch() == "s390": + if iutil.isS390(): return _isys.vtActivate (num)
--- upgrade.py | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/upgrade.py b/upgrade.py index 9d7081e..83555b0 100644 --- a/upgrade.py +++ b/upgrade.py @@ -35,9 +35,6 @@ from storage import findExistingRootDevices, getReleaseString from storage import mountExistingSystem from storage.formats import getFormat
-import rhpl -import rhpl.arch - import gettext _ = lambda x: gettext.ldgettext("anaconda", x)
Switch to using iutil.isFoo() methods rather than checking the value of rhpl.getArch() --- booty/__init__.py | 17 +++++++---------- booty/bootloaderInfo.py | 13 ++++++------- booty/checkbootloader.py | 1 - booty/ppc.py | 7 +++---- booty/x86.py | 3 +-- 5 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/booty/__init__.py b/booty/__init__.py index fc34a56..9ee6398 100644 --- a/booty/__init__.py +++ b/booty/__init__.py @@ -16,7 +16,7 @@ # """Module for manipulation and creation of boot loader configurations"""
-import rhpl +import iutil from bootloaderInfo import * from bootloader import *
@@ -30,25 +30,22 @@ class BootyNoKernelWarning: # return instance of the appropriate bootloader for our arch def getBootloader(storage): """Get the bootloader info object for your architecture""" - if rhpl.getArch() == 'i386': + if iutil.isX86(): import x86 return x86.x86BootloaderInfo(storage) - elif rhpl.getArch() == 'ia64': + elif iutil.isIA64(): import ia64 return ia64.ia64BootloaderInfo(storage) - elif rhpl.getArch() == 's390' or rhpl.getArch() == "s390x": + elif iutil.isS390(): import s390 return s390.s390BootloaderInfo(storage) - elif rhpl.getArch() == "alpha": + elif iutil.isAlpha(): import alpha return alpha.alphaBootloaderInfo(storage) - elif rhpl.getArch() == "x86_64": - import x86 - return x86.x86BootloaderInfo(storage) - elif rhpl.getArch() == "ppc": + elif iutil.isPPC(): import ppc return ppc.ppcBootloaderInfo(storage) - elif rhpl.getArch() == "sparc": + elif iutil.isSparc(): import sparc return sparc.sparcBootloaderInfo(storage) else: diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py index 0cee1f6..bdfb1d9 100644 --- a/booty/bootloaderInfo.py +++ b/booty/bootloaderInfo.py @@ -29,7 +29,6 @@ _ = lambda x: gettext.ldgettext("anaconda", x) N_ = lambda x: x
from lilo import LiloConfigFile -import rhpl
from flags import flags import iutil @@ -40,13 +39,13 @@ import booty import checkbootloader from util import getDiskPart
-if rhpl.getArch() not in ("s390", "s390x"): +if not iutil.isS390(): import block
dosFilesystems = ('FAT', 'fat16', 'fat32', 'ntfs', 'hpfs')
def doesDualBoot(): - if rhpl.getArch() == "i386" or rhpl.getArch() == "x86_64": + if iutil.isX86(): return 1 return 0
@@ -112,7 +111,7 @@ class KernelArguments: newArgs = [] cfgFilename = "/tmp/install.cfg"
- if rhpl.getArch() == "s390": + if iutil.isS390(): self.cargs = [] f = open(cfgFilename) for line in f: @@ -189,7 +188,7 @@ class BootImages: if not self.images.has_key(dev.name): if type in dosFilesystems and doesDualBoot(): self.images[dev.name] = ("Other", "Other", type) - elif type in ("hfs", "hfs+") and rhpl.getPPCMachine() == "PMac": + elif type in ("hfs", "hfs+") and iutil.getPPCMachine() == "PMac": self.images[dev.name] = ("Other", "Other", type) else: self.images[dev.name] = (None, None, type) @@ -228,7 +227,7 @@ class BootImages: # maybe questionable, but the first ntfs or fat is likely to # be the correct one to boot with XP using ntfs foundDos = True - elif type == "appleboot" and rhpl.getPPCMachine() == "PMac" and part.bootable: + elif type == "appleboot" and iutil.getPPCMachine() == "PMac" and part.bootable: foundAppleBootstrap = True elif type in ["hfs", "hfs+"] and foundAppleBootstrap: # questionable for same reason as above, but on mac this time @@ -505,7 +504,7 @@ class bootloaderInfo: else: device = console
- if not device and rhpl.getArch() != "ia64": + if not device and iutil.isIA64(): self.serialDevice = "ttyS0" self.serialOptions = "" else: diff --git a/booty/checkbootloader.py b/booty/checkbootloader.py index 9508e14..1b1ca1d 100644 --- a/booty/checkbootloader.py +++ b/booty/checkbootloader.py @@ -17,7 +17,6 @@
import os import string -import rhpl
from util import getDiskPart import iutil diff --git a/booty/ppc.py b/booty/ppc.py index 8cd4275..e5320c3 100644 --- a/booty/ppc.py +++ b/booty/ppc.py @@ -5,14 +5,13 @@ from booty import BootyNoKernelWarning from util import getDiskPart from bootloaderInfo import * import iutil -import rhpl
class ppcBootloaderInfo(bootloaderInfo): def getBootDevs(self, bl): import parted
retval = [] - machine = rhpl.getPPCMachine() + machine = iutil.getPPCMachine()
if machine == 'pSeries': for dev in self.storage.fsset.devices: @@ -74,7 +73,7 @@ class ppcBootloaderInfo(bootloaderInfo): f.write("enablenetboot\n")
yabootProg = "/sbin/mkofboot" - if rhpl.getPPCMachine() == "PMac": + if iutil.getPPCMachine() == "PMac": # write out the first hfs/hfs+ partition as being macosx for (label, longlabel, device) in chainList: if ((not label) or (label == "")): @@ -84,7 +83,7 @@ class ppcBootloaderInfo(bootloaderInfo):
f.write("magicboot=/usr/lib/yaboot/ofboot\n")
- elif rhpl.getPPCMachine() == "pSeries": + elif iutil.getPPCMachine() == "pSeries": f.write("nonvram\n") f.write("fstype=raw\n")
diff --git a/booty/x86.py b/booty/x86.py index d0972c8..3890e69 100644 --- a/booty/x86.py +++ b/booty/x86.py @@ -7,7 +7,6 @@ from bootloaderInfo import * from flags import flags import checkbootloader import iutil -import rhpl
class x86BootloaderInfo(efiBootloaderInfo): def setPassword(self, val, isCrypted = 1): @@ -413,7 +412,7 @@ class x86BootloaderInfo(efiBootloaderInfo): config.addEntry("message", message, replace = 0)
if not config.testEntry('lba32'): - if bl.above1024 and rhpl.getArch() != "x86_64": + if bl.above1024 and not iutil.isX86(bits=32): config.addEntry("lba32", replace = 0)
return config
--- desktop.py | 3 +- instdata.py | 3 +- language.py | 2 +- network.py | 4 +-- simpleconfig.py | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 simpleconfig.py
diff --git a/desktop.py b/desktop.py index fe34a5a..49b7bbe 100644 --- a/desktop.py +++ b/desktop.py @@ -20,8 +20,7 @@ #
import string - -from rhpl.simpleconfig import SimpleConfigFile +from simpleconfig import SimpleConfigFile
import logging log = logging.getLogger("anaconda") diff --git a/instdata.py b/instdata.py index 30bdaf6..07984d5 100644 --- a/instdata.py +++ b/instdata.py @@ -39,8 +39,7 @@ import users import shlex from flags import * from constants import * - -from rhpl.simpleconfig import SimpleConfigFile +from simpleconfig import SimpleConfigFile import rhpl.keyboard as keyboard
from pykickstart.version import versionToString, DEVEL diff --git a/language.py b/language.py index 1307909..78c86ad 100644 --- a/language.py +++ b/language.py @@ -25,7 +25,7 @@ import string import locale
import gettext -from rhpl.simpleconfig import SimpleConfigFile +from simpleconfig import SimpleConfigFile
import logging log = logging.getLogger("anaconda") diff --git a/network.py b/network.py index 7cfb399..5c08e18 100644 --- a/network.py +++ b/network.py @@ -32,11 +32,9 @@ import socket import struct import os import time -import rhpl import dbus from flags import flags - -from rhpl.simpleconfig import SimpleConfigFile +from simpleconfig import SimpleConfigFile
import gettext _ = lambda x: gettext.ldgettext("anaconda", x) diff --git a/simpleconfig.py b/simpleconfig.py new file mode 100644 index 0000000..94e74be --- /dev/null +++ b/simpleconfig.py @@ -0,0 +1,88 @@ +# +# simpleconifg.py - representation of a simple configuration file (sh-like) +# +# Matt Wilson msw@redhat.com +# Jeremy Katz katzj@redhat.com +# +# Copyright 1999-2002 Red Hat, Inc. +# +# This software may be freely redistributed under the terms of the GNU +# library public license. +# +# You should have received a copy of the GNU Library Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +import string +import os + +# use our own ASCII only uppercase function to avoid locale issues +# not going to be fast but not important +def uppercase_ASCII_string(str): + newstr = "" + for i in range(0,len(str)): + if str[i] in string.lowercase: + newstr += chr(ord(str[i])-32) + else: + newstr += str[i] + + return newstr + +class SimpleConfigFile: + def __str__ (self): + s = "" + keys = self.info.keys () + keys.sort () + for key in keys: + # FIXME - use proper escaping + if type (self.info[key]) == type(""): + s = s + key + "="" + self.info[key] + ""\n" + return s + + def __init__ (self): + self.info = {} + + def write(self, file): + f = open(file, "w") + f.write(self.__str__()) + f.close() + + def read(self, file): + if not os.access(file, os.R_OK): + return + + f = open(file, "r") + lines = f.readlines() + f.close() + + for line in lines: + fields = line[:-1].split('=', 2) + if len(fields) < 2: + # how am I supposed to know what to do here? + continue + key = uppercase_ASCII_string(fields[0]) + value = fields[1] + # XXX hack + value = value.replace('"', '') + value = value.replace("'", '') + self.info[key] = value + + def set (self, *args): + for (key, data) in args: + self.info[uppercase_ASCII_string(key)] = data + + def unset (self, *keys): + for key in keys: + key = uppercase_ASCII_string(key) + if self.info.has_key (key): + del self.info[key] + + def get (self, key): + key = uppercase_ASCII_string(key) + if self.info.has_key (key): + return self.info[key] + else: + return "" + +
yum's rpmUtils.arch has the same bits as rhpl.arch, so use those instead for writing out /etc/rpm/platform --- iutil.py | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/iutil.py b/iutil.py index f80d4a5..8649224 100644 --- a/iutil.py +++ b/iutil.py @@ -26,7 +26,6 @@ import signal import os.path from errno import * import inspect -import rhpl import warnings import subprocess from flags import flags @@ -565,7 +564,7 @@ def isEfi(): ## Generate the /etc/rpm/macros file. # @param root The root of the filesystem to create the files in. def writeRpmPlatform(root="/"): - import rhpl.arch + import rpmUtils.arch
if flags.test: return @@ -574,14 +573,14 @@ def writeRpmPlatform(root="/"): if not os.access("%s/etc/rpm" %(root,), os.X_OK): os.mkdir("%s/etc/rpm" %(root,))
- myarch = rhpl.arch.canonArch + myarch = rpmUtils.arch.canonArch
# now allow an override with rpmarch=i586 on the command line (#101971) if flags.targetarch != None: myarch = flags.targetarch
# now make the current install believe it, too - rhpl.arch.canonArch = myarch + rpmUtils.arch.canonArch = myarch
# FIXME: writing /etc/rpm/macros feels wrong somehow # temporary workaround for #92285
anaconda-devel@lists.stg.fedoraproject.org