summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rwxr-xr-xanaconda560
-rw-r--r--anaconda.spec.in1
-rw-r--r--anaconda_log.py16
-rw-r--r--comps.py323
-rw-r--r--exception.py31
-rw-r--r--fstab.py995
-rwxr-xr-xgettzlist4
-rwxr-xr-xgui.py752
-rw-r--r--harddrive.py2
-rw-r--r--installclass.py493
-rw-r--r--iutil.py138
-rw-r--r--kbd.py9
-rw-r--r--kickstart.py342
-rw-r--r--lilo.py381
-rw-r--r--log.py16
-rw-r--r--mouse.py122
-rw-r--r--rescue.py26
-rw-r--r--syslogd.py10
-rw-r--r--text.py1050
-rw-r--r--todo.py2132
-rw-r--r--upgrade.py149
-rw-r--r--urlinstall.py2
-rw-r--r--xserver.py126
24 files changed, 1987 insertions, 5704 deletions
diff --git a/Makefile b/Makefile
index c1adbb2a4..8430fea43 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,13 @@ clean:
subdirs:
for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1; done
+# this rule is a hack
+install-python:
+ cp -var $(PYFILES) $(DESTDIR)/$(PYTHONLIBDIR)
+ ./py-compile --basedir $(DESTDIR)/$(PYTHONLIBDIR) $(PYFILES)
+ install -m 755 anaconda $(DESTDIR)/usr/bin/anaconda
+ for d in installclasses isys iw textw; do make DESTDIR=`cd $(DESTDIR); pwd` -C $$d install; [ $$? = 0 ] || exit 1; done
+
install:
@if [ "$(DESTDIR)" = "" ]; then \
echo " "; \
@@ -89,6 +96,7 @@ create-snapshot:
echo "*** Pulling off $$tag!"; \
cd /tmp ; cvs -Q -d $(CVSROOT) export -r $$tag anaconda || echo "Um... export aborted."
@cd /tmp/anaconda ; rm isys/modutils/modutils.spec
+ @cd /tmp/anaconda ; rm pycheckrc-for-anaconda
@cd /tmp/anaconda ; rm -rf comps
@cd /tmp/anaconda ; sed -e "s/@@VERSION@@/$(VERSION)/g" -e "s/@@RELEASE@@/$(SNAPRELEASE)/g" < anaconda.spec.in > anaconda.spec
@mv /tmp/anaconda /tmp/anaconda-$(VERSION)
@@ -101,3 +109,6 @@ create-snapshot:
create-archive:
make SNAPRELEASE=$(RELEASE) create-snapshot
+
+pycheck:
+ PYTHONPATH=edd:isys:balkan:textw:iw pychecker *.py textw/*.py gui/*.py | grep -v "__init__() not called"
diff --git a/anaconda b/anaconda
index 883366904..aa999b53b 100755
--- a/anaconda
+++ b/anaconda
@@ -1,7 +1,6 @@
#!/usr/bin/python
-import sys, os, signal
-signal.signal(signal.SIGINT, signal.SIG_DFL)
+import sys, os
# For anaconda in test mode
if (os.path.exists('isys')):
@@ -20,9 +19,7 @@ else:
sys.path.append('/usr/lib/anaconda/iw')
sys.path.append('/usr/lib/anaconda/installclasses')
-os.environ['HOME'] = '/tmp'
-os.environ["LC_NUMERIC"] = "C"
-
+# do this early to keep our import footprint as small as possible
# Python passed my path as argv[0]!
# if sys.argv[0][-7:] == "syslogd":
if len(sys.argv) > 1:
@@ -31,110 +28,87 @@ if len(sys.argv) > 1:
root = sys.argv[2]
output = sys.argv[3]
syslog = Syslogd (root, open (output, "w+"))
+ # this never returns
-import traceback
-import string
-
-import isys
-(osname, host, release, version, machine) = os.uname()
-if isys.isPsudoTTY(0) and not (machine == "s390" or machine == "s390x") :
- os.environ["TERM"] = "kon"
-
-import iutil
+import signal, traceback, string, isys, iutil
+from log import log
from translate import _
from exception import handleException
+import dispatch
+from flags import flags
-setverPath = None
+# reset python's default SIGINT handler
+signal.signal(signal.SIGINT, signal.SIG_DFL)
+
+# Silly GNOME stuff
+if os.environ.has_key('HOME'):
+ os.environ['XAUTHORITY'] = os.environ['HOME'] + '/.Xauthority'
+os.environ['HOME'] = '/tmp'
+os.environ['LC_NUMERIC'] = 'C'
if os.environ.has_key ("ANACONDAARGS"):
theargs = string.split (os.environ["ANACONDAARGS"])
else:
theargs = sys.argv[1:]
+
try:
(args, extra) = isys.getopt(theargs, 'GTRxtdr:fm:',
- [ 'gui', 'text', 'reconfig', 'xmode', 'test', 'debug', 'nofallback',
+ [ 'text', 'reconfig', 'xmode', 'test', 'debug', 'nofallback',
'method=', 'rootpath=', 'pcic=', "overhead=",
'testpath=', 'mountfs', 'traceonly', 'kickstart=',
- 'lang=', 'keymap=', 'kbdtype=', 'module=', 'class=',
+ 'lang=', 'keymap=', 'module=', 'class=',
'expert', 'serial', 'lowres', 'nofb', 'rescue', 'nomount'])
except TypeError, msg:
- print "Error:", msg
+ sys.stderr.write("Error %s\n:" % msg)
sys.exit(-1)
-# save because we're about to munge argv
-[execname] = string.split(sys.argv[0], '/')[-1:]
+if extra:
+ sys.stderr.write("Unexpected arguments: %s\n" % extra)
+ sys.exit(-1)
-savedargs = []
+# Save the arguments in case we need to reexec anaconda for kon
+os.environ["ANACONDAARGS"] = string.join(sys.argv[1:])
# remove the arguments - gnome_init doesn't understand them
-for arg in sys.argv[1:]:
- savedargs.append (arg)
- sys.argv.remove (arg)
+savedargs = sys.argv[1:]
+sys.argv = sys.argv[:1]
sys.argc = 1
-os.environ["ANACONDAARGS"] = string.join(savedargs)
-
+# Parameters for the main anaconda routine
#
-# default root to install into if doing a normal install
-#
-rootPath = '/mnt/sysimage'
-
-extraModules = []
-
-# display mode is either 'g' for graphical or 't' for text
-display_mode = 'g'
-forced_display_mode = None
-
-# Force text mode on ia64
-#if iutil.getArch() == 'ia64':
-# forced_display_mode = 't'
-
-# booleans - value is 0 for false or non-zero for true
-# test - in test mode?
-# xmode - bring up text mode in a X terminal window?
-# debug - in debug mode?
-# serial - install via serial port (?)
-# expert - in expert mode?
-# traceOnly - print out loaded modules
-# forceMount - ? used ?
-# localInstall - install to chroot
-# reconfigOnly - allow user to reconfig installed box w/o reinstall
-# nofallback - don't fall back to text mode on gui startup failure
-# runres - resolution to run
-# rescue - run rescue mode instead
-test = 0
-xmode = 0
-debug = 0
-serial = 0
-expert = 0
-traceOnly = 0
-forceMount = 0
-localInstall = 0
-reconfigOnly = 0
-nofallback = 0
-rescue = 0
-rescue_nomount = 0
-overhead = 0
-runres = '800x600'
-nofbmode = 0
+rootPath = '/mnt/sysimage' # where to instal packages
+extraModules = [] # kernel modules to use
+display_mode = 'g' # try GUI by default
+xmode = 0 # bring up text mode in a remote xterm?
+debug = 0 # start up pdb immediately
+traceOnly = 0 # don't run, just list modules we use
+nofallback = 0 # if GUI mode fails, exit
+rescue = 0 # run in rescue mode
+rescue_nomount = 0 # don't automatically mount device in rescue
+overhead = 0 # kilobytes of memory used already
+runres = '800x600' # resolution to run the GUI install in
+nofbmode = 0 # don't use framebuffer X, no matter what
+instClass = None # the install class to use
+progmode = 'install' # 'reconfig', 'rescue', or 'install'
+method = None # URL representation of install method
+logFile = None # may be a file object or a file name
#
-# x - xserver info (?)
+# xcfg - xserver info (?)
+# mousehw - mouseinfo info
+# videohw - videocard info
+# monitorhw - monitor info
# lang - language to use for install/machine default
-# method - install method (not used if reconfigOnly is true)
# keymap - kbd map
-# kbdtype - type of keyboard (84 key, 101 key, etc)
-# kickstart - ?
-# mouseInfo - type of mouse
-# progmode - either 'reconfig', 'rescue', or 'install'
#
-x = None
+xcfg = None
+monitorhw = None
+videohw = None
+mousehw = None
lang = None
method = None
keymap = None
kbdtpye = None
-kickstart = None
-mouseInfo = None
progmode = None
customClass = None
@@ -144,115 +118,158 @@ customClass = None
for n in args:
(str, arg) = n
- if (str == '-G' or str == '--gui'):
- forced_display_mode = 'g'
- elif (str == '-T' or str == '--text'):
- forced_display_mode = 't'
- elif (str == '-R' or str == '--reconfig'):
- reconfigOnly = 1
- progmode = 'reconfig'
- elif (str == '-x' or str == '--xmode'):
- xmode = 1
- elif (str == '-t' or str == '--test'):
- test = 1
- elif (str == '--overhead'):
- overhead = int(arg)
- elif (str == '--rescue'):
- progmode = 'rescue'
- elif (str == "--nomount"):
- rescue_nomount = 1
- elif (str == '--nofallback'):
- nofallback = 1
- elif (str == '--module'):
- (path, subdir, name) = string.split(arg, ":")
- extraModules.append((path, subdir, name))
+ if (str == '--class'):
+ customClass = arg
+ elif (str == '-d' or str == '--debug'):
+ debug = 1
+ elif (str == '--expert'):
+ flags.expert = 1
+ elif (str == '--keymap'):
+ keymap = arg
+ elif (str == '--kickstart'):
+ from kickstart import Kickstart
+ instClass = Kickstart(arg, flags.serial)
+ elif (str == '--lang'):
+ lang = arg
+ elif (str == '--lowres'):
+ runres = '640x480'
elif (str == '-m' or str == '--method'):
method = arg
- reconfigOnly = 0
- progmode = 'install'
if method[0] == '@':
+ # ftp installs pass the password via a file in /tmp so
+ # ps doesn't show it
filename = method[1:]
- f = open(filename, "r")
- method = f.readline()
+ method = open(filename, "r").readline()
method = method[:len(method) - 1]
- del f
os.unlink(filename)
- elif (str == '-d' or str == '--debug'):
- debug = 1
- elif (str == '--kickstart'):
- kickstart = arg
- forced_display_mode = 't'
+ elif (str == '--module'):
+ (path, subdir, name) = string.split(arg, ":")
+ extraModules.append((path, subdir, name))
+ elif (str == '--nofallback'):
+ nofallback = 1
+ elif (str == '--nofb'):
+ nofbmode = 1
+ elif (str == "--nomount"):
+ rescue_nomount = 1
+ elif (str == '--overhead'):
+ overhead = int(arg)
+ elif (str == '-R' or str == '--reconfig'):
+ progmode = 'reconfig'
+ rootPath = '/'
+ logFile = "/var/log/reconfig.log"
+ flags.setupFilesystems = 0
+ customClass = 'reconfig'
+ elif (str == '--rescue'):
+ progmode = 'rescue'
elif (str == '-r' or str == '--rootpath'):
rootPath = arg
- localInstall = 1
- elif (str == '--mountfs'):
- forceMount = 1
+ flags.setupFilesystems = 0
+ logFile = sys.stderr
elif (str == '--traceonly'):
traceOnly = 1
- elif (str == '--expert'):
- expert = 1
elif (str == '--serial'):
- serial = 1
- elif (str == '--lang'):
- lang = arg
- elif (str == '--keymap'):
- keymap = arg
- elif (str == '--kbdtype'):
- kbdtype = arg
- elif (str == '--class'):
- customClass = arg
- elif (str == '--lowres'):
- runres = '640x480'
- elif (str == '--nofb'):
- nofbmode = 1
+ logFile = "/tmp/install.log"
+ flags.serial = 1
+ elif (str == '-t' or str == '--test'):
+ flags.test = 1
+ flags.setupFilesystems = 0
+ logFile = "/tmp/anaconda-debug.log"
+ elif (str == '-T' or str == '--text'):
+ display_mode = 't'
+ elif (str == '-x' or str == '--xmode'):
+ xmode = 1
#
# must specify install, rescue or reconfig mode
#
-if (progmode == None):
- print "Must specify either --reconfig or --method for program mode"
- sys.exit(1)
if (progmode == 'rescue'):
+ if (not method):
+ sys.stderr.write('--method required for rescue mode\n')
+ sys.exit(1)
+
import rescue
- rescue.runRescue(method, serial, not rescue_nomount)
+
+ log.open (logFile)
+ rescue.runRescue(method, flags.serial, not rescue_nomount)
# shouldn't get back here
sys.exit(1)
+elif (progmode == 'reconfig'):
+ pass
+else:
+ if (not method):
+ sys.stderr.write('no install method specified\n')
+ sys.exit(1)
-#
-# if not just reconfiguring box, must have install method
-#
-if (not reconfigOnly and not method):
- print "no install method specified"
- sys.exit(1)
+log.open (logFile)
if (debug):
import pdb
pdb.set_trace()
-#
-# don't let a developer reinstall their box unknowingly
-#
-if (not reconfigOnly and not test and not localInstall and os.getpid() > 90):
- print "you're running me on a live system! that's incredibly stupid."
+
+# don't let folks do anything stupid
+if (not flags.test and os.getpid() > 90 and flags.setupFilesystems):
+ sys.stderr.write(
+ "You're running me on a live system! that's incredibly stupid.\n")
sys.exit(1)
-import rpm
-import lilo
-from todo import ToDo
import isys
-from installclass import DefaultInstall
-from installclass import ReconfigStation
-from kickstart import Kickstart
+import instdata
+import videocard
+import monitor
+import mouse
+
+# handle traceonly and exit
+if traceOnly:
+
+ if display_mode == 'g':
+ sys.stderr.write("traceonly is only supported for text mode\n")
+ sys.exit(0)
+
+ # prints a list of all the modules imported
+ from text import InstallInterface
+ from text import stepToClasses
+ import pdb
+ import image
+ import harddrive
+ import urlinstall
+ import mimetools
+ import mimetypes
+ import syslogd
+ import installclass
+ import re
+ import rescue
+ import xserver
+
+ installclass.availableClasses()
+
+ if iutil.getArch() == "i386":
+ import edd
+
+ if display_mode == 't':
+ for step in stepToClasses.keys():
+ if stepToClasses[step]:
+ (mod, klass) = stepToClasses[step]
+ exec "import %s" % mod
+
+ for module in sys.__dict__['modules'].keys ():
+ if module not in [ "__builtin__", "__main__" ]:
+ foo = repr (sys.__dict__['modules'][module])
+ bar = string.split (foo, "'")
+ if len (bar) > 3:
+ print bar[3]
+
+ sys.exit(0)
iutil.setMemoryOverhead(overhead)
#
# override display mode if machine cannot nicely run X
#
-if (not test):
+if (not flags.test):
if (iutil.memInstalled() < isys.MIN_GUI_RAM):
print _("You do not have enough RAM to use the graphical installer. Starting text mode.")
- forced_display_mode = 't'
+ display_mode = 't'
if iutil.memInstalled() < isys.MIN_RAM:
from snack import *
@@ -260,7 +277,7 @@ if iutil.memInstalled() < isys.MIN_RAM:
screen = SnackScreen()
ButtonChoiceWindow(screen, _('Fatal Error'),
_('You do not have enough RAM to install Red Hat '
- 'Linux on this machine. '
+ 'Linux on this machine.\n'
'\n'
'Press <return> to reboot your system.\n'),
buttons = (_("OK"),))
@@ -270,75 +287,99 @@ if iutil.memInstalled() < isys.MIN_RAM:
#
# handle class passed from loader
#
-instClass = None
if customClass:
import installclass
classes = installclass.availableClasses(showHidden=1)
for (className, objectClass, logo) in classes:
if className == customClass:
- instClass = objectClass(expert)
- reqmode = instClass.requiredDisplayMode()
- if reqmode:
- forced_display_mode = reqmode
+ instClass = objectClass(flags.expert)
if not instClass:
- raise TypeError, "installation class "+customClass+" not available"
- sys.exit(0)
+ sys.stderr.write("installation class %s not available\n" % customClass)
+ sys.stderr.write("\navailable classes:\n")
+ for (className, objectClass, logo) in classes:
+ sys.stderr.write("\t%s\n" % className)
+ sys.exit(1)
#
-# if in reconfig mode set display mode based on inittab default runlevel
+# if no instClass declared by user figure it out based on other cmdline args
+#
+if not instClass:
+ from installclass import DefaultInstall
+ instClass = DefaultInstall(flags.expert)
+
+# this lets install classes force text mode instlls
+if instClass.forceTextMode:
+ display_mode = 't'
+
#
-# but always let command line specified mode override defaults
+# find out what video hardware is available to run installer
#
-if (forced_display_mode == None):
- if (reconfigOnly != 0):
- if (iutil.getDefaultRunlevel() == '5' and
- os.access("/etc/X11/XF86Config", os.R_OK)):
- display_mode = 'g'
- else:
- display_mode = 't'
+
+mousehw = mouse.Mouse(skipProbe = 1)
+#if display_mode == 'g':
+
+# lets try always probing this stuff, probably ought to provide way to
+# skip probing if we have really sensitive hw that HAS to use text mode
+if 1:
+ sys.stdout.write( _("Probing for video card: "))
+ videohw = videocard.VideoCardInfo()
+ if videohw and videohw.primaryCard():
+ sys.stdout.write(videohw.primaryCard().shortDescription()+'\n')
+ sys.stdout.write( _("Probing for monitor type: "))
+ monitorhw = monitor.MonitorInfo()
+ sys.stdout.write(monitorhw.shortDescription()+'\n')
+
+ # only probe if we're installing a real box or
+ # we're running in a virtual console and need to startup X server
+ if not os.environ.has_key('DISPLAY') or flags.setupFilesystems:
+ sys.stdout.write(_("Probing for mouse type: "))
+ mousehw.probe (frob = 1)
+ sys.stdout.write(mousehw.shortDescription()+'\n')
else:
- display_mode = 'g'
-else:
- display_mode = forced_display_mode
+ sys.stdout.write(_("Skipping mouse probe.\n"))
#
# startup X server is we're not already running under an X session
#
-
-#print "sleeping 40 seconds"
-#import os
-#os.read(2, 1)
-
-
-
startXServer = 0
-if (display_mode == 'g' and not os.environ.has_key('DISPLAY')):
- startXServer = 1
- import xserver
- try:
- if (reconfigOnly == 0):
- result = xserver.startX (runres, nofbmode)
- else:
- result = xserver.start_existing_X ()
+if display_mode == 'g':
+ import xf86config
+
+ if not os.environ.has_key('DISPLAY'):
+ startXServer = 1
+ import xserver
+ try:
+ if os.access("/etc/X11/XF86Config", os.R_OK):
+ xcfg = xserver.start_existing_X ()
+ else:
+ xcfg = xserver.startX (runres, nofbmode, videohw, monitorhw, mousehw)
- except RuntimeError:
- print " X startup failed, falling back to text mode"
- display_mode = 't'
+ except RuntimeError:
+ print " X startup failed, falling back to text mode"
+ display_mode = 't'
else:
- (mouseInfo, x) = (result)
+ xcfg = xf86config.XF86Config(videohw, monitorhw, mousehw, runres)
+else:
+ import xf86config
+ xcfg = xf86config.XF86Config(videohw, monitorhw, mousehw, runres)
#
# setup links required by graphical mode if installing and verify display mode
#
if (display_mode == 'g'):
- if not test and not localInstall and not reconfigOnly:
+ if not flags.test and flags.setupFilesystems:
for i in ( "imrc", "im_palette.pal", "gtk" ):
try:
os.symlink ("../mnt/runtime/etc/" + i, "/etc/" + i)
except:
pass
+
+ # display splash screen
+ from gui import display_splash_screen
+ display_splash_screen()
+
if nofallback:
from gui import InstallInterface
else:
@@ -350,59 +391,17 @@ if (display_mode == 'g'):
if startXServer:
isys.vtActivate (1)
print "GUI installer startup failed, falling back to text mode."
- display_mode = 't'
from text import InstallInterface
-elif (display_mode == 't'):
- if ((method and len (method) >= 6 and method[:6] == "ftp://")
- or (method and len (method) >= 7 and method[:7] == "http://")):
+
+if (display_mode == 't'):
+ if (method and ((len (method) >= 6 and method[:6] == "ftp://")
+ or (len (method) >= 7 and method[:7] == "http://")
+ or (len (method) >= 5 and method[:5] == "hd://"))):
print _("Graphical installation not available for %s installs. "
"Starting text mode.") % (string.split(method, ':')[0],)
- elif method and len (method) >= 5 and method[:5] == "hd://":
- print _("Graphical installation not available for hard drive installs. "
- "Starting text mode.")
from text import InstallInterface
-else:
- sys.exit(1)
+ from text import stepToClasses
-if traceOnly:
- # prints a list of all the modules imported
- import pdb
- import image
- import harddrive
- import urlinstall
- import mimetools
- import mimetypes
- import syslogd
- import installclass
- import re
- import rescue
-
- installclass.availableClasses()
-
- if iutil.getArch() == "i386":
- import edd
-
- if display_mode == 't':
- from newtpyfsedit import fsedit
- for module in sys.__dict__['modules'].keys ():
- if module not in [ "__builtin__", "__main__" ]:
- foo = repr (sys.__dict__['modules'][module])
- bar = string.split (foo, "'")
- if len (bar) > 3:
- print bar[3]
-
- sys.exit(0)
-
-#
-# if no instClass declared by user figure it out based on other cmdline args
-#
-if not instClass:
- if kickstart:
- instClass = Kickstart(kickstart, serial)
- elif reconfigOnly:
- instClass = ReconfigStation(expert)
- else:
- instClass = DefaultInstall(expert)
# we like to have a way to shoot text mode back at a display
if xmode:
@@ -428,14 +427,13 @@ if xmode:
pass
sys.exit (0)
-#print runres
if display_mode == "t":
intf = InstallInterface ()
else:
intf = InstallInterface (runres = runres, nofbmode = nofbmode)
# imports after setting up the path
-if not reconfigOnly:
+if method:
if (method[0:8] == "cdrom://"):
from image import CdromInstallMethod
method = CdromInstallMethod(method[8:], intf.messageWindow,
@@ -476,59 +474,55 @@ if not reconfigOnly:
print "unknown install method:", method
sys.exit(1)
-#
-# do some final sanity checking before going off into the great wide wonder
-#
-if reconfigOnly and method != None:
- print "Conflicting options: cannot reconfig and install simultaneously!\n"
- sys.exit(1)
+id = instClass.installDataClass(extraModules)
+
+if mousehw:
+ id.setMouse(mousehw)
+
+if videohw:
+ id.setVideoCard(videohw)
+
+if monitorhw:
+ id.setMonitor(monitorhw)
-# set the default actions
-installPackages = 1
-setupFilesystems = 1
+if xcfg:
+ id.setXconfig(xcfg)
+
+instClass.setInstallData(id)
-if localInstall:
- installPackages = 1
- setupFilesystems = 0
-if test:
- installPackages = 0
- setupFilesystems = 0
-if forceMount:
- setupFilesystems = 1
+dispatch = dispatch.Dispatcher(intf, id, method, rootPath)
if lang:
- instClass.addToSkipList("language")
- instClass.setLanguage(lang)
+ dispatch.skipStep("language")
+ instClass.setLanguage(id, lang)
if keymap:
- instClass.addToSkipList("keyboard")
- instClass.setKeyboard(keymap)
-
-if iutil.getArch() == "sparc":
- import kudzu
- mice = kudzu.probe (kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC, kudzu.PROBE_ONE);
- if mice:
- (mouseDev, driver, descr) = mice[0]
- if mouseDev == 'sunmouse':
- instClass.addToSkipList("mouse")
- instClass.setMouseType("Sun - Mouse", "sunmouse")
-
-if reconfigOnly:
- installPackages = 0
- setupFilesystems = 0
- rootPath = '/'
-
-todo = ToDo(intf, method, rootPath, installSystem = installPackages,
- setupFilesystems = setupFilesystems, mouse = mouseInfo,
- instClass = instClass, x = x, expert = expert,
- serial = serial, reconfigOnly = reconfigOnly, test = test,
- extraModules = extraModules)
+ dispatch.skipStep("keyboard")
+ instClass.setKeyboard(id, keymap)
+
+instClass.setSteps(dispatch)
+
+# We shouldn't need this again
+# XXX
+#del id
+
+#
+# XXX This is surely broken
+#
+#if iutil.getArch() == "sparc":
+# import kudzu
+# mice = kudzu.probe (kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC, kudzu.PROBE_ONE);
+# if mice:
+# (mouseDev, driver, descr) = mice[0]
+# if mouseDev == 'sunmouse':
+# instClass.addToSkipList("mouse")
+# instClass.setMouseType("Sun - Mouse", "sunmouse")
try:
- intf.run(todo, test = test)
+ intf.run(id, dispatch)
except SystemExit, code:
intf.shutdown()
except:
- handleException(todo, sys.exc_info())
+ handleException(id, intf, sys.exc_info())
del intf
diff --git a/anaconda.spec.in b/anaconda.spec.in
index f71328a77..d25377e15 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -1,3 +1,4 @@
+ExclusiveArch: i386
Name: anaconda
Version: @@VERSION@@
Release: @@RELEASE@@
diff --git a/anaconda_log.py b/anaconda_log.py
index 25f9163cd..8b086aef6 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -1,4 +1,4 @@
-import sys, os
+import sys
class LogFile:
def __init__ (self):
@@ -7,18 +7,14 @@ class LogFile:
def close (self):
self.logFile.close ()
- def open (self, serial, reconfigOnly, test, setupFilesystems):
- if reconfigOnly:
+ def open (self, file):
+ if type(file) == type("hello"):
try:
- self.logFile = open("/var/log/reconfig.log", "w")
+ self.logFile = open(file, "w")
except:
self.logFile = sys.stderr
- elif not setupFilesystems:
- self.logFile = sys.stderr
- elif serial:
- self.logFile = open("/tmp/install.log", "w")
- elif test:
- self.logFile = open("/tmp/anaconda-debug.log", "w")
+ elif file:
+ self.logFile = file
else:
self.logFile = open("/dev/tty3", "w")
diff --git a/comps.py b/comps.py
index dfead72cf..3c352d7fb 100644
--- a/comps.py
+++ b/comps.py
@@ -1,4 +1,3 @@
-import sys
import rpm
import os
from string import *
@@ -8,6 +7,7 @@ from translate import _
from translate import N_
from log import log
import time
+import string
ExcludePackages = { 'XFree86-3DLabs' : None, 'XFree86-8514' : None,
'XFree86-AGX' : None, 'XFree86-I128' : None,
@@ -30,13 +30,16 @@ ExcludePackages = { 'XFree86-3DLabs' : None, 'XFree86-8514' : None,
#
# Else:
#
-# Each package contains a list of selection chains. Each chain consists
-# of a set of components. If all of the components in any chain are selected,
-# the package is selected.
+# Each package contains a list of components that include it. Each
+# registered component is checked to see if it and all its parent
+# components are on (this is done by recursive checking of
+# parent.isSelected()). Some subcomps are keyed on the state of
+# another toplevel component. If a component, all of its ancestors,
+# and conditional components are selected, the package is selected.
+# Otherwise it is not.
#
-# Otherwise, the package is not selected.
-CHECK_CHAIN = 0
+CHECK_COMPS = 0
FORCE_SELECT = 1
FORCE_UNSELECT = 2
@@ -58,24 +61,41 @@ class Package:
def isSelected(self):
return self.selected
+ def wasForcedOff(self):
+ if self.state == FORCE_UNSELECT and not self.selected:
+ return 1
+ else:
+ return 0
+
def updateSelectionCache(self):
if self.state == FORCE_SELECT or self.state == FORCE_UNSELECT:
return
self.selected = 0
- for chain in self.chains:
+ for comp in self.comps:
on = 1
- for comp in chain:
- if not comp.isSelected(justManual = 0):
- on = 0
- else:
- if comp.pkgDict[self] != None:
- on = 0
- for expr in comp.pkgDict[self]:
- if comp.set.exprMatch (expr):
+ # if this component is selected for any reason at all,
+ # the package is not selected.
+ if not comp.isSelected(justManual = 0):
+ on = 0
+ else:
+ # if the component is on, check to see if this package
+ # was listed with an expression conditional in the comps
+ # file. If it did, we'll find a list of expressions
+ # in the component's package dictionary. If any of them
+ # evaluates to be true, the package is selected.
+ if comp.pkgDict[self] != None:
+ on = 0
+ for expr in comp.pkgDict[self]:
+ if comp.set.exprMatch (expr):
on = 1
- if on:
- self.selected = 1
+ # one is sufficient
+ break
+ if on:
+ self.selected = 1
+ # one component is sufficient in the "package is selected"
+ # case, stop looking to save time.
+ break
def getState(self):
return (self.state, self.selected)
@@ -83,14 +103,14 @@ class Package:
def setState(self, state):
(self.state, self.selected) = state
- def addSelectionChain(self, chain):
- self.chains.append(chain)
+ def registerComponent(self, comp):
+ self.comps.append(comp)
def __init__(self, header):
self.h = header
- self.chains = []
+ self.comps = []
self.selected = 0
- self.state = CHECK_CHAIN
+ self.state = CHECK_COMPS
self.name = header[rpm.RPMTAG_NAME]
self.size = header[rpm.RPMTAG_SIZE]
@@ -177,8 +197,8 @@ class HeaderListFD (HeaderList):
# being selected. Selection and deselection recurses through included
# components.
#
-# When the component file is parsed, the selection chain rules for the
-# packages are built up. Component selection is used by the packages to
+# When the component file is parsed, the comp lists that include each
+# package are built up. Component selection is used by the packages to
# determine whether or not they are selected.
#
# The selection state consists of a manually selected flag and an included
@@ -188,38 +208,59 @@ class Component:
def __len__(self):
return len(self.pkgs)
- def __getitem__(self, key):
- return self.pkgs[key]
-
def __repr__(self):
return "comp %s" % (self.name)
- def __keys__(self):
- return self.pkgs.keys()
+ def packages(self):
+ return self.pkgs
def includesPackage(self, pkg):
- return self.pkgDict.has_key(pkg)
-
- def select(self, forInclude = 0):
+ if not self.pkgDict.has_key(pkg):
+ return 0
+ if self.pkgDict[pkg] == None:
+ return 1
+ # if this package is the component with a condition,
+ # check to see if the condition is met before saying that
+ # the package is included in this component
+ for expr in self.pkgDict[pkg]:
+ if self.set.exprMatch (expr):
+ return 1
+ return 0
+
+ def select(self, forInclude = 0, toplevel = 1):
if forInclude:
- self.selectionCount = self.selectionCount + 1
+ self.selectionCount = self.selectionCount + 1
else:
self.manuallySelected = 1
- for pkg in self.pkgs:
- pkg.updateSelectionCache()
+ 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 = 1, toplevel = 0)
- for comp in self.includes:
- comp.select(forInclude = 1)
+ if toplevel:
+ self.set.updateSelections()
def isSelected(self, justManual = 0):
+ if self.conditionalKey:
+ if not self.set.has_key(self.conditionalKey):
+ log ("warning, unknown conditional trigger %s wanted by %s",
+ self.conditionalKey, self.name)
+ return 0
+ else:
+ if (self.set[self.conditionalKey].isSelected()
+ and self.parent.isSelected()):
+ return 1
+ return 0
+
# don't admit to selection-by-inclusion
if justManual:
return self.manuallySelected
return self.manuallySelected or (self.selectionCount > 0)
- def unselect(self, forInclude = 0):
+ def unselect(self, forInclude = 0, toplevel = 1):
if forInclude:
self.selectionCount = self.selectionCount - 1
if self.selectionCount < 0:
@@ -227,36 +268,34 @@ class Component:
else:
self.manuallySelected = 0
- for pkg in self.pkgs:
- pkg.updateSelectionCache()
+ 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].unselect(forInclude = 1, toplevel = 0)
- for comp in self.includes:
- comp.unselect(forInclude = 1)
+ if toplevel:
+ self.set.updateSelections()
def addInclude(self, comp):
self.includes.append(comp)
def addPackage(self, p):
self.pkgs.append(p)
- p.addSelectionChain([self])
+ p.registerComponent(self)
self.pkgDict[p] = None
def addPackageWithExpression(self, expr, p):
if not self.pkgDict.has_key (p):
self.pkgDict[p] = [ expr ]
self.pkgs.append(p)
- p.addSelectionChain([self])
+ p.registerComponent(self)
else:
if type (self.pkgDict[p]) == type ([]):
self.pkgDict[p].append (expr)
else:
self.pkgDict[p] = [ expr ]
- def addConditionalPackage(self, condComponent, p):
- self.pkgs.append(p)
- p.addSelectionChain([self, condComponent])
- self.pkgDict[p] = None
-
def setDefault(self, default):
self.default = default
@@ -270,11 +309,14 @@ class Component:
def setState(self, state):
(self.manuallySelected, self.selectionCount) = state
- def __init__(self, set, name, selected, hidden = 0):
+ def __init__(self, set, name, selected, hidden = 0, conditionalKey = "",
+ parent=None):
self.set = set
self.name = name
self.hidden = hidden
self.default = selected
+ self.conditionalKey = conditionalKey
+ self.parent = parent
self.pkgs = []
self.pkgDict = {}
self.includes = []
@@ -290,6 +332,9 @@ class ComponentSet:
return self.comps[key]
return self.compsDict[key]
+ def has_key(self, key):
+ return self.compsDict.has_key(key)
+
def getSelectionState(self):
compsState = []
for comp in self.comps:
@@ -379,7 +424,6 @@ class ComponentSet:
if theTags and "lang" not in theTags:
newTruth = 1
else:
- #print "check", l, "in", langs
if len(l) != 2:
raise ValueError, "too many arguments for lang"
if l[1] and l[1][0] == "!":
@@ -423,10 +467,10 @@ class ComponentSet:
raise TypeError, "comp file version 3 or 4 expected"
comp = None
- conditional = None
self.comps = []
self.compsDict = {}
self.expressions = {}
+ state = [ None ]
for l in lines:
l = strip (l)
if (not l): continue
@@ -445,7 +489,13 @@ class ComponentSet:
if (find(l, "?") > -1):
(trash, cond) = split (l, '?', 1)
(cond, trash) = split (cond, '{', 1)
- conditional = self.compsDict[strip (cond)]
+ cond = strip(cond)
+ conditional = "%s/%s" % (comp.name, cond)
+ # push our parent onto the stack, we'll need to restore
+ # it when this subcomp comes to a close.
+ parent = comp
+ state.append(parent)
+ comp = Component(self, conditional, 0, 1, cond, parent)
continue
if (comp == None):
@@ -456,27 +506,26 @@ class ComponentSet:
(foo, l) = split(l, None, 1)
(l, trash) = split(l, '{', 1)
l = strip (l)
- if l == "Base":
+ if l == "Base" and expression == None:
hidden = 1
comp = Component(self, l, default == '1', hidden)
elif (l == "}"):
- if conditional:
- conditional = None
- else:
+ parent = state.pop()
+ if parent == None:
+ # toplevel, add it to the set
self.comps.append(comp)
self.compsDict[comp.name] = comp
comp = None
+ state.append(None)
+ else:
+ # end of a subcomp group, restore state
+ comp = parent
else:
if (l[0] == "@"):
(at, l) = split(l, None, 1)
- comp.addInclude(self.compsDict[l])
+ comp.addInclude(l)
else:
- if conditional:
- # Let both components involved in this conditional
- # know what's going on.
- comp.addConditionalPackage (conditional, packages[l])
- conditional.addConditionalPackage (comp, packages[l])
- elif expression:
+ if expression:
# this is a package with some qualifier prefixing it
# XXX last expression noted wins when setting up Everything.
self.expressions[packages[l]] = expression
@@ -502,10 +551,8 @@ class ComponentSet:
comp.setDefaultSelection()
def updateSelections(self):
- for comp in self.comps:
- if comp.isSelected ():
- for pkg in comp.pkgs:
- pkg.updateSelectionCache()
+ for pkg in self.packages.values():
+ pkg.updateSelectionCache()
def __repr__(self):
s = ""
@@ -520,9 +567,151 @@ class ComponentSet:
return s
+ def verifyDeps (self, instPath, upgrade):
+ def formatRequire (name, version, flags):
+ string = name
+
+ if flags:
+ if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER |
+ rpm.RPMSENSE_EQUAL):
+ string = string + " "
+ if flags & rpm.RPMSENSE_LESS:
+ string = string + "<"
+ if flags & rpm.RPMSENSE_GREATER:
+ string = string + ">"
+ if flags & rpm.RPMSENSE_EQUAL:
+ string = string + "="
+ string = string + " %s" % version
+ return string
+
+ # if we still have the same packages selected, bail - we don't need to
+ # do this again.
+ if self.verifiedState == self.getSelectionState()[1]:
+ return
+
+ self.verifiedState = None
+
+ if upgrade:
+ db = rpm.opendb (0, instPath)
+ ts = rpm.TransactionSet(instPath, db)
+ how = 'u'
+ else:
+ ts = rpm.TransactionSet()
+ db = None
+ how = 'i'
+
+ for p in self.packages.packages.values ():
+ if p.selected:
+ ts.add(p.h, (p.h, p.h[rpm.RPMTAG_NAME]), how)
+ else:
+ ts.add(p.h, (p.h, p.h[rpm.RPMTAG_NAME]), "a")
+
+ checkDeps = 1
+ rc = []
+ while checkDeps:
+ deps = ts.depcheck()
+ checkDeps = 0
+
+ if not deps:
+ break
+
+ for ((name, version, release),
+ (reqname, reqversion),
+ flags, suggest, sense) in deps:
+ if sense == rpm.RPMDEP_SENSE_REQUIRES:
+ if suggest:
+ (header, sugname) = suggest
+ log ("depcheck: package %s needs %s (provided by %s)",
+ name, formatRequire(reqname, reqversion, flags),
+ sugname)
+
+ ts.add(header, (header, header[rpm.RPMTAG_NAME]), how)
+ checkDeps = 1
+ else:
+ log ("depcheck: package %s needs %s (not provided)",
+ name, formatRequire(reqname, reqversion, flags))
+ sugname = _("no suggestion")
+ if not (name, sugname) in rc:
+ rc.append ((name, sugname))
+ elif sense == rpm.RPMDEP_SENSE_CONFLICTS:
+ # We need to check if the one we are going to
+ # install is ok.
+ conflicts = 1
+ if reqversion:
+ fields = string.split(reqversion, '-')
+ if (len (fields) == 2):
+ needed = ("", fields [0], fields [1])
+ else:
+ needed = ("", fields [0], "")
+ try:
+ h = self.packages[reqname].h
+ except KeyError:
+ conflicts = 0
+ installed = ("", h[rpm.RPMTAG_VERSION],
+ h [rpm.RPMTAG_RELEASE])
+ if rpm.labelCompare (installed, needed) >= 0:
+ conflicts = 0
+
+ if conflicts:
+ log ("%s-%s-%s conflicts with to-be-installed "
+ "package %s-%s, removing from set",
+ name, version, release, reqname, reqversion)
+ if self.packages.packages.has_key (reqname):
+ self.packages.packages[reqname].selected = 0
+ log ("... removed")
+
+ del ts
+ if db:
+ del db
+
+ if not rc:
+ self.verifiedState = self.getSelectionState()[1]
+
+ return rc
+
+ def selectDepCause (self, deps):
+ for (who, dep) in deps:
+ self.packages[who].select ()
+
+ def unselectDepCause (self, deps):
+ for (who, dep) in deps:
+ self.packages[who].unselect ()
+
+ def selectDeps (self, deps):
+ for (who, dep) in deps:
+ # this skips right over "no suggestion"
+ if self.packages.has_key(dep):
+ self.packages[dep].select ()
+
+ def unselectDeps (self, deps):
+ for (who, dep) in deps:
+ # this skips right over "no suggestion"
+ if self.packages.has_key(dep):
+ self.packages[dep].unselect ()
+
+ def kernelVersionList(self):
+ kernelVersions = []
+
+ # nick is used to generate the lilo name
+ for (ktag, nick) in [ ('kernel-enterprise', 'nick'),
+ ('kernel-smp', 'smp') ]:
+ tag = string.split(ktag, '-')[1]
+ if (self.packages.has_key(ktag) and
+ self.packages[ktag].selected):
+ version = (self.packages[ktag][rpm.RPMTAG_VERSION] + "-" +
+ self.packages[ktag][rpm.RPMTAG_RELEASE] + tag)
+ kernelVersions.append((version, nick))
+
+ version = (self.packages['kernel'][rpm.RPMTAG_VERSION] + "-" +
+ self.packages['kernel'][rpm.RPMTAG_RELEASE])
+ kernelVersions.append((version, 'up'))
+
+ return kernelVersions
+
def __init__(self, file, hdlist, arch = None, matchAllLang = 0):
self.allLangs = matchAllLang
self.archList = []
+ self.verifiedState = None
if not arch:
import iutil
arch = iutil.getArch()
diff --git a/exception.py b/exception.py
index 41b080398..1594b11cb 100644
--- a/exception.py
+++ b/exception.py
@@ -7,27 +7,27 @@ from cPickle import Pickler
from translate import _
import iutil
-def handleException(todo, (type, value, tb)):
+def handleException( id, intf, (type, value, tb)):
list = traceback.format_exception (type, value, tb)
text = joinfields (list, "")
- rc = todo.intf.exceptionWindow (_("Exception Occurred"), text)
+ rc = intf.exceptionWindow (_("Exception Occurred"), text)
if rc == 1:
- todo.intf.__del__ ()
+ intf.__del__ ()
print text
import pdb
pdb.post_mortem (tb)
os.kill(os.getpid(), signal.SIGKILL)
elif not rc:
- todo.intf.__del__ ()
+ intf.__del__ ()
os.kill(os.getpid(), signal.SIGKILL)
while 1:
- rc = todo.intf.dumpWindow()
+ rc = intf.dumpWindow()
if rc:
- todo.intf.__del__ ()
+ intf.__del__ ()
os.kill(os.getpid(), signal.SIGKILL)
- device = todo.fdDevice
+ device = iutil.getFloppyDevice()
file = "/tmp/floppy"
try:
isys.makeDevInode(device, file)
@@ -72,16 +72,17 @@ def handleException(todo, (type, value, tb)):
out.write ("%s: %s\n" % (key, value))
out.write("\nToDo object:\n")
- intf = todo.intf
- todo.intf = None
- todo.fstab = None
- todo.comps = None
- todo.hdList = None
- todo.rootpassword = None
- todo.users = None
+
+ # these have C objects in them which can't dump
+ id.hdList = None
+ id.comps = None
+
+ # we don't need to know passwords
+ id.rootPassword = None
+ id.accounts = None
try:
- p.dump(todo)
+ p.dump(id)
except:
out.write("\n<failed>\n")
diff --git a/fstab.py b/fstab.py
index 3c704ebcf..4e192def1 100644
--- a/fstab.py
+++ b/fstab.py
@@ -24,596 +24,81 @@ import _balkan
import sys
from translate import _
from log import log
+import kudzu
fstabFormatString = "%-23s %-23s %-7s %-15s %d %d\n";
-def isValidExt2(device):
- file = '/tmp/' + device
- isys.makeDevInode(device, file)
- try:
- fd = os.open(file, os.O_RDONLY)
- except:
- return 0
-
- buf = os.read(fd, 2048)
- os.close(fd)
-
- if len(buf) != 2048:
- return 0
-
- if struct.unpack("H", buf[1080:1082]) == (0xef53,):
- return 1
-
- return 0
-
class Fstab:
# return 1 if we should stay on the same screen
def checkFormatting(self, messageWindow):
- alreadyExists = {}
-
- (drives, raid) = self.partitionList()
- for (drive, part, type, start, cyl, size, preexisting) in drives:
- if preexisting and isValidExt2(drive):
- alreadyExists[part] = 1
-
- badList = []
- for (part, drive, fsystem, format, size) in \
- self.formattablePartitions():
- if not alreadyExists.has_key(part) and not format:
- badList.append((part, drive))
-
- if badList:
- message = _("The following partitions are newly created, but "
- "you have chosen not to format them. This will "
- "probably cause an error later in the install.\n"
- "\n")
-
- for (part, drive) in badList:
- message = message + ("\t%-20s /dev/%s\n" % (part, drive))
-
- message = message + _("\n\nPress OK to continue, or Cancel to go back and select these partitions to be formatted (RECOMMENDED).")
- rc = messageWindow(_("Warning"), message, type = "okcancel").getrc()
-
- return rc
-
return 0
- def attemptPartitioning(self, partitions, prefstab, clearParts):
-
- attempt = []
- swapCount = 0
-
-#
-# this is probably not required
-#
-# fstab = []
-# for (mntpoint, dev, fstype, reformat, size) in self.extraFilesystems:
-# fstab.append ((dev, mntpoint))
-
- fstab = []
- if prefstab != None:
- for (mntpoint, (dev, fstype, reformat)) in prefstab:
- fstab.append ((dev, mntpoint))
-
- # if doing a harddrive install mark source partition so it isnt erased
- if self.protectList:
- for i in self.protectList:
- fstab.append ((i, "DONT ERASE "+i))
-
- ddruid = self.createDruid(fstab = fstab, ignoreBadDrives = 1)
-
- # skip out here if not partitions defined, just onpart def's
- # cant do this now, have to let attempt fixup partition types
- #if partitions == None:
- # return ddruid
-
- for (mntpoint, sizespec, locspec, typespec, fsopts) in partitions:
- (device, part, primOnly) = locspec
- (size, maxsize, grow) = sizespec
- (type, active) = typespec
-
- if (part == 0):
- part = -1
-
- if (type == 0):
- type = 0x83
-
- if (mntpoint == "swap"):
- mntpoint = "Swap%04d-auto" % swapCount
- swapCount = swapCount + 1
- type = 0x82
- elif (mntpoint[0:5] == "raid."):
- type = 0xfd
-
- attempt.append((mntpoint, size, maxsize, type, grow, -1, device, part, primOnly, active))
-
- success = 0
-
- try:
- rc = ddruid.attempt (attempt, "Junk Argument", clearParts)
- success = 1
-
- except self.fserror, msg:
- log("Autopartitioning failed because following errors:")
- for i in string.split(msg, '\n'):
- if len(i) > 0:
- log (i)
- pass
-
- if success == 1:
- # configure kickstart requested ext2 filesystem options
- for (mntpoint, sizespce, locspec, typespec, fsopts) in partitions:
- if fsopts != None:
- self.setfsOptions (mntpoint, fsopts)
-
- # sanity check
- for (partition, mount, fsystem, size) in ddruid.getFstab():
- if mount == '/' and fsystem != 'ext2':
- raise ValueError, "--onpart specified for mount point / on non-ext2 partition"
-
- # if mount point other than '/' is on non-ext2, better have
- # specified --noformat
- for (mntpoint, (dev, fstype, reformat)) in prefstab:
- if mntpoint == mount and reformat != 0 and fsystem != fstype:
- raise ValueError, "--onpart specified for mount point %s on non-ext2 partition without --noformat option" % mntpoint
-
- return ddruid
- else:
- return None
-
- # returns max cylinder, starting counting from 1
- # reads DIRECTLY from drive partition table, not the desired
- # partition table we construct at the start of the install
- # in disk druid/autopartitioning!!!
- def getBootPartitionMaxCylFromDrive(self):
-
- # avoid if partitionless install
- if self.rootOnLoop():
- return 0
-
- bootpart = self.getBootDevice()
- boothd = self.getMbrDevice()
-
- # for now just assume this will work on RAID systems, not simple to
- # test at all
- if bootpart[0:2] == "md":
- return 0
-
- maxcyl = 0
-
- try:
- bootgeom = isys.getGeometry(boothd)
- except:
- bootgeom = None
-
- if bootgeom != None:
- isys.makeDevInode(boothd, '/tmp/' + boothd)
-
- try:
- table = _balkan.readTable ('/tmp/' + boothd)
- except SystemError:
- pass
- else:
- for i in range (len (table)):
- part = "%s%d" % (boothd, i+1)
- if part == bootpart:
- (type, sector, size) = table[i]
- maxcyl = (sector+size) / string.atoi(bootgeom[2])
- maxcyl = maxcyl / string.atoi(bootgeom[1])
-
- os.remove ('/tmp/' + boothd)
-
- return maxcyl
-
- # returns max cylinder, starting counting from 1
- # this is read from the ddruid object of the partitioning scheme we
- # are currently building up from disk druid/autopartitioning
- # NOT guaranteed to be same as getBootPartitionMaxCylFromDrive() result
- def getBootPartitionMaxCylFromDesired(self):
- bootpart = self.getBootDevice()
- boothd = self.getMbrDevice()
-
- # for now just assume this will work on RAID systems, not simple to
- # test at all
- if bootpart[0:2] == "md":
- return 0
-
- (drives, raid) = self.partitionList()
-
- for (dev, devName, type, start, size, maxcyl, preexist) in drives:
- # only test if putting on ext2 partition, skip for
- # dos since its a partitionless install
- if type == 1:
- continue
- if dev == bootpart:
- return maxcyl
-
- return 0
-
def getMbrDevice(self):
- return self.driveList()[0]
+ return self.drive
def getBootDevice(self):
- bootDevice = None
- rootDevice = None
- for (mntpoint, partition, fsystem, doFormat, size) in self.mountList():
- if mntpoint == '/':
- rootDevice = partition
- elif mntpoint == '/boot':
- bootDevice = partition
-
- if not bootDevice:
- bootDevice = rootDevice
-
- return bootDevice
+ return self.boot
def getRootDevice(self):
- for (mntpoint, partition, fsystem, doFormat, size) in self.mountList():
- if mntpoint == '/':
- return (partition, fsystem)
+ return self.root
def rootOnLoop(self):
- for (mntpoint, partition, fsystem, doFormat, size) in self.mountList():
- if mntpoint == '/':
- if fsystem == "vfat":
- return 1
- else:
- return 0
-
- raise ValueError, "no root device has been set"
-
- def setLoopbackSize(self, size, swapSize):
- self.loopbackSize = size
- self.addMount("/mnt/loophost/rh-swap.img", swapSize, "swap")
-
- def getLoopbackSize(self):
- lSize = 0
- for (device, rel, size) in self.swapList(devices = 1, files = 1):
- if device == "/mnt/loophost/rh-swap.img":
- lSize = size
-
- return (self.loopbackSize, lSize)
+ return 0
- def setDruid(self, druid, raid):
- self.ddruid = druid
- self.fsCache = {}
- for (mntPoint, raidDev, level, devices) in raid:
- if mntPoint == "swap":
- fsystem = "swap"
- else:
- fsystem = "ext2"
- self.addNewRaidDevice(mntPoint, raidDev, fsystem, level, devices)
-
def rescanPartitions(self, clearFstabCache = 0):
- if self.ddruid:
- self.closeDrives(clearFstabCache)
-
- fstab = []
- for (mntpoint, dev, fstype, reformat, size) in self.cachedFstab:
- fstab.append ((dev, mntpoint))
-
- self.ddruid = self.fsedit(0, self.driveList(), fstab, self.zeroMbr,
- self.readOnly, self.upgrade,
- self.expert, self.edd)
- del self.cachedFstab
+ pass
def closeDrives(self, clearFstabCache = 0):
- # we expect a rescanPartitions() after this!!!
- if clearFstabCache:
- self.cachedFstab = []
- else:
- self.cachedFstab = self.mountList(skipExtra = 1)
- self.ddruid = None
+ pass
def setReadonly(self, readOnly):
- self.readOnly = readOnly
- self.ddruid.setReadOnly(readOnly)
+ pass
def savePartitions(self):
- import sys
- try:
- self.ddruid.save()
- except SystemError:
- # We can't reread the partition table for some reason. Display
- # an error message and reboot
- self.messageWindow(_("Error"),
- _("The kernel is unable to read your new partitioning "
- "information, probably because you modified extended "
- "partitions. While this is not critical, you must "
- "reboot your machine before proceeding. Insert the "
- "Red Hat boot disk now and press \"Ok\" to reboot "
- "your system.\n"))
- sys.exit(0)
+ pass
def runDruid(self):
- rc = self.ddruid.edit()
- return rc
+ pass
def updateFsCache(self):
- realFs = {}
- for (partition, mount, fsystem, size) in self.ddruid.getFstab():
- realFs[(partition, mount)] = 1
- for ((partition, mount)) in self.fsCache.keys():
- if not realFs.has_key((partition, mount)):
- del self.fsCache[(partition, mount)]
+ pass
def setFormatFilesystem(self, device, format):
- for (mntpoint, partition, fsystem, doFormat, size) in self.mountList():
- if partition == device:
- self.fsCache[(partition, mntpoint)] = (format,)
- return
-
- raise TypeError, "unknown partition to format %s" % (device,)
-
- # sorted largest to smallest
- def spaceSort(self, a, b):
- (m1, s1) = a
- (m2, s2) = b
-
- if (s1 > s2):
- return -1
- elif s1 < s2:
- return 1
-
- return 0
-
- def filesystemSpace(self, topMount):
- space = []
- for (mntpoint, partition, fsystem, doFormat, size) in self.mountList():
- if fsystem == 'ext2':
- try:
- space.append((mntpoint, isys.fsSpaceAvailable(topMount + '/' + mntpoint)))
- except SystemError:
- pass
- elif mntpoint == '/' and fsystem == 'vfat':
- try:
- space.append((mntpoint, isys.fsSpaceAvailable(topMount + '/' + mntpoint)))
- except SystemError:
- pass
-
- space.sort(self.spaceSort)
- return space
-
- def formatAllFilesystems(self):
- for (partition, mount, fsystem, size) in self.ddruid.getFstab():
- if mount[0] == '/' and fsystem == "ext2":
- self.fsCache[(partition, mount)] = (1,)
- (devices, raid) = self.ddruid.partitionList()
- for (mount, partition, fsystem, level, i, j, deviceList) in \
- self.raidList()[1]:
- if mount[0] == '/' and fsystem == "ext2":
- self.fsCache[(partition, mount)] = (1,)
-
-# FSOptions is a list of options to be passed when creating fs for mount
- def setfsOptions (self, mount, fsopts):
- self.fsOptions[mount] = fsopts;
- return
-
- def getfsOptions (self, mount):
- if self.fsOptions.has_key(mount):
- return self.fsOptions[mount]
- else:
- return None
-
- def clearfsOptions (self):
- self.fsOptions = {}
- return
-
- def partitionList(self):
- return self.ddruid.partitionList()
+ pass
def writeCleanupPath(self, f):
- if self.rootOnLoop():
- # swap gets turned off by init, then turn off loop1, and filesystem
- # unmounts will just happen
- f.write("umount /mnt/sysimage/proc\n")
- f.write("umount /mnt/sysimage\n")
- isys.makeDevInode("loop1", "/tmp/loop1")
- f.write("lounsetup /tmp/loop1\n")
-
- def getprotectedList(self):
- if self.protectList:
- return self.protectList
- else:
- return []
-
- def formattablePartitions(self):
- l = []
- for item in self.mountList():
- (mount, dev, fstype, format, size) = item
-
- # dont format protected partitions
- for n in self.getprotectedList():
- if n == dev:
- continue
-
- if fstype == "ext2" or (fstype == "vfat" and mount == "/boot/efi"):
- l.append(item)
-
- return l
+ pass
def driveList(self):
- drives = isys.hardDriveDict().keys()
- drives.sort (isys.compareDrives)
- return drives
-
- def drivesByName(self):
- return isys.hardDriveDict()
-
- # returns a list of tuples
- # each tuple is (swapArea, relative, size)
- # if relative is true, instPath needs to be added to the name of the
- # swap file. if false, the swapArea is relative to /
- # if the swapArea is a device, no leading / is used at all
- # size is only valid (i.e. an integer) if we expect to create the
- # swap space
- def swapList(self, devices = 1, files = 0):
- fstab = []
- for (partition, mount, fsystem, size) in self.ddruid.getFstab():
- if fsystem != "swap": continue
- fstab.append((partition, 1, None))
-
- # Add raid mounts to mount list
- (devices, raid) = self.raidList()
- for (mntpoint, device, fsType, raidType, start, size, makeup) in raid:
- if fsType != "swap": continue
- fstab.append((device, 1, None))
-
- for n in self.extraFilesystems:
- (mntpoint, device, fsType, doFormat, size) = n
- if fsType != "swap": continue
-
- onDev = device[0] != '/'
- if (onDev and devices) or ((not onDev) and files):
- relative = 1
- if device[0:14] == '/mnt/loophost/':
- relative = 0
- # for swap, the mntpoint doubles as the size
- fstab.append((device, relative, mntpoint))
-
- # we need to find existing raid swap as well
- existing = self.existingRaidList()
- for (raidDevice, mntPoint, fileSystem, deviceList) in existing:
- if fileSystem == "swap":
- fstab.append(raidDevice, 1, None)
-
- return fstab
+ return self.drive
def turnOffSwap(self, devices = 1, files = 0):
- for n in enabledSwapDict().keys():
- isys.swapoff(n)
-
- def turnOnSwap(self, instPath, formatSwap = 1):
- swaps = enabledSwapDict()
+ isys.swapoff(self.swap)
+ def turnOnSwap(self, instPath, waitWindow, formatSwap = 1):
iutil.mkdirChain('/tmp/swap')
- for (device, rel, size) in self.swapList(devices = 1, files = 1):
- formatThisSwap = formatSwap
-
- if device[0] == '/':
- if rel:
- file = os.path.normpath(instPath + device)
- else:
- file = device
-
- if swaps.has_key(file): continue
-
- if not os.access(file, os.R_OK):
- if type(size) == type(1):
- isys.ddfile(file, size, (self.progressWindow,
- _("Swap Space"),
- _("Creating swap space...")))
-
- iutil.execWithRedirect ("/usr/sbin/mkswap",
- [ "mkswap", '-v1', file ],
- stdout = None, stderr = None)
- os.chmod(file, 0600)
- formatThisSwap = 1
- else:
- log("swap file %s is in the fstab, but does not exist",
- file)
- continue
-
- else:
- file = '/tmp/swap/' + device
- if swaps.has_key(file): continue
- isys.makeDevInode(device, file)
-
- if formatThisSwap:
- w = self.waitWindow(_("Formatting"),
- _("Formatting swap space..."))
-
- rc = iutil.execWithRedirect ("/usr/sbin/mkswap",
- [ "mkswap", '-v1', file ],
- stdout = None, stderr = None,
- searchPath = 1)
- w.pop()
-
- if rc:
- self.messageWindow(_("Error"), _("Error creating swap on device ") + file)
- else:
- isys.swapon (file)
- else:
- try:
- isys.swapon (file)
- except:
- # XXX should we complain?
- pass
-
- def addNewRaidDevice(self, mountPoint, raidDevice, fileSystem,
- raidLevel, deviceList):
- self.supplementalRaid.append((mountPoint, raidDevice, fileSystem,
- raidLevel, deviceList))
-
- def clearExistingRaid(self):
- self.existingRaid = []
-
- def startExistingRaid(self):
- for (raidDevice, mntPoint, fileSystem, deviceList) in self.existingRaid:
- isys.raidstart(raidDevice, deviceList[0])
-
- def stopExistingRaid(self):
- for (raidDevice, mntPoint, fileSystem, deviceList) in self.existingRaid:
- isys.raidstop(raidDevice)
-
- def addExistingRaidDevice(self, raidDevice, mntPoint, fsystem, deviceList):
- self.existingRaid.append(raidDevice, mntPoint, fsystem, deviceList)
-
- def existingRaidList(self):
- return self.existingRaid
-
- def raidList(self):
- (devices, raid) = self.ddruid.partitionList()
+ device = self.swap
- if raid == None:
- raid = []
+ file = '/tmp/swap/' + device
+ isys.makeDevInode(device, file)
- for (mountPoint, raidDevice, fileSystem, raidLevel, deviceList) in \
- self.supplementalRaid:
- raid.append(mountPoint, raidDevice, fileSystem, raidLevel,
- 0, 0, deviceList)
+ w = waitWindow(_("Formatting"),
+ _("Formatting swap space..."))
- return (devices, raid)
+ rc = iutil.execWithRedirect ("/usr/sbin/mkswap",
+ [ "mkswap", '-v1', file ],
+ stdout = None, stderr = None,
+ searchPath = 1)
+ w.pop()
- def createRaidTab(self, file, devPrefix, createDevices = 0):
- (devices, raid) = self.raidList()
-
- if not raid: return
-
- deviceDict = {}
- for (device, name, type, start, size, maxcyl, preexist) in devices:
- deviceDict[name] = device
-
- rt = open(file, "w")
- for (mntpoint, device, fstype, raidType, start, size, makeup) in raid:
-
- if createDevices:
- isys.makeDevInode(device, devPrefix + '/' + device)
-
- rt.write("raiddev %s/%s\n" % (devPrefix, device,))
- rt.write("raid-level %d\n" % (raidType,))
- rt.write("nr-raid-disks %d\n" % (len(makeup),))
- rt.write("chunk-size 64k\n")
- rt.write("persistent-superblock 1\n");
- rt.write("#nr-spare-disks 0\n")
- i = 0
- for subDevName in makeup:
- if createDevices:
- isys.makeDevInode(deviceDict[subDevName], '%s/%s' %
- (devPrefix, deviceDict[subDevName]))
- rt.write(" device %s/%s\n" %
- (devPrefix, deviceDict[subDevName],))
- rt.write(" raid-disk %d\n" % (i,))
- i = i + 1
-
- rt.write("\n")
- rt.close()
+ if rc:
+ self.messageWindow(_("Error"), _("Error creating swap on device ") + file)
+ else:
+ isys.swapon (file)
def umountFilesystems(self, instPath, ignoreErrors = 0):
- if (not self.setupFilesystems): return
-
isys.umount(instPath + '/proc', removeDir = 0)
try:
@@ -625,142 +110,25 @@ class Fstab:
mounts = self.mountList()
mounts.reverse()
- for (n, device, fsystem, doFormat, size) in mounts:
- if fsystem != "swap":
- try:
- mntPoint = instPath + n
- isys.umount(mntPoint, removeDir = 0)
- except SystemError, (errno, msg):
- if not ignoreErrors:
- self.messageWindow(_("Error"),
- _("Error unmounting %s: %s") % (device, msg))
-
- if self.rootOnLoop():
- self.loopbackMountCount = self.loopbackMountCount - 1
- if self.loopbackMountCount == 0:
- isys.makeDevInode("loop1", '/tmp/' + "loop1")
- isys.unlosetup("/tmp/loop1")
-
- self.stopExistingRaid()
-
- def readLabels(self, skipList = []):
- labels = {}
- for drive in self.driveList():
- isys.makeDevInode(drive, '/tmp/' + drive)
-
- try:
- table = _balkan.readTable ('/tmp/' + drive)
- except SystemError:
- continue
+ for (n, device, fsystem, doFormat, size) in self.mountList():
- for i in range (len (table)):
- (type, start, size) = table[i]
-
- # right now we only support label's on ext2 partitions
- if type != _balkan.EXT2: continue
-
- dev = drive + str (i + 1)
- try:
- skipList.index(dev)
- except ValueError, msg:
- (type, sector, size) = table[i]
-
- # we check the label on all filesystems because mount
- # does to!
- label = isys.readExt2Label(dev)
- if label:
- labels[dev] = label
- #print "label for", dev
- return labels
-
- def makeFilesystems(self):
- # let's make the RAID devices first -- the fstab will then proceed
- # naturally
- (devices, raid) = self.raidList()
-
- if self.serial:
- messageFile = "/tmp/mke2fs.log"
- else:
- messageFile = "/dev/tty5"
-
- if raid:
- self.createRaidTab("/tmp/raidtab", "/tmp", createDevices = 1)
-
- w = self.waitWindow(_("Creating"), _("Creating RAID devices..."))
-
- for (mntpoint, device, fsType, raidType, start, size, makeup) in raid:
- iutil.execWithRedirect ("/usr/sbin/mkraid",
- [ 'mkraid', '--really-force', '--configfile',
- '/tmp/raidtab', '/tmp/' + device ],
- stderr = messageFile, stdout = messageFile)
-
- w.pop()
-
- # XXX remove extraneous inodes here
-# print "created raid"
-
- self.startExistingRaid()
-
- if not self.setupFilesystems: return
-
- arch = iutil.getArch ()
-
- if arch == "alpha":
- bootPart = self.getBootDevice()
+ isys.umount(mntPoint, removeDir = 0)
+ def makeFilesystems(self, messageWindow, progressWindow):
labelSkipList = []
labels = {}
for (mntpoint, device, fsystem, doFormat, size) in self.mountList():
if doFormat: labelSkipList.append(device)
- for label in self.readLabels(labelSkipList).values():
- labels[label] = 1
for (mntpoint, device, fsystem, doFormat, size) in self.mountList():
if not doFormat:
continue
- # Handle these before we handle the protect list, as the vfat
- # partition itself could be in the protect list.
- if fsystem == "vfat" and mntpoint == "/":
- # do a magical loopback mount -- whee!
- isys.mount(device, "/mnt/loophost", fstype = "vfat")
-
- isys.makeDevInode("loop1", '/tmp/' + "loop1")
- isys.ddfile("/mnt/loophost/redhat.img", self.loopbackSize,
- (self.progressWindow, _("Loopback"),
- _("Creating loopback filesystem on device /dev/%s...")
- % device))
-
- if self.serial:
- messageFile = "/tmp/mke2fs.log"
- else:
- messageFile = "/dev/tty5"
-
- ext2FormatFilesystem([ "/usr/sbin/mke2fs", "-F",
- "/mnt/loophost/redhat.img"],
- messageFile, self.progressWindow,
- mntpoint)
- continue
-
- if self.protectList:
- founddev = 0
- for i in self.protectList:
- if i == device:
- founddev = 1
- break;
- if founddev != 0:
- # Next
- continue
-
isys.makeDevInode(device, '/tmp/' + device)
if fsystem == "ext2":
label = createLabel(labels, mntpoint)
args = [ "/usr/sbin/mke2fs", '/tmp/' + device, '-L', label ]
- # FORCE the partition that MILO has to read
- # to have 1024 block size. It's the only
- # thing that our milo seems to read.
- if arch == "alpha" and device == bootPart:
- args = args + ["-b", "1024", '-r', '0', '-O', 'none']
+
# set up raid options for md devices.
if device[:2] == 'md':
for (rmnt, rdevice, fsType, raidType, start, size, makeup) in raid:
@@ -776,71 +144,27 @@ class Fstab:
if self.badBlockCheck:
args.append ("-c")
- fsopts = self.getfsOptions(mntpoint)
- if fsopts:
- args.extend(fsopts)
-
- rc = ext2FormatFilesystem(args, messageFile,
- self.progressWindow, mntpoint)
+ rc = ext2FormatFilesystem(args, "/dev/tty5",
+ progressWindow, mntpoint)
if rc:
- self.messageWindow(_("Error"),
+ messageWindow(_("Error"),
_("An error occured trying to format %s. This problem "
"is serious, and the install cannot continue.\n\n"
"Press Enter to reboot your system.") % mntpoint)
- sys.exit(0)
+ raise SystemError
- elif fsystem == "vfat" and mntpoint == "/boot/efi":
- args = [ "mkdosfs", '/tmp/' + device ]
-
- w = self.waitWindow(_("Formatting"),
- _("Formatting %s filesystem...") % (mntpoint,))
-
- iutil.execWithRedirect ("/usr/sbin/mkdosfs",
- args, stdout = messageFile,
- stderr = messageFile, searchPath = 1)
- w.pop()
else:
pass
- self.stopExistingRaid()
-
- def hasDirtyFilesystems(self):
- if (not self.setupFilesystems): return
-
- if self.rootOnLoop():
- (rootDev, rootFs) = self.getRootDevice()
- mountLoopbackRoot(rootDev, skipMount = 1)
- dirty = isys.ext2IsDirty("loop1")
- unmountLoopbackRoot(skipMount = 1)
- if dirty: return 1
-
- for (mntpoint, device, fsystem, doFormat, size) in self.mountList():
- if fsystem != "ext2": continue
- if doFormat: continue
-
- if isys.ext2IsDirty(device): return 1
-
- return 0
+ def mountList(self):
+ return [("/", self.root, "ext2", 1, 0),
+ ("/boot", self.boot, "ext2", 1, 0),
+ ("swap", self.swap, "swap", 1, 0)]
def mountFilesystems(self, instPath, raiseErrors = 0, readOnly = 0):
- if (not self.setupFilesystems): return
-
- self.startExistingRaid()
-
for (mntpoint, device, fsystem, doFormat, size) in self.mountList():
if fsystem == "swap":
continue
- elif fsystem == "vfat" and mntpoint == "/":
- self.loopbackMountCount = self.loopbackMountCount + 1
- if self.loopbackMountCount == 1:
- isys.mount(device, "/mnt/loophost", fstype = "vfat",
- readOnly = readOnly)
-
- isys.makeDevInode("loop1", '/tmp/' + "loop1")
-
- isys.losetup("/tmp/loop1", "/mnt/loophost/redhat.img",
- readOnly = readOnly)
- isys.mount("loop1", instPath, readOnly = readOnly)
elif fsystem == "ext2" or fsystem == "ext3" or \
(fsystem == "vfat" and mntpoint == "/boot/efi"):
try:
@@ -868,7 +192,7 @@ class Fstab:
format = fstabFormatString
f = open (prefix + "/etc/fstab", "w")
- labels = self.readLabels()
+ labels = {}
for (mntpoint, dev, fs, reformat, size) in self.mountList():
if mntpoint[:10] == 'DONT ERASE':
continue
@@ -898,168 +222,17 @@ class Fstab:
f.write (format % ("none", "/dev/pts", 'devpts', 'gid=5,mode=620',
0, 0))
- for (partition, relative, size) in self.swapList(devices = 1, files = 1):
- if not relative:
- # if it's not relative, it's in /mnt/loophost/, and needs
- # to be in /initrd/loopfs instead
- partition = "/initrd/loopfs/" + partition[14:]
- else:
- partition = "/dev/" + partition
- f.write (format % (partition, 'swap', 'swap',
- 'defaults', 0, 0))
-
f.close ()
# touch mtab
open (prefix + "/etc/mtab", "w+")
f.close ()
- self.createRaidTab(prefix + "/etc/raidtab", "/dev")
+ def __init__(self):
- def clearMounts(self):
- self.extraFilesystems = []
-
- # gross, but the "mount" parameter doubles as the size of swap partitions
- # that need to be created
- def addMount(self, partition, mount, fsystem, doFormat = 0, size = 0):
- partition = os.path.normpath(partition)
-
- self.extraFilesystems.append(mount, partition, fsystem, doFormat,
- size)
-# XXX code from sparc merge
-# if fsystem == "swap":
-# ufs = 0
-# try:
-# isys.makeDevInode(device, '/tmp/' + device)
-# except:
-# pass
-# try:
-# ufs = isys.checkUFS ('/tmp/' + device)
-# except:
-# pass
-# if not ufs:
-# location = "swap"
-# reformat = 1
-# self.mounts[location] = (device, fsystem, reformat)
-
-
- def mountList(self, skipExtra = 0):
- def sortMounts(one, two):
- mountOne = one[0]
- mountTwo = two[0]
- if (mountOne < mountTwo):
- return -1
- elif (mountOne == mountTwo):
- return 0
- return 1
-
- fstab = []
- for (partition, mount, fsystem, size) in self.ddruid.getFstab():
-
- if fsystem == "swap":
- continue
-
- if not self.fsCache.has_key((partition, mount)):
- if mount == '/home' and isValidExt2(partition):
- self.fsCache[(partition, mount)] = (0, )
- else:
- self.fsCache[(partition, mount)] = (1, )
- (doFormat,) = self.fsCache[(partition, mount)]
- fstab.append((mount, partition, fsystem, doFormat, size ))
-
- for (raidDevice, mntPoint, fsType, deviceList) in self.existingRaid:
- if fsType == "swap": continue
-
- fstab.append((mntPoint, raidDevice, fsType, 0, 0 ))
-
- # Add raid mounts to mount list
- (devices, raid) = self.raidList()
- for (mntpoint, device, fsType, raidType, start, size, makeup) in raid:
- if fsType == "swap": continue
-
- if not self.fsCache.has_key((device, mntpoint)):
- self.fsCache[(device, mntpoint)] = (1, )
- (doFormat,) = self.fsCache[(device, mntpoint)]
- fstab.append((mntpoint, device, fsType, doFormat, size ))
-
- if not skipExtra:
- for n in self.extraFilesystems:
- (mntpoint, sevice, fsType, doFormat, size) = n
-
- # skip swap
- if fsType == "swap":
- continue
-
- # skip duplicate entries (happens when ks used with --onpart)
- foundit = 0
- for p in fstab:
- (mntpoint2, device2, fsType2, doFormat2, size2) = p
- if mntpoint2 == mntpoint:
- foundit = 1
- break
-
- if not foundit:
- fstab.append(n)
-
- fstab.sort(sortMounts)
-
- return fstab
-
- def setBadBlockCheck(self, state):
- self.badBlockCheck = state
-
- def getBadBlockCheck(self):
- return self.badBlockCheck
-
- def createDruid(self, fstab = [], ignoreBadDrives = 0):
- tlist = self.driveList()
- list = []
- if self.ignoreRemovable:
- for dev in tlist:
- if isys.driveIsRemovable(dev):
- log("Not in expert mode, ignoring removable device %s", dev)
- continue
- list.append(dev)
- else:
- list = tlist
-
- return self.fsedit(0, list, fstab, self.zeroMbr,
- self.readOnly,
- (self.upgrade or ignoreBadDrives),
- self.expert, self.edd)
-
- def getRunDruid(self):
- return self.shouldRunDruid
-
- def setRunDruid(self, state):
- self.shouldRunDruid = state
-
- def __init__(self, fsedit, fserror, setupFilesystems, serial, zeroMbr,
- readOnly, waitWindow, messageWindow, progressWindow,
- ignoreRemovable, protected, expert, upgrade):
-
- self.fsedit = fsedit
- self.fserror = fserror
self.fsCache = {}
- self.clearfsOptions()
- self.protectList = protected
self.swapOn = 0
self.supplementalRaid = []
- self.setupFilesystems = setupFilesystems
- self.serial = serial
- self.zeroMbr = zeroMbr
- self.readOnly = readOnly
- self.waitWindow = waitWindow
- self.messageWindow = messageWindow
- self.progressWindow = progressWindow
self.badBlockCheck = 0
- self.ignoreRemovable = ignoreRemovable
- self.expert = expert
- self.upgrade = upgrade
- if iutil.getArch() == "i386":
- import edd
- self.edd = edd.detect()
- else:
- self.edd = 0
#
# extraFilesystems used for upgrades when /etc/fstab is read as
@@ -1068,76 +241,26 @@ class Fstab:
#
self.extraFilesystems = []
self.existingRaid = []
- self.ddruid = self.createDruid()
self.loopbackSize = 0
self.loopbackMountCount = 0
# I intentionally don't initialize this, as all install paths should
# initialize this automatically
#self.shouldRunDruid = 0
-class GuiFstab(Fstab):
- def accel (self, widget, area):
- self.accelgroup = self.GtkAccelGroup (_obj = widget.get_data ("accelgroup"))
- self.toplevel = widget.get_toplevel()
- self.toplevel.add_accel_group (self.accelgroup)
-
- def runDruid(self, callback):
- self.ddruid.setCallback (callback)
- bin = self.GtkFrame (None, _obj = self.ddruid.getWindow ())
- bin.connect ("draw", self.accel)
- bin.set_shadow_type (self.SHADOW_NONE)
- self.ddruid.edit ()
- return bin
-
- def runDruidFinished(self):
- if self.accelgroup:
- self.toplevel.remove_accel_group (self.accelgroup)
- self.ddruid.next ()
- self.updateFsCache()
- # yikes! this needs to be smarter
-
- def __init__(self, setupFilesystems, serial, zeroMbr, readOnly, waitWindow,
- messageWindow, progressWindow, ignoreRemovable,
- protected, expert, upgrade, requireBlockDevices = 1):
- from gnomepyfsedit import fsedit
- from gnomepyfsedit import fserror
- from gtk import *
-
- try:
- Fstab.__init__(self, fsedit, fserror, setupFilesystems, serial,
- zeroMbr, readOnly, waitWindow, messageWindow,
- progressWindow, ignoreRemovable, protected,
- expert, upgrade)
- except SystemError:
- if requireBlockDevices:
- print "no valid block devices found"
- sys.exit(0)
- raise SystemError, text
-
- self.GtkFrame = GtkFrame
- self.GtkAccelGroup = GtkAccelGroup
- self.SHADOW_NONE = SHADOW_NONE
- self.accelgroup = None
-
-class NewtFstab(Fstab):
-
- def __init__(self, setupFilesystems, serial, zeroMbr, readOnly,
- waitWindow, messageWindow, progressWindow,
- ignoreRemovable, protected, expert, upgrade,
- requireBlockDevices = 1):
- from newtpyfsedit import fsedit
- from newtpyfsedit import fserror
-
- try:
- Fstab.__init__(self, fsedit, fserror, setupFilesystems, serial,
- zeroMbr, readOnly, waitWindow, messageWindow,
- progressWindow, ignoreRemovable, protected, expert,
- upgrade)
- except SystemError, text:
- if requireBlockDevices:
- print "no valid block devices found"
- sys.exit(0)
- raise SystemError, text
+ devices = kudzu.probe(kudzu.CLASS_HD, 0, 0)
+ list = []
+ for dev in devices:
+ if dev.device:
+ list.append(dev.device)
+
+ list.sort()
+ drive = list[0]
+
+ self.drive = drive
+ self.root = drive + "1"
+ self.boot = drive + "2"
+ self.swap = drive + "3"
+
def readFstab (path, fstab):
loopIndex = {}
@@ -1181,7 +304,7 @@ def readFstab (path, fstab):
# all valid fstab entries have 6 fields
if len (fields) < 4 or len (fields) > 6: continue
- if fields[2] != "ext2" and fields[2] != "ext3" and fields[2] != "swap" and fields[2] != "vfat":
+ if fields[2] != "ext2" and fields[2] != "ext3" and fields[2] != "swap":
continue
if string.find(fields[3], "noauto") != -1: continue
diff --git a/gettzlist b/gettzlist
deleted file mode 100755
index e028dcccd..000000000
--- a/gettzlist
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd /usr/share/zoneinfo; find . -type f -or -type l |
- grep '^./[A-Z]' | sort | sed 's/^..//'
diff --git a/gui.py b/gui.py
index 0a3369444..85b293f3e 100755
--- a/gui.py
+++ b/gui.py
@@ -10,95 +10,121 @@ from _gtk import gtk_rc_init
from _gtk import gtk_rc_reparse_all
from _gtk import _gtk_nuke_rc_files
from _gtk import _gtk_nuke_rc_mtimes
+import GDK
import GdkImlib
-from GDK import *
+
import time
-import glob
+import iutil
+from language import expandLangs
from log import log
StayOnScreen = "stayOnScreen"
-im = None
-splashwindow = None
-
-#print "Inside gui.py"
-#print x.res
-#time.sleep (5)
-width = screen_width()
-
-#--If the xserver is running at 800x600 res or higher, use the 800x600 splash screen.
-if width >= 800:
- try:
- im = GdkImlib.Image ("/usr/share/anaconda/pixmaps/first.png")
- except:
- try:
- im = GdkImlib.Image ("pixmaps/first.png")
- except:
- print "Unable to load", file
-#--Otherwise, use the old 640x480 one
+stepToClass = {
+ "language" : ( "language_gui", "LanguageWindow" ),
+ "keyboard" : ( "keyboard_gui", "KeyboardWindow" ),
+ "mouse" : ( "mouse_gui", "MouseWindow" ),
+ "welcome" : ("welcome_gui", "WelcomeWindow" ),
+ "installtype" : ( "installpath_gui", "InstallPathWindow" ),
+ "partitionmethod" : ( "partmethod_gui", "PartitionMethodWindow" ),
+ "partition" : ( "partition_gui", "PartitionWindow" ),
+ "custom-upgrade" : ( "examine_gui", "UpgradeExamineWindow" ),
+ "addswap" : ( "upgrade_swap_gui", "UpgradeSwapWindow" ),
+ "fdisk" : ( "fdisk_gui", "FDiskWindow" ),
+ "format" : ( "format_gui", "FormatWindow" ),
+ "bootloader": ("lilo_gui", "LiloWindow" ),
+ "network" : ( "network_gui", "NetworkWindow" ),
+ "firewall" : ( "firewall_gui", "FirewallWindow" ),
+ "languagesupport" : ( "language_support_gui", "LanguageSupportWindow" ),
+ "timezone" : ( "timezone_gui", "TimezoneWindow" ),
+ "accounts" : ( "account_gui", "AccountWindow" ),
+ "authentication" : ( "auth_gui", "AuthWindow" ),
+ "package-selection" : ( "package_gui", "PackageSelectionWindow" ),
+ "indivpackage" : ( "package_gui", "IndividualPackageSelectionWindow" ),
+ "dependencies" : ( "dependencies_gui", "UnresolvedDependenciesWindow" ),
+ "videocard" : ( "xconfig_gui", "XConfigWindow" ),
+ "monitor" : ( "xconfig_gui", "MonitorWindow" ),
+ "xcustom" : ( "xconfig_gui", "XCustomWindow" ),
+ "confirminstall" : ( "confirm_gui", "InstallConfirmWindow" ),
+ "confirmupgrade" : ( "confirm_gui", "UpgradeConfirmWindow" ),
+ "finishxconfig" : None,
+ "install" : ( "progress_gui", "InstallProgressWindow" ),
+ "bootdisk" : ( "bootdisk_gui", "BootdiskWindow" ),
+ "complete" : ( "congrats_gui", "CongratulationWindow" )
+}
+
+if iutil.getArch() == 'sparc':
+ stepToClass["bootloader"] = ( "silo_gui", "SiloWindow" )
else:
-# print "In lowres mode..."
- try:
- im = GdkImlib.Image ("/usr/share/anaconda/pixmaps/first-lowres.png")
- except:
- try:
- im = GdkImlib.Image ("pixmaps/first-lowres.png")
- except:
- print "Unable to load", file
-
-if im:
- threads_enter ()
- im.render ()
- splashwindow = GtkWindow ()
- splashwindow.set_position (WIN_POS_CENTER)
- box = GtkEventBox ()
- pix = im.make_pixmap ()
- style = box.get_style ().copy ()
- style.bg[STATE_NORMAL] = style.white
- box.set_style (style)
- box.add (pix)
- splashwindow.add (box)
- splashwindow.show_all ()
- gdk_flush ()
- while events_pending ():
- mainiteration (FALSE)
- threads_leave ()
-
-root = _root_window ()
-
+ stepToClass["bootloader"] = ( "lilo_gui", "LiloWindow" )
-cursor = cursor_new (LEFT_PTR)
-root.set_cursor (cursor)
-
from translate import cat, _
from gnome.ui import *
from gnome.xmhtml import *
-from language_gui import *
-#from language_support_gui import *
-from welcome_gui import *
-from mouse_gui import *
-from keyboard_gui import *
-from installpath_gui import *
+import string
import isys
import sys
import rpm
-from threading import *
-def processEvents():
- thread = currentThread ()
- if thread.getName () == "gtk_main":
- gdk_flush()
+# setup globals
+root = _root_window ()
+cursor = cursor_new (GDK.LEFT_PTR)
+root.set_cursor (cursor)
+
+splashwindow = None
+
+def display_splash_screen():
+
+ def load_image(file):
+ try:
+ im = GdkImlib.Image("/usr/share/anaconda/pixmaps/" + file)
+ except:
+ try:
+ im = GdkImlib.Image("pixmaps/" + file)
+ except:
+ print "Unable to load", file
+
+ return im
+
+ global splashwindow
+
+ width = screen_width()
+ im = None
+
+ # If the xserver is running at 800x600 res or higher, use the
+ # 800x600 splash screen.
+ if width >= 800:
+ im = load_image('first.png')
+ else:
+ im = load_image('first-lowres.png')
+
+ if im:
+ im.render ()
+ splashwindow = GtkWindow ()
+ splashwindow.set_position (WIN_POS_CENTER)
+ box = GtkEventBox ()
+ pix = im.make_pixmap ()
+ style = box.get_style ().copy ()
+ style.bg[STATE_NORMAL] = style.white
+ box.set_style (style)
+ box.add (pix)
+ splashwindow.add (box)
+ box.show_all()
+ splashwindow.show_now()
+ gdk_flush ()
while events_pending ():
mainiteration (FALSE)
- else:
- gdk_flush()
+
+def processEvents():
+ gdk_flush()
+ while events_pending ():
+ mainiteration (FALSE)
class WaitWindow:
def __init__(self, title, text):
- threads_enter ()
self.window = GtkWindow (WINDOW_POPUP)
self.window.set_title (_(title))
self.window.set_position (WIN_POS_CENTER)
@@ -115,16 +141,12 @@ class WaitWindow:
self.window.add (frame)
self.window.show_all ()
processEvents ()
- threads_leave ()
def pop(self):
- threads_enter ()
self.window.destroy ()
- threads_leave ()
class ProgressWindow:
def __init__(self, title, text, total):
- threads_enter ()
self.window = GtkWindow (WINDOW_POPUP)
self.window.set_title (_(title))
self.window.set_position (WIN_POS_CENTER)
@@ -147,18 +169,13 @@ class ProgressWindow:
self.window.add (frame)
self.window.show_all ()
processEvents ()
- threads_leave ()
def set (self, amount):
- threads_enter ()
self.progress.update (float (amount) / self.total)
processEvents ()
- threads_leave ()
def pop(self):
- threads_enter ()
self.window.destroy ()
- threads_leave ()
class ExceptionWindow:
def __init__ (self, text):
@@ -176,6 +193,8 @@ class ExceptionWindow:
hbox = GtkHBox (FALSE)
# XXX fix me, use util function when we upgrade pygnome
# s = unconditional_pixmap_file ("gnome-error.png")
+ # use this for now
+ s = None
if s:
hbox.pack_start (GnomePixmap ('/usr/share/pixmaps/gnome-warning.png'),
FALSE)
@@ -195,21 +214,10 @@ class ExceptionWindow:
win.set_position (WIN_POS_CENTER)
win.show_all ()
self.window = win
-
- thread = currentThread ()
- if thread.getName () == "gtk_main":
- self.mutex = None
- self.rc = self.window.run ()
- threads_leave()
- else:
- threads_leave ()
- self.mutex = Event ()
- self.mutex.wait ()
+ self.rc = self.window.run ()
def quit (self, dialog, button):
self.rc = button
- if self.mutex:
- self.mutex.set ()
def getrc (self):
# I did it this way for future expantion
@@ -233,27 +241,18 @@ class MessageWindow:
def quit (self, dialog, button=None):
if button != None:
self.rc = button
- if self.mutex:
- self.mutex.set ()
- self.mutex = None
def okcancelquit (self, button):
self.rc = button
- if self.mutex:
- self.mutex.set ()
def questionquit (self, button):
self.rc = button
-
- if self.mutex:
- self.mutex.set ()
def getrc (self):
return self.rc
def __init__ (self, title, text, type = "ok"):
self.rc = None
- threads_enter ()
if type == "ok":
self.window = GnomeOkDialog (_(text))
self.window.connect ("clicked", self.quit)
@@ -271,29 +270,8 @@ class MessageWindow:
win = self.window.get_window()
win.keyboard_grab(0)
self.window.show_all ()
-
- threads_leave ()
-
- # there are two cases to cover here in order to be
- # modal:
- # 1) the MessageWindow is being created by the gtk_main
- # thread, in which case we must call the mainloop recursively.
- # 2) the MessageWindow is created by some other thread, in
- # which case we must _not_ call the mainloop (currently,
- # you can not call the mainloop from a second thread).
- # Instead, create an Event mutex and wait for it to get set.
- # by the clicked signal handler
- thread = currentThread ()
- if thread.getName () == "gtk_main":
- self.mutex = None
- threads_enter ()
- self.rc = self.window.run ()
- win.keyboard_ungrab()
- threads_leave ()
- else:
- self.mutex = Event ()
- self.mutex.wait ()
- win.keyboard_ungrab()
+ self.rc = self.window.run ()
+ win.keyboard_ungrab()
class InstallInterface:
def __init__ (self, runres, nofbmode):
@@ -337,73 +315,52 @@ class InstallInterface:
rc = window.getrc()
return rc
- def getBootdisk ():
+ def getBootdisk (self):
return None
- def getCongratulation ():
+ def getCongratulation (self):
return CongratulationWindow
- def run (self, todo, test = 0):
- # This is the same as the file
- if todo.reconfigOnly:
- if not todo.serial:
- commonSteps = [ ( ReconfigWelcomeWindow, "reconfig"),
- ( KeyboardWindow, "keyboard" ),
- ]
-
- commonSteps = commonSteps + [
- ( NetworkWindow, "network" ),
- ( FirewallWindow, "firewall" ),
- ( LanguageSupportWindow, "languagesupport" ),
- ( TimezoneWindow, "timezone" ),
- ( AccountWindow, "accounts" ),
- ( AuthWindow, "authentication" ),
- ( ReconfigCongratulationWindow, "complete" )
- ]
-
- else:
- if todo.serial:
- commonSteps = [ ( LanguageWindow, "language" ),
- ( WelcomeWindow, "welcome" ),
- ( InstallPathWindow, "installtype" ),
- ]
- else:
- commonSteps = [ ( LanguageWindow, "language" ),
- ( KeyboardWindow, "keyboard" ),
- ( MouseWindow, "mouse" ),
- ( WelcomeWindow, "welcome" ),
- ( InstallPathWindow, "installtype" ),
- ]
-
+ def run(self, id, dispatch):
from xkb import XKB
kb = XKB()
- if todo.installSystem:
- try:
- kb.setMouseKeys (1)
- except SystemError:
- pass
- if todo.instClass.keyboard:
- info = todo.keyboard.getXKB()
- if info:
- (rules, model, layout, variant, options) = info
- kb.setRule (model, layout, variant, "complete")
- self.icw = InstallControlWindow (self, commonSteps, todo)
- self.icw.run ()
+
+ self.dispatch = dispatch
+
+ # XXX
+ #if todo.installSystem:
+ #try:
+ #kb.setMouseKeys (1)
+ #except SystemError:
+ #pass
+ #if todo.instClass.keyboard:
+ #info = todo.keyboard.getXKB()
+ #if info:
+ #(rules, model, layout, variant, options) = info
+ #kb.setRule (model, layout, variant, "complete")
+
+ id.fsset.registerMessageWindow(self.messageWindow)
+ id.fsset.registerProgressWindow(self.progressWindow)
+
+ lang = id.instLanguage.getCurrent()
+ lang = id.instLanguage.getLangNick(lang)
+ self.icw = InstallControlWindow (self, self.dispatch, lang)
+ self.icw.run (self.runres)
class InstallControlWindow:
def getLanguage (self):
return self.lang
- def setLanguage (self, lang):
- self.todo.instTimeLanguage.setRuntimeLanguage(lang)
-
+ def setLanguage (self, locale):
gtk_set_locale ()
_gtk_nuke_rc_files ()
gtk_rc_init ()
gtk_rc_reparse_all ()
+
+ self.langSearchPath = expandLangs(locale) + ['C']
found = 0
- for l in self.todo.instTimeLanguage.getCurrentLangSearchList():
+ for l in self.langSearchPath:
if os.access ("/etc/gtk/gtkrc." + l, os.R_OK):
rc_parse("/etc/gtk/gtkrc." + l)
found = 1
@@ -417,116 +374,63 @@ class InstallControlWindow:
self.reloadRcQueued = 1
- locale = self.todo.instTimeLanguage.getLangNick(lang)
- self.html.set_font_charset (locale)
-
- # get the labels
- for (button, text) in [ (self.nextButtonStock, _("Next")),
- (self.prevButtonStock, _("Back")),
- (self.releaseButton, _("Release Notes")),
- (self.showHelpButton, _("Show Help")),
- (self.hideHelpButton, _("Hide Help")),
- (self.finishButton, _("Finish")) ]:
- label = button.children ()[0].children ()[0].children()[1]
- label.set_text (text)
- button.queue_resize()
- self.helpFrame.set_label (_("Online Help"))
+# self.html.set_font_charset (locale)
+ self.updateStockButtons()
+ self.navFrame.set_label (_("Navigation"))
self.installFrame.set_label (_("Language Selection"))
self.loadReleaseNotes()
- def instantiateWindow (self, windowClass):
- ics = InstallControlState (self, self.ii, self.todo)
- self.buildingWindows = 1
- window = windowClass (ics)
- self.buildingWindows = 0
- self.windowList.append (window)
- return window
-
- def setStateList (self, list, pos):
- self.stateList = []
- self.stateTagByWindow = {}
- for x in list:
- if type(x) == type((1,)):
- (x, tag) = x
- else:
- tag = None
- instantiated = 0
- for y in self.windowList:
- if isinstance (y, x):
- self.stateList.append (y)
- self.stateTagByWindow[y] = tag
- instantiated = 1
- break
- if not instantiated:
- instance = self.instantiateWindow (x)
- self.stateList.append (instance)
- self.stateTagByWindow[instance] = tag
-
- self.stateListIndex = pos
-
def prevClicked (self, *args):
try:
- prev = self.currentScreen.getPrev ()
+ self.currentWindow.getPrev ()
except StayOnScreen:
return
- self.prevList.pop ()
- (self.currentScreen, self.stateListIndex) = self.prevList[-1]
-
- self.setScreen (self.currentScreen, self.prevClicked)
+ self.dispatch.gotoPrev()
+ self.dir = -1
+ self.setScreen ()
def nextClicked (self, *args):
try:
- next = self.currentScreen.getNext ()
+ rc = self.currentWindow.getNext ()
except StayOnScreen:
return
-
- if next:
- instantiated = 0
- for x in self.windowList:
- if isinstance (x, next):
- self.currentScreen = x
- instantiated = 1
- break
- if not instantiated:
- self.currentScreen = self.instantiateWindow (next)
- else:
- self.stateListIndex = self.stateListIndex + 1
- if self.stateListIndex < len (self.stateList):
- self.currentScreen = self.stateList[self.stateListIndex]
- else:
- mainquit ()
- self.setScreen (self.currentScreen, self.nextClicked)
- def helpClicked (self, widget, simulated = 0):
- if not simulated:
- self.helpState = (widget == self.showHelpButton)
-
- self.hbox.remove (widget)
- if widget == self.hideHelpButton:
- self.bin.remove (self.table)
- self.installFrame.reparent (self.bin)
+ self.dispatch.gotoNext()
+ self.dir = 1
- self.showHelpButton.show ()
- self.showHelpButton.set_state (STATE_NORMAL)
+ self.setScreen ()
+ if self.helpWin:
+ self.html.source (self.currentWindow.getICS().getHTML(self.langSearchPath))
+ self.navigator.source ("<HTML><BODY BGCOLOR=white></BODY></HTML>")
+ self.navigator.source ("<HTML><BODY BGCOLOR=white><H1>Flight of the Navigator</h1><br>&nbsp;<br>&nbsp;<br><p>Coming soon to an anaconda near you</BODY></HTML>")
- self.hbox.pack_start (self.showHelpButton, FALSE)
- self.hbox.reorder_child (self.showHelpButton, 0)
- self.displayHelp = FALSE
- else:
- self.bin.remove (self.installFrame)
- self.table.attach (self.installFrame, 1, 3, 0, 1)
- self.bin.add (self.table)
- # fix to set the bgcolor to white (xmhtml sucks)
- self.html.source ("<HTML><BODY BGCOLOR=white></BODY></HTML>")
- self.html.source (self.currentScreen.getICS ().getHTML ())
- self.hideHelpButton.show ()
- self.showHelpButton.set_state (STATE_NORMAL)
- self.hbox.pack_start (self.hideHelpButton, FALSE)
- self.hbox.reorder_child (self.hideHelpButton, 0)
- self.displayHelp = TRUE
+ def helpClicked (self, widget, simulated = 0):
+ self.showHelpButton.set_sensitive(FALSE)
+ self.helpWin = GnomeDialog()
+ table = GtkTable(3, 3, FALSE)
+ self.helpWin.vbox.pack_start(table)
+ self.helpWin.append_button(_("Close"))
+ self.helpWin.set_default_size(620, 430)
+ self.helpWin.set_usize(620, 430)
+ self.helpWin.set_position(WIN_POS_CENTER)
+ self.helpWin.button_connect( 0, self.closeHelp)
+ self.html = GtkXmHTML()
+ self.html.set_allow_body_colors(TRUE)
+# self.html.source ( "<HTML><BODY BGCOLOR=white>HTML Help Here</BODY></HTML>")
+ self.html.source (self.currentWindow.getICS().getHTML(self.langSearchPath))
+ self.helpWin.vbox.pack_start(self.html)
+ self.html.show()
+ self.helpWin.show()
+
+
+ def closeHelp(self, args):
+ self.helpWin.destroy()
+ self.html.destroy()
+ self.helpWin = None
+ self.showHelpButton.set_sensitive(TRUE)
def close (self, args):
self.textWin.destroy()
@@ -583,8 +487,7 @@ class InstallControlWindow:
def loadReleaseNotes(self):
self.buff = ""
- langList = self.todo.instTimeLanguage.getCurrentLangSearchList()
- langList = langList + [ "" ]
+ langList = self.langSearchPath + [ "" ]
for lang in langList:
fn = "/mnt/source/RELEASE-NOTES"
if len(lang):
@@ -596,125 +499,131 @@ class InstallControlWindow:
file.close()
return
- self.buff = "Release notes are missing.\n"
+ self.buff = _("Release notes are missing.\n")
- def setScreen (self, screen, direction):
- # if getScreen returns None, or we're supposed to skip this screen
- # entirely, we continue advancing in direction given
- if (self.stateTagByWindow.has_key(screen)
- and self.todo.instClass.skipStep(self.stateTagByWindow[screen])):
-# log("skipping step screen %s", screen)
- direction ()
- return
+ def setScreen (self):
+ (step, args) = self.dispatch.currentStep()
+ if not step:
+ mainquit()
+ return
+
+ if not stepToClass[step]:
+ if self.dir == 1:
+ return self.nextClicked()
+ else:
+ return self.prevClicked()
+
+ (file, className) = stepToClass[step]
+ s = "from %s import %s; newScreenClass = %s" % (file, className, className)
+ exec s
+
+ ics = InstallControlState (self)
+
+ self.destroyCurrentWindow()
+ self.currentWindow = newScreenClass(ics)
- new_screen = screen.getScreen ()
+ new_screen = apply(self.currentWindow.getScreen, args)
if not new_screen:
- direction ()
return
- # if we're the initial screen (because of kickstart), make sure we can't go back.
- if not self.initialScreenShown:
- self.initialScreenShown = 1
- screen.getICS ().setPrevEnabled (FALSE)
- self.prevList = []
+ self.update (ics)
- if not direction == self.prevClicked:
- self.prevList.append ((screen, self.stateListIndex))
+ self.installFrame.set_label (ics.getTitle ())
+ self.installFrame.add (new_screen)
+ self.installFrame.show_all ()
+ self.currentWindow.renderCallback()
- if self.helpState != self.displayHelp:
- if self.displayHelp:
- self.helpClicked (self.hideHelpButton, 1)
- else:
- self.helpClicked (self.showHelpButton, 1)
-
- self.update (screen.getICS ())
+ if self.reloadRcQueued:
+ self.window.reset_rc_styles ()
+ self.reloadRcQueued = 0
+ def destroyCurrentWindow(self):
children = self.installFrame.children ()
if children:
child = children[0]
self.installFrame.remove (child)
child.destroy ()
-
- self.installFrame.set_label (_(screen.getICS ().getTitle ()))
- self.installFrame.add (new_screen)
- self.installFrame.show_all ()
- if self.reloadRcQueued:
- self.window.reset_rc_styles ()
- self.reloadRcQueued = 0
+ self.currentWindow = None
def update (self, ics):
- if self.buildingWindows or ics != self.currentScreen.getICS ():
- return
-
self.installFrame.set_label (_(ics.getTitle ()))
- buttons = { "prev" : ics.getPrevButton (),
- "next" : ics.getNextButton () }
+ prevButton = self.prevButtonStock
+ nextButton = self.nextButtonStock
- for (name, button) in buttons.items ():
- if button["pixmap"] == STOCK_BUTTON_PREV and not button["label"]:
- buttons[name] = self.prevButtonStock
- elif button["pixmap"] == STOCK_BUTTON_NEXT and not button["label"]:
- buttons[name] = self.nextButtonStock
- else:
- buttons[name] = GnomePixmapButton (GnomeStock (button["pixmap"]), _(button["label"]))
- if name == "prev": buttons[name].connect ("clicked", self.prevClicked)
- elif name == "next": buttons[name].connect ("clicked", self.nextClicked)
- buttons[name].show ()
+ if ics.getNextButton():
+ (icon, text) = ics.getNextButton()
+ nextButton = GnomePixmapButton (GnomeStock (icon), text)
+ nextButton.connect ("clicked", self.nextClicked)
+ nextButton.show_all()
children = self.buttonBox.children ()
- if not buttons["prev"] in children:
+
+ if not prevButton in children:
self.buttonBox.remove (children[0])
- self.buttonBox.pack_start (buttons["prev"])
- if not buttons["next"] in children:
+ self.buttonBox.pack_start (prevButton)
+
+ if not nextButton in children:
self.buttonBox.remove (children[1])
- self.buttonBox.pack_end (buttons["next"])
+ self.buttonBox.pack_end (nextButton)
- buttons["prev"].set_sensitive (ics.getPrevEnabled ())
- buttons["next"].set_sensitive (ics.getNextEnabled ())
- self.hideHelpButton.set_sensitive (ics.getHelpButtonEnabled ())
- self.showHelpButton.set_sensitive (ics.getHelpButtonEnabled ())
+ prevButton.set_sensitive (ics.getPrevEnabled ())
+ nextButton.set_sensitive (ics.getNextEnabled ())
- if ics.getHelpEnabled () == FALSE:
- if self.displayHelp:
- self.helpClicked (self.hideHelpButton, 1)
- elif ics.getHelpEnabled () == TRUE:
- if not self.displayHelp:
- self.helpClicked (self.showHelpButton, 1)
-
- if self.displayHelp:
- self.html.source (ics.getHTML ())
-
if (ics.getGrabNext ()):
- buttons["next"].grab_focus ()
+ nextButton.grab_focus ()
+
+ def __init__ (self, ii, dispatch, locale):
+ self.stockButtons = [
+ ( STOCK_BUTTON_PREV, "prevButtonStock",
+ _("Back"), self.prevClicked ),
+ ( STOCK_BUTTON_NEXT, "nextButtonStock",
+ _("Next"), self.nextClicked ),
+ ( STOCK_BUTTON_HELP, "releaseButton",
+ _("Release Notes"), self.releaseClicked ),
+ ( STOCK_BUTTON_HELP, "showHelpButton",
+ _("Show Help"), self.helpClicked )
+ ]
- def __init__ (self, ii, steps, todo):
self.reloadRcQueued = 0
self.ii = ii
- self.todo = todo
- self.steps = steps
- self.setLanguage(todo.instTimeLanguage.getCurrent())
+ self.dispatch = dispatch
+ self.setLanguage(locale)
+ self.helpWin = None
def keyRelease (self, window, event):
- if ((event.keyval == KP_Delete or event.keyval == Delete)
- and (event.state & (CONTROL_MASK | MOD1_MASK))):
+ if ((event.keyval == GDK.KP_Delete or event.keyval == GDK.Delete)
+ and (event.state & (GDK.CONTROL_MASK | GDK.MOD1_MASK))):
mainquit ()
import os
os._exit (0)
- def setup_window (self):
- threads_enter()
+ def buildStockButtons(self):
+ for (icon, item, text, action) in self.stockButtons:
+ button = GnomePixmapButton(GnomeStock(icon), text)
+ button.connect("clicked", action)
+ button.show_all()
+ self.__dict__[item] = button
+
+ def updateStockButtons(self):
+ for (icon, item, text, action) in self.stockButtons:
+ button = self.__dict__[item]
+ label = button.children ()[0].children ()[0].children()[1]
+ label.set_text (text)
+ button.queue_resize()
+
+ def setup_window (self, runres):
self.window = GtkWindow ()
- self.window.set_events (KEY_RELEASE_MASK)
+ self.window.set_events (GDK.KEY_RELEASE_MASK)
- if self.todo.intf.runres == '640x480':
+ if runres == '640x480':
self.window.set_default_size (640, 480)
self.window.set_usize (640, 480)
else:
self.window.set_default_size (800, 600)
self.window.set_usize (800, 600)
- cursor = cursor_new (LEFT_PTR)
+ cursor = cursor_new (GDK.LEFT_PTR)
_root_window ().set_cursor (cursor)
self.window.set_border_width (10)
@@ -723,7 +632,7 @@ class InstallControlWindow:
if os.environ["DISPLAY"][:1] != ':':
# from gnome.zvt import *
# zvtwin = GtkWindow ()
- shtitle = _("Red Hat Linux Install Shell")
+# shtitle = _("Red Hat Linux Install Shell")
try:
f = open ("/tmp/netinfo", "r")
except:
@@ -735,7 +644,7 @@ class InstallControlWindow:
netinf = string.splitfields (line, '=')
if netinf[0] == "HOSTNAME":
title = _("Red Hat Linux Installer on %s") % string.strip (netinf[1])
- shtitle = _("Red Hat Linux Install Shell on %s") % string.strip (netinf[1])
+# shtitle = _("Red Hat Linux Install Shell on %s") % string.strip (netinf[1])
break
# zvtwin.set_title (shtitle)
@@ -751,42 +660,27 @@ class InstallControlWindow:
self.window.set_border_width(0)
vbox = GtkVBox (FALSE, 10)
-
- if self.todo.intf.runres != '640x480':
-
- #Create header at the top of the installer
- try:
- im = GdkImlib.Image ("/usr/share/anaconda/pixmaps/anaconda_header.png")
- if im:
- im.render ()
- pix = im.make_pixmap ()
- a = GtkAlignment ()
- a.add (pix)
- a.set (0.5, 0.5, 1.0, 1.0)
- vbox.pack_start (a, FALSE, TRUE, 0)
- except:
+ # Create header at the top of the installer
+ if runres != '640x480':
+ for dir in ["/usr/share/anaconda/pixmaps/",
+ "pixmaps/",
+ "/tmp/updates"]:
try:
- im = GdkImlib.Image ("pixmaps/anaconda_header.png")
- if im:
- im.render ()
- pix = im.make_pixmap ()
- a = GtkAlignment ()
- a.add (pix)
- a.set (0.5, 0.5, 1.0, 1.0)
- vbox.pack_start (a, FALSE, TRUE, 0)
+ im = GdkImlib.Image (dir + "anaconda_header.png")
except:
- try:
- im = GdkImlib.Image ("/tmp/updates/anaconda_header.png")
- if im:
- im.render ()
- pix = im.make_pixmap ()
- a = GtkAlignment ()
- a.add (pix)
- a.set (0.5, 0.5, 1.0, 1.0)
- vbox.pack_start (a, FALSE, TRUE, 0)
- except:
- print "Unable to load anaconda_header.png"
-
+ im = None
+ else:
+ break
+
+ if im:
+ im.render ()
+ pix = im.make_pixmap ()
+ a = GtkAlignment ()
+ a.add (pix)
+ a.set (0.5, 0.5, 1.0, 1.0)
+ vbox.pack_start (a, FALSE, TRUE, 0)
+ else:
+ print _("Unable to load anaconda_header.png")
self.loadReleaseNotes()
@@ -795,21 +689,11 @@ class InstallControlWindow:
self.buttonBox = GtkHButtonBox ()
self.buttonBox.set_layout (BUTTONBOX_END)
self.buttonBox.set_spacing (30)
- self.prevButtonStock = GnomePixmapButton (GnomeStock (STOCK_BUTTON_PREV), _("Back"))
- self.nextButtonStock = GnomePixmapButton (GnomeStock (STOCK_BUTTON_NEXT), _("Next"))
-
- self.releaseButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_HELP), _("Release Notes"))
- self.finishButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_APPLY), _("Finish"))
- self.hideHelpButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_HELP), _("Hide Help"))
- self.showHelpButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_HELP), _("Show Help"))
- self.releaseButton.connect ("clicked", self.releaseClicked)
- self.hideHelpButton.connect ("clicked", self.helpClicked)
- self.showHelpButton.connect ("clicked", self.helpClicked)
- self.prevButtonStock.connect ("clicked", self.prevClicked)
- self.nextButtonStock.connect ("clicked", self.nextClicked)
+
+ self.buildStockButtons()
group = GtkAccelGroup()
- self.nextButtonStock.add_accelerator ("clicked", group, F12, RELEASE_MASK, 0);
+ self.nextButtonStock.add_accelerator ("clicked", group, GDK.F12, GDK.RELEASE_MASK, 0);
self.window.add_accel_group (group)
self.window.connect ("key-release-event", self.keyRelease)
@@ -818,40 +702,36 @@ class InstallControlWindow:
self.hbox = GtkHBox ()
self.hbox.set_border_width(5)
- self.hbox.pack_start (self.hideHelpButton, FALSE)
+ self.hbox.pack_start (self.showHelpButton, FALSE)
self.hbox.set_spacing (25)
self.hbox.pack_start (self.releaseButton, FALSE)
self.hbox.pack_start (self.buttonBox)
vbox.pack_end (self.hbox, FALSE)
- self.html = GtkXmHTML()
- self.html.set_allow_body_colors(TRUE)
- self.html.source ("<HTML><BODY>HTML Help Window</BODY></HTML>")
- self.displayHelp = TRUE
- self.helpState = TRUE
+ self.navigator = GtkXmHTML()
+ self.navigator.set_allow_body_colors(TRUE)
+ self.navigator.source ("<HTML><BODY BGCOLOR=white></BODY></HTML>")
+ self.navigator.source ("<HTML><BODY BGCOLOR=white><H1>Flight of the Navigator</h1><br>&nbsp;<br>&nbsp;<br><p>Coming soon to an anaconda near you</BODY></HTML>")
- self.helpFrame = GtkFrame (_("Online Help"))
+ self.navFrame = GtkFrame (_("Navigation"))
self.box = GtkVBox (FALSE, 0)
self.box.set_spacing(0)
self.box.pack_start (GtkHSeparator (), FALSE)
- self.box.pack_start (self.html, TRUE)
+ self.box.pack_start (self.navigator, TRUE)
- self.helpFrame.add (self.box)
+ self.navFrame. add (self.box)
table = GtkTable (1, 3, TRUE)
- table.attach (self.helpFrame, 0, 1, 0, 1)
+ table.attach (self.navFrame, 0, 1, 0, 1)
self.installFrame = GtkFrame ()
-# self.installFrame.set_shadow_type (SHADOW_NONE)
self.windowList = []
- self.setStateList (self.steps, 0)
- self.currentScreen = self.stateList[self.stateListIndex]
- self.initialScreenShown = 0
- self.setScreen (self.currentScreen, self.nextClicked)
+ #self.setStateList (self.steps, 0)
+ self.setScreen ()
table.attach (self.installFrame, 1, 3, 0, 1)
table.set_col_spacing (0, 5)
@@ -869,28 +749,21 @@ class InstallControlWindow:
global splashwindow
if splashwindow:
splashwindow.destroy ()
- threads_leave ()
- def run (self):
- self.setup_window ()
- threads_enter ()
- thread = currentThread ()
- thread.setName ("gtk_main")
+ def run (self, runres):
+ self.setup_window (runres)
mainloop ()
- threads_leave ()
class InstallControlState:
- def __init__ (self, cw, ii, todo, title = _("Install Window"),
- prevEnabled = 1, nextEnabled = 0, html = ""):
- self.searchPath = [ "/usr/share/anaconda/", "./" ]
- self.ii = ii
+ def __init__ (self, cw):
+ self.searchPath = [ "./", "/usr/share/anaconda/", "./" ]
self.cw = cw
- self.todo = todo
- self.prevEnabled = prevEnabled
- self.nextEnabled = nextEnabled
+ self.prevEnabled = 1
+ self.nextEnabled = 0
+ self.nextButtonInfo = None
self.helpButtonEnabled = TRUE
- self.title = title
- self.html = html
+ self.title = _("Install Window")
+ self.html = ""
self.htmlFile = None
self.nextButton = STOCK_BUTTON_NEXT
self.prevButton = STOCK_BUTTON_PREV
@@ -899,9 +772,6 @@ class InstallControlState:
self.helpEnabled = 3 # Values other than TRUE or FALSE don't change the help setting
self.grabNext = 0
- def getState (self):
- return (self.title, prevEnabled, nextEnabled, prevText, nextTest)
-
def setTitle (self, title):
self.title = title
self.cw.update (self)
@@ -918,9 +788,9 @@ class InstallControlState:
return self.prevEnabled
def setNextEnabled (self, value):
- if value == self.nextEnabled: return
- self.nextEnabled = value
- self.cw.update (self)
+ if value != self.nextEnabled:
+ self.nextEnabled = value
+ self.cw.update (self)
def getNextEnabled (self):
return self.nextEnabled
@@ -951,13 +821,13 @@ class InstallControlState:
self.html = text
self.cw.update (self)
- def getHTML (self):
+ def getHTML (self, langPath):
text = None
if self.htmlFile:
file = self.htmlFile
for path in self.searchPath:
- for lang in self.todo.instTimeLanguage.getCurrentLangSearchList():
+ for lang in langPath:
try:
text = open("%s/help/%s/s1-help-screens-%s.html" %
(path, lang, file)).read ()
@@ -980,32 +850,12 @@ class InstallControlState:
return self.html
- def getToDo (self):
- return self.todo
-
- def setNextButton (self, button, label=None):
- self.nextButton = button
- self.nextButtonLabel = label
-
- def getNextButton (self):
- return { "pixmap" : self.nextButton, "label" : self.nextButtonLabel }
-
- def setPrevButton (self, button, label=None):
- self.prevButton = button
- self.prevButtonLabel = label
-
- def getPrevButton (self):
- return { "pixmap" : self.prevButton, "label" : self.prevButtonLabel }
-
def setScreenPrev (self):
self.cw.prevClicked ()
def setScreenNext (self):
self.cw.nextClicked ()
- def getInstallInterface (self):
- return self.ii
-
def setHelpEnabled (self, value):
self.helpEnabled = value
self.cw.update (self)
@@ -1022,3 +872,9 @@ class InstallControlState:
def getICW (self):
return self.cw
+
+ def setNextButton(self, icon, text):
+ self.nextButtonInfo = (icon, text)
+
+ def getNextButton(self):
+ return self.nextButtonInfo
diff --git a/harddrive.py b/harddrive.py
index 78d4433d6..71e8d9cd3 100644
--- a/harddrive.py
+++ b/harddrive.py
@@ -9,8 +9,6 @@ import rpm
import string
from translate import _, cat, N_
-import todo
-
FILENAME = 1000000
# Install from a set of files laid out on the hard drive like a CD
diff --git a/installclass.py b/installclass.py
index fe1403631..51b6c4796 100644
--- a/installclass.py
+++ b/installclass.py
@@ -14,17 +14,25 @@ import gettext_rh, os, iutil
import string
from xf86config import XF86Config
from translate import _
+from instdata import InstallData
class BaseInstallClass:
# default to not being hidden
hidden = 0
+ pixmap = None
# don't select this class by default
default = 0
- # look in mouse.py for a list of valid mouse names -- use the LONG names
- def setMouseType(self, name, device = None, emulateThreeButtons = 0):
- self.mouse = (name, device, emulateThreeButtons)
+ # don't force text mode
+ forceTextMode = 0
+
+ # by default, place this under the "install" category; it gets it's
+ # own toplevel category otherwise
+ parentClass = ( _("Install"), "install.png" )
+
+ # we can use a different install data class
+ installDataClass = InstallData
def postAction(self, rootPath, serial):
pass
@@ -97,244 +105,316 @@ class BaseInstallClass:
self.partitions.append((mntPoint, sizespec, (device, part, primOnly),typespec, fsopts))
- # only defined in kickstart for now
- # merges in fstab entries given in ks file
- # expects the todo object, currently called from todo::setClass()
- def mergeFstabEntries(self, todo):
- pass
-
def addToFstab(self, mntpoint, dev, fstype = "ext2" , reformat = 1):
self.fstab.append((mntpoint, (dev, fstype, reformat)))
- def setTimezoneInfo(self, timezone, asUtc = 0, asArc = 0):
- self.timezone = (timezone, asUtc, asArc)
+ def setSteps(self, dispatch):
+ dispatch.setStepList(
+ "language",
+ "keyboard",
+ "mouse",
+ "welcome",
+ "installtype",
+ "partition",
+ "partitiondone",
+ "bootloader",
+ "network",
+ "firewall",
+ "languagesupport",
+ "timezone",
+ "accounts",
+ "authentication",
+ "readcomps",
+ "package-selection",
+ "handleX11pkgs",
+ "checkdeps",
+ "dependencies",
+ "videocard",
+ "monitor",
+ "xcustom",
+ "confirminstall",
+ "enablefilesystems",
+ "install",
+ "installpackages",
+ "writeconfig",
+ "instbootloader",
+ "writexconfig",
+ "writeksconfig",
+ "bootdisk",
+ "complete"
+ )
+
+ if iutil.getArch() == "alpha" or iutil.getArch() == "ia64":
+ dispatch.skipStep("bootdisk")
+
+ # This is called after the hdlist is read in.
+ def setPackageSelection(self, hdlist):
+ pass
- def getTimezoneInfo(self):
- return self.timezone
+ # This is called after the comps is read in (after setPackageSelection()).
+ # It can both select groups, change the default selection for groups, and
+ # change which groups are hidden.
+ def setGroupSelection(self, comps):
+ pass
- def removeFromSkipList(self, type):
- if self.skipSteps.has_key(type):
- del self.skipSteps[type]
+ # this is a utility function designed to be called from setGroupSelection()
+ # it hides all of the groups not in the "groups" list
+ def showGroups(self, comps, groups):
+ groupSet = {}
- def addToSkipList(self, type):
- # this throws an exception if there is a problem
- [ "lilo", "mouse", "network", "firewall", "authentication", "complete", "complete",
- "package-selection", "bootdisk", "partition", "format", "timezone",
- "accounts", "dependencies", "language", "keyboard", "xconfig",
- "welcome", "custom-upgrade", "installtype", "mouse",
- "confirm-install", "confirm-upgrade", "languagesupport",
- "languagedefault", "lba32warning", "indivpackage" ].index(type)
- self.skipSteps[type] = 1
-
- def setHostname(self, hostname):
- self.hostname = hostname
-
- def getHostname(self):
- return self.hostname
-
- def setFirewall(self, enable = -1, policy = 1, trusts = [], ports = "",
- dhcp = 0, ssh = 0, telnet = 0, smtp = 0, http = 0,
- ftp = 0):
- self.firewall = (enable, policy, trusts, ports, dhcp, ssh, telnet,
- smtp, http, ftp)
-
- def getFirewall(self):
- return self.firewall
-
- def setAuthentication(self, useShadow, useMd5,
- useNIS = 0, nisDomain = "", nisBroadcast = 0,
- nisServer = "",
- useLdap = 0, useLdapauth = 0, ldapServer = "",
- ldapBasedn = "",
- useKrb5 = 0, krb5Realm = "", krb5Kdc = "",
- krb5Admin = "",
- useHesiod = 0, hesiodLhs = "", hesiodRhs = ""):
-
- self.auth = ( useShadow, useMd5,
- useNIS, nisDomain, nisBroadcast, nisServer,
- useLdap, useLdapauth, ldapServer, ldapBasedn,
- useKrb5, krb5Realm, krb5Kdc, krb5Admin,
- useHesiod, hesiodLhs, hesiodRhs)
-
- def getAuthentication(self):
- return self.auth
-
- def skipStep(self, step):
- return self.skipSteps.has_key(step)
-
- def configureX(self, server, card, monitor, hsync, vsync, noProbe, startX):
- self.x = XF86Config(mouse = None)
- if (not noProbe):
- self.x.probe()
-
- if not self.x.server:
- if (card != None):
- self.x.setVidcardByName (card)
- elif (server != None):
- self.x.setVidcardByServer (server)
- else:
- raise RuntimeError, "Could not probe video card and no fallback specified."
-
+ for group in groups:
+ if type(group) == type("a"):
+ groupSet[group] = None
+ else:
+ (group, val) = group
+ groupSet[group] = val
+
+ for comp in comps:
+ if groupSet.has_key(comp.name):
+ comp.hidden = 0
+
+ # do nothing if groupSet[comp.name] == None
+ if groupSet[comp.name] == 1:
+ comp.select()
+ elif groupSet[comp.name] == 0:
+ comp.unselect(0)
+ else:
+ comp.hidden = 1
- if not self.x.monID and monitor:
- self.x.setMonitor((monitor, (None, None)))
- elif hsync and vsync:
- self.x.setMonitor((None, (hsync, vsync)))
+ def getMakeBootdisk(self):
+ return self.makeBootdisk
- if startX:
- self.defaultRunlevel = 5
+ def setMakeBootdisk(self, state):
+ self.makeBootdisk = state
- # Groups is a list of group names -- the full list can be found in
- # ths comps file for each release
- def setGroups(self, groups):
- self.groups = groups
+ def setZeroMbr(self, state):
+ self.zeroMbr = state
- def getGroups(self):
- return self.groups
+ def setEarlySwapOn(self, state = 0):
+ self.earlySwapOn = state
- # Groups is a list of group names -- the full list can be found in
- # ths comps file for each release
- def setOptionalGroups(self, groups):
- self.showgroups = groups
+ def setDesktop(self, desktop):
+ self.desktop = desktop
- def getOptionalGroups(self):
- return self.showgroups
+ def getDesktop(self):
+ return self.desktop
- def findOptionalGroup(self, needle):
- for g in self.showgroups:
- name = g
- if type((1,)) == type(g):
- (on, name) = g
- if name == needle:
- return g
+ def setKeyboard(self, id, kb):
+ id.keyboard.set(kb)
- return None
+ # XXX
+ #xkb = todo.keyboard.getXKB ()
- # This is a list of packages -- it is combined with the group list
- def setPackages(self, packages):
- hash = {}
- for package in packages:
- hash[package] = None
- self.packages = hash.keys()
+ #if xkb:
+ #apply (todo.x.setKeyboard, xkb)
- def getPackages(self):
- return self.packages
+ ## hack - apply to instclass preset if present as well
+ #if (todo.instClass.x):
+ #apply (todo.instClass.x.setKeyboard, xkb)
- def doRootPw(self, pw, isCrypted = 0):
- self.rootPassword = pw
- self.rootPasswordCrypted = isCrypted
+ def setHostname(self, id, hostname):
+ id.network.setHostname(hostname);
- def getMakeBootdisk(self):
- return self.makeBootdisk
+ def setTimezoneInfo(self, id, timezone, asUtc = 0, asArc = 0):
+ id.timezone.setTimezoneInfo(timezone, asUtc, asArc)
- def setMakeBootdisk(self, state):
- self.makeBootdisk = state
-
- def setNetwork(self, bootproto, ip, netmask, gateway, nameserver,
- device = None):
- self.bootProto = bootproto
- self.ip = ip
- self.netmask = netmask
- self.gateway = gateway
- self.nameserver = nameserver
- self.networkDevice = device
+ def setRootPassword(self, id, pw, isCrypted = 0):
+ id.rootPassword.set(pw, isCrypted)
- def setZeroMbr(self, state):
- self.zeroMbr = state
+ def setAuthentication(self, id, useShadow, useMd5,
+ useNIS = 0, nisDomain = "", nisBroadcast = 0,
+ nisServer = "",
+ useLdap = 0, useLdapauth = 0, ldapServer = "",
+ ldapBasedn = "",
+ useKrb5 = 0, krb5Realm = "", krb5Kdc = "",
+ krb5Admin = "",
+ useHesiod = 0, hesiodLhs = "", hesiodRhs = ""):
- def getNetwork(self):
- return (self.bootProto, self.ip, self.netmask, self.gateway,
- self.nameserver, self.networkDevice)
+ id.auth.useShadow = useShadow
+ id.auth.useMD5 = useMd5
- def setEarlySwapOn(self, state = 0):
- self.earlySwapOn = state
+ id.auth.useNIS = useNIS
+ id.auth.nisDomain = nisDomain
+ id.auth.nisuseBroadcast = nisBroadcast
+ id.auth.nisServer = nisServer
- def setLanguage(self, lang):
- self.language = lang
+ id.auth.useLdap = useLdap
+ id.auth.useLdapauth = useLdapauth
+ id.auth.ldapServer = ldapServer
+ id.auth.ldapBasedn = ldapBasedn
- def setLanguageSupport(self, langlist):
- self.langsupported = langlist
+ id.auth.useKrb5 = useKrb5
+ id.auth.krb5Realm = krb5Realm
+ id.auth.krb5Kdc = krb5Kdc
+ id.auth.krb5Admin = krb5Admin
- def setLanguageDefault(self, default):
- self.langdefault = default
+ id.auth.useHesiod = useHesiod
+ id.auth.hesiodLhs = hesiodLhs
+ id.auth.hesiodRhs = hesiodRhs
- def setKeyboard(self, kb):
- self.keyboard = kb
+ def setNetwork(self, id, bootProto, ip, netmask, gateway, nameserver,
+ device = None):
+ if bootProto:
+ id.network.gateway = gateway
+ id.network.primaryNS = nameserver
+
+ devices = id.network.available ()
+ if (devices and bootProto):
+ if not device:
+ list = devices.keys ()
+ list.sort()
+ device = list[0]
+ dev = devices[device]
+ dev.set (("bootproto", bootProto))
+ dev.set (("onboot", "yes"))
+ if bootProto == "static":
+ if (ip):
+ dev.set (("ipaddr", ip))
+ if (netmask):
+ dev.set (("netmask", netmask))
+
+ def setLanguageSupport(self, id, langlist):
+ if len (langlist) == 0:
+ id.langSupport.setSupported(id.langSupport.getAllSupported())
+ else:
+ newlist = []
+ for lang in langlist:
+ newlist.append(id.langSupport.getLangNameByNick(lang))
+ id.langSupport.setSupported(newlist)
+
+ def setLanguageDefault(self, id, default):
+ id.langSupport.setDefault(id.langSupport.getLangNameByNick(default))
+
+ def setLanguage(self, id, lang):
+ instLangName = id.instLanguage.getLangNameByNick(lang)
+ id.instLanguage.setRuntimeLanguage(instLangName)
+
+ def setDesktop(self, id, desktop):
+ id.desktop.setDefaultDesktop (desktop)
+
+ def setFirewall(self, id, enable = -1, policy = 1, trusts = [], ports = "",
+ dhcp = 0, ssh = 0, telnet = 0, smtp = 0, http = 0,
+ ftp = 0):
+ id.firewall.enabled = enable
+ id.firewall.policy = policy
+ id.firewall.trustdevs = trusts
+ id.firewall.portlist = ports
+ id.firewall.dhcp = dhcp
+ id.firewall.ssh = ssh
+ id.firewall.telnet = telnet
+ id.firewall.smtp = smtp
+ id.firewall.http = http
+ id.firewall.ftp = ftp
+
+
+ def configureX(self, id, server = None, card = None, videoRam = None, monitorName = None, hsync = None, vsync = None, resolution = None, depth = None, noProbe = 0, startX = 0):
+ import videocard
+ import monitor
+
+ # XXX they could have sensitive hardware, but we need this info =\
+ videohw = videocard.VideoCardInfo()
+ if videohw:
+ id.setVideoCard(videohw)
+
+ if (not noProbe):
+ monitorhw = monitor.MonitorInfo()
+
+ if monitorhw:
+ id.setMonitor(monitorhw)
+
+ if id.videocard and not id.videocard.primaryCard().getXServer():
+ if (card != None):
+ vc = id.videocard.locateVidcardByName(card)
+ elif (server != None):
+ vc = id.videocard.locateVidcardByServer(server)
+ else:
+ raise RuntimeError, "Could not probe video card and no fallback specified"
+ id.videocard.setVidcard(vc)
+
+ if videoRam in id.videocard.possible_ram_sizes():
+ id.videocard.primaryCard().setVideoRam(videoRam)
+
+ if (id.monitor.getMonitorID() != "Unprobed monitor") and monitorName:
+ (model, eisa, vert, horiz) = id.monitor.lookupMonitor(monitorName)
+ id.monitor.setSpecs(horiz, vert, id=model, name=model)
+ elif hsync and vsync:
+ id.monitor.setSpecs(hsync, vsync)
+ else:
+ raise RuntimeError, "Could not probe monitor and no fallback specified"
- def setDesktop(self, desktop):
- self.desktop = desktop
+ if startX:
+ id.desktop.setDefaultRunLevel(5)
+ else:
+ id.desktop.setDefaultRunLevel(3)
- def getDesktop(self):
- return self.desktop
+ import xf86config
+ xcfg = xf86config.XF86Config(id.videocard, id.monitor, id.mouse)
- def __init__(self):
- self.skipSteps = {}
- self.hostname = None
- self.lilo = ("mbr", 1, "")
- self.groups = None
- self.packages = None
- self.makeBootdisk = 0
- self.timezone = None
- self.setFirewall()
- self.setAuthentication(1, 1, 0)
- self.rootPassword = None
- self.rootPasswordCrypted = 0
- self.installType = None
- self.bootProto = None
- self.ip = ""
- self.networkDevice = None
- self.netmask = ""
- self.gateway = ""
- self.nameserver = ""
- self.partitions = []
- self.clearParts = 0
- self.clearType = None
- self.clearText = None
- self.clearPartText = None
- self.zeroMbr = 0
- self.language = None
- self.langsupported = None
- self.langdefault = None
- self.keyboard = None
- self.mouse = None
- self.x = None
- self.defaultRunlevel = None
- self.postScript = None
- self.postInChroot = 0
- self.fstab = []
- self.earlySwapOn = 0
- self.desktop = ""
- self.raidList = []
- self.name = ""
- self.pixmap = ""
- self.showgroups = None
-
- if iutil.getArch () == "alpha":
- self.addToSkipList("bootdisk")
- self.addToSkipList("lilo")
- elif iutil.getArch () == "ia64":
- self.addToSkipList("bootdisk")
- self.addToSkipList("lilo")
+ available = xcfg.availableModes()
+
+ if resolution and depth:
+ if depth not in id.videocard.possible_depths():
+ raise RuntimeError, "Invalid depth specified"
+ # XXX should we fallback to our "best possible" here?
+ if resolution not in available[depth]:
+ raise RuntimeError, "Selected resolution and bitdepth not possible with video ram detected. Perhaps you need to specify video ram"
+ else:
+ if len(available) == 1:
+ depth = "8"
+ elif len(available) >= 2:
+ depth = "16"
+
+ if "1024x768" in available[depth]:
+ resolution = "1024x768"
+ elif "800x600" in available[depth]:
+ resolution = "800x600"
+ else:
+ resolution = "640x480"
+
+ xcfg.setManualModes( { depth: [ resolution ] } )
+ id.setXconfig(xcfg)
+
+
+ def setMouse(self, id, mouseType, device = None, emulThree = -1):
+ import mouse
+
+ # blindly trust what we're told
+ mouse = mouse.Mouse(skipProbe = 1)
+ mouseName = mouse.mouseToMouse()[mouseType]
+ mouse.set(mouseName, emulThree, device)
+ id.setMouse(mouse)
+
-# we need to be able to differentiate between this and custom
-class DefaultInstall(BaseInstallClass):
+ def setInstallData(self, id):
+ id.reset()
+ id.instClass = self
+
+ # Classes should call these on __init__ to set up install data
+ #id.setKeyboard()
+ #id.setLanguage()
+ #id.setNetwork()
+ #id.setFirewall()
+ #id.setLanguageSupport()
+ #id.setLanguageDefault()
+ #id.setTimezone()
+ #id.setRootPassword()
+ #id.setAuthentication()
+ #id.setHostname()
+ #id.setDesktop()
+ #id.setMouse()
+
+ # These are callbacks used to let classes configure packages
+ #id.setPackageSelection()
+ #id.setGroupSelection()
def __init__(self, expert):
- BaseInstallClass.__init__(self)
+ pass
-# reconfig machine w/o reinstall
-class ReconfigStation(BaseInstallClass):
+# we need to be able to differentiate between this and custom
+class DefaultInstall(BaseInstallClass):
def __init__(self, expert):
- BaseInstallClass.__init__(self)
- self.setHostname("localhost.localdomain")
- self.addToSkipList("lilo")
- self.addToSkipList("bootdisk")
- self.addToSkipList("partition")
- self.addToSkipList("package-selection")
- self.addToSkipList("format")
- self.addToSkipList("mouse")
- self.addToSkipList("xconfig")
+ BaseInstallClass.__init__(self, expert)
allClasses = []
allClasses_hidden = []
@@ -371,6 +451,7 @@ def availableClasses(showHidden=0):
name = None
cmd = "import %s\nif %s.__dict__.has_key('InstallClass'): obj = %s.InstallClass\n" % (mainName, mainName, mainName)
exec(cmd)
+
if obj:
if obj.__dict__.has_key('sortPriority'):
sortOrder = obj.sortPriority
diff --git a/iutil.py b/iutil.py
index c454f073b..53566ef52 100644
--- a/iutil.py
+++ b/iutil.py
@@ -1,15 +1,75 @@
-
import types, os, sys, isys, select, string, stat, signal
import os.path
-from log import *
+from log import log
memoryOverhead = 0
+floppyDevice = None
def setMemoryOverhead(amount):
global memoryOverhead
memoryOverhead = amount
+def SetFdDevice():
+ global floppyDevice
+
+ if floppyDevice:
+ return floppydevice
+
+ floppyDevice = "fd0"
+ if iutil.getArch() == "sparc":
+ try:
+ f = open(floppyDevice, "r")
+ except IOError, (errnum, msg):
+ if errno.errorcode[errnum] == 'ENXIO':
+ floppyDevice = "fd1"
+ else:
+ f.close()
+ elif iutil.getArch() == "alpha":
+ pass
+ elif iutil.getArch() == "i386" or iutil.getArch() == "ia64":
+ # Look for the first IDE floppy device
+ drives = isys.floppyDriveDict()
+ if not drives:
+ log("no IDE floppy devices found")
+ return 0
+
+ floppyDrive = drives.keys()[0]
+ # need to go through and find if there is an LS-120
+ for dev in drives.keys():
+ if re.compile(".*[Ll][Ss]-120.*").search(drives[dev]):
+ floppyDrive = dev
+
+ # No IDE floppy's -- we're fine w/ /dev/fd0
+ if not floppyDrive: return
+
+ if iutil.getArch() == "ia64":
+ floppyDevice = floppyDrive
+ log("anaconda floppy device is %s", floppyDevice)
+ return
+
+ # Look in syslog for a real fd0 (which would take precedence)
+ try:
+ f = open("/tmp/syslog", "r")
+ except IOError:
+ return
+ for line in f.readlines():
+ # chop off the loglevel (which init's syslog leaves behind)
+ line = line[3:]
+ match = "Floppy drive(s): "
+ if match == line[:len(match)]:
+ # Good enough
+ floppyDrive = "fd0"
+ break
+
+ floppyDevice = floppyDrive
+ else:
+ raise SystemError, "cannot determine floppy device for this arch"
+
+ log("anaconda floppy device is %s", floppyDevice)
+
+ return floppyDevice
+
def getArch ():
arch = os.uname ()[4]
if (len (arch) == 4 and arch[0] == 'i' and
@@ -44,10 +104,7 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
stderr = getfd(stderr)
if not os.access (root + command, os.X_OK):
- if not os.access (command, os.X_OK):
- raise RuntimeError, command + " can not be run"
- else:
- root = ""
+ raise RuntimeError, command + " can not be run"
childpid = os.fork()
if (not childpid):
@@ -104,10 +161,7 @@ def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0,
catchfd = 1, closefd = -1):
if not os.access (root + command, os.X_OK):
- if not os.access (command, os.X_OK):
- raise RuntimeError, command + " can not be run"
- else:
- root = ""
+ raise RuntimeError, command + " can not be run"
(read, write) = os.pipe()
@@ -363,3 +417,67 @@ def swapAmount():
return mem
+class InstSyslog:
+ def __init__ (self, root, log):
+ self.pid = os.fork ()
+ if not self.pid:
+ # look on PYTHONPATH first, so we use updated anaconda
+ path = None
+ if os.environ.has_key('PYTHONPATH'):
+ for f in string.split(os.environ['PYTHONPATH'], ":"):
+ if os.access (f+"/anaconda", os.X_OK):
+ path = f+"/anaconda"
+ break
+
+ if not path:
+ if os.access ("./anaconda", os.X_OK):
+ path = "./anaconda"
+ elif os.access ("/usr/bin/anaconda.real", os.X_OK):
+ path = "/usr/bin/anaconda.real"
+ else:
+ path = "/usr/bin/anaconda"
+
+ os.execv (path, ("syslogd", "--syslogd", root, log))
+
+ def __del__ (self):
+ os.kill (self.pid, 15)
+ os.wait (self.pid)
+
+# XXX this doesn't work!
+#
+# funky, but importing dispatch at the top of iutil breaks things!?!
+def makeBootdisk (intf):
+ # this is faster then waiting on mkbootdisk to fail
+
+ import dispatch
+ return dispatch.DISPATCH_NOOP
+
+ device = floppyDevice
+ file = "/tmp/floppy"
+ isys.makeDevInode(device, file)
+ try:
+ fd = os.open(file, os.O_RDONLY)
+ except:
+ import dispatch
+ return dispatch.DISPATCH_BACK
+ os.close(fd)
+
+ kernel = self.hdList['kernel']
+ kernelTag = "-%s-%s" % (kernel[rpm.RPMTAG_VERSION],
+ kernel[rpm.RPMTAG_RELEASE])
+
+ w = self.intf.waitWindow (_("Creating"), _("Creating boot disk..."))
+ rc = iutil.execWithRedirect("/sbin/mkbootdisk",
+ [ "/sbin/mkbootdisk",
+ "--noprompt",
+ "--device",
+ "/dev/" + floppyDevice,
+ kernelTag[1:] ],
+ stdout = '/dev/tty5', stderr = '/dev/tty5',
+ searchPath = 1, root = self.instPath)
+ w.pop()
+
+ if rc:
+ import dispatch
+ return dispatch.DISPATCH_BACK
+
diff --git a/kbd.py b/kbd.py
index 02e740a90..9b5831c95 100644
--- a/kbd.py
+++ b/kbd.py
@@ -296,3 +296,12 @@ class Keyboard (SimpleConfigFile):
if Keyboard.console2xsun.has_key (self.get ()):
keylayout = Keyboard.console2xsun[self.get ()]
return ("sun", self.model, keylayout, "", "")
+
+ def write(self, instPath):
+ f = open(instPath + "/etc/sysconfig/keyboard", "w")
+ f.write(str (self))
+ f.close()
+
+ def writeKS(self, f):
+ f.write("keyboard %s\n" % self.get())
+
diff --git a/kickstart.py b/kickstart.py
index b3c3c247f..6f5916c94 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -2,8 +2,8 @@ import iutil
import isys
import os
from installclass import BaseInstallClass
-from installclass import FSEDIT_CLEAR_LINUX
-from installclass import FSEDIT_CLEAR_ALL
+from partitioning import *
+from autopart import doPartitioning
import sys
import string
@@ -67,7 +67,7 @@ class KickstartBase(BaseInstallClass):
for script in self.postScripts:
script.run(rootPath, serial)
- def doRootPw(self, args):
+ def doRootPw(self, id, args):
(args, extra) = isys.getopt(args, '', [ 'iscrypted' ])
isCrypted = 0
@@ -79,10 +79,10 @@ class KickstartBase(BaseInstallClass):
if len(extra) != 1:
raise ValueError, "a single argument is expected to rootPw"
- BaseInstallClass.doRootPw(self, extra[0], isCrypted = isCrypted)
- self.addToSkipList("accounts")
+ self.setRootPassword(id, extra[0], isCrypted = isCrypted)
+ self.skipSteps.append("accounts")
- def doFirewall(self, args):
+ def doFirewall(self, id, args):
(args, extra) = isys.getopt(args, '',
[ 'dhcp', 'ssh', 'telnet', 'smtp', 'http', 'ftp',
'port=', 'high', 'medium', 'disabled', 'trust=' ])
@@ -128,12 +128,12 @@ class KickstartBase(BaseInstallClass):
else:
ports = arg
- self.setFirewall(enable, policy, trusts, ports, dhcp, ssh, telnet,
+ self.setFirewall(id, enable, policy, trusts, ports, dhcp, ssh, telnet,
smtp, http, ftp)
- def doAuthconfig(self, args):
+ def doAuthconfig(self, id, args):
(args, extra) = isys.getopt(args, '',
- [ 'useshadow',
+ [ 'useshadow', 'enableshadow',
'enablemd5',
'enablenis', 'nisdomain=', 'nisserver=',
'enableldap', 'enableldapauth', 'ldapserver=', 'ldapbasedn=',
@@ -167,7 +167,7 @@ class KickstartBase(BaseInstallClass):
(str, arg) = n
if (str == '--enablenis'):
useNis = 1
- elif (str == '--useshadow'):
+ elif (str == '--useshadow') or (str == '--enableshadow'):
useShadow = 1
elif (str == '--enablemd5'):
useMd5 = 1
@@ -200,13 +200,13 @@ class KickstartBase(BaseInstallClass):
if useNis and not nisServer: nisBroadcast = 1
- self.setAuthentication(useShadow, useMd5,
+ self.setAuthentication(id, useShadow, useMd5,
useNis, nisDomain, nisBroadcast, nisServer,
useLdap, useLdapauth, ldapServer, ldapBasedn,
useKrb5, krb5Realm, krb5Kdc, krb5Admin,
useHesiod, hesiodLhs, hesiodRhs )
- self.addToSkipList("authentication")
+ self.skipSteps.append("authentication")
def doLilo (self, args):
(args, extra) = isys.getopt(args, '',
@@ -248,7 +248,7 @@ class KickstartBase(BaseInstallClass):
if block[6:10] == "LILO":
sys.exit(0)
- def doTimezone(self, args):
+ def doTimezone(self, id, args):
(args, extra) = isys.getopt(args, '',
[ 'utc' ])
@@ -259,14 +259,16 @@ class KickstartBase(BaseInstallClass):
if str == '--utc':
isUtc = 1
- self.setTimezoneInfo(extra[0], asUtc = isUtc)
+ self.setTimezoneInfo(id, extra[0], asUtc = isUtc)
- self.addToSkipList("timezone")
+ self.skipSteps.append("timezone")
- def doXconfig(self, args):
+ def doXconfig(self, id, args):
(args, extra) = isys.getopt(args, '',
- [ 'server=', 'card=', 'monitor=', 'hsync=', 'vsync=',
+ [ 'server=', 'card=', 'videoram=',
+ 'monitor=', 'hsync=', 'vsync=',
+ 'resolution=', 'depth=',
'startxonboot', 'noprobe', 'defaultdesktop=' ])
if extra:
@@ -274,13 +276,17 @@ class KickstartBase(BaseInstallClass):
server = None
card = None
+ videoRam = None
monitor = None
hsync = None
vsync = None
+ resolution = None
+ depth = None
noProbe = 0
startX = 0
defaultdesktop = ""
+ # XXX make sure new xconfig args get documented
for n in args:
(str, arg) = n
if (str == "--noprobe"):
@@ -289,30 +295,42 @@ class KickstartBase(BaseInstallClass):
server = arg
elif (str == "--card"):
card = arg
+ elif (str == "--videoram"):
+ videoRam = arg
elif (str == "--monitor"):
monitor = arg
elif (str == "--hsync"):
hsync = arg
elif (str == "--vsync"):
vsync = arg
+ elif (str == "--resolution"):
+ resolution = arg
+ elif (str == "--depth"):
+ depth = arg
elif (str == "--startxonboot"):
startX = 1
elif (str == "--defaultdesktop"):
defaultdesktop = arg
- self.configureX(server, card, monitor, hsync, vsync, noProbe,
- startX)
- self.setDesktop(defaultdesktop)
-
- self.addToSkipList("xconfig")
+ self.configureX(id, server, card, videoRam, monitor, hsync, vsync,
+ resolution, depth, noProbe, startX)
+ self.setDesktop(id, defaultdesktop)
+
+ self.skipSteps.append("videocard")
+ self.skipSteps.append("monitor")
+ self.skipSteps.append("xcustom")
+ self.skipSteps.append("handleX11pkgs")
- def doInstall(self, args):
- self.installType = "install"
- def doUpgrade(self, args):
+ def doUpgrade(self, id, args):
+ #
+ # XXX
+ #
+ # this won't work. it needs to much with the set of install steps
+ #
self.installType = "upgrade"
- def doNetwork(self, args):
+ def doNetwork(self, id, args):
# nodns is only used by the loader
(args, extra) = isys.getopt(args, '',
[ 'bootproto=', 'ip=', 'netmask=', 'gateway=', 'nameserver=',
@@ -341,66 +359,32 @@ class KickstartBase(BaseInstallClass):
elif str == "--hostname":
hostname = arg
- self.setNetwork(bootProto, ip, netmask, gateway, nameserver, device=device)
+ self.setNetwork(id, bootProto, ip, netmask, gateway, nameserver, device=device)
if hostname != "":
self.setHostname(hostname)
- def doLang(self, args):
- self.setLanguage(args[0])
- self.addToSkipList("language")
- # XXX remove these two when langsupport is documented
- self.addToSkipList("languagesupport")
- self.addToSkipList("languagedefault")
+ def doLang(self, id, args):
+ self.setLanguage(id, args[0])
+ self.skipSteps.append("language")
- def doLangSupport (self, args):
+ def doLangSupport (self, id, args):
(args, extra) = isys.getopt(args, '', [ 'default=' ])
if args:
- self.addToSkipList("languagedefault")
- self.setLanguageDefault (args[0][1])
- self.addToSkipList("languagesupport")
- self.setLanguageSupport(extra)
+ self.setLanguageDefault (id, args[0][1])
+ self.setLanguageSupport(id, extra)
- def doKeyboard(self, args):
- self.setKeyboard(args[0])
- self.addToSkipList("keyboard")
+ # XXX make sure langsupport command gets documented
+ self.skipSteps.append("languagesupport")
+
+ def doKeyboard(self, id, args):
+ self.setKeyboard(id, args[0])
+ self.skipSteps.append("keyboard")
def doZeroMbr(self, args):
if args[0] == "yes":
self.setZeroMbr(1)
- def doMouse(self, args):
- mouseToMouse = {
- "alpsps/2" : "ALPS - GlidePoint (PS/2)",
- "ascii" : "ASCII - MieMouse (serial)",
- "asciips/2" : "ASCII - MieMouse (PS/2)",
- "atibm" : "ATI - Bus Mouse",
- "generic" : "Generic - 2 Button Mouse (serial)" ,
- "generic3" : "Generic - 3 Button Mouse (serial)" ,
- "genericps/2" : "Generic - 2 Button Mouse (PS/2)" ,
- "generic3ps/2" : "Generic - 3 Button Mouse (PS/2)" ,
- "geniusnm" : "Generic - 2 Button Mouse (PS/2)" ,
- "geniusnmps/2" : "Genius - NetMouse (PS/2)" ,
- "geniusnsps/2" : "Genius - NetScroll (PS/2)" ,
- "thinking" : "" ,
- "thinkingps/2" : "" ,
- "logitech" : "Logitech - C7 Mouse (serial, old C7 type)" ,
- "logitechcc" : "Logitech - CC Series (serial)" ,
- "logibm" : "Logitech - Bus Mouse" ,
- "logimman" : "Logitech - MouseMan/FirstMouse (serial)" ,
- "logimmanps/2" : "Logitech - MouseMan/FirstMouse (PS/2)" ,
- "logimman+" : "Logitech - MouseMan+/FirstMouse+ (serial)" ,
- "logimman+ps/2" : "Logitech - MouseMan+/FirstMouse+ (PS/2)" ,
- "microsoft" : "Microsoft - Compatible Mouse (serial)" ,
- "msnew" : "Microsoft - Rev 2.1A or higher (serial)" ,
- "msintelli" : "Microsoft - IntelliMouse (serial)" ,
- "msintellips/2" : "Microsoft - IntelliMouse (PS/2)" ,
- "msbm" : "Microsoft - Bus Mouse" ,
- "mousesystems" : "Mouse Systems - Mouse (serial)" ,
- "mmseries" : "MM - Series (serial)" ,
- "mmhittab" : "MM - HitTablet (serial)" ,
- "sun" : "Sun - Mouse"
- }
-
+ def doMouse(self, id, args):
(args, extra) = isys.getopt(args, '', [ 'device=', 'emulthree' ])
mouseType = "none"
device = None
@@ -417,17 +401,21 @@ class KickstartBase(BaseInstallClass):
mouseType = extra[0]
if mouseType != "none":
- self.setMouseType(mouseToMouse[mouseType], device, emulThree)
+ self.setMouse(id, mouseType, device, emulThree)
- self.addToSkipList("mouse")
+ self.skipSteps.append("mouse")
def doReboot(self, args):
self.addToSkipList("complete")
- def doSkipX(self, args):
- self.addToSkipList("xconfig")
+ def doSkipX(self, id, args):
+ self.skipSteps.append("videocard")
+ self.skipSteps.append("monitor")
+ self.skipSteps.append("xcustom")
+ self.skipSteps.append("handleX11pkgs")
+ self.skipSteps.append("writexconfig")
- def readKickstart(self, file):
+ def readKickstart(self, id, file):
handlers = {
"auth" : self.doAuthconfig ,
"authconfig" : self.doAuthconfig ,
@@ -438,7 +426,7 @@ class KickstartBase(BaseInstallClass):
"driverdisk" : None ,
"firewall" : self.doFirewall ,
"harddrive" : None ,
- "install" : self.doInstall ,
+ "install" : None ,
"keyboard" : self.doKeyboard ,
"lang" : self.doLang ,
"langsupport" : self.doLangSupport ,
@@ -465,8 +453,9 @@ class KickstartBase(BaseInstallClass):
where = "commands"
packages = []
groups = []
- newSection = None
+ excludedPackages = []
for n in open(file).readlines():
+ print n
args = isys.parseArgv(n)
# don't eliminate white space or comments from scripts
@@ -520,28 +509,45 @@ class KickstartBase(BaseInstallClass):
n = n[1:]
n = string.strip (n)
groups.append(n)
+ elif n[0] == '-':
+ n = n[1:]
+ n = string.strip(n)
+ excludedPackages.append(n)
else:
n = string.strip (n)
packages.append(n)
elif where == "commands":
if handlers[args[0]]:
- handlers[args[0]](args[1:])
+ handlers[args[0]](id, args[1:])
elif where == "pre" or where == "post":
script = script + n
else:
raise SyntaxError, "I'm lost in kickstart"
- self.setGroups(groups)
- self.setPackages(packages)
+ self.groupList = groups
+ self.packageList = packages
+ self.excludedList = excludedPackages
+
+ # XXX actual partitioning processing should happen after %pre
+ doPartitioning(id.diskset, id.partrequests)
+ for request in id.partrequests.requests:
+ # XXX improve sanity checking
+ if not request.fstype or (request.fstype.isMountable() and not request.mountpoint):
+ continue
+ entry = request.toEntry()
+ id.fsset.add (entry)
# test to see if they specified to clear partitions and also
# tried to --onpart on a logical partition
- if iutil.getArch() == 'i386' and self.fstab:
- clear = self.getClearParts()
- if clear == FSEDIT_CLEAR_LINUX or clear == FSEDIT_CLEAR_ALL:
- for (mntpoint, (dev, fstype, reformat)) in self.fstab:
- if int(dev[-1:]) > 4:
- raise RuntimeError, "Clearpart and --onpart on non-primary partition %s not allowed" % dev
+ #
+ # XXX
+ #
+ #if iutil.getArch() == 'i386' and self.fstab:
+ #clear = self.getClearParts()
+ #if clear == FSEDIT_CLEAR_LINUX or clear == FSEDIT_CLEAR_ALL:
+ #for (mntpoint, (dev, fstype, reformat)) in self.fstab:
+ #if int(dev[-1:]) > 4:
+ #raise RuntimeError, "Clearpart and --onpart on non-primary partition %s not allowed" % dev
if where =="pre" or where == "post":
s = Script(script, scriptInterp, scriptChroot)
@@ -550,12 +556,29 @@ class KickstartBase(BaseInstallClass):
else:
self.postScripts.append(s)
- def doClearPart(self, args):
- if args[0] == '--linux':
- clear = FSEDIT_CLEAR_LINUX
- elif args[0] == '--all':
- clear = FSEDIT_CLEAR_ALL
- self.setClearParts(clear)
+ def doClearPart(self, id, args):
+ if args[0] == '--linux':
+ linuxOnly = 1
+ elif args[0] == '--all':
+ linuxOnly = 0
+ else:
+ # XXX invalid clearpart arguments
+ return
+ drives = id.diskset.disks.keys()
+ drives.sort()
+ for drive in drives:
+ disk = id.diskset.disks[drive]
+ part = disk.next_partition()
+ while part:
+ if part.fs_type and ( (linuxOnly == 0) or (part.fs_type.isLinuxNativeFS()) ):
+ old = id.partrequests.getRequestByDeviceName(get_partition_name(part))
+ id.partrequests.removeRequest(old)
+
+ drive = part.geom.disk.dev.path[5:]
+ delete = DeleteSpec(drive, part.geom.start, part.geom.end)
+ id.partrequests.addDelete(delete)
+ part = disk.next_partition(part)
+
def defineRaid(self, args):
(args, extra) = isys.getopt(args, '', [ 'level=', 'device=' ] )
@@ -572,27 +595,27 @@ class KickstartBase(BaseInstallClass):
self.addRaidEntry(mntPoint, raidDev, level, extra)
- def definePartition(self, args):
- # we just set up the desired partitions -- magic in our base class
- # does the actual partitioning (no, you don't want to know the
- # details)
- size = 0
- grow = 0
- maxSize = -1
+ def definePartition(self, id, args):
+ # we set up partition requests (whee!)
+ size = None
+ grow = None
+ maxSize = None
device = None
onPart = None
fsopts = None
- type = 0
- partNum = 0
- primOnly = 0
- active = 0
+ type = None
+ partNum = None
+ primOnly = None
+ active = None
format = 1
+ fstype = None
+ mountpoint = None
(args, extra) = isys.getopt(args, '', [ 'size=', 'maxsize=',
'grow', 'onpart=', 'ondisk=',
'bytes-per-inode=', 'usepart=',
'onprimary=', 'active', 'type=',
- 'asprimary', 'noformat'])
+ 'fstype=', 'asprimary', 'noformat'])
for n in args:
(str, arg) = n
@@ -618,54 +641,105 @@ class KickstartBase(BaseInstallClass):
primOnly = 1
elif str == "--noformat":
format = 0
+ elif str == "--fstype":
+ fstype = arg
if len(extra) != 1:
raise ValueError, "partition command requires one anonymous argument"
- if onPart:
- if extra[0] == 'swap':
- # handle swap filesystems correctly
- self.addToFstab(extra[0], onPart, 'swap',1)
- else:
- if format == 0:
- self.addToFstab(extra[0], onPart, reformat = 0)
- else:
- self.addToFstab(extra[0], onPart, 'ext2', 1)
- else:
- self.addNewPartition(extra[0], (size, maxSize, grow), (device, partNum, primOnly), (type, active), fsopts)
+ if extra[0] == 'swap':
+ filesystem = fileSystemTypeGet('swap')
+ mountpoint = None
+ elif not fstype:
+ filesystem = fileSystemTypeGetDefault()
+ mountpoint = extra[0]
+ else:
+ filesystem = fileSystemTypeGet(fstype)
+ mountpoint = extra[0]
+
+ if not size:
+ raise ValueError, "temporarily requiring a size to be specified"
+
+ request = PartitionSpec(filesystem, size = size, mountpoint = mountpoint, format=1)
+ id.partrequests.addRequest(request)
+
+ self.skipSteps.append("partition")
+
+## if onPart:
+## if extra[0] == 'swap':
+## # handle swap filesystems correctly
+## self.addToFstab(extra[0], onPart, 'swap',1)
+## else:
+## if format == 0:
+## self.addToFstab(extra[0], onPart, reformat = 0)
+## else:
+## self.addToFstab(extra[0], onPart, 'ext2', 1)
+## else:
+## self.addNewPartition(extra[0], (size, maxSize, grow), (device, partNum, primOnly), (type, active), fsopts)
+
+ def setSteps(self, dispatch):
+ BaseInstallClass.setSteps(self, dispatch)
+
+ dispatch.skipStep("bootdisk")
+ dispatch.skipStep("welcome")
+ dispatch.skipStep("package-selection")
+ dispatch.skipStep("confirminstall")
+ dispatch.skipStep("confirmupgrade")
+ dispatch.skipStep("network")
+ dispatch.skipStep("installtype")
- def __init__(self, file, serial):
- BaseInstallClass.__init__(self)
- self.addToSkipList("bootdisk")
- self.addToSkipList("welcome")
- self.addToSkipList("package-selection")
- self.addToSkipList("confirm-install")
- self.addToSkipList("confirm-upgrade")
- self.addToSkipList("custom-upgrade")
- self.addToSkipList("network")
# skipping firewall by default, disabled by default
- self.addToSkipList("firewall")
- # skip interactive warning about placing boot partition > 1024 cyl
- self.addToSkipList("lba32warning")
-
+ dispatch.skipStep("firewall")
+
+ for n in self.skipSteps:
+ dispatch.skipStep(n)
+
+ def setInstallData(self, id):
+ BaseInstallClass.setInstallData(self, id)
+
self.setEarlySwapOn(1)
self.partitions = []
self.postScripts = []
self.preScripts = []
self.installType = "install"
- self.readKickstart(file)
+ self.readKickstart(id, self.file)
for script in self.preScripts:
script.run("/", serial)
+ # Note that this assumes setGroupSelection() is called after
+ # setPackageSelection()
+ def setPackageSelection(self, hdlist):
+ for pkg in hdlist.keys():
+ hdlist[pkg].setState((0, 0))
+
+ for n in self.packageList:
+ hdlist[n].select()
+
+ def setGroupSelection(self, comps):
+ for comp in comps:
+ comp.unselect()
+
+ comps['Base'].select()
+ for n in self.groupList:
+ comps[n].select()
+
+ for n in self.excludedList:
+ comps.packages[n].unselect()
+
+ def __init__(self, file, serial):
+ self.serial = serial
+ self.file = file
+ self.skipSteps = []
+ BaseInstallClass.__init__(self, 0)
+
def Kickstart(file, serial):
f = open(file, "r")
lines = f.readlines()
f.close()
- customClass = None
passedLines = []
while lines:
l = lines[0]
diff --git a/lilo.py b/lilo.py
index e56f56242..25197619f 100644
--- a/lilo.py
+++ b/lilo.py
@@ -147,384 +147,3 @@ class LiloConfigFile:
self.order = []
self.images = []
self.items = {}
-
-class LiloConfiguration:
-
- def allowLiloLocationConfig(self, fstab):
- bootDevice = fstab.getBootDevice()
- if bootDevice[0:2] == "md":
- self.setDevice(("raid", bootDevice))
- return None
-
- return 1
-
- def setLiloImages(self, images):
- self.liloImages = images
-
- def getLiloImages(self, fstab):
- (drives, raid) = fstab.raidList()
-
- # rearrange the fstab so it's indexed by device
- mountsByDev = {}
- for (mntpoint, device, fsystem, doFormat, size) in \
- fstab.mountList():
- mountsByDev[device] = mntpoint
-
- for (mntpoint, device, fstype, raidType, start, size, makeup) in raid:
- mountsByDev[device] = mntpoint
- drives.append(device, "", 2, 0, 0, 0, 0)
-
- for (device, mntpoint, fsystem, makeup) in fstab.existingRaidList():
- mountsByDev[device] = mntpoint
- drives.append(device, "", 2, 0, 0, 0, 0)
-
- oldImages = {}
- for dev in self.liloImages.keys():
- oldImages[dev] = self.liloImages[dev]
-
- self.liloImages = {}
- foundDos = 0
- for (dev, devName, fsType, start, size, maxcyl, preexist) in drives:
- # ext2 and raid partitions get listed if they're / -- we do
- # not allow non-mounted partitions to be booted anymore as
- # modules are so unlikely to work out as to be not worth
- # worrying about
- #
- # there is a good chance we should configure them as chain
- # loadable, but we don't
-
- # only list dos and ext2 partitions
- if fsType != 1 and fsType != 2:
- continue
-
- if (mountsByDev.has_key(dev)):
- if mountsByDev[dev] == '/':
- if oldImages.has_key(dev):
- self.liloImages[dev] = oldImages[dev]
- else:
- self.liloImages[dev] = ("linux", 2)
-
- if fsType == 1:
- if foundDos: continue
-
- foundDos = 1
- isys.makeDevInode(dev, '/tmp/' + dev)
- # this can fail for several reasons, main being
- # they created a DOS partition in disk druid, but
- # we haven't written new partition table out yet!
- # this is because we are called from init in todo.py
- # which is way too early! FIX in future
- try:
- bootable = isys.checkBoot('/tmp/' + dev)
- except:
- bootable = 0
-
- os.unlink('/tmp/' + dev)
-
- if bootable:
- if oldImages.has_key(dev):
- self.liloImages[dev] = oldImages[dev]
- else:
- self.liloImages[dev] = ("dos", fsType)
-
- # if there is no default image (self.default is None, or invalid)
- # set the default image to the liunx partition
- if self.default:
- for (label, fsType) in self.liloImages.values():
- if label == self.default: break
- if label != self.default:
- self.default = None
-
- if not self.default:
- for (label, fsType) in self.liloImages.values():
- if fsType == 2:
- self.default = label
- break
-
- return (self.liloImages, self.default)
-
- def makeInitrd (self, kernelTag, instRoot):
- initrd = "/boot/initrd%s.img" % (kernelTag, )
- if not self.initrdsMade.has_key(initrd):
- iutil.execWithRedirect("/sbin/mkinitrd",
- [ "/sbin/mkinitrd",
- "--ifneeded",
- "-f",
- initrd,
- kernelTag[1:] ],
- stdout = None, stderr = None, searchPath = 1,
- root = instRoot)
- self.initrdsMade[kernelTag] = 1
- return initrd
-
- def install(self, fstab, instRoot, hdList, upgrade, langs):
- # If self.liloDevice is None, skipping lilo doesn't work
- if not self.liloDevice: return
-
- # If the root partition is on a loopback device, lilo won't work!
- if fstab.rootOnLoop():
- return
-
- if not self.liloImages:
- (images, default) = self.getLiloImages(fstab)
- self.setLiloImages(images)
-
- # on upgrade read in the lilo config file
- lilo = LiloConfigFile ()
- perms = 0644
- if os.access (instRoot + '/etc/lilo.conf', os.R_OK):
- perms = os.stat(instRoot + '/etc/lilo.conf')[0] & 0777
- lilo.read (instRoot + '/etc/lilo.conf')
- os.rename(instRoot + '/etc/lilo.conf',
- instRoot + '/etc/lilo.conf.rpmsave')
-
- # Remove any invalid entries that are in the file; we probably
- # just removed those kernels.
- for label in lilo.listImages():
- (fsType, sl) = lilo.getImage(label)
- if fsType == "other": continue
-
- if not os.access(instRoot + sl.getPath(), os.R_OK):
- lilo.delImage(label)
-
- bootpart = fstab.getBootDevice()
- boothd = fstab.getMbrDevice()
-
- useLBA32 = 0
-
- maxcyl = fstab.getBootPartitionMaxCylFromDrive()
- if maxcyl > 1024:
- from log import log
- log("Maximum cylinder is %s, using lba32" % maxcyl)
- useLBA32 = 1
-
-
- if (self.liloDevice == "mbr"):
- liloTarget = boothd
- elif (type(self.liloDevice) == type((1,)) and
- self.liloDevice[0] == "raid"):
- liloTarget = self.liloDevice[1]
- else:
- liloTarget = bootpart
-
- lilo.addEntry("boot", '/dev/' + liloTarget, replace = 0)
- lilo.addEntry("map", "/boot/map", replace = 0)
- lilo.addEntry("install", "/boot/boot.b", replace = 0)
- lilo.addEntry("prompt", replace = 0)
- lilo.addEntry("timeout", "50", replace = 0)
- message = "/boot/message"
- for lang in langs:
- fn = "/boot/message." + lang
- if os.access(instRoot + fn, os.R_OK):
- message = fn
- break
- lilo.addEntry("message", message, replace = 0)
- # XXX edd overrides linear, lba32/linear are mutually exclusive
- #
- # test to see if one of these already in lilo.conf, use if so
- if not lilo.testEntry('lba32') and not lilo.testEntry('linear'):
- if useLBA32:
- lilo.addEntry("lba32", replace = 0)
- if lilo.testEntry("linear"):
- lilo.delEntry("linear")
- elif self.liloLinear:
- lilo.addEntry("linear", replace = 0)
-
- smpInstalled = (hdList.has_key('kernel-smp') and
- hdList['kernel-smp'].selected)
-
- kernelInstalled = (hdList.has_key('kernel') and
- hdList['kernel'].selected)
-
- enterpriseInstalled = (hdList.has_key('kernel-enterprise') and
- hdList['kernel-enterprise'].selected)
-
- # This is a bit odd, but old versions of Red Hat could install
- # SMP kernels on UP systems, but (properly) configure the UP version.
- # We don't want to undo that, but we do want folks using this install
- # to be able to override the kernel to use during installs. This rule
- # seems to nail this.
- if (upgrade and not isys.smpAvailable()):
- smpInstalled = 0
-
- rootDev = fstab.getRootDevice ()
- if rootDev:
- # strip off the filesystem; we don't need it
- rootDev = rootDev[0]
- else:
- raise RuntimeError, "Installing lilo, but there is no root device"
-
- kernelList = []
- otherList = []
-
- main = self.default
-
- for (drive, (label, liloType)) in self.liloImages.items ():
- if (drive == rootDev) and label:
- main = label
- elif label:
- otherList.append (label, "/dev/" + drive)
-
- lilo.addEntry("default", self.default)
-
- mainLabelUsed = 0
-
- if needsEnterpriseKernel() and enterpriseInstalled:
- mainLabelUsed = 1
- kernelList.append((main,
- hdList['kernel-enterprise'], "enterprise"))
-
- if smpInstalled:
- thisLabel = main
- if mainLabelUsed:
- thisLabel = thisLabel + '-smp'
- mainLabelUsed = 1
-
- kernelList.append((thisLabel, hdList['kernel-smp'], "smp"))
-
- thisLabel = main
- if mainLabelUsed:
- thisLabel = thisLabel + '-up'
-
- if kernelInstalled:
- kernelList.append((thisLabel, hdList['kernel'], ""))
-
- for (label, kernel, tag) in kernelList:
- kernelTag = "-%s-%s%s" % (kernel[rpm.RPMTAG_VERSION],
- kernel[rpm.RPMTAG_RELEASE], tag)
- kernelFile = "/boot/vmlinuz" + kernelTag
-
- try:
- lilo.delImage(label)
- except IndexError, msg:
- pass
-
- sl = LiloConfigFile(imageType = "image", path = kernelFile)
-
- initrd = self.makeInitrd (kernelTag, instRoot)
-
- sl.addEntry("label", label)
- if os.access (instRoot + initrd, os.R_OK):
- sl.addEntry("initrd", initrd)
-
- sl.addEntry("read-only")
- sl.addEntry("root", '/dev/' + rootDev)
-
- if self.liloAppend:
- sl.addEntry('append', '"%s"' % (self.liloAppend,))
-
- lilo.addImage (sl)
-
- for (label, device) in otherList:
- try:
- (fsType, sl) = lilo.getImage(label)
- lilo.delImage(label)
- except IndexError:
- sl = LiloConfigFile(imageType = "other", path = device)
- sl.addEntry("optional")
-
- sl.addEntry("label", label)
- lilo.addImage (sl)
-
- # Sanity check #1. There could be aliases in sections which conflict
- # with the new images we just created. If so, erase those aliases
- imageNames = {}
- for label in lilo.listImages():
- imageNames[label] = 1
-
- for label in lilo.listImages():
- (fsType, sl) = lilo.getImage(label)
- if sl.testEntry('alias'):
- alias = sl.getEntry('alias')
- if imageNames.has_key(alias):
- sl.delEntry('alias')
- imageNames[alias] = 1
-
- # Sanity check #2. If single-key is turned on, go through all of
- # the image names (including aliases) (we just built the list) and
- # see if single-key will still work.
- if lilo.testEntry('single-key'):
- singleKeys = {}
- turnOff = 0
- for label in imageNames.keys():
- l = label[0]
- if singleKeys.has_key(l):
- turnOff = 1
- singleKeys[l] = 1
- if turnOff:
- lilo.delEntry('single-key')
-
- lilo.write(instRoot + "/etc/lilo.conf", perms = perms)
-
- # throw away stdout, catch stderr
- str = iutil.execWithCapture(instRoot + '/sbin/lilo' ,
- [ "lilo", "-r", instRoot ],
- catchfd = 2, closefd = 1)
- return str
-
- def setDevice(self, device):
- if (type(device) == type((1,))):
- self.liloDevice = device
- elif device != "mbr" and device != "partition" and device:
- raise ValueError, "device must be raid, mbr, partition, or None"
- self.liloDevice = device
-
- def setLinear(self, linear):
- self.liloLinear = linear
-
- def setAppend(self, append):
- self.liloAppend = append
-
- def setDefault(self, default):
- for (label, fsType) in self.liloImages.values():
- if label == default:
- self.default = default
- return
- raise IndexError, "unknown lilo label %s" % (default,)
-
- def getLinear(self):
- return self.liloLinear
-
- def getDevice(self):
- return self.liloDevice
-
- def getAppend(self):
- return self.liloAppend
-
- def setDefaultAppend(self):
- cdrw = isys.ideCdRwList()
- str = ""
- for device in cdrw:
- if str: str = str + " "
- str = str + ("%s=ide-scsi" % device)
-
- self.liloAppend = str
-
- def __init__(self):
- self.liloImages = {}
- self.liloDevice = 'mbr'
- self.liloLinear = 1
- self.default = None
- self.initrdsMade = {}
- # XXX only i386 supports edd, nothing else should
- # instantiate this class
- if iutil.getArch() == "i386":
- import edd
- self.edd = edd.detect()
- else:
- self.edd = 0
-
- self.setDefaultAppend()
-
-if __name__ == "__main__":
- config = LiloConfigFile ()
- config.read ('lilo.conf')
- print config
- print "image list", config.listImages()
- config.delImage ('linux')
- print '----------------------------------'
- config = LiloConfigFile ()
- config.read ('lilo.conf')
- print config
- print '----------------------------------'
- print config.getImage('linux')
diff --git a/log.py b/log.py
index 25f9163cd..8b086aef6 100644
--- a/log.py
+++ b/log.py
@@ -1,4 +1,4 @@
-import sys, os
+import sys
class LogFile:
def __init__ (self):
@@ -7,18 +7,14 @@ class LogFile:
def close (self):
self.logFile.close ()
- def open (self, serial, reconfigOnly, test, setupFilesystems):
- if reconfigOnly:
+ def open (self, file):
+ if type(file) == type("hello"):
try:
- self.logFile = open("/var/log/reconfig.log", "w")
+ self.logFile = open(file, "w")
except:
self.logFile = sys.stderr
- elif not setupFilesystems:
- self.logFile = sys.stderr
- elif serial:
- self.logFile = open("/tmp/install.log", "w")
- elif test:
- self.logFile = open("/tmp/anaconda-debug.log", "w")
+ elif file:
+ self.logFile = file
else:
self.logFile = open("/dev/tty3", "w")
diff --git a/mouse.py b/mouse.py
index 8e4182f2c..f11ebde99 100644
--- a/mouse.py
+++ b/mouse.py
@@ -1,85 +1,95 @@
import kudzu
from simpleconfig import SimpleConfigFile
import os
+from translate import _
class Mouse (SimpleConfigFile):
mice = {
- # (gpm protocol, X protocol, emulate3)
+ # (gpm protocol, X protocol, device, emulate3, shortname)
"ALPS - GlidePoint (PS/2)" :
- ("ps/2", "GlidePointPS/2", "psaux", 1),
+ ("ps/2", "GlidePointPS/2", "psaux", 1, "alpsps/2"),
"ASCII - MieMouse (serial)" :
- ("ms3", "IntelliMouse", "ttyS", 0),
+ ("ms3", "IntelliMouse", "ttyS", 0, "ascii"),
"ASCII - MieMouse (PS/2)" :
- ("ps/2", "NetMousePS/2", "psaux", 1),
+ ("ps/2", "NetMousePS/2", "psaux", 1, "asciips/2"),
"ATI - Bus Mouse" :
- ("Busmouse", "BusMouse", "atibm", 1),
+ ("Busmouse", "BusMouse", "atibm", 1, "atibm"),
"Generic - 2 Button Mouse (serial)" :
- ("Microsoft", "Microsoft", "ttyS", 1),
+ ("Microsoft", "Microsoft", "ttyS", 1, "generic"),
"Generic - 3 Button Mouse (serial)" :
- ("Microsoft", "Microsoft", "ttyS", 0),
+ ("Microsoft", "Microsoft", "ttyS", 0, "generic3"),
"Generic - 2 Button Mouse (PS/2)" :
- ("ps/2", "PS/2", "psaux", 1),
+ ("ps/2", "PS/2", "psaux", 1, "generisps/2"),
"Generic - 3 Button Mouse (PS/2)" :
- ("ps/2", "PS/2", "psaux", 0),
+ ("ps/2", "PS/2", "psaux", 0, "generic3ps/2"),
"Generic - 2 Button Mouse (USB)" :
- ("imps2", "IMPS/2", "input/mice", 1),
+ ("imps2", "IMPS/2", "input/mice", 1, "genericusb"),
"Generic - 3 Button Mouse (USB)" :
- ("imps2", "IMPS/2", "input/mice", 0),
+ ("imps2", "IMPS/2", "input/mice", 0, "generic3usb"),
"Genius - NetMouse (serial)" :
- ("ms3", "IntelliMouse", "ttyS", 1),
+ ("ms3", "IntelliMouse", "ttyS", 1, "geniusnm"),
"Genius - NetMouse (PS/2)" :
- ("netmouse", "NetMousePS/2", "psaux", 1),
+ ("netmouse", "NetMousePS/2", "psaux", 1, "geniusnmps/2"),
"Genius - NetMouse Pro (PS/2)" :
- ("netmouse", "NetMousePS/2", "psaux", 1),
+ ("netmouse", "NetMousePS/2", "psaux", 1, "geniusprops/2"),
"Genius - NetScroll (PS/2)" :
- ("netmouse", "NetScrollPS/2", "psaux", 1),
+ ("netmouse", "NetScrollPS/2", "psaux", 1, "geniusscrollps/2"),
"Kensington - Thinking Mouse (serial)" :
- ("Microsoft", "ThinkingMouse", "ttyS", 1),
+ ("Microsoft", "ThinkingMouse", "ttyS", 1, "thinking"),
"Kensington - Thinking Mouse (PS/2)" :
- ("ps/2", "ThinkingMousePS/2", "psaux", 1),
+ ("ps/2", "ThinkingMousePS/2", "psaux", 1, "thinkingps/2"),
"Logitech - C7 Mouse (serial, old C7 type)" :
- ("Logitech", "Logitech", "ttyS", 0),
+ ("Logitech", "Logitech", "ttyS", 0, "logitech"),
"Logitech - CC Series (serial)" :
- ("logim", "MouseMan", "ttyS", 0),
+ ("logim", "MouseMan", "ttyS", 0, "logitechcc"),
"Logitech - Bus Mouse" :
- ("Busmouse", "BusMouse", "logibm", 0),
+ ("Busmouse", "BusMouse", "logibm", 0, "logibm"),
"Logitech - MouseMan/FirstMouse (serial)" :
- ("MouseMan", "MouseMan", "ttyS", 0),
+ ("MouseMan", "MouseMan", "ttyS", 0, "logimman"),
"Logitech - MouseMan/FirstMouse (PS/2)" :
- ("ps/2", "PS/2", "psaux", 0),
+ ("ps/2", "PS/2", "psaux", 0, "logimmanps/2"),
"Logitech - MouseMan+/FirstMouse+ (serial)" :
- ("pnp", "IntelliMouse", "ttyS", 0),
+ ("pnp", "IntelliMouse", "ttyS", 0, "logimman+"),
"Logitech - MouseMan+/FirstMouse+ (PS/2)" :
- ("ps/2", "MouseManPlusPS/2", "psaux", 0),
+ ("ps/2", "MouseManPlusPS/2", "psaux", 0, "logimman+ps/2"),
"Logitech - MouseMan Wheel (USB)" :
- ("ps/2", "IMPS/2", "input/mice", 0),
+ ("ps/2", "IMPS/2", "input/mice", 0, "logimmusb"),
"Microsoft - Compatible Mouse (serial)" :
- ("Microsoft", "Microsoft", "ttyS", 1),
+ ("Microsoft", "Microsoft", "ttyS", 1, "microsoft"),
"Microsoft - Rev 2.1A or higher (serial)" :
- ("pnp", "Auto", "ttyS", 1),
+ ("pnp", "Auto", "ttyS", 1, "msnew"),
"Microsoft - IntelliMouse (serial)" :
- ("ms3", "IntelliMouse", "ttyS", 0),
+ ("ms3", "IntelliMouse", "ttyS", 0, "msintelli"),
"Microsoft - IntelliMouse (PS/2)" :
- ("imps2", "IMPS/2", "psaux", 0),
+ ("imps2", "IMPS/2", "psaux", 0, "msintellips/2"),
"Microsoft - IntelliMouse (USB)" :
- ("ps/2", "IMPS/2", "input/mice", 0),
+ ("ps/2", "IMPS/2", "input/mice", 0, "msintelliusb"),
"Microsoft - Bus Mouse" :
- ("Busmouse", "BusMouse", "inportbm", 1),
+ ("Busmouse", "BusMouse", "inportbm", 1, "msbm"),
"Mouse Systems - Mouse (serial)" :
- ("MouseSystems", "MouseSystems", "ttyS", 1),
+ ("MouseSystems", "MouseSystems", "ttyS", 1, "mousesystems"),
"MM - Series (serial)" :
- ("MMSeries", "MMSeries", "ttyS", 1),
+ ("MMSeries", "MMSeries", "ttyS", 1, "mmseries"),
"MM - HitTablet (serial)" :
- ("MMHitTab", "MMHittab", "ttyS", 1),
+ ("MMHitTab", "MMHittab", "ttyS", 1, "mmhittab"),
"None - None" :
- ("none", "none", "null", 0),
+ ("none", "none", "null", 0, "none"),
"Sun - Mouse":
- ("sun", "sun", "sunmouse", 0),
+ ("sun", "sun", "sunmouse", 0, "sun"),
}
+
+ def mouseToMouse(self):
+ types = {}
+ for mouse in self.mice.keys():
+ mouseType = self.mice[mouse][4]
+ types[mouseType] = mouse
+ return types
+
+
# XXX fixme - externalize
def __init__ (self, skipProbe = 0):
self.info = {}
@@ -94,6 +104,7 @@ class Mouse (SimpleConfigFile):
return self.wasProbed
def probe (self, frob = 0):
+
list = kudzu.probe(kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC,
kudzu.PROBE_ONE)
@@ -101,7 +112,7 @@ class Mouse (SimpleConfigFile):
(device, module, desc) = list[0]
if frob and device == 'psaux':
- # kickstart some ps/2 mice. Blame the kernel
+ # jumpstart some ps/2 mice. Blame the kernel
try:
f = open ('/dev/psaux')
f.write ('1')
@@ -153,12 +164,17 @@ class Mouse (SimpleConfigFile):
def getDevice(self):
return self.device
+ def shortDescription(self):
+ if self.info.has_key("FULLNAME"):
+ return self.info["FULLNAME"]
+ else:
+ return _("Unable to probe")
+
def setDevice(self, device):
self.device = device
def set (self, mouse, emulateThreeButtons = -1, thedev = None):
-
- (gpm, x11, dev, em) = self.mice[mouse]
+ (gpm, x11, dev, em, shortname) = self.mice[mouse]
self.info["MOUSETYPE"] = gpm
self.info["XMOUSETYPE"] = x11
self.info["FULLNAME"] = mouse
@@ -196,3 +212,31 @@ class Mouse (SimpleConfigFile):
pass
except TypeError:
pass
+
+ def write(self, instPath):
+ f = open(instPath + "/etc/sysconfig/mouse", "w")
+ f.write(str (self))
+ f.close()
+ self.makeLink(instPath)
+
+
+ def writeKS(self, f):
+ f.write("mouse")
+
+ for arg in self.getArgList():
+ f.write(" " + arg)
+ f.write("\n")
+
+
+ def getArgList(self):
+ args = []
+
+ if self.info["FULLNAME"]:
+ mouseName = self.info["FULLNAME"]
+ args.append(self.mice[mouseName][4])
+ if self.device:
+ args.append("--device %s" %(self.device))
+ if self.emulate:
+ args.append("--emulthree")
+
+ return args
diff --git a/rescue.py b/rescue.py
index 7758125c7..f16b492f3 100644
--- a/rescue.py
+++ b/rescue.py
@@ -2,9 +2,7 @@ import upgrade
from snack import *
from text import WaitWindow, OkCancelWindow
from translate import _
-import _balkan
import sys
-import raid
import os
from log import log
import isys
@@ -26,25 +24,29 @@ class RescueInterface:
def runRescue(url, serial, mountroot):
- from fstab import NewtFstab
+#
+# XXX - disabling mounting of existing installations
+#
+# from fstab import NewtFstab
fstab = None
- log.open (serial, 0, 0, 1)
-
for file in [ "services", "protocols", "group" ]:
os.symlink('/mnt/runtime/etc/' + file, '/etc/' + file)
if (not mountroot):
os.execv("/bin/sh", [ "-/bin/sh" ])
- try:
- fstab = NewtFstab(1, serial, 0, 0, None, None, None, 0, [], 0, 0,
- requireBlockDevices = 0)
- except SystemError, text:
- print _("WARNING: no valid block devices were found.\n")
- except:
- print _("ERROR: unknown error encountered reading partition tables.\n")
+#
+# XXX - disabling mounting of existing installations
+#
+# try:
+# fstab = NewtFstab(1, serial, 0, 0, None, None, None, 0, [], 0, 0,
+# requireBlockDevices = 0)
+# except SystemError, text:
+# print _("WARNING: no valid block devices were found.\n")
+# except:
+# print _("ERROR: unknown error encountered reading partition tables.\n")
if not fstab:
os.execv("/bin/sh", [ "-/bin/sh" ])
diff --git a/syslogd.py b/syslogd.py
index e9e78c502..a6ea012e0 100644
--- a/syslogd.py
+++ b/syslogd.py
@@ -35,16 +35,6 @@ class Syslogd:
acceptedFds.remove(fd)
fd.close()
- def __del__(self):
- self.kill()
-
- def kill(self):
- os.kill(self.child, 15)
- try:
- os.waitpid(self.child, 0)
- except OSError, (errno, msg):
- print __name__, "waitpid:", msg
-
def __init__(self, root = "", output = sys.stdout, socket = "/dev/log"):
output = output
filename = root + socket;
diff --git a/text.py b/text.py
index 4402548b5..23fd59465 100644
--- a/text.py
+++ b/text.py
@@ -1,550 +1,66 @@
from snack import *
import sys
-import isys
import os
-import stat
import iutil
-import rpm
import time
import gettext_rh
import signal
-import installclass
from translate import _, cat, N_
+from language import expandLangs
from log import log
-
+from flags import flags
from constants_text import *
-from lilo_text import LiloWindow
-from lilo_text import LiloAppendWindow
-from lilo_text import LiloImagesWindow
-from silo_text import SiloWindow
-from silo_text import SiloAppendWindow
-from silo_text import SiloImagesWindow
-from network_text import NetworkWindow
-from network_text import HostnameWindow
-from userauth_text import RootPasswordWindow
-from userauth_text import UsersWindow
-from userauth_text import AuthConfigWindow
-from partitioning_text import PartitionMethod
-from partitioning_text import LoopSizeWindow
-from partitioning_text import ManualPartitionWindow
-from partitioning_text import AutoPartitionWindow
-from partitioning_text import PartitionWindow
-from partitioning_text import TurnOnSwapWindow
-from partitioning_text import FormatWindow
-from partitioning_text import LBA32WarningWindow
-from packages_text import PackageGroupWindow
-from packages_text import IndividualPackageWindow
-from packages_text import PackageDepWindow
-from timezone_text import TimezoneWindow
-from bootdisk_text import BootDiskWindow
-from bootdisk_text import MakeBootDiskWindow
-from mouse_text import MouseWindow, MouseDeviceWindow
-from firewall_text import FirewallWindow
-from upgrade_text import UpgradeExamineWindow
-from upgrade_text import UpgradeSwapWindow
-from upgrade_text import CustomizeUpgradeWindow
-
-import installclass
-
-class LanguageWindow:
- def __call__(self, screen, todo, textInterface):
- languages = todo.instTimeLanguage.available ()
-
- haveKon = os.access ("/sbin/continue", os.X_OK)
- if "Japanese" in languages and not haveKon:
- languages.remove("Japanese")
-
- current = todo.instTimeLanguage.getCurrent()
-
- height = min((screen.height - 16, len(languages)))
- if todo.reconfigOnly:
- buttons = [_("Ok"), _("Back")]
- else:
- buttons = [_("Ok")]
-
- translated = []
- for lang in languages:
- translated.append (_(lang))
- (button, choice) = \
- ListboxChoiceWindow(screen, _("Language Selection"),
- _("What language would you like to use during the "
- "installation process?"), translated,
- buttons, width = 30, default = _(current), scroll = 1,
- height = height, help = "lang")
-
- if (button == string.lower(_("Back"))): return INSTALL_BACK
-
- choice = languages[choice]
-
- if (todo.setupFilesystems
- and choice == "Japanese" and not isys.isPsudoTTY(0)):
- # we're not running KON yet, lets fire it up
- os.environ["ANACONDAARGS"] = (os.environ["ANACONDAARGS"] +
- " --lang ja_JP.eucJP")
- os.environ["TERM"] = "kon"
- os.environ["LANG"] = "ja_JP.eucJP"
- os.environ["LC_ALL"] = "ja_JP.eucJP"
- os.environ["LC_NUMERIC"] = "C"
- if os.access("/tmp/updates/anaconda", os.X_OK):
- prog = "/tmp/updates/anaconda"
- else:
- prog = "/usr/bin/anaconda"
- args = [ "kon", "-e", prog ]
- screen.finish()
- os.execv ("/sbin/loader", args)
-
- todo.instTimeLanguage.setRuntimeLanguage(choice)
-
- if not todo.serial:
- map = todo.instTimeLanguage.getFontMap(choice)
- font = todo.instTimeLanguage.getFontFile(choice)
- if map != "None":
- if os.access("/bin/consolechars", os.X_OK):
- iutil.execWithRedirect ("/bin/consolechars",
- ["/bin/consolechars", "-f", font, "-m", map])
- else:
- try:
- isys.loadFont(map)
- except SystemError, (errno, msg):
- log("Could not load font %s: %s" % (font, msg))
- elif os.access("/bin/consolechars", os.X_OK):
- # test and reconfig
- iutil.execWithRedirect ("/bin/consolechars",
- ["/bin/consolechars", "-d", "-m", "iso01"])
-
- textInterface.drawFrame()
-
- return INSTALL_OK
-
-class LanguageSupportWindow:
- def __call__(self, screen, todo):
- # should already be sorted
-
- ct = CheckboxTree(height = 8, scroll = 1)
-
- for lang in todo.language.getAllSupported():
- ct.append(lang, lang, 0)
-
- for lang in todo.language.getSupported ():
- ct.setEntryValue(lang, 1)
-
- current = todo.language.getDefault()
- ct.setCurrent(current)
- ct.setEntryValue(current, 1)
-
- bb = ButtonBar (screen, ((_("OK"), "ok"), (_("Select All"), "all"), (_("Reset"), "reset"), (_("Back"), "back")))
-
- message = (_("Choose the languages to be installed:"))
- width = len(message)
- tb = Textbox (width, 2, message)
-
- g = GridFormHelp (screen, _("Language Support"), "langsupport", 1, 4)
-
- g.add (tb, 0, 0, (0, 0, 0, 0), anchorLeft = 1)
- g.add (ct, 0, 1, (0, 0, 0, 1))
- g.add (bb, 0, 3, growx = 1)
-
- while 1:
- result = g.run()
-
- rc = bb.buttonPressed (result)
-
- if rc == "back":
- screen.popWindow()
- return INSTALL_BACK
-
- if rc == "all":
- for lang in todo.language.getAllSupported():
- ct.setEntryValue(lang, 1)
-
- if rc == "reset":
- for lang in todo.language.getAllSupported():
- if lang == current:
- ct.setEntryValue(lang, 1)
- else:
- ct.setEntryValue(lang, 0)
-
- if rc == "ok" or result == "F12":
- # --If they selected all langs, then set todo.language.setSupported to
- # None. This installs all langs
-
- if ct.getSelection() == []:
- ButtonChoiceWindow(screen, _("Invalid Choice"),
- _("You must select at least one language to install."),
- buttons = [ _("OK") ], width = 40)
-
- else:
- # we may need to reset the default language
- todo.language.setSupported (ct.getSelection())
- default = todo.language.getDefault()
- if default not in ct.getSelection():
- todo.language.setDefault(None)
- screen.popWindow()
- return INSTALL_OK
-
-
-class LanguageDefaultWindow:
- def __call__(self,screen, todo):
- langs = todo.language.getSupported ()
- current = todo.language.getDefault()
-
- if not langs or len(langs) <= 1:
- todo.language.setDefault(current)
- return
-
- langs.sort()
-
- height = min((screen.height - 16, len(langs)))
-
- buttons = [_("Ok"), _("Back")]
-
- (button, choice) = ListboxChoiceWindow(screen, _("Default Language"),
- _("Choose the default language: "), langs,
- buttons, width = 30, default = current, scroll = 1,
- height = height, help = "langdefault")
-
- if (button == string.lower(_("Back"))): return INSTALL_BACK
-
- todo.language.setDefault (langs[choice])
- return INSTALL_OK
-
-class KeyboardWindow:
- beenRun = 0
-
- def __call__(self, screen, todo):
- if todo.serial:
- return INSTALL_NOOP
- keyboards = todo.keyboard.available ()
- keyboards.sort ()
-
- if self.beenRun:
- default = todo.keyboard.get ()
- else:
- default = todo.instTimeLanguage.getDefaultKeyboard()
-
- (button, choice) = \
- ListboxChoiceWindow(screen, _("Keyboard Selection"),
- _("Which model keyboard is attached to this computer?"), keyboards,
- buttons = [_("OK"), _("Back")], width = 30, scroll = 1, height = 8,
- default = default, help = "kybd")
-
- if button == string.lower (_("Back")):
- return INSTALL_BACK
-
- todo.keyboard.set (keyboards[choice])
- self.beenRun = 1
-
- if not todo.serial:
- if todo.reconfigOnly:
- iutil.execWithRedirect ("/bin/loadkeys",
- ["/bin/loadkeys", keyboards[choice]],
- stderr = "/dev/null")
- else:
- try:
- isys.loadKeymap(keyboards[choice])
- except SystemError, (errno, msg):
- log("Could not install keymap %s: %s" % (keyboards[choice], msg))
- return INSTALL_OK
-
-class InstallPathWindow:
- def __call__ (self, screen, todo, intf):
- from fstab import NewtFstab
-
- # see if kickstart specified install type
- showScreen = 1
- if (todo.instClass.installType == "install"):
- intf.steps = intf.commonSteps + intf.installSteps
- todo.upgrade = 0
- showScreen = 0
- elif (todo.instClass.installType == "upgrade"):
- intf.steps = intf.commonSteps + intf.upgradeSteps
- todo.upgrade = 1
- showScreen = 0
-
- # this is (probably) the first place todo.fstab gets created
- if not showScreen:
- todo.fstab = NewtFstab(todo.setupFilesystems,
- todo.serial, todo.zeroMbr, 0,
- todo.intf.waitWindow,
- todo.intf.messageWindow,
- todo.intf.progressWindow,
- not todo.expert,
- todo.method.protectedPartitions(),
- todo.expert, todo.upgrade)
-#
-# merge in fstab entries specified in ks
-#
- todo.instClass.mergeFstabEntries(todo)
-
- return INSTALL_NOOP
-
- classes = installclass.availableClasses()
-
- choices = []
- for (name, object, icon) in classes:
- choices.append(_(name))
- upgradeChoice = len(choices)
- choices.append(_("Upgrade Existing Installation"))
-
- if (todo.upgrade):
- default = upgradeChoice
- orig = None
- else:
- instClass = todo.getClass()
- orig = None
- default = 0
- i = 0
- for (name, object, icon) in classes:
- if isinstance(instClass, object):
- orig = i
- break
- elif object.default:
- default = i
-
- i = i + 1
-
- if (orig):
- default = orig
-
- (button, choice) = ListboxChoiceWindow(screen, _("Installation Type"),
- _("What type of system would you like to install?"),
- choices, [(_("OK"), "ok"), (_("Back"), "back")],
- width = 40, default = default, help = "installpath")
-
- if button == "back":
- return INSTALL_BACK
-
- needNewDruid = 0
-
- if (choice == upgradeChoice):
- intf.steps = intf.commonSteps + intf.upgradeSteps
- if not todo.upgrade:
- needNewDruid = 1
- todo.upgrade = 1
- else:
- intf.steps = intf.commonSteps + intf.installSteps
- todo.upgrade = 0
- if (choice != orig):
- (name, objectClass, logo) = classes[choice]
- todo.setClass(objectClass(todo.expert))
- needNewDruid = 1
-
- if needNewDruid or not todo.fstab:
- todo.fstab = NewtFstab(todo.setupFilesystems,
- todo.serial, 0, 0,
- todo.intf.waitWindow,
- todo.intf.messageWindow,
- todo.intf.progressWindow,
- not todo.expert,
- todo.method.protectedPartitions(),
- todo.expert, todo.upgrade)
-
- return INSTALL_OK
-
-
-class WelcomeWindow:
- def __call__(self, screen):
- rc = ButtonChoiceWindow(screen, _("Red Hat Linux"),
- _("Welcome to Red Hat Linux!\n\n"
- "This installation process is outlined in detail in the "
- "Official Red Hat Linux Installation Guide available from "
- "Red Hat Software. If you have access to this manual, you "
- "should read the installation section before continuing.\n\n"
- "If you have purchased Official Red Hat Linux, be sure to "
- "register your purchase through our web site, "
- "http://www.redhat.com/."),
- buttons = [_("OK"), _("Back")], width = 50,
- help = "welcome")
-
- if rc == string.lower(_("Back")):
- return INSTALL_BACK
-
- return INSTALL_OK
-
-class ReconfigWelcomeWindow:
- def __call__(self, screen):
- rc = ButtonChoiceWindow(screen, _("Red Hat Linux"),
- _("Welcome to the Red Hat Linux!\n\n"
- "You have entered reconfiguration mode, "
- "which will allow you to configure "
- "site-specific options of your computer."
- "\n\n"
- "To exit without changing your setup "
- "select the ""Cancel"" button below."),
- buttons = [_("OK"), _("Cancel")], width = 50,
- help = "reconfigwelcome")
-
- if rc == string.lower(_("Cancel")):
- screen.finish()
- os._exit(0)
-
- return INSTALL_OK
-
-class XConfigWindow:
- def __call__(self, screen, todo):
- #
- # if in reconfigOnly mode we query existing rpm db
- # if X not installed, just skip this step
- #
- if todo.reconfigOnly:
-# import rpm
-# db = rpm.opendb()
-# rc = db.findbyname ("XFree86")
-# if len(rc) == 0:
-# return None
-
-#
-# for now ignore request to configure X11 in reconfig mode
-#
- return None
-
- else:
- # we need to get the package list here for things like
- # workstation install - which will not have read the
- # package list yet.
- todo.getCompsList ()
-
- if not todo.hdList.packages.has_key('XFree86') or \
- not todo.hdList.packages['XFree86'].selected:
- return None
-
- todo.x.probe (probeMonitor = 0)
-# todo.x.server = None #-hack
- if todo.x.server:
- rc = ButtonChoiceWindow (screen, _("X probe results"),
- todo.x.probeReport (),
- buttons = [ _("OK"), _("Back") ],
- help = 'xprobe')
-
- if rc == string.lower (_("Back")):
- return INSTALL_BACK
-
- todo._cardindex = -1
- return INSTALL_OK
-
- if todo.serial:
- # if doing serial installation and no card was probed,
- # assume no card is present (typical case).
- return INSTALL_NOOP
-
- # if we didn't find a server, we need the user to choose...
- carddb = todo.x.cards()
- cards = carddb.keys ()
- cards.sort ()
- cards.append (_("Unlisted Card"))
-
- servers = [ "Mono", "VGA16", "SVGA", "S3", "Mach32", "Mach8", "8514", "P9000", "AGX",
- "W32", "W32", "Mach64", "I128", "S3V", "3DLabs" ]
-
- rc = INSTALL_NOOP
- server = None
- while rc != INSTALL_OK:
- (rc, choice) = ListboxChoiceWindow(screen, _("Video Card Selection"),
- _("Which video card do you have?"),
- cards,
- buttons = [_("OK"), _("Back")],
- width = 70, scroll = 1,
- height = screen.height - 14,
- help = "videocard")
- if rc == string.lower (_("Back")):
- return INSTALL_BACK
-
- todo._cardindex = -1
-
- if cards[choice] == _("Unlisted Card"):
- (rc , choice) = \
- ListboxChoiceWindow(screen, _("X Server Selection"), _("Choose a server"),
- servers,
- buttons = [ (_("Ok"), "ok"), (_("Back"), "back") ],
- scroll = 1,
- height = screen.height - 14,
- help = "xserver")
-
- if (rc == "back"):
- rc = INSTALL_BACK
- else:
- rc = INSTALL_OK
- server = servers[choice]
- else:
- todo._cardindex = choice
- rc = INSTALL_OK
-
- if server:
- todo.x.setVidcard ( { "NAME" : "Generic " + server,
- "SERVER" : server } )
- else:
- card = carddb[cards[choice]]
-
- depth = 0
- while depth < 16 and card.has_key ("SEE"):
- card = carddb[card["SEE"]]
- depth = depth + 1
-
- todo.x.setVidcard (card)
-
- return INSTALL_OK
+stepToClasses = {
+ "language" : ( "language_text", "LanguageWindow" ),
+ "keyboard" : ( "keyboard_text", "KeyboardWindow" ),
+ "mouse" : ( "mouse_text", ( "MouseWindow", "MouseDeviceWindow" ) ),
+ "welcome" : ("welcome_text", "WelcomeWindow" ),
+ "reconfigwelcome" : ("welcome_text", "ReconfigWelcomeWindow" ),
+ "installtype" : ("installpath_text", "InstallPathWindow" ),
+ "autopartition" : ("partitioning_text", ( "AutoPartitionWindow",
+ "PartitionMethod" ) ),
+ "custom-upgrade" : ("upgrade_text", "UpgradeExamineWindow" ),
+ "addswap" : ("upgrade_text", "UpgradeSwapWindow" ),
+ "fdisk" : ("partitioning_text", "ManualPartitionWindow" ),
+ "partition": ("partition_text", ("PartitionWindow") ),
+ "bootloader" : ("lilo_text", ("LiloAppendWindow",
+ "LiloWindow",
+ "LiloImagesWindow" ) ),
+ "network" : ("network_text", ( "NetworkWindow", "HostnameWindow" ) ),
+ "firewall" : ( "firewall_text", "FirewallWindow" ),
+ "languagesupport" : ( "language_text", ( "LanguageDefaultWindow",
+ "LanguageSupportWindow" ) ),
+ "timezone" : ( "timezone_text", "TimezoneWindow" ),
+ "accounts" : ( "userauth_text", ( "RootPasswordWindow", "UsersWindow" ) ),
+ "authentication" : ( "userauth_text", ( "AuthConfigWindow" ) ),
+ "package-selection" : ( "packages_text", "PackageGroupWindow" ),
+ "indivpackage" : ("packages_text", ( "IndividualPackageWindow" ) ),
+ "dependencies" : ( "packages_text", "PackageDepWindow" ),
+ "videocard" : ( "xconfig_text", "XConfigWindowCard"),
+ "monitor" : ( "xconfig_text", "MonitorWindow" ),
+ "xcustom" : ( "xconfig_text", "XCustomWindow" ),
+ "confirminstall" : ( "confirm_text", "BeginInstallWindow" ),
+ "confirmupgrade" : ( "confirm_text", "BeginUpgradeWindow" ),
+ "install" : ( "progress_text", "setupForInstall" ),
+ "bootdisk" : ( "bootdisk_text", ( "BootDiskWindow",
+ "MakeBootDiskWindow" ) ),
+# "finishxconfig" : ( "xconfig_text", "XconfiguratorWindow" ),
+ "complete" : ( "complete_text", "FinishedWindow" ),
+ "reconfigcomplete" : ( "complete_text", "ReconfigFinishedWindow" ),
+}
+
+stepToClasses["reconfigkeyboard"] = stepToClasses["keyboard"]
+
+if iutil.getArch() == 'sparc':
+ stepToClasses["bootloader"] = ( "silo_text", ( "SiloAppendWindow",
+ "SiloWindow"
+ "SiloImagesWindow" ) )
+else:
+ stepToClasses["bootloader"] = ( "lilo_text", ( "LiloAppendWindow",
+ "LiloWindow",
+ "LiloImagesWindow") )
-class XconfiguratorWindow:
- def __call__ (self, screen, todo):
- if not todo.x.server: return INSTALL_NOOP
-
- # if serial install, we can't run it.
- if todo.serial:
- todo.x.skip = 1
- return INSTALL_NOOP
-
- # if Xconfigurator isn't installed, we can't run it.
- if not os.access (todo.instPath + '/usr/X11R6/bin/Xconfigurator',
- os.X_OK):
- log("Could not find Xconfigurator, skipping X configuration.")
- return INSTALL_NOOP
-
- f = open (todo.instPath + "/var/run/SERVER", "w")
- if todo._cardindex == -1:
- f.write ("%d\n" % todo._cardindex)
- else:
- f.write ("%s %d\n" % (todo.x.server, todo._cardindex))
- f.close ()
-
- args = ["xconfigurator", "--continue"]
- if todo.expert:
- args = args + [ '--noddcprobe' ]
-
- screen.suspend ()
- iutil.execWithRedirect ("/usr/X11R6/bin/Xconfigurator", args,
- root = todo.instPath)
- screen.resume ()
- todo.x.skip = 1
- return INSTALL_NOOP
-
-class BeginInstallWindow:
- def __call__ (self, dir, screen, todo):
-
- if dir == -1:
- return INSTALL_NOOP
-
- rc = ButtonChoiceWindow (screen, _("Installation to begin"),
- _("A complete log of your installation will be in "
- "/tmp/install.log after rebooting your system. You "
- "may want to keep this file for later reference."),
- buttons = [ _("OK"), _("Back") ],
- help = "begininstall")
- if rc == string.lower (_("Back")):
- return INSTALL_BACK
- return INSTALL_OK
-
-class BeginUpgradeWindow:
- def __call__ (self, screen, todo):
- rc = ButtonChoiceWindow (screen, _("Upgrade to begin"),
- _("A complete log of your upgrade will be in "
- "/tmp/upgrade.log after rebooting your system. You "
- "may want to keep this file for later reference."),
- buttons = [ _("OK"), _("Back") ],
- help = "beginupgrade")
- if rc == string.lower (_("Back")):
- return INSTALL_BACK
- return INSTALL_OK
class InstallWindow:
def __call__ (self, screen, todo):
@@ -553,178 +69,6 @@ class InstallWindow:
return INSTALL_OK
-class FinishedWindow:
- def __call__ (self, screen, todo):
-
-
- screen.pushHelpLine (_(" <Return> to reboot "))
-
- rc = ButtonChoiceWindow (screen, _("Complete"),
- _("Congratulations, installation is complete.\n\n"
- "Press return to reboot, and be sure to remove your "
- "boot medium after the system reboots, or your system "
- "will rerun the install. For information on fixes which "
- "are available for this release of Red Hat Linux, "
- "consult the "
- "Errata available from http://www.redhat.com/errata.\n\n"
- "Information on configuring and using your Red Hat "
- "Linux system is contained in the Red Hat Linux "
- "manuals."),
- [ _("OK") ], help = "finished")
-
- return INSTALL_OK
-
-
-class ReconfigFinishedWindow:
- def __call__ (self, screen, todo):
-
- screen.pushHelpLine (_(" <Return> to exit "))
-
- todo.writeConfiguration()
-
- rc = ButtonChoiceWindow (screen, _("Complete"),
- _("Congratulations, configuration is complete.\n\n"
- " For information on fixes which "
- "are available for this release of Red Hat Linux, "
- "consult the "
- "Errata available from http://www.redhat.com.\n\n"
- "Information on further configuring your system is "
- "available at http://www.redhat.com/support/manuals/"),
-
- [ _("OK") ], help = "reconfigfinished")
-
- return INSTALL_OK
-
-class InstallProgressWindow:
- def completePackage(self, header, timer):
- def formatTime(amt):
- hours = amt / 60 / 60
- amt = amt % (60 * 60)
- min = amt / 60
- amt = amt % 60
- secs = amt
-
- return "%01d:%02d:%02d" % (int(hours) ,int(min), int(secs))
-
- self.numComplete = self.numComplete + 1
- self.sizeComplete = self.sizeComplete + (header[rpm.RPMTAG_SIZE] / 1024)
- self.numCompleteW.setText("%12d" % self.numComplete)
- self.sizeCompleteW.setText("%10dM" % (self.sizeComplete/1024))
- self.numRemainingW.setText("%12d" % (self.numTotal - self.numComplete))
- self.sizeRemainingW.setText("%10dM" % (self.sizeTotal/1024 - self.sizeComplete/1024))
- self.total.set(self.sizeComplete)
-
- elapsedTime = timer.elapsed()
- if not elapsedTime:
- elapsedTime = 1
- self.timeCompleteW.setText("%12s" % formatTime(elapsedTime))
- if self.sizeComplete != 0:
- finishTime = (float (self.sizeTotal) / (self.sizeComplete)) * elapsedTime;
- else:
- finishTime = (float (self.sizeTotal) / (self.sizeComplete+1)) * elapsedTime;
- self.timeTotalW.setText("%12s" % formatTime(finishTime))
- remainingTime = finishTime - elapsedTime;
- self.timeRemainingW.setText("%12s" % formatTime(remainingTime))
-
- self.g.draw()
- self.screen.refresh()
-
- def setPackageScale(self, amount, total):
- self.s.set(int(((amount * 1.0)/ total) * 100))
- self.g.draw()
- self.screen.refresh()
-
- def setPackage(self, header):
- self.name.setText("%s-%s-%s" % (header[rpm.RPMTAG_NAME],
- header[rpm.RPMTAG_VERSION],
- header[rpm.RPMTAG_RELEASE]))
- self.size.setText("%dk" % (header[rpm.RPMTAG_SIZE] / 1024))
- summary = header[rpm.RPMTAG_SUMMARY]
- if (summary != None):
- self.summ.setText(summary)
- else:
- self.summ.setText("(none)")
-
- self.g.draw()
- self.screen.refresh()
-
- def __init__(self, screen, total, totalSize):
- self.screen = screen
- toplevel = GridForm(self.screen, _("Package Installation"), 1, 5)
-
- name = _("Name : ")
- size = _("Size : ")
- sum = _("Summary: ")
-
- width = 40 + max (len (name), len (size), len (sum))
- self.name = Label(" " * 40)
- self.size = Label(" ")
- detail = Grid(2, 2)
- detail.setField(Label(name), 0, 0, anchorLeft = 1)
- detail.setField(Label(size), 0, 1, anchorLeft = 1)
- detail.setField(self.name, 1, 0, anchorLeft = 1)
- detail.setField(self.size, 1, 1, anchorLeft = 1)
- toplevel.add(detail, 0, 0)
-
- summary = Grid(2, 1)
- summlabel = Label(sum)
- self.summ = Textbox(40, 2, "", wrap = 1)
- summary.setField(summlabel, 0, 0)
- summary.setField(self.summ, 1, 0)
- toplevel.add(summary, 0, 1)
-
- self.s = Scale (width, 100)
- toplevel.add (self.s, 0, 2, (0, 1, 0, 1))
-
- overall = Grid(4, 4)
- # don't ask me why, but if this spacer isn"t here then the
- # grid code gets unhappy
- overall.setField (Label (" "), 0, 0, anchorLeft = 1)
- overall.setField (Label (_(" Packages")), 1, 0, anchorLeft = 1)
- overall.setField (Label (_(" Bytes")), 2, 0, anchorLeft = 1)
- overall.setField (Label (_(" Time")), 3, 0, anchorLeft = 1)
-
- overall.setField (Label (_("Total :")), 0, 1, anchorLeft = 1)
- overall.setField (Label ("%12d" % total), 1, 1, anchorLeft = 1)
- overall.setField (Label ("%10dM" % (totalSize/1024)),
- 2, 1, anchorLeft = 1)
- self.timeTotalW = Label("")
- overall.setField(self.timeTotalW, 3, 1, anchorLeft = 1)
-
- overall.setField (Label (_("Completed: ")), 0, 2, anchorLeft = 1)
- self.numComplete = 0
- self.numCompleteW = Label("%12d" % self.numComplete)
- overall.setField(self.numCompleteW, 1, 2, anchorLeft = 1)
- self.sizeComplete = 0
- self.sizeCompleteW = Label("%10dM" % (self.sizeComplete))
- overall.setField(self.sizeCompleteW, 2, 2, anchorLeft = 1)
- self.timeCompleteW = Label("")
- overall.setField(self.timeCompleteW, 3, 2, anchorLeft = 1)
-
- overall.setField (Label (_("Remaining: ")), 0, 3, anchorLeft = 1)
- self.numRemainingW = Label("%12d" % total)
- self.sizeRemainingW = Label("%10dM" % (totalSize/1024))
- overall.setField(self.numRemainingW, 1, 3, anchorLeft = 1)
- overall.setField(self.sizeRemainingW, 2, 3, anchorLeft = 1)
- self.timeRemainingW = Label("")
- overall.setField(self.timeRemainingW, 3, 3, anchorLeft = 1)
-
- toplevel.add(overall, 0, 3)
-
- self.numTotal = total
- self.sizeTotal = totalSize
- self.total = Scale (width, totalSize)
- toplevel.add(self.total, 0, 4, (0, 1, 0, 0))
-
- self.timeStarted = -1
-
- toplevel.draw()
- self.g = toplevel
- screen.refresh()
-
- def __del__ (self):
- self.screen.popWindow ()
-
class WaitWindow:
def pop(self):
@@ -761,7 +105,7 @@ class OkCancelWindow:
def __init__(self, screen, title, text):
rc = ButtonChoiceWindow(screen, _(title), _(text),
- buttons = [ _("OK"), _("Cancel") ])
+ buttons = [ TEXT_OK_BUTTON, _("Cancel") ])
if rc == string.lower(_("Cancel")):
self.rc = 1
else:
@@ -798,7 +142,12 @@ class InstallInterface:
def helpWindow(self, screen, key, firstTime = 1):
try:
f = None
- for lang in self.todo.instTimeLanguage.getCurrentLangSearchList():
+
+ # XXX
+ #
+ # HelpWindow can't get to the langauge
+
+ for lang in self.langSearchPath:
fn = "/usr/share/anaconda/help/%s/s1-help-screens-%s.txt" \
% (lang, key)
try:
@@ -817,7 +166,7 @@ class InstallInterface:
else:
ButtonChoiceWindow(screen, _("Help not available"),
_("No help is available for this install."),
- buttons = [ _("OK") ])
+ buttons = [ TEXT_OK_BUTTON ])
return None
l = f.readlines()
@@ -843,7 +192,7 @@ class InstallInterface:
if len(line) > width:
width = len(line)
- bb = ButtonBar(screen, [ (_("OK"), "ok" ) ] )
+ bb = ButtonBar(screen, [ TEXT_OK_BUTTON ] )
t = Textbox(width, height, stream, scroll = scroll)
g = GridFormHelp(screen, title, "helponhelp", 1, 2)
@@ -852,7 +201,7 @@ class InstallInterface:
g.runOnce()
except:
- import sys, traceback
+ import traceback
(type, value, tb) = sys.exc_info()
from string import joinfields
list = traceback.format_exception (type, value, tb)
@@ -869,7 +218,7 @@ class InstallInterface:
def messageWindow(self, title, text, type = "ok"):
if type == "ok":
ButtonChoiceWindow(self.screen, _(title), _(text),
- buttons = [ _("OK") ])
+ buttons = [ TEXT_OK_BUTTON ])
else:
return OkCancelWindow(self.screen, _(title), _(text))
@@ -877,7 +226,7 @@ class InstallInterface:
rc = ButtonChoiceWindow(self.screen, _("Save Crash Dump"),
_("Please insert a floppy now. All contents of the disk "
"will be erased, so please choose your diskette carefully."),
- [ _("OK"), _("Cancel") ])
+ [ TEXT_OK_BUTTON, _("Cancel") ])
if rc == string.lower (_("Cancel")):
return 1
@@ -892,7 +241,7 @@ class InstallInterface:
"and will help Red Hat in fixing the problem.\n\n")
rc = ButtonChoiceWindow(self.screen, title, ugh + text,
- buttons = [ _("OK"), _("Save"), _("Debug") ])
+ buttons = [ TEXT_OK_BUTTON, _("Save"), _("Debug") ])
if rc == string.lower (_("Debug")):
return 1
elif rc == string.lower (_("Save")):
@@ -919,226 +268,81 @@ class InstallInterface:
self.screen = None
def __init__(self):
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ signal.signal(signal.SIGTSTP, signal.SIG_IGN)
+ self.screen = None
+
+ def __del__(self):
+ if self.screen:
+ self.screen.finish()
+
+ def run(self, id, dispatch):
self.screen = SnackScreen()
self.screen.helpCallback(self.helpWindow)
self.drawFrame()
+
# uncomment this line to make the installer quit on <Ctrl+Z>
# handy for quick debugging.
self.screen.suspendCallback(killSelf, self.screen)
# uncomment this line to drop into the python debugger on <Ctrl+Z>
# --VERY handy--
#self.screen.suspendCallback(debugSelf, self.screen)
- self.individual = Flag(0)
- self.step = 0
- self.dir = 1
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTSTP, signal.SIG_IGN)
-
- def __del__(self):
- self.screen.finish()
- def run(self, todo, test = 0):
- if todo.serial:
+ if flags.serial:
self.screen.suspendCallback(spawnShell, self.screen)
- self.todo = todo
-
- if todo.reconfigOnly:
- self.commonSteps = [
- [N_("Welcome"), ReconfigWelcomeWindow,
- (self.screen,), "reconfig" ],
- [N_("Keyboard Selection"), KeyboardWindow,
- (self.screen, todo), "keyboard" ],
- [N_("Hostname Setup"), HostnameWindow, (self.screen, todo),
- "network"],
- [N_("Network Setup"), NetworkWindow, (self.screen, todo),
- "network"],
- [N_("Firewall Configuration"), FirewallWindow, (self.screen, todo),
- "firewall" ],
- [N_("Language Default"), LanguageDefaultWindow,
- (self.screen, todo), "languagedefault" ],
- [N_("Time Zone Setup"), TimezoneWindow,
- (self.screen, todo, test), "timezone" ],
- [N_("Root Password"), RootPasswordWindow,
- (self.screen, todo), "accounts" ],
- [N_("User Account Setup"), UsersWindow,
- (self.screen, todo), "accounts" ],
- [N_("Authentication"), AuthConfigWindow, (self.screen, todo),
- "authentication" ],
- [N_("Configuration Complete"), ReconfigFinishedWindow, (self.screen,todo),
- "complete" ],
- ]
- else:
- self.commonSteps = [
- [N_("Language Selection"), LanguageWindow,
- (self.screen, todo, self), "language" ],
- [N_("Keyboard Selection"), KeyboardWindow,
- (self.screen, todo), "keyboard" ],
- [N_("Welcome"), WelcomeWindow, (self.screen,), "welcome" ],
- [N_("Installation Type"), InstallPathWindow,
- (self.screen, todo, self), "installtype" ],
- ]
-
- if iutil.getArch() == 'sparc':
- BootloaderAppendWindow = SiloAppendWindow
- BootloaderWindow = SiloWindow
- BootloaderImagesWindow = SiloImagesWindow
- BootloaderConfiguration = _("SILO Configuration")
- BootloaderSkipName = "silo"
- else:
- BootloaderAppendWindow = LiloAppendWindow
- BootloaderWindow = LiloWindow
- BootloaderImagesWindow = LiloImagesWindow
- BootloaderConfiguration = _("LILO Configuration")
- BootloaderSkipName = "lilo"
-
- # note that the parameter "dir" will be replaced with the direction
- # we're traveling
-
- self.installSteps = [
- [N_("Automatic Partition"), AutoPartitionWindow,
- (self.screen, todo), "partition" ],
- [N_("Partition"), PartitionMethod,
- (self.screen, todo), "partition" ],
- [N_("Manually Partition"), ManualPartitionWindow,
- (self.screen, todo), "partition" ],
- [N_("Partition"), PartitionWindow, (self.screen, todo),
- "partition" ],
- [N_("Root Filesystem Size"), LoopSizeWindow, (self.screen, todo),
- "partition" ],
- [N_("Swap"), TurnOnSwapWindow, (self.screen, todo),
- "partition" ],
- [N_("Boot Partition Warning"), LBA32WarningWindow, ("dir", self.screen, todo),
- "lba32warning" ],
- [N_("Filesystem Formatting"), FormatWindow, (self.screen, todo),
- "format" ],
- [BootloaderConfiguration, BootloaderAppendWindow,
- (self.screen, todo), BootloaderSkipName ],
- [BootloaderConfiguration, BootloaderWindow,
- (self.screen, todo), BootloaderSkipName ],
- [BootloaderConfiguration, BootloaderImagesWindow,
- (self.screen, todo), BootloaderSkipName ],
-# [N_("Hostname Setup"), HostnameWindow, (self.screen, todo),
-# "network"],
- [N_("Network Setup"), NetworkWindow, (self.screen, todo),
- "network"],
-
- [N_("Hostname Setup"), HostnameWindow, (self.screen, todo),
- "network"],
- [N_("Firewall Configuration"), FirewallWindow, (self.screen, todo),
- "firewall" ],
- [N_("Mouse Configuration"), MouseWindow, (self.screen, todo.mouse),
- "mouse" ],
- [N_("Mouse Configuration"), MouseDeviceWindow, (self.screen, todo.mouse),
- "mouse" ],
-
- [N_("Language Support"), LanguageSupportWindow,
- (self.screen, todo), "languagesupport" ],
- [N_("Language Default"), LanguageDefaultWindow,
- (self.screen, todo), "languagedefault" ],
-
- [N_("Time Zone Setup"), TimezoneWindow,
- (self.screen, todo, test), "timezone" ],
- [N_("Root Password"), RootPasswordWindow,
- (self.screen, todo), "accounts" ],
- [N_("User Account Setup"), UsersWindow,
- (self.screen, todo), "accounts" ],
- [N_("Authentication"), AuthConfigWindow, (self.screen, todo),
- "authentication" ],
- [N_("Package Groups"), PackageGroupWindow,
- (self.screen, todo, self.individual), "package-selection" ],
- [N_("Individual Packages"), IndividualPackageWindow,
- (self.screen, todo, self.individual), "package-selection" ],
- [N_("Package Dependencies"), PackageDepWindow, (self.screen, todo),
- "package-selection" ],
- [N_("X Configuration"), XConfigWindow, (self.screen, todo),
- "xconfig" ],
- [N_("Installation Begins"), BeginInstallWindow,
- ("dir", self.screen, todo), "confirm-install" ],
- [N_("Install System"), InstallWindow, (self.screen, todo) ],
- [N_("Boot Disk"), BootDiskWindow, (self.screen, todo),
- "bootdisk" ],
- [N_("Boot Disk"), MakeBootDiskWindow, (self.screen, todo), "bootdisk"],
- [N_("X Configuration"), XconfiguratorWindow, (self.screen, todo),
- "xconfig"],
- [N_("Installation Complete"), FinishedWindow, (self.screen, todo),
- "complete" ]
- ]
-
- self.upgradeSteps = [
- [_("Examine System"), UpgradeExamineWindow, ("dir", self.screen, todo)],
- [_("System Swap Space"), UpgradeSwapWindow, ("dir", self.screen, todo)],
- [BootloaderConfiguration, BootloaderAppendWindow,
- (self.screen, todo), "lilo"],
- [BootloaderConfiguration, BootloaderWindow,
- (self.screen, todo), "lilo"],
- [BootloaderConfiguration, BootloaderImagesWindow,
- (self.screen, todo), "lilo"],
- [_("Customize Upgrade"), CustomizeUpgradeWindow,
- (self.screen, todo, self.individual), "custom-upgrade" ],
- [_("Individual Packages"), IndividualPackageWindow, (self.screen, todo, self.individual)],
- [N_("Package Dependencies"), PackageDepWindow, (self.screen, todo),
- "package-selection" ],
- [N_("Upgrade Begins"), BeginUpgradeWindow,
- (self.screen, todo), "confirm-upgrade" ],
- [_("Upgrade System"), InstallWindow, (self.screen, todo)],
- [_("Boot Disk"), BootDiskWindow, (self.screen, todo),
- "bootdisk" ],
- [_("Boot Disk"), MakeBootDiskWindow, (self.screen, todo), "bootdisk"],
- [_("Upgrade Complete"), FinishedWindow, (self.screen, todo),
- "complete"]
- ]
-
- # set to 1 if you want to see where in the install you are
- debugsteps = 0
-
- dir = 1
- self.steps = self.commonSteps
-
- while self.step >= 0 and self.step < len(self.steps) and self.steps[self.step]:
- step = self.steps[self.step]
- if debugsteps:
- log("step is %s", step[0])
- rc = INSTALL_OK
- if (len(step) == 4):
- if debugsteps:
- log("skipStep[step] = %s", todo.instClass.skipStep(step[3]))
- if (todo.instClass.skipStep(step[3])):
- rc = INSTALL_NOOP
-
- if (rc != INSTALL_NOOP):
- # clear out the old root text by writing spaces in the blank
- # area on the right side of the screen
- self.screen.drawRootText (len(_(self.welcomeText)), 0,
- (self.screen.width - len(_(self.welcomeText))) * " ")
- self.screen.drawRootText (0 - len(_(step[0])), 0, _(step[0]))
-
- args = step[2]
- if "dir" in args:
- newArgs = ()
- for n in args:
- if n == "dir":
- n = dir
-
- newArgs = newArgs + (n,)
- args = newArgs
-
- rc = apply (step[1](), args)
-
- if rc == INSTALL_BACK:
- dir = -1
- elif rc == INSTALL_OK:
- dir = 1
-
- self.step = self.step + dir
- if self.step < 0:
- ButtonChoiceWindow(self.screen, _("Cancelled"),
- _("I can't go to the previous step"
- " from here. You will have to try again."),
- buttons = [ _("OK") ])
-
- self.step = 0
- dir = 1
+ # clear out the old root text by writing spaces in the blank
+ # area on the right side of the screen
+ #self.screen.drawRootText (len(_(self.welcomeText)), 0,
+ #(self.screen.width - len(_(self.welcomeText))) * " ")
+ #self.screen.drawRootText (0 - len(_(step[0])), 0, _(step[0]))
+
+ lang = id.instLanguage.getCurrent()
+ lang = id.instLanguage.getLangNick(lang)
+ self.langSearchPath = expandLangs(lang) + ['C']
+
+ lastrc = INSTALL_OK
+ (step, args) = dispatch.currentStep()
+ while step:
+ (file, classNames) = stepToClasses[step]
+
+ if type(classNames) != type(()):
+ classNames = (classNames,)
+
+ if lastrc == INSTALL_OK:
+ step = 0
+ else:
+ step = len(classNames) - 1
+
+ while step >= 0 and step < len(classNames):
+ s = "from %s import %s; nextWindow = %s" % \
+ (file, classNames[step], classNames[step])
+ exec s
+
+ win = nextWindow()
+
+ #log("TUI running step %s (class %s, file %s)" %
+ #(step, file, classNames))
+
+ rc = apply(win, (self.screen, ) + args)
+
+ if rc == INSTALL_NOOP:
+ rc = lastrc
+
+ if rc == INSTALL_BACK:
+ step = step - 1
+ elif rc == INSTALL_OK:
+ step = step + 1
+
+ lastrc = rc
+
+ if step == -1:
+ dispatch.gotoPrev()
+ else:
+ dispatch.gotoNext()
+
+ (step, args) = dispatch.currentStep()
+
self.screen.finish ()
def killSelf(screen):
diff --git a/todo.py b/todo.py
deleted file mode 100644
index 09991630f..000000000
--- a/todo.py
+++ /dev/null
@@ -1,2132 +0,0 @@
-import rpm
-import os
-rpm.addMacro("_i18ndomains", "redhat-dist")
-
-import iutil, isys
-from lilo import LiloConfiguration
-arch = iutil.getArch ()
-if arch == "sparc":
- from silo import SiloInstall
-elif arch == "alpha":
- from milo import MiloInstall, onMILO
-elif arch == "ia64":
- from elilo import EliloConfiguration
-import string
-import socket
-import crypt
-import sys
-import whrandom
-import pcmcia
-import _balkan
-import kudzu
-from kbd import Keyboard
-from simpleconfig import SimpleConfigFile
-from mouse import Mouse
-from xf86config import XF86Config
-import errno
-import raid
-from translate import cat
-import timer
-import fstab
-import time
-import re
-import gettext_rh
-import os.path
-import upgrade
-from translate import _
-from log import log
-
-class NetworkDevice (SimpleConfigFile):
- def __str__ (self):
- s = ""
- s = s + "DEVICE=" + self.info["DEVICE"] + "\n"
- keys = self.info.keys ()
- keys.sort ()
- keys.remove ("DEVICE")
-
- # Don't let onboot be turned on unless we have config information
- # to go along with it
- if self.get('bootproto') != 'dhcp' and not self.get('ipaddr'):
- forceOffOnBoot = 1
- else:
- forceOffOnBoot = 0
-
- onBootWritten = 0
- for key in keys:
- if key == 'ONBOOT' and forceOffOnBoot:
- s = s + key + "=" + 'no' + "\n"
- else:
- s = s + key + "=" + self.info[key] + "\n"
-
- if key == 'ONBOOT':
- onBootWritten = 1
-
- if not onBootWritten:
- s = s + 'ONBOOT=no\n'
-
- return s
-
- def __init__ (self, dev):
- self.info = { "DEVICE" : dev }
-
-class Network:
- def __init__ (self):
- self.netdevices = {}
- self.gateway = ""
- self.primaryNS = ""
- self.secondaryNS = ""
- self.ternaryNS = ""
- self.domains = []
- self.readData = 0
- self.isConfigured = 0
- self.hostname = "localhost.localdomain"
-
- try:
- f = open ("/tmp/netinfo", "r")
- except:
- pass
- else:
- lines = f.readlines ()
- f.close ()
- info = {}
- self.isConfigured = 1
- for line in lines:
- netinf = string.splitfields (line, '=')
- info [netinf[0]] = string.strip (netinf[1])
- self.netdevices [info["DEVICE"]] = NetworkDevice (info["DEVICE"])
- if info.has_key ("IPADDR"):
- self.netdevices [info["DEVICE"]].set (("IPADDR", info["IPADDR"]))
- if info.has_key ("NETMASK"):
- self.netdevices [info["DEVICE"]].set (("NETMASK", info["NETMASK"]))
- if info.has_key ("BOOTPROTO"):
- self.netdevices [info["DEVICE"]].set (("BOOTPROTO", info["BOOTPROTO"]))
- if info.has_key ("ONBOOT"):
- self.netdevices [info["DEVICE"]].set (("ONBOOT", info["ONBOOT"]))
- if info.has_key ("GATEWAY"):
- self.gateway = info["GATEWAY"]
- if info.has_key ("DOMAIN"):
- self.domains.append(info["DOMAIN"])
- if info.has_key ("HOSTNAME"):
- self.hostname = info["HOSTNAME"]
-
- self.readData = 1
- try:
- f = open ("/etc/resolv.conf", "r")
- except:
- pass
- else:
- lines = f.readlines ()
- f.close ()
- for line in lines:
- resolv = string.split (line)
- if resolv and resolv[0] == 'nameserver':
- if self.primaryNS == "":
- self.primaryNS = resolv[1]
- elif self.secondaryNS == "":
- self.secondaryNS = resolv[1]
- elif self.ternaryNS == "":
- self.ternaryNS = resolv[1]
-
- def getDevice(self, device):
- return self.netdevices[device]
-
- def available (self):
- f = open ("/proc/net/dev")
- lines = f.readlines()
- f.close ()
- # skip first two lines, they are header
- lines = lines[2:]
- for line in lines:
- dev = string.strip (line[0:6])
- if dev != "lo" and not self.netdevices.has_key (dev):
- self.netdevices[dev] = NetworkDevice (dev)
- return self.netdevices
-
- def lookupHostname (self):
- # can't look things up if they don't exist!
- if not self.hostname or self.hostname == "localhost.localdomain": return None
- if not self.primaryNS: return
- if not self.isConfigured:
- for dev in self.netdevices.values():
- if dev.get('bootproto') == "dhcp":
- self.primaryNS = isys.pumpNetDevice(dev.get('device'))
- self.isConfigured = 1
- break
- elif dev.get('ipaddr') and dev.get('netmask'):
- try:
- isys.configNetDevice(dev.get('device'),
- dev.get('ipaddr'),
- dev.get('netmask'),
- self.gateway)
- self.isConfigured = 1
- break
- except SystemError:
- log ("failed to configure network device %s when "
- "looking up host name", dev.get('device'))
-
- if not self.isConfigured:
- log ("no network devices were availabe to look up host name")
- return None
-
- f = open("/etc/resolv.conf", "w")
- f.write("nameserver %s\n" % self.primaryNS)
- f.close()
- isys.resetResolv()
- isys.setResolvRetry(2)
-
- try:
- ip = socket.gethostbyname(self.hostname)
- except:
- return None
-
- return ip
-
- def nameservers (self):
- return [ self.primaryNS, self.secondaryNS, self.ternaryNS ]
-
-class Password:
- def __init__ (self):
- self.crypt = None
- self.pure = None
-
- def getPure(self):
- return self.pure
-
- def set (self, password, isCrypted = 0):
- if isCrypted:
- self.crypt = password
- self.pure = None
- else:
- salt = (whrandom.choice (string.letters +
- string.digits + './') +
- whrandom.choice (string.letters +
- string.digits + './'))
- self.crypt = crypt.crypt (password, salt)
- self.pure = password
-
- def getCrypted(self):
- return self.crypt
-
-class Desktop (SimpleConfigFile):
- def __init__ (self):
- SimpleConfigFile.__init__ (self)
-
- def set (self, desktop):
- self.info ['DESKTOP'] = desktop
-
-def expandLangs(str):
- langs = [str]
- # remove charset ...
- if '.' in str:
- langs.append(string.split(str, '.')[0])
-
- if '@' in str:
- langs.append(string.split(str, '@')[0])
-
- # also add 2 character language code ...
- if len(str) > 2:
- langs.append(str[:2])
-
- return langs
-
-class InstallTimeLanguage:
-
- def __init__ (self):
- if os.access("lang-table", os.R_OK):
- f = open("lang-table", "r")
- elif os.access("/etc/lang-table", os.R_OK):
- f = open("/etc/lang-table", "r")
- else:
- f = open("/usr/lib/anaconda/lang-table", "r")
-
- lines = f.readlines ()
- f.close()
- self.langNicks = {}
- self.font = {}
- self.map = {}
- self.kbd = {}
- self.tz = {}
- self.langList = []
-
- self.tempDefault = ""
-
- for line in lines:
- string.strip(line)
- l = string.split(line)
-
- longName = l[0]
- font = l[2]
- map = l[3]
- shortName = l[4]
- keyboard = l[5]
- timezone = l[6]
-
- self.langList.append(longName)
- self.langNicks[longName] = shortName
- self.font[longName] = font
- self.map[longName] = map
- self.kbd[longName] = keyboard
- self.tz[longName] = timezone
-
- self.langList.sort()
-
- def getFontMap (self, lang):
- return self.map[lang]
-
- def getFontFile (self, lang):
- # Note: in /etc/fonts.cgz fonts are named by the map
- # name as that's unique, font names are not
- return self.font[lang]
-
- def getLangNick (self, lang):
- # returns the short locale ID
- return self.langNicks[lang]
-
- def getLangNameByNick(self, lang):
- # The nick we get here may be long (fr_FR@euro), when we need
- # shorter (fr_FR), so be a bit fuzzy
- for (langName, nick) in self.langNicks.items():
- if (nick == lang) or (nick == lang[0:len(nick)]):
- return langName
-
- raise KeyError, "language %s not found" % lang
-
- def getDefaultKeyboard(self):
- return self.kbd[self.getCurrent()]
-
- def getDefaultTimeZone(self):
- return self.tz[self.getCurrent()]
-
- def available (self):
- return self.langList
-
- def getCurrentLangSearchList(self):
- return expandLangs(self.langNicks[self.getCurrent()]) + ['C']
-
- def getCurrent(self):
- if os.environ.has_key('LANG'):
- what = os.environ['LANG']
- else:
- what = 'en_US'
- return self.getLangNameByNick(what)
-
- def setRuntimeLanguage(self, name):
- lang = self.langNicks[name]
-
- os.environ["LC_ALL"] = lang
- os.environ["LANG"] = lang
- os.environ["LC_NUMERIC"] = 'C'
-
- newlangs = [lang]
- if len(lang) > 2:
- newlangs.append(lang[:2])
- cat.setlangs (newlangs)
-
-class Language (SimpleConfigFile):
-
- def __init__ (self, useInstalledLangs):
- self.info = {}
- self.info["SUPPORTED"] = None
- self.supported = []
- self.default = None
-
- self.allSupportedLangs = []
- self.langInfoByName = {}
-
- allSupportedLangs = []
- langInfoByName = {}
- langFilter = {}
- allInstalledFlag = 0
-
- if useInstalledLangs:
- # load from /etc/sysconfig/i18n
- supported = None
- if os.access("/etc/sysconfig/i18n", os.R_OK):
- f = open("/etc/sysconfig/i18n")
- lines = f.readlines()
- f.close()
- for line in lines:
- if line[0:9] == "SUPPORTED":
- tmpstr = line[11:]
- supported = tmpstr[:string.find(tmpstr,'\"')]
- break
-
- # if no info on current system, with RH 7.1 this means ALL
- # languages were installed
- if not supported:
- allInstalledFlag = 1
- else:
- for lang in string.split(supported, ":"):
- langFilter[lang] = 1
-
- langsInstalled = []
- if os.access("/usr/share/anaconda/locale-list", os.R_OK):
- f = open("/usr/share/anaconda/locale-list")
- lines = f.readlines()
- f.close()
- for line in lines:
- line = string.strip(line)
- (lang, map, font, name) = string.split(line, ' ', 3)
- langInfoByName[name] = (lang, map, font)
- allSupportedLangs.append(name)
-
- if allInstalledFlag or (langFilter and langFilter.has_key(lang)):
- langsInstalled.append(name)
- else:
- langInfoByName['English (USA)'] = ('en_US', 'iso01', 'default8x16')
- allSupportedLangs.append('English (USA)')
- langsInstalled.append('English (USA)')
-
- self.langInfoByName = langInfoByName
- self.allSupportedLangs = allSupportedLangs
-
- # set languages which were selected at install time for reconfig mode
- if useInstalledLangs:
- self.setSupported(langsInstalled)
-
- def getAllSupported(self):
- return self.allSupportedLangs
-
- def getLangNameByNick(self, nick):
- for langName in self.langInfoByName.keys():
- (lang, map, font) = self.langInfoByName[langName]
- if (nick == lang) or (nick == lang[0:len(nick)]):
- return langName
-
- raise KeyError, "language %s not found" % nick
-
- def getLangNickByName(self, name):
- (lang, map, font) = self.langInfoByName[name]
- return lang
-
- def getSupported (self):
- return self.supported
-
- def getDefault (self):
- if self.default:
- return self.default
- elif os.environ.has_key('LANG'):
- lang = os.environ['LANG']
- name = self.getLangNameByNick(lang)
- if name not in self.getSupported():
- # the default language needs to be in the supported list!
- s = self.getSupported()
- s.append(name)
- s.sort()
- self.setSupported(s)
-
- return name
- else:
- return 'English (USA)'
-
- def setDefault(self, name):
- if not name:
- self.default = None
- return
-
- self.default = name
- (lang, map, font) = self.langInfoByName[name]
-
- self.info['LANG'] = lang
- self.info['SYSFONT'] = font
- self.info['SYSFONTACM'] = map
-
- def setSupported (self, langlist):
- if len(langlist) == len(self.allSupportedLangs):
- self.info["SUPPORTED"] = None
- self.supported = langlist
- rpm.delMacro ("_install_langs")
- elif langlist:
- rpmNickList = []
- for name in langlist:
- (lang, map, font) = self.langInfoByName[name]
- rpmNickList = rpmNickList + expandLangs(lang)
-
- linguas = string.join (rpmNickList, ':')
- self.info["SUPPORTED"] = linguas
- self.supported = langlist
-
- shortLinguas = string.join (rpmNickList, ':')
- rpm.addMacro("_install_langs", shortLinguas)
- else:
- self.info["SUPPORTED"] = None
- rpm.delMacro ("_install_langs")
- self.supported = None
-
- if self.info["SUPPORTED"]:
- os.environ ["LINGUAS"] = self.info["SUPPORTED"]
- else:
- os.environ ["LINGUAS"] = ""
-
-class Firewall:
- def __init__ (self):
- self.enabled = -1
- self.ssh = 0
- self.telnet = 0
- self.smtp = 0
- self.http = 0
- self.ftp = 0
- self.portlist = ""
- self.ports = []
- self.policy = 0
- self.dhcp = 0
- self.trustdevs = []
-
-class Authentication:
- def __init__ (self):
- self.useShadow = 1
- self.useMD5 = 1
-
- self.useNIS = 0
- self.nisDomain = ""
- self.nisuseBroadcast = 1
- self.nisServer = ""
-
- self.useLdap = 0
- self.useLdapauth = 0
- self.ldapServer = ""
- self.ldapBasedn = ""
- self.ldapTLS = ""
-
- self.useKrb5 = 0
- self.krb5Realm = ""
- self.krb5Kdc = ""
- self.krb5Admin = ""
-
- self.useHesiod = 0
- self.hesiodDlhs = ""
- self.hesiodRhs = ""
-
-class InstSyslog:
- def __init__ (self, root, log):
- self.pid = os.fork ()
- if not self.pid:
- if os.access ("./anaconda", os.X_OK):
- path = "./anaconda"
- elif os.access ("/usr/bin/anaconda.real", os.X_OK):
- path = "/usr/bin/anaconda.real"
- else:
- path = "/usr/bin/anaconda"
- os.execv (path, ("syslogd", "--syslogd", root, log))
-
- def __del__ (self):
- os.kill (self.pid, 15)
- os.wait (self.pid)
-
-class ToDo:
- def __init__(self, intf, method, rootPath, setupFilesystems = 1,
- installSystem = 1, mouse = None, instClass = None, x = None,
- expert = 0, serial = 0, reconfigOnly = 0, test = 0,
- extraModules = []):
- self.intf = intf
- self.method = method
- self.hdList = None
- self.comps = None
- self.instPath = rootPath
- self.setupFilesystems = setupFilesystems
- self.installSystem = installSystem
- self.instTimeLanguage = InstallTimeLanguage ()
- self.language = Language (reconfigOnly)
- self.serial = serial
- self.reconfigOnly = reconfigOnly
- self.network = Network ()
- self.rootpassword = Password ()
- self.extraModules = extraModules
- self.verifiedState = None
-
- if mouse:
- self.mouse = mouse
- else:
- self.mouse = Mouse ()
-
- self.keyboard = Keyboard ()
- self.deadkeyState = ""
- self.auth = Authentication ()
- self.firewall = Firewall()
- self.ddruidReadOnly = 0
- self.bootdisk = 1
- self.bdstate = ""
-
- log.open (serial, reconfigOnly, test, setupFilesystems)
-
- self.fstab = None
-
- # liloDevice, liloLinear, liloAppend are initialized form the
- # default install class
- arch = iutil.getArch ()
- self.lilo = LiloConfiguration()
- if arch == "sparc":
- self.silo = SiloInstall (self.serial)
- elif arch == "alpha":
- self.milo = MiloInstall (self)
- elif arch == "ia64":
- self.elilo = EliloConfiguration ()
- self.timezone = None
- self.upgrade = 0
- self.ddruidAlreadySaved = 0
- self.initlevel = 3
- self.expert = expert
- self.progressWindow = None
- self.fdDevice = None
- self.lilostate = ""
- self.videoCardOriginalName = ""
- self.videoCardOriginalNode = ""
- self.isDDC = ""
- self.videoCardStateName = ""
- self.videoCardStateNode = ""
- self.videoRamState = ""
- self.videoRamOriginal = ""
- self.monitorOriginalName = ""
- self.monitorOriginalNode = ""
- self.monitorHsync = ""
- self.monitorVsync = ""
- self.monitorHsyncState = ""
- self.monitorVsyncState = ""
- self.probedFlag = ""
- self.resState = ""
- self.depthState = ""
- self.initState = 0
- self.dhcpState = ""
- self.firewallState = 0
- self.rebuildTime = None
-
- # If reconfig mode, don't probe floppy
- if self.reconfigOnly != 1:
- self.setFdDevice()
-
- if (not instClass):
- raise TypeError, "installation class expected"
- if x:
- self.x = x
- self.x.setMouse (self.mouse)
- else:
- self.x = XF86Config (mouse = self.mouse)
-
- # This absolutely, positively MUST BE LAST
- self.setClass(instClass)
-
- def setFdDevice(self):
- if self.fdDevice:
- return
-
- self.fdDevice = "fd0"
- if iutil.getArch() == "sparc":
- try:
- f = open(self.fdDevice, "r")
- except IOError, (errnum, msg):
- if errno.errorcode[errnum] == 'ENXIO':
- self.fdDevice = "fd1"
- else:
- f.close()
- elif iutil.getArch() == "alpha":
- pass
- elif iutil.getArch() == "i386" or iutil.getArch() == "ia64":
- # Look for the first IDE floppy device
- drives = isys.floppyDriveDict()
- if not drives:
- log("no IDE floppy devices found")
- return 0
-
- floppyDrive = drives.keys()[0]
- # need to go through and find if there is an LS-120
- for dev in drives.keys():
- if re.compile(".*[Ll][Ss]-120.*").search(drives[dev]):
- floppyDrive = dev
-
- # No IDE floppy's -- we're fine w/ /dev/fd0
- if not floppyDrive: return
-
- if iutil.getArch() == "ia64":
- self.fdDevice = floppyDrive
- log("anaconda floppy device is %s", self.fdDevice)
- return
-
- # Look in syslog for a real fd0 (which would take precedence)
- try:
- f = open("/tmp/syslog", "r")
- except IOError:
- return
- for line in f.readlines():
- # chop off the loglevel (which init's syslog leaves behind)
- line = line[3:]
- match = "Floppy drive(s): "
- if match == line[:len(match)]:
- # Good enough
- floppyDrive = "fd0"
- break
-
- self.fdDevice = floppyDrive
- else:
- raise SystemError, "cannot determine floppy device for this arch"
-
- log("anaconda floppy device is %s", self.fdDevice)
-
- def writeTimezone(self):
- if (self.timezone):
- (timezone, asUtc, asArc) = self.timezone
- fromFile = self.instPath + "/usr/share/zoneinfo/" + timezone
-
- try:
- iutil.copyFile(fromFile, self.instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log ("Error copying timezone (from %s): %s" % (fromFile, msg))
- else:
- asUtc = 0
- asArc = 0
-
- f = open(self.instPath + "/etc/sysconfig/clock", "w")
- f.write('ZONE="%s"\n' % timezone)
- f.write("UTC=")
- if (asUtc):
- f.write("true\n")
- else:
- f.write("false\n")
-
- f.write("ARC=")
- if (asArc):
- f.write("true\n")
- else:
- f.write("false\n")
- f.close()
-
- def getTimezoneInfo(self):
- return self.timezone
-
- def setTimezoneInfo(self, timezone, asUtc = 0, asArc = 0):
- self.timezone = (timezone, asUtc, asArc)
-
- def writeLanguage(self):
- f = open(self.instPath + "/etc/sysconfig/i18n", "w")
- f.write(str (self.language))
- f.close()
-
- def writeMouse(self):
- if self.serial: return
- f = open(self.instPath + "/etc/sysconfig/mouse", "w")
- f.write(str (self.mouse))
- f.close()
- self.mouse.makeLink(self.instPath)
-
- def writeDesktop(self):
- desktop = Desktop ()
- desktop.set (self.instClass.getDesktop())
- f = open(self.instPath + "/etc/sysconfig/desktop", "w")
- f.write(str (desktop))
- f.close()
-
- def writeKeyboard(self):
- if self.serial: return
- f = open(self.instPath + "/etc/sysconfig/keyboard", "w")
- f.write(str (self.keyboard))
- f.close()
-
- def needBootdisk (self):
- if self.bootdisk or self.fstab.rootOnLoop(): return 1
-
- def makeBootdisk (self):
- # this is faster then waiting on mkbootdisk to fail
- device = self.fdDevice
- file = "/tmp/floppy"
- isys.makeDevInode(device, file)
- try:
- fd = os.open(file, os.O_RDONLY)
- except:
- raise RuntimeError, "boot disk creation failed"
- os.close(fd)
-
- kernel = self.hdList['kernel']
- kernelTag = "-%s-%s" % (kernel[rpm.RPMTAG_VERSION],
- kernel[rpm.RPMTAG_RELEASE])
-
- w = self.intf.waitWindow (_("Creating"), _("Creating boot disk..."))
- rc = iutil.execWithRedirect("/sbin/mkbootdisk",
- [ "/sbin/mkbootdisk",
- "--noprompt",
- "--device",
- "/dev/" + self.fdDevice,
- kernelTag[1:] ],
- stdout = '/dev/tty5', stderr = '/dev/tty5',
- searchPath = 1, root = self.instPath)
- w.pop()
- if rc:
- raise RuntimeError, "boot disk creation failed"
-
- def freeHeaderList(self):
- if (self.hdList):
- self.hdList = None
-
- def getHeaderList(self):
- if (not self.hdList):
- w = self.intf.waitWindow(_("Reading"),
- _("Reading package information..."))
- self.hdList = self.method.readHeaders()
- w.pop()
- return self.hdList
-
- def getCompsList(self):
- if not self.comps:
- self.getHeaderList()
- self.comps = self.method.readComps(self.hdList)
- self.updateInstClassComps ()
- else:
- # re-evaluate all the expressions for packages with qualifiers.
- self.comps.updateSelections()
-
- return self.comps
-
- def updateInstClassComps(self):
- # don't load it just for this
- if not self.comps: return
-
-
- group = self.instClass.getGroups()
- optional = self.instClass.getOptionalGroups()
- packages = self.instClass.getPackages()
- for comp in self.comps:
- comp.unselect()
-
- if group == None and packages == None:
- # this comp has no special groups, set up the defaults
- # and exit
- for comp in self.comps:
- comp.setDefaultSelection()
- return
-
- self.comps['Base'].select()
- if group:
- for n in group:
- self.comps[n].select()
-
- if optional:
- for n in optional:
- if type((1,)) == type(n):
- (on, n) = n
- if (on):
- self.comps[n].select()
- else:
- self.comps[n].setDefaultSelection()
-
- if packages:
- for n in packages:
- self.selectPackage(n)
-
-
- if self.hdList.packages.has_key('XFree86') and self.hdList.packages['XFree86'].selected:
- log ("X is being installed, need to enable server if set")
- if self.x.server and not self.x.server == "XFree86":
- log("enabling server %s" % self.x.server)
- try:
- self.selectPackage ('XFree86-' + self.x.server[5:])
- except ValueError, message:
- log ("Error selecting XFree86 server package: %s", message)
-
- def selectPackage(self, package):
- if not self.hdList.packages.has_key(package):
- str = "package %s is not available" % (package,)
- raise ValueError, str
- self.hdList.packages[package].selected = 1
-
- def writeNetworkConfig (self):
- # /etc/sysconfig/network-scripts/ifcfg-*
- for dev in self.network.netdevices.values ():
- device = dev.get ("device")
- fn = self.instPath + "/etc/sysconfig/network-scripts/ifcfg-" + device
- f = open (fn, "w")
- os.chmod(fn, 0600)
- f.write (str (dev))
- f.close ()
-
- # /etc/sysconfig/network
-
- f = open (self.instPath + "/etc/sysconfig/network", "w")
- f.write ("NETWORKING=yes\n"
- "HOSTNAME=")
-
-
- # use instclass hostname if set (kickstart) to override
- if self.instClass.getHostname():
- f.write(self.instClass.getHostname() + "\n")
- elif self.network.hostname:
- f.write(self.network.hostname + "\n")
- else:
- f.write("localhost.localdomain" + "\n")
- if self.network.gateway:
- f.write("GATEWAY=" + self.network.gateway + "\n")
- f.close ()
-
- # /etc/hosts
- f = open (self.instPath + "/etc/hosts", "w")
- localline = "127.0.0.1\t\t"
-
- log ("self.network.hostname = %s", self.network.hostname)
-
- ip = self.network.lookupHostname()
-
- # If the hostname is not resolvable, tie it to 127.0.0.1
- if not ip and self.network.hostname != "localhost.localdomain":
- localline = localline + self.network.hostname + " "
- l = string.split(self.network.hostname, ".")
- if len(l) > 1:
- localline = localline + l[0] + " "
-
- localline = localline + "localhost.localdomain localhost\n"
- f.write("# Do not remove the following line, or various programs\n")
- f.write("# that require network functionality will fail.\n")
- f.write (localline)
-
- if ip:
- f.write ("%s\t\t%s\n" % (ip, self.network.hostname))
-
- # If the hostname was not looked up, but typed in by the user,
- # domain might not be computed, so do it now.
- if self.network.domains == [ "localdomain" ] or not self.network.domains:
- if '.' in self.network.hostname:
- # chop off everything before the leading '.'
- domain = self.network.hostname[(string.find(self.network.hostname, '.') + 1):]
- self.network.domains = [ domain ]
-
- # /etc/resolv.conf
- f = open (self.instPath + "/etc/resolv.conf", "w")
-
- if self.network.domains != [ 'localdomain' ] and self.network.domains:
- f.write ("search " + string.joinfields (self.network.domains, ' ')
- + "\n")
-
- for ns in self.network.nameservers ():
- if ns:
- f.write ("nameserver " + ns + "\n")
-
- f.close ()
-
- def writeRootPassword (self):
- pure = self.rootpassword.getPure()
- if pure:
- self.setPassword("root", pure)
- else:
- self.setPassword("root", self.rootpassword.getCrypted (),
- alreadyCrypted = 1)
-
- def setupFirewall (self):
- args = [ "/usr/sbin/lokkit", "--quiet", "--nostart" ]
- if self.firewall.policy:
- args.append ("--medium")
- else:
- args.append ("--high")
- if self.firewall.dhcp:
- args.append ("--dhcp")
- if self.firewall.portlist:
- ports = string.split(self.firewall.portlist,',')
- for port in ports:
- port = string.strip(port)
- try:
- if not string.index(port,':'):
- port = '%s:tcp' % port
- except:
- pass
- self.firewall.ports.append(port)
- for port in self.firewall.ports:
- args = args + [ "--port", port ]
- if self.firewall.smtp:
- args = args + [ "--port","smtp:tcp" ]
- if self.firewall.http:
- args = args + [ "--port","http:tcp" ]
- if self.firewall.ftp:
- args = args + [ "--port","ftp:tcp" ]
- if self.firewall.ssh:
- args = args + [ "--port","ssh:tcp" ]
- if self.firewall.telnet:
- args = args + [ "--port","telnet:tcp" ]
- for dev in self.firewall.trustdevs:
- args = args + [ "--trust", dev ]
- if self.firewall.enabled > 0:
- try:
- iutil.execWithRedirect(args[0], args, root = self.instPath,
- stdout = None, stderr = None)
- except RuntimeError, msg:
- log ("lokkit run failed: %s", msg)
- except OSError, (errno, msg):
- log ("lokkit run failed: %s", msg)
- elif self.reconfigOnly:
- # remove /etc/sysconfig/ipchains
- try:
- os.remove("/etc/sysconfig/ipchains")
- except:
- pass
-
- def setupAuthentication (self):
- args = [ "/usr/sbin/authconfig", "--kickstart", "--nostart" ]
- if self.auth.useShadow:
- args.append ("--enableshadow")
- else:
- args.append ("--disableshadow")
-
- if self.auth.useMD5:
- args.append ("--enablemd5")
- else:
- args.append ("--disablemd5")
-
-
- if self.auth.useNIS:
- args.append ("--enablenis")
- args.append ("--nisdomain")
- args.append (self.auth.nisDomain)
- if not self.auth.nisuseBroadcast:
- args.append ("--nisserver")
- args.append (self.auth.nisServer)
- else:
- args.append ("--disablenis")
-
- if self.auth.useLdap:
- args.append ("--enableldap")
- else:
- args.append ("--disableldap")
- if self.auth.useLdapauth:
- args.append ("--enableldapauth")
- else:
- args.append ("--disableldapauth")
- if self.auth.useLdap or self.auth.useLdapauth:
- args.append ("--ldapserver")
- args.append (self.auth.ldapServer)
- args.append ("--ldapbasedn")
- args.append (self.auth.ldapBasedn)
- if self.auth.ldapTLS:
- args.append ("--enableldaptls")
- else:
- args.append ("--disableldaptls")
-
- if self.auth.useKrb5:
- args.append ("--enablekrb5")
- args.append ("--krb5realm")
- args.append (self.auth.krb5Realm)
- args.append ("--krb5kdc")
- args.append (self.auth.krb5Kdc)
- args.append ("--krb5adminserver")
- args.append (self.auth.krb5Admin)
- else:
- args.append ("--disablekrb5")
-
- if self.auth.useHesiod:
- args.append ("--enablehesiod")
- args.append ("--hesiodlhs")
- args.append (self.auth.hesiodLhs)
- args.append ("--hesiodrhs")
- args.append (self.auth.hesiodRhs)
- else:
- args.append ("--disablehesiod")
-
- try:
- iutil.execWithRedirect(args[0], args,
- stdout = None, stderr = None,
- searchPath = 1,
- root = self.instPath)
- except RuntimeError, msg:
- log ("Error running %s: %s", args, msg)
-
- def copyConfModules (self):
- try:
- inf = open ("/tmp/modules.conf", "r")
- except:
- pass
- else:
- out = open (self.instPath + "/etc/modules.conf", "a")
- out.write (inf.read ())
-
- def verifyDeps (self):
- def formatRequire (name, version, flags):
- string = name
-
- if flags:
- if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER |
- rpm.RPMSENSE_EQUAL):
- string = string + " "
- if flags & rpm.RPMSENSE_LESS:
- string = string + "<"
- if flags & rpm.RPMSENSE_GREATER:
- string = string + ">"
- if flags & rpm.RPMSENSE_EQUAL:
- string = string + "="
- string = string + " %s" % version
- return string
-
- # if we still have the same packages selected, bail - we don't need to
- # do this again.
- if self.verifiedState == self.comps.getSelectionState()[1]:
- return
-
- self.verifiedState = None
-
- win = self.intf.waitWindow(_("Dependency Check"),
- _("Checking dependencies in packages selected for installation..."))
- self.getCompsList()
- if self.upgrade:
- # the partitions are already mounted
- db = rpm.opendb (0, self.instPath)
- ts = rpm.TransactionSet(self.instPath, db)
- else:
- ts = rpm.TransactionSet()
-
- if self.upgrade:
- how = 'u'
- else:
- how = 'i'
- for p in self.hdList.packages.values ():
- if p.selected:
- ts.add(p.h, (p.h, p.h[rpm.RPMTAG_NAME]), how)
- else:
- ts.add(p.h, (p.h, p.h[rpm.RPMTAG_NAME]), "a")
-
- deps = ts.depcheck()
- rc = []
- if deps:
- for ((name, version, release),
- (reqname, reqversion),
- flags, suggest, sense) in deps:
- if sense == rpm.RPMDEP_SENSE_REQUIRES:
- if suggest:
- (header, sugname) = suggest
- log ("depcheck: package %s needs %s (provided by %s)",
- name, formatRequire(reqname, reqversion, flags),
- sugname)
- else:
- log ("depcheck: package %s needs %s (not provided)",
- name, formatRequire(reqname, reqversion, flags))
- sugname = _("no suggestion")
- if not (name, sugname) in rc:
- rc.append ((name, sugname))
- elif sense == rpm.RPMDEP_SENSE_CONFLICTS:
- # We need to check if the one we are going to
- # install is ok.
- conflicts = 1
- if reqversion:
- fields = string.split(reqversion, '-')
- if (len (fields) == 2):
- needed = ("", fields [0], fields [1])
- else:
- needed = ("", fields [0], "")
- try:
- h = self.hdList[reqname].h
- except KeyError:
- conflicts = 0
- installed = ("", h[rpm.RPMTAG_VERSION],
- h [rpm.RPMTAG_RELEASE])
- if rpm.labelCompare (installed, needed) >= 0:
- conflicts = 0
-
- if conflicts:
- log ("%s-%s-%s conflicts with to-be-installed "
- "package %s-%s, removing from set",
- name, version, release, reqname, reqversion)
- if self.hdList.packages.has_key (reqname):
- self.hdList.packages[reqname].selected = 0
- log ("... removed")
-
- del ts
- if self.upgrade:
- del db
-
- win.pop()
-
- if not rc:
- self.verifiedState = self.comps.getSelectionState()[1]
-
- return rc
-
- def selectDeps (self, deps):
- if deps:
- for (who, dep) in deps:
- if dep != _("no suggestion"):
- try:
- self.hdList[dep].select ()
- except KeyError:
- pass
-
- def unselectDeps (self, deps):
- if deps:
- for (who, dep) in deps:
- if dep != _("no suggestion"):
- try:
- self.hdList[dep].unselect ()
- except KeyError:
- pass
-
- def selectDepCause (self, deps):
- if deps:
- for (who, dep) in deps:
- try:
- self.hdList[who].select ()
- except KeyError:
- pass
-
- def unselectDepCause (self, deps):
- if deps:
- for (who, dep) in deps:
- try:
- self.hdList[who].unselect ()
- except KeyError:
- pass
-
- def canResolveDeps (self, deps):
- canresolve = 0
- if deps:
- for (who, dep) in deps:
- if dep != _("no suggestion"):
- canresolve = 1
- return canresolve
-
- def upgradeFindRoot(self):
- if not self.setupFilesystems: return [ (self.instPath, 'ext2') ]
- return upgrade.findExistingRoots(self.intf, self.fstab)
-
- def upgradeMountFilesystems(self, rootInfo):
- # mount everything and turn on swap
-
- if self.setupFilesystems:
- try:
- upgrade.mountRootPartition(self.intf,rootInfo,
- self.fstab, self.instPath,
- allowDirty = 0)
- except SystemError, msg:
- self.intf.messageWindow(_("Dirty Filesystems"),
- _("One or more of the filesystems listed in the "
- "/etc/fstab on your Linux system cannot be mounted. "
- "Please fix this problem and try to upgrade again."))
- sys.exit(0)
-
- checkLinks = [ '/etc', '/var', '/var/lib', '/var/lib/rpm',
- '/boot', '/tmp', '/var/tmp' ]
- badLinks = []
- for n in checkLinks:
- if not os.path.islink(self.instPath + n): continue
- l = os.readlink(self.instPath + n)
- if l[0] == '/':
- badLinks.append(n)
-
- if badLinks:
- message = _("The following files are absolute symbolic "
- "links, which we do not support during an "
- "upgrade. Please change them to relative "
- "symbolic links and restart the upgrade.\n\n")
- for n in badLinks:
- message = message + '\t' + n + '\n'
- self.intf.messageWindow(("Absolute Symlinks"), message)
- sys.exit(0)
- else:
- fstab.readFstab(self.instPath + '/etc/fstab', self.fstab)
-
-
- self.fstab.turnOnSwap(self.instPath, formatSwap = 0)
-
- def upgradeFindPackages (self):
- if not self.rebuildTime:
- self.rebuildTime = str(int(time.time()))
- self.getCompsList ()
- self.getHeaderList ()
- self.method.mergeFullHeaders(self.hdList)
-
- win = self.intf.waitWindow (_("Finding"),
- _("Finding packages to upgrade..."))
-
- self.dbpath = "/var/lib/anaconda-rebuilddb" + self.rebuildTime
- rpm.addMacro("_dbpath_rebuild", self.dbpath)
- rpm.addMacro("_dbapi", "-1")
-
- # now, set the system clock so the timestamps will be right:
- iutil.setClock (self.instPath)
-
- # and rebuild the database so we can run the dependency problem
- # sets against the on disk db
- rc = rpm.rebuilddb (self.instPath)
- if rc:
- iutil.rmrf (self.instPath + "/var/lib/anaconda-rebuilddb"
- + self.rebuildTime)
- win.pop()
- self.intf.messageWindow(_("Error"),
- _("Rebuild of RPM database failed. "
- "You may be out of disk space?"))
- if self.setupFilesystems:
- self.fstab.umountFilesystems (self.instPath)
- sys.exit(0)
-
- rpm.addMacro("_dbpath", self.dbpath)
- rpm.addMacro("_dbapi", "3")
- try:
- packages = rpm.findUpgradeSet (self.hdList.hdlist, self.instPath)
- except rpm.error:
- iutil.rmrf (self.instPath + "/var/lib/anaconda-rebuilddb"
- + self.rebuildTime)
- win.pop()
- self.intf.messageWindow(_("Error"),
- _("An error occured when finding the packages to "
- "upgrade."))
- if self.setupFilesystems:
- self.fstab.umountFilesystems (self.instPath)
- sys.exit(0)
-
- # Turn off all comps
- for comp in self.comps:
- comp.unselect()
-
- # unselect all packages
- for package in self.hdList.packages.values ():
- package.selected = 0
-
- hasX = 0
- hasFileManager = 0
- # turn on the packages in the upgrade set
- for package in packages:
- self.hdList[package[rpm.RPMTAG_NAME]].select()
- if package[rpm.RPMTAG_NAME] == "XFree86":
- hasX = 1
- if package[rpm.RPMTAG_NAME] == "gmc":
- hasFileManager = 1
- if package[rpm.RPMTAG_NAME] == "kdebase":
- hasFileManager = 1
-
- # open up the database to check dependencies
- db = rpm.opendb (0, self.instPath)
-
- # if we have X but not gmc, we need to turn on GNOME. We only
- # want to turn on packages we don't have installed already, though.
- if hasX and not hasFileManager:
- log ("Has X but no desktop -- Installing GNOME")
- for package in self.comps['GNOME'].pkgs:
- try:
- rec = db.findbyname (package.name)
- except rpm.error:
- rec = None
- if not rec:
- log ("GNOME: Adding %s", package)
- package.select()
-
- del db
-
- # new package dependency fixup
- deps = self.verifyDeps ()
- loops = 0
- while deps and self.canResolveDeps (deps) and loops < 10:
- for (name, suggest) in deps:
- if name != _("no suggestion"):
- log ("Upgrade Dependency: %s needs %s, "
- "automatically added.", name, suggest)
- self.selectDeps (deps)
- deps = self.verifyDeps ()
- loops = loops + 1
-
- win.pop ()
-
- def rpmError (todo):
- todo.instLog.write (rpm.errorString () + "\n")
-
- def getClass(todo):
- return todo.instClass
-
- def setClass(todo, instClass):
- todo.instClass = instClass
- todo.hostname = todo.instClass.getHostname()
- todo.updateInstClassComps()
- ( enable, policy, trusts, ports, dhcp, ssh,
- telnet, smtp, http, ftp ) = todo.instClass.getFirewall()
-
- todo.firewall.enabled = enable
- todo.firewall.policy = policy
- todo.firewall.trustdevs = trusts
- todo.firewall.portlist = ports
- todo.firewall.dhcp = dhcp
- todo.firewall.ssh = ssh
- todo.firewall.telnet = telnet
- todo.firewall.smtp = smtp
- todo.firewall.http = http
- todo.firewall.ftp = ftp
-
- ( useShadow, useMd5,
- useNIS, nisDomain, nisBroadcast, nisServer,
- useLdap, useLdapauth, ldapServer, ldapBasedn,
- useKrb5, krb5Realm, krb5Kdc, krb5Admin,
- useHesiod, hesiodLhs, hesiodRhs) = todo.instClass.getAuthentication()
-
- todo.auth.useShadow = useShadow
- todo.auth.useMD5 = useMd5
- todo.auth.useNIS = useNIS
- todo.auth.nisDomain = nisDomain
- todo.auth.nisuseBroadcast = nisBroadcast
- todo.auth.nisServer = nisServer
- todo.auth.useLdap = useLdap
- todo.auth.useLdapauth = useLdapauth
- todo.auth.ldapServer = ldapServer
- todo.auth.ldapBasedn = ldapBasedn
- todo.auth.useKrb5 = useKrb5
- todo.auth.krb5Realm = krb5Realm
- todo.auth.krb5Kdc = krb5Kdc
- todo.auth.krb5Admin = krb5Admin
- todo.auth.useHesiod = useHesiod
- todo.auth.hesiodLhs = hesiodLhs
- todo.auth.hesiodRhs = hesiodRhs
-
- todo.timezone = instClass.getTimezoneInfo()
- todo.bootdisk = todo.instClass.getMakeBootdisk()
- todo.zeroMbr = todo.instClass.zeroMbr
- (where, linear, append) = todo.instClass.getLiloInformation()
-
- arch = iutil.getArch ()
- if arch == "i386":
- todo.lilo.setDevice(where)
- todo.lilo.setLinear(linear)
- if append: todo.lilo.setAppend(append)
- elif arch == "sparc":
- todo.silo.setDevice(where)
- todo.silo.setAppend(append)
-
- todo.users = []
- if todo.instClass.rootPassword:
- todo.rootpassword.set(todo.instClass.rootPassword,
- isCrypted = todo.instClass.rootPasswordCrypted)
-
- if todo.instClass.language:
- langName = todo.language.getLangNameByNick(todo.instClass.language)
- if todo.instClass.langsupported != None:
- todo.language.setSupported([langName])
- if not todo.instClass.langdefault:
- todo.language.setDefault(langName)
- instLangName = todo.instTimeLanguage.getLangNameByNick(todo.instClass.language)
- todo.instTimeLanguage.setRuntimeLanguage(instLangName)
-
- if todo.instClass.langsupported != None:
- if len (todo.instClass.langsupported) == 0:
- all = todo.language.getAllSupported()
- todo.language.setSupported(all)
- else:
- newlist = []
- for lang in todo.instClass.langsupported:
- newlist.append(todo.language.getLangNameByNick(lang))
- todo.language.setSupported(newlist)
-
- if todo.instClass.langdefault:
- todo.language.setDefault(todo.language.getLangNameByNick(
- todo.instClass.langdefault))
-
- if todo.instClass.keyboard:
- todo.keyboard.set(todo.instClass.keyboard)
- if todo.instClass.keyboard != "us":
- xkb = todo.keyboard.getXKB ()
-
- if xkb:
- apply (todo.x.setKeyboard, xkb)
-
- # hack - apply to instclass preset if present as well
- if (todo.instClass.x):
- apply (todo.instClass.x.setKeyboard, xkb)
-
- (bootProto, ip, netmask, gateway, nameserver, netDevice) = \
- todo.instClass.getNetwork()
- if bootProto:
- todo.network.gateway = gateway
- todo.network.primaryNS = nameserver
-
- devices = todo.network.available ()
- if (devices and bootProto):
- if not netDevice:
- list = devices.keys ()
- list.sort()
- netDevice = list[0]
- dev = devices[netDevice]
- dev.set (("bootproto", bootProto))
- dev.set (("onboot", "yes"))
- if bootProto == "static":
- if (ip):
- dev.set (("ipaddr", ip))
- if (netmask):
- dev.set (("netmask", netmask))
-
- if (todo.instClass.x):
- todo.x = todo.instClass.x
-
- if (todo.instClass.mouse):
- (type, device, emulateThreeButtons) = todo.instClass.mouse
- todo.mouse.set(type, emulateThreeButtons, thedev = device)
- todo.x.setMouse(todo.mouse)
-
- # this is messy, needed for upgradeonly install class
- if todo.instClass.installType == "upgrade":
- todo.upgrade = 1
-
- def getPartitionWarningText(self):
- return self.instClass.clearPartText
-
- # List of (accountName, fullName, password) tupes
- def setUserList(todo, users):
- todo.users = users
-
- def getUserList(todo):
- return todo.users
-
- def setPassword(self, account, password, alreadyCrypted = 0):
- if not alreadyCrypted:
- if self.auth.useMD5:
- salt = "$1$"
- saltLen = 8
- else:
- salt = ""
- saltLen = 2
-
- for i in range(saltLen):
- salt = salt + whrandom.choice (string.letters +
- string.digits + './')
-
- password = crypt.crypt (password, salt)
-
- devnull = os.open("/dev/null", os.O_RDWR)
-
- argv = [ "/usr/sbin/usermod", "-p", password, account ]
- iutil.execWithRedirect(argv[0], argv, root = self.instPath,
- stdout = '/dev/null', stderr = None)
- os.close(devnull)
-
- def createAccounts(todo):
- if not todo.users: return
-
- for (account, name, password) in todo.users:
- devnull = os.open("/dev/null", os.O_RDWR)
-
- argv = [ "/usr/sbin/useradd", account ]
- iutil.execWithRedirect(argv[0], argv, root = todo.instPath,
- stdout = devnull)
-
- argv = [ "/usr/bin/chfn", "-f", name, account]
- iutil.execWithRedirect(argv[0], argv, root = todo.instPath,
- stdout = devnull)
-
- todo.setPassword(account, password)
-
- os.close(devnull)
-
- def setDefaultRunlevel (self):
- try:
- inittab = open (self.instPath + '/etc/inittab', 'r')
- except IOError:
- log ("WARNING, there is no inittab, bad things will happen!")
- return
- lines = inittab.readlines ()
- inittab.close ()
- inittab = open (self.instPath + '/etc/inittab', 'w')
- for line in lines:
- if len (line) > 3 and line[:3] == "id:":
- fields = string.split (line, ':')
- fields[1] = str (self.initlevel)
- line = string.join (fields, ':')
- inittab.write (line)
- inittab.close ()
-
- def migrateXinetd(self):
- if not os.access (self.instPath + "/usr/sbin/inetdconvert", os.X_OK):
- log("did not find %s" % self.instPath + "/usr/sbin/inetdconvert")
- return
-
- if not os.access (self.instPath + "/etc/inetd.conf.rpmsave", os.R_OK):
- log("did not run inetdconvert because no inetd.conf.rpmsave found")
- return
-
- argv = [ "/usr/sbin/inetdconvert", "--convertremaining",
- "--inetdfile", "/etc/inetd.conf.rpmsave" ]
-
- log("found inetdconvert, executing %s" % argv)
-
- logfile = os.open (self.instLogName, os.O_APPEND)
- iutil.execWithRedirect(argv[0], argv, root = self.instPath,
- stdout = logfile, stderr = logfile)
- os.close(logfile)
-
- def instCallback(self, what, amount, total, h, (param)):
- (intf, messageWindow, pkgTimer) = param
- if (what == rpm.RPMCALLBACK_TRANS_START):
- # step 6 is the bulk of the transaction set
- # processing time
- if amount == 6:
- self.progressWindow = \
- self.intf.progressWindow (_("Processing"),
- _("Preparing to install..."),
- total)
- if (what == rpm.RPMCALLBACK_TRANS_PROGRESS):
- if self.progressWindow:
- self.progressWindow.set (amount)
-
- if (what == rpm.RPMCALLBACK_TRANS_STOP and self.progressWindow):
- self.progressWindow.pop ()
-
- if (what == rpm.RPMCALLBACK_INST_OPEN_FILE):
- # We don't want to start the timer until we get to the first
- # file.
- pkgTimer.start()
-
- intf.setPackage(h)
- intf.setPackageScale(0, 1)
- self.instLog.write (self.modeText % (h[rpm.RPMTAG_NAME],))
- self.instLog.flush ()
- fn = self.method.getFilename(h, pkgTimer)
-
- self.rpmFD = -1
- while self.rpmFD < 0:
- try:
- self.rpmFD = os.open(fn, os.O_RDONLY)
- # Make sure this package seems valid
- try:
- (h, isSource) = rpm.headerFromPackage(self.rpmFD)
- os.lseek(self.rpmFD, 0, 0)
- except:
- self.rpmFD = -1
- os.close(self.rpmFD)
- raise SystemError
- except:
- messageWindow(_("Error"),
- _("The file %s cannot be opened. This is due to "
- "a missing file, a bad package, or bad media. "
- "Press <return> to try again.") % fn)
-
- fn = self.method.unlinkFilename(fn)
- return self.rpmFD
- elif (what == rpm.RPMCALLBACK_INST_PROGRESS):
- if total:
- intf.setPackageScale(amount, total)
- elif (what == rpm.RPMCALLBACK_INST_CLOSE_FILE):
- os.close (self.rpmFD)
- intf.completePackage(h, pkgTimer)
- else:
- pass
-
- def kernelVersionList(self):
- kernelVersions = []
-
- for ktag in [ 'kernel-smp', 'kernel-enterprise' ]:
- tag = string.split(ktag, '-')[1]
- if (self.hdList.has_key(ktag) and
- self.hdList[ktag].selected):
- version = (self.hdList[ktag][rpm.RPMTAG_VERSION] + "-" +
- self.hdList[ktag][rpm.RPMTAG_RELEASE] + tag)
- kernelVersions.append(version)
-
- version = (self.hdList['kernel'][rpm.RPMTAG_VERSION] + "-" +
- self.hdList['kernel'][rpm.RPMTAG_RELEASE])
- kernelVersions.append(version)
-
- return kernelVersions
-
- def copyExtraModules(self):
- kernelVersions = self.kernelVersionList()
-
- for (path, subdir, name) in self.extraModules:
- pattern = ""
- names = ""
- for n in kernelVersions:
- pattern = pattern + " " + n + "/" + name + ".o"
- names = names + " " + name + ".o"
- command = ("cd %s/lib/modules; gunzip < %s/modules.cgz | " +
- "%s/bin/cpio --quiet -iumd %s") % \
- (self.instPath, path, self.instPath, pattern)
- log("running: '%s'" % (command, ))
- os.system(command)
-
- for n in kernelVersions:
- fromFile = "%s/lib/modules/%s/%s.o" % (self.instPath, n, name)
- toDir = "%s/lib/modules/%s/kernel/drivers/%s" % \
- (self.instPath, n, subdir)
- to = "%s/%s.o" % (toDir, name)
-
- if (os.access(fromFile, os.R_OK) and
- os.access(toDir, os.X_OK)):
- log("moving %s to %s" % (fromFile, to))
- os.rename(fromFile, to)
-
- # the file might not have been owned by root in the cgz
- os.chown(to, 0, 0)
- else:
- log("missing DD module %s (this may be okay)" %
- fromFile)
-
- def depmodModules(self):
- kernelVersions = self.kernelVersionList()
-
- for version in kernelVersions:
- iutil.execWithRedirect ("/sbin/depmod",
- [ "/sbin/depmod", "-a", version ],
- root = self.instPath, stderr = '/dev/null')
-
- def writeConfiguration(self):
- self.writeLanguage ()
- self.writeMouse ()
- self.writeKeyboard ()
- self.writeNetworkConfig ()
- self.setupAuthentication ()
- self.setupFirewall ()
- self.writeRootPassword ()
- self.createAccounts ()
-
- self.writeTimezone()
-
- def sortPackages(self, first, second):
- # install packages in cd order (cd tag is 1000002)
- one = None
- two = None
-
- if first[1000003] != None:
- one = first[1000003]
-
- if second[1000003] != None:
- two = second[1000003]
-
- if one == None or two == None:
- one = 0
- two = 0
- if first[1000002] != None:
- one = first[1000002]
-
- if second[1000002] != None:
- two = second[1000002]
-
- if one < two:
- return -1
- elif one > two:
- return 1
- elif string.lower(first[rpm.RPMTAG_NAME]) < string.lower(second[rpm.RPMTAG_NAME]):
- return -1
- elif string.lower(first[rpm.RPMTAG_NAME]) > string.lower(second[rpm.RPMTAG_NAME]):
- return 1
-
- return 0
-
- def doInstall(self):
- # make sure we have the header list and comps file
- self.getHeaderList()
- self.getCompsList()
-
- arch = iutil.getArch ()
-
- if arch == "alpha":
- # if were're on alpha with ARC console, set the clock
- # so that our installed files won't be in the future
- if onMILO ():
- args = ("clock", "-A", "-s")
- try:
- iutil.execWithRedirect('/usr/sbin/clock', args)
- except:
- pass
-
- if not self.upgrade:
- # this is NICE and LATE. It lets kickstart/server/workstation
- # installs detect this properly
- if (self.hdList.has_key('kernel-smp') and isys.smpAvailable()):
- self.hdList['kernel-smp'].selected = 1
-
- if (self.hdList.has_key('kernel-enterprise')):
- import lilo
-
- if lilo.needsEnterpriseKernel():
- self.hdList['kernel-enterprise'].selected = 1
-
- # we *always* need a kernel installed
- if (self.hdList.has_key('kernel')):
- self.hdList['kernel'].selected = 1
-
- # if NIS is configured, install ypbind and dependencies:
- if self.auth.useNIS:
- self.hdList['ypbind'].selected = 1
- self.hdList['yp-tools'].selected = 1
- self.hdList['portmap'].selected = 1
-
- if self.auth.useLdap:
- self.hdList['nss_ldap'].selected = 1
- self.hdList['openldap'].selected = 1
- self.hdList['perl'].selected = 1
-
- if self.auth.useKrb5:
- self.hdList['pam_krb5'].selected = 1
- self.hdList['krb5-workstation'].selected = 1
- self.hdList['krbafs'].selected = 1
- self.hdList['krb5-libs'].selected = 1
-
- if (self.x.server
- and self.hdList.packages.has_key('XFree86')
- and self.hdList.packages['XFree86'].selected
- and self.x.server != "XFree86"):
- # trim off the XF86_
- try:
- self.selectPackage ('XFree86-' + self.x.server[5:])
- except ValueError, message:
- log ("Error selecting XFree86 server package: %s", message)
-
- # make sure that all comps that include other comps are
- # selected (i.e. - recurse down the selected comps and turn
- # on the children
- if self.setupFilesystems:
- if not self.upgrade:
- if (self.ddruidAlreadySaved):
- self.fstab.makeFilesystems ()
- else:
- self.fstab.savePartitions ()
- self.fstab.makeFilesystems ()
- self.fstab.turnOnSwap(self.instPath)
-
- # We do this for upgrades, even though everything is already
- # mounted. While this may seem a bit strange, we reference
- # count the mounts, which is easier then special casing
- # the mount/unmounts all the way through
- self.fstab.mountFilesystems (self.instPath)
-
- self.method.mergeFullHeaders(self.hdList)
-
- if self.upgrade:
- # An old mtab can cause confusion (esp if loop devices are
- # in it)
- f = open(self.instPath + "/etc/mtab", "w+")
- f.close()
-
- if self.method.systemMounted (self.fstab, self.instPath, self.hdList.selected()):
- self.fstab.umountFilesystems(self.instPath)
- return 1
-
- if not self.installSystem:
- return
-
- for i in ( '/var', '/var/lib', '/var/lib/rpm', '/tmp', '/dev', '/etc',
- '/etc/sysconfig', '/etc/sysconfig/network-scripts',
- '/etc/X11' ):
- try:
- os.mkdir(self.instPath + i)
- except os.error, (errno, msg):
- # self.intf.messageWindow("Error", "Error making directory %s: %s" % (i, msg))
- pass
-
- db = rpm.opendb(1, self.instPath)
- ts = rpm.TransactionSet(self.instPath, db)
-
- total = 0
- totalSize = 0
-
- if self.upgrade:
- how = "u"
- else:
- how = "i"
-
- l = []
-
- for p in self.hdList.selected():
- l.append(p)
- l.sort(self.sortPackages)
-
- for p in l:
- ts.add(p.h, p.h, how)
- total = total + 1
- totalSize = totalSize + (p[rpm.RPMTAG_SIZE] / 1024 )
-
- if not self.hdList.preordered():
- log ("WARNING: not all packages in hdlist had order tag")
- ts.order()
-
- if self.upgrade:
- logname = '/tmp/upgrade.log'
- else:
- logname = '/tmp/install.log'
-
- self.instLogName = self.instPath + logname
- try:
- os.unlink (self.instLogName)
- except OSError:
- pass
- self.instLog = open(self.instLogName, "w+")
- syslog = InstSyslog (self.instPath, self.instPath + logname)
-
- ts.scriptFd = self.instLog.fileno ()
- # the transaction set dup()s the file descriptor and will close the
- # dup'd when we go out of scope
-
- p = self.intf.packageProgressWindow(total, totalSize)
-
- if self.upgrade:
- self.modeText = _("Upgrading %s.\n")
- else:
- self.modeText = _("Installing %s.\n")
-
- oldError = rpm.errorSetCallback (self.rpmError)
- pkgTimer = timer.Timer(start = 0)
-
- problems = ts.run(0, ~rpm.RPMPROB_FILTER_DISKSPACE,
- self.instCallback,
- (p, self.intf.messageWindow, pkgTimer))
-
-# problems = ts.run(rpm.RPMTRANS_FLAG_TEST, ~0,
-# self.instCallback, (p, self.intf.messageWindow))
-
- if problems:
- spaceneeded = {}
- nodeneeded = {}
- size = 12
-
- # XXX
- nodeprob = -1
- if rpm.__dict__.has_key ("RPMPROB_DISKNODES"):
- nodeprob = rpm.RPMPROB_DISKNODES
-
- for (descr, (type, mount, need)) in problems:
- idx = string.find (mount, "/mnt/sysimage")
- if mount[0:13] == "/mnt/sysimage":
- mount = mount[13:]
- if not mount:
- mount = '/'
-
- if type == rpm.RPMPROB_DISKSPACE:
- if spaceneeded.has_key (mount) and spaceneeded[mount] < need:
- spaceneeded[mount] = need
- else:
- spaceneeded[mount] = need
- elif type == nodeprob:
- if nodeneeded.has_key (mount) and nodeneeded[mount] < need:
- nodeneeded[mount] = need
- else:
- nodeneeded[mount] = need
- else:
- log ("WARNING: unhandled problem returned from transaction set type %d",
- type)
-
- probs = ""
- if spaceneeded:
- probs = probs + _("You don't appear to have enough disk space to install "
- "the packages you've selected. You need more space on the "
- "following filesystems:\n\n")
- probs = probs + ("%-15s %s\n") % (_("Mount Point"), _("Space Needed"))
-
- for (mount, need) in spaceneeded.items ():
- if need > (1024*1024):
- need = (need + 1024 * 1024 - 1) / (1024 * 1024)
- suffix = "M"
- else:
- need = (need + 1023) / 1024
- suffix = "k"
-
- prob = "%-15s %d %c\n" % (mount, need, suffix)
- probs = probs + prob
- if nodeneeded:
- if probs:
- probs = probs + '\n'
- probs = probs + _("You don't appear to have enough file nodes to install "
- "the packages you've selected. You need more file nodes on the "
- "following filesystems:\n\n")
- probs = probs + ("%-15s %s\n") % (_("Mount Point"), _("Nodes Needed"))
-
- for (mount, need) in nodeneeded.items ():
- prob = "%-15s %d\n" % (mount, need)
- probs = probs + prob
-
- self.intf.messageWindow (_("Disk Space"), probs)
-
- del ts
- del db
- self.instLog.close()
- del syslog
-
- self.method.systemUnmounted ()
- self.fstab.umountFilesystems(self.instPath)
-
- rpm.errorSetCallback (oldError)
- return 1
-
- # This should close the RPM database so that you can
- # do RPM ops in the chroot in a %post ks script
- del ts
- del db
- rpm.errorSetCallback (oldError)
-
- self.method.filesDone ()
-
- del p
-
- if self.upgrade:
- self.instLog.write ("\n\nThe following packages were available on the CD but NOT upgraded:\n")
- for p in self.hdList.packages.values ():
- if not p.selected:
- self.instLog.write("%s-%s-%s.%s.rpm\n" %
- (p.h[rpm.RPMTAG_NAME],
- p.h[rpm.RPMTAG_VERSION],
- p.h[rpm.RPMTAG_RELEASE],
- p.h[rpm.RPMTAG_ARCH]))
- self.instLog.close ()
-
- createWindow = (self.intf.progressWindow,
- (_("Post Install"),
- _("Performing post install configuration..."), 8))
- w = apply(apply, createWindow)
-
- try:
- if not self.upgrade:
- if self.fdDevice[0:2] == "fd":
- self.fstab.addMount(self.fdDevice, "/mnt/floppy", "auto")
-
- w.set(1)
-
- self.copyExtraModules()
- self.fstab.write (self.instPath)
- self.writeConfiguration ()
- self.writeDesktop ()
- if (self.instClass.defaultRunlevel):
- self.initlevel = self.instClass.defaultRunlevel
- self.setDefaultRunlevel ()
-
- w.set(2)
-
- # pcmcia is supported only on i386 at the moment
- if arch == "i386":
- pcmcia.createPcmciaConfig(
- self.instPath + "/etc/sysconfig/pcmcia")
-
- self.copyConfModules ()
- if not self.x.skip and self.x.server:
- if os.access (self.instPath + "/etc/X11/X", os.R_OK):
- os.rename (self.instPath + "/etc/X11/X",
- self.instPath + "/etc/X11/X.rpmsave")
- try:
- os.unlink (self.instPath + "/etc/X11/X")
- except OSError:
- pass
- os.symlink ("../../usr/X11R6/bin/" + self.x.server,
- self.instPath + "/etc/X11/X")
-
- self.x.write (self.instPath + "/etc/X11")
- self.setDefaultRunlevel ()
-
- w.set(3)
-
- # blah. If we're on a serial mouse, and we have X, we need to
- # close the mouse device, then run kudzu, then open it again.
-
- # turn it off
- mousedev = None
-
- # XXX currently Bad Things (X async reply) happen when doing
- # Mouse Magic on Sparc (Mach64, specificly)
- if os.environ.has_key ("DISPLAY") and not arch == "sparc":
- import xmouse
- try:
- mousedev = xmouse.get()[0]
- except RuntimeError:
- pass
-
- if mousedev:
- try:
- os.rename (mousedev, "/dev/disablemouse")
- except OSError:
- pass
- try:
- xmouse.reopen()
- except RuntimeError:
- pass
-
- log("Mounting /proc/bus/usb in install path")
- unmountUSB = 0
- try:
- isys.mount('/usbdevfs', self.instPath+'/proc/bus/usb', 'usbdevfs')
- log("Mount of USB succeeded")
- unmountUSB = 1
- except:
- log("Mount of USB failed")
- pass
-
-
- argv = [ "/usr/sbin/kudzu", "-q" ]
- devnull = os.open("/dev/null", os.O_RDWR)
- iutil.execWithRedirect(argv[0], argv, root = self.instPath,
- stdout = devnull)
- # turn it back on
- if mousedev:
- try:
- os.rename ("/dev/disablemouse", mousedev)
- except OSError:
- pass
- try:
- xmouse.reopen()
- except RuntimeError:
- pass
- if unmountUSB:
- isys.umount(self.instPath + '/proc/bus/usb', removeDir = 0)
-
- w.set(4)
-
- if self.upgrade:
- # move the rebuilt db into place.
- try:
- iutil.rmrf (self.instPath + "/var/lib/rpm.rpmsave")
- except OSError:
- pass
- os.rename (self.instPath + "/var/lib/rpm",
- self.instPath + "/var/lib/rpm.rpmsave")
- os.rename (self.instPath + self.dbpath,
- self.instPath + "/var/lib/rpm")
-
- # XXX - rpm 4.0.2 %post braindeadness support
- try:
- os.unlink (self.instPath + "/etc/rpm/macros.db1")
- except OSError:
- pass
-
- # needed for prior systems which were not xinetd based
- self.migrateXinetd()
-
- # XXX make me "not test mode"
- if self.setupFilesystems:
- errors = None
-
- if arch == "sparc":
- errors = self.silo.install (self.fstab, self.instPath,
- self.hdList, self.upgrade)
- elif arch == "i386":
- defaultlang = self.language.getLangNickByName(self.language.getDefault())
- langlist = expandLangs(defaultlang)
- errors = self.lilo.install (self.fstab, self.instPath,
- self.hdList, self.upgrade, langlist)
- elif arch == "ia64":
- errors = self.elilo.install (self.fstab, self.instPath,
- self.hdList, self.upgrade)
- elif arch == "alpha":
- errors = self.milo.write ()
- else:
- raise RuntimeError, "What kind of machine is this, anyway?!"
-
- if errors:
- w.pop()
- mess = _("An error occured while installing "
- "the bootloader.\n\n"
- "We HIGHLY recommend you make a recovery "
- "boot floppy when prompted, otherwise you "
- "may not be able to reboot into Red Hat Linux."
- "\n\nThe error reported was:\n\n") + errors
- self.intf.messageWindow(_("Bootloader Errors"), mess)
-
- # make sure bootdisk window appears
- if iutil.getArch () == "i386":
- self.instClass.removeFromSkipList('bootdisk')
- self.bootdisk = 1
-
- w = apply(apply, createWindow)
-
-
- w.set(5)
-
- # go ahead and depmod modules as modprobe in rc.sysinit
- # will complain loaduly if we don't do it now.
- self.depmodModules()
-
- w.set(6)
-
- self.instClass.postAction(self.instPath, self.serial)
-
- w.set(7)
-
- if self.setupFilesystems:
- f = open("/tmp/cleanup", "w")
- self.method.writeCleanupPath(f)
- self.fstab.writeCleanupPath(f)
- f.close()
-
- w.set(8)
-
- del syslog
-
- finally:
- w.pop ()
- sys.stdout.flush()
diff --git a/upgrade.py b/upgrade.py
index 873620caa..07c6c8fbd 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -8,7 +8,7 @@ import fstab
from log import log
import os.path
-def findExistingRoots (intf, theFstab):
+def findExistingRoots (intf, diskset):
rootparts = []
win = intf.waitWindow (_("Searching"),
_("Searching for Red Hat Linux installations..."))
@@ -194,3 +194,150 @@ def createSwapFile(instPath, theFstab, mntPoint, size):
f.write(fstab.fstabFormatString % (prefix + file, "swap", "swap", "defaults",
0, 0))
f.close()
+
+def upgradeFindRoot(self):
+ if not self.setupFilesystems: return [ (self.instPath, 'ext2') ]
+ return upgrade.findExistingRoots(self.intf, self.fstab)
+
+def upgradeMountFilesystems(self, rootInfo):
+ # mount everything and turn on swap
+
+ if self.setupFilesystems:
+ try:
+ upgrade.mountRootPartition(self.intf,rootInfo,
+ self.fstab, self.instPath,
+ allowDirty = 0)
+ except SystemError, msg:
+ self.intf.messageWindow(_("Dirty Filesystems"),
+ _("One or more of the filesystems listed in the "
+ "/etc/fstab on your Linux system cannot be mounted. "
+ "Please fix this problem and try to upgrade again."))
+ sys.exit(0)
+
+ checkLinks = [ '/etc', '/var', '/var/lib', '/var/lib/rpm',
+ '/boot', '/tmp', '/var/tmp' ]
+ badLinks = []
+ for n in checkLinks:
+ if not os.path.islink(self.instPath + n): continue
+ l = os.readlink(self.instPath + n)
+ if l[0] == '/':
+ badLinks.append(n)
+
+ if badLinks:
+ message = _("The following files are absolute symbolic "
+ "links, which we do not support during an "
+ "upgrade. Please change them to relative "
+ "symbolic links and restart the upgrade.\n\n")
+ for n in badLinks:
+ message = message + '\t' + n + '\n'
+ self.intf.messageWindow(("Absolute Symlinks"), message)
+ sys.exit(0)
+ else:
+ fstab.readFstab(self.instPath + '/etc/fstab', self.fstab)
+
+ # XXX fssetify
+ self.fstab.turnOnSwap(self.instPath, formatSwap = 0)
+
+def upgradeFindPackages (self):
+ if not self.rebuildTime:
+ self.rebuildTime = str(int(time.time()))
+ self.getCompsList ()
+ self.getHeaderList ()
+ self.method.mergeFullHeaders(self.hdList)
+
+ win = self.intf.waitWindow (_("Finding"),
+ _("Finding packages to upgrade..."))
+
+ self.dbpath = "/var/lib/anaconda-rebuilddb" + self.rebuildTime
+ rpm.addMacro("_dbpath_rebuild", self.dbpath)
+ rpm.addMacro("_dbapi", "-1")
+
+ # now, set the system clock so the timestamps will be right:
+ iutil.setClock (self.instPath)
+
+ # and rebuild the database so we can run the dependency problem
+ # sets against the on disk db
+ rc = rpm.rebuilddb (self.instPath)
+ if rc:
+ try:
+ iutil.rmrf (self.instPath + "/var/lib/anaconda-rebuilddb"
+ + self.rebuildTime)
+ except:
+ pass
+
+ win.pop()
+ self.intf.messageWindow(_("Error"),
+ _("Rebuild of RPM database failed. "
+ "You may be out of disk space?"))
+ if self.setupFilesystems:
+ self.fstab.umountFilesystems (self.instPath)
+ sys.exit(0)
+
+ rpm.addMacro("_dbpath", self.dbpath)
+ rpm.addMacro("_dbapi", "3")
+ try:
+ packages = rpm.findUpgradeSet (self.hdList.hdlist, self.instPath)
+ except rpm.error:
+ iutil.rmrf (self.instPath + "/var/lib/anaconda-rebuilddb"
+ + self.rebuildTime)
+ win.pop()
+ self.intf.messageWindow(_("Error"),
+ _("An error occured when finding the packages to "
+ "upgrade."))
+ if self.setupFilesystems:
+ self.fstab.umountFilesystems (self.instPath)
+ sys.exit(0)
+
+ # Turn off all comps
+ for comp in self.comps:
+ comp.unselect()
+
+ # unselect all packages
+ for package in self.hdList.packages.values ():
+ package.selected = 0
+
+ hasX = 0
+ hasFileManager = 0
+ # turn on the packages in the upgrade set
+ for package in packages:
+ self.hdList[package[rpm.RPMTAG_NAME]].select()
+ if package[rpm.RPMTAG_NAME] == "XFree86":
+ hasX = 1
+ if package[rpm.RPMTAG_NAME] == "gmc":
+ hasFileManager = 1
+ if package[rpm.RPMTAG_NAME] == "kdebase":
+ hasFileManager = 1
+
+ # open up the database to check dependencies
+ db = rpm.opendb (0, self.instPath)
+
+ # if we have X but not gmc, we need to turn on GNOME. We only
+ # want to turn on packages we don't have installed already, though.
+ if hasX and not hasFileManager:
+ log ("Has X but no desktop -- Installing GNOME")
+ for package in self.comps['GNOME'].pkgs:
+ try:
+ rec = db.findbyname (package.name)
+ except rpm.error:
+ rec = None
+ if not rec:
+ log ("GNOME: Adding %s", package)
+ package.select()
+
+ del db
+
+ # new package dependency fixup
+ deps = self.verifyDeps ()
+ loops = 0
+ while deps and self.canResolveDeps (deps) and loops < 10:
+ for (name, suggest) in deps:
+ if name != _("no suggestion"):
+ log ("Upgrade Dependency: %s needs %s, "
+ "automatically added.", name, suggest)
+ self.selectDeps (deps)
+ deps = self.verifyDeps ()
+ loops = loops + 1
+
+ win.pop ()
+
+
diff --git a/urlinstall.py b/urlinstall.py
index fa8798786..060c1e940 100644
--- a/urlinstall.py
+++ b/urlinstall.py
@@ -16,8 +16,6 @@ import ftplib
import httplib
import StringIO
-import todo
-
FILENAME = 1000000
class UrlInstallMethod(InstallMethod):
diff --git a/xserver.py b/xserver.py
index 8587ed075..07589f08a 100644
--- a/xserver.py
+++ b/xserver.py
@@ -13,6 +13,7 @@ from translate import _
from constants_text import *
from mouse_text import MouseWindow, MouseDeviceWindow
+serverPath = ""
def mouseWindow(mouse):
screen = SnackScreen()
@@ -58,132 +59,101 @@ def mouseWindow(mouse):
continue
screen.finish()
return 1
-
-def startX(resolution, nofbmode):
+
+# start X server for install process ONLY
+def startX(resolution, nofbmode, video, monitor, mouse):
global serverPath
global mode
os.environ['DISPLAY'] = ':1'
serverPath = None
- print _("Probing for mouse type...")
-
- mouse = Mouse()
- if not mouse.probe (frob=1):
- if not mouseWindow(mouse):
- raise RuntimeError, "failed to get a mouse for X startup"
- else:
- (Xtype, Xtmp) = mouse.get()
-
- x = XF86Config (mouse, resolution)
- x.res = resolution
- x.probe ()
-
- probedServer = x.server
-
- #--Run fb_check() and see if framebuffer works on this card
- if fb_check() == 0:
- x.server = "XF86_FBDev"
+ #--see if framebuffer works on this card
+ probedServer = video.primaryCard().getXServer()
+ if canUseFrameBuffer(video.primaryCard()) == 0:
+ video.primaryCard().setXServer("XF86_FBDev")
- if x.server:
- serverPath = '/usr/X11R6/bin/' + x.server
-# print "Using X server", serverPath
-
- elif iutil.getArch() == "sparc":
- raise RuntimeError, "Unknown card"
- else:
- x.server = "XF86_VGA16"
- serverPath = '/usr/X11R6/bin/XF86_VGA16'
+ if not video.primaryCard().getXServer():
+ video.primaryCard().setXServer("XF86_VGA16")
- if not os.access (serverPath, os.X_OK): #--If framebuffer server isn't there...try original probed server
- x.server = probedServer
- serverPath = '/usr/X11R6/bin/' + x.server
+ serverPath = '/usr/X11R6/bin/' + video.primaryCard().getXServer()
+
+ x = XF86Config (video, monitor, mouse, resolution)
+ #--If framebuffer server isn't there...try original probed server
+ if not os.access (serverPath, os.X_OK):
+ video.primaryCard().setXServer(probedServer)
+ serverPath = '/usr/X11R6/bin/' + video.primaryCard().getXServer()
- if not os.access (serverPath, os.X_OK): #--If original server isn't there...send them to text mode
-# print serverPath, "missing. Falling back to text mode"
+ #--If original server isn't there...send them to text mode
+ if not os.access (serverPath, os.X_OK):
raise RuntimeError, "No X server binaries found to run"
-# try:
if nofbmode == 0:
try:
- fbdevice = open("/dev/fb0", "r") #-- If can't access /dev/fb0, we're not in framebuffer mode
+ #-- If can't access /dev/fb0, we're not in framebuffer mode
+ fbdevice = open("/dev/fb0", "r")
fbdevice.close()
- testx(mouse, x)
+ testx(x)
except (RuntimeError, IOError):
-# from log import log
-# log.open(0, 0, 0, 0)
-# log ("can't open /dev/fb0")
-# log.close()
-
- x.server = probedServer
-
- if not x.server:
+ if not probedServer:
print "Unknown card"
raise RuntimeError, "Unable to start X for unknown card"
-
+
+ video.primaryCard().setXServer(probedServer)
+ serverPath = '/usr/X11R6/bin/' + video.primaryCard().getXServer()
+
# if this fails, we want the exception to go back to anaconda to
# it knows that this didn't work
- testx(mouse, x)
+ testx(x)
else: #-We're in nofb mode
- x.server = probedServer
-
- if not x.server:
+ if not probedServer:
print "Unknown card"
raise RuntimeError, "Unable to start X for unknown card"
+ x.getVideoCard().setXServer(probedServer)
+ serverPath = '/usr/X11R6/bin/' + x.getVideoCard().getXServer()
+
# if this fails, we want the exception to go back to anaconda to
# it knows that this didn't work
- testx(mouse, x)
+ testx(x)
- return (mouse, x)
+ return x
-def fb_check ():
- result = None
- cards = kudzu.probe (kudzu.CLASS_VIDEO,
- kudzu.BUS_UNSPEC,
- kudzu.PROBE_ALL);
-
- if cards != []:
- for card in cards:
- (junk, man, junk2) = card
-
- if man[:13] == "Card:NeoMagic":
- return 1
- else:
- return 0
- else:
- return 0
-
-def testx(mouse, x):
-# print "going to test the x server"
+def canUseFrameBuffer (videocard):
+ if videocard:
+ carddata = videocard.getProbedCard()
+
+ if carddata:
+ if carddata[:13] == "Card:NeoMagic":
+ return 0
+
+ return 1
+
+def testx(x):
try:
server = x.test ([':1', 'vt7', '-s', '1440', '-terminate'], spawn=1)
except:
import traceback
from string import joinfields
+ server = None
(type, value, tb) = sys.exc_info()
list = traceback.format_exception (type, value, tb)
text = joinfields (list, "")
print text
-# print "tested the x server"
# give time for the server to fail (if it is going to fail...)
# FIXME: Should find out if X server is already running
# otherwise with NFS installs the X server may be still being
# fetched from the network while we already continue to run
-# print "in testx, server is |%s| " %server
-# time.sleep (4)
-
if not server:
sys.stderr.write("X SERVER FAILED");
raise RuntimeError, "X server failed to start"
-
count = 0
sys.stdout.write(_("Waiting for X server to start...log located in /tmp/X.log\n"))
@@ -201,7 +171,6 @@ def testx(mouse, x):
raise RuntimeError, "X server failed to start"
try:
os.stat ("/tmp/.X11-unix/X1")
-# print
break
except OSError:
pass
@@ -219,7 +188,7 @@ def testx(mouse, x):
sys.exit (-1)
try:
- sys.kill(server, 15)
+ os.kill(server, 15)
os.waitpid(server, 0)
except:
pass
@@ -255,7 +224,6 @@ def start_existing_X():
"/usr/share/fonts/KOI8-R/misc/,"
"/usr/share/fonts/KOI8-R/75dpi/")
-# print args
os.execv(serverPath, args)
# give time for the server to fail (if it is going to fail...)