From 1d5cd06af5ec9ef67b9119c71c0d81282b8a1bc4 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Tue, 14 Sep 1999 22:11:04 +0000 Subject: revert --- todo.py | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 235 insertions(+), 1 deletion(-) diff --git a/todo.py b/todo.py index 3e9dd08dc..35750b1d8 100644 --- a/todo.py +++ b/todo.py @@ -1070,4 +1070,238 @@ class ToDo: if (todo.instClass.x): todo.x = todo.instClass.x - + def getSkipPartitioning(self): + return self.instClass.skipPartitioning + + def getPartitionWarningText(self): + return self.instClass.clearPartText + + def manuallyPartition(self): + self.instClass.skipPartitioning = 0 + self.instClass.clearPartText = None + self.instClass.removeFromSkipList("partition") + self.instClass.removeFromSkipList("format") + + # List of (accountName, fullName, password) tupes + def setUserList(todo, users): + todo.users = users + + def getUserList(todo): + return todo.users + + 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) + + argv = [ "/usr/bin/passwd", "--stdin", account ] + p = os.pipe() + os.write(p[1], password + "\n") + iutil.execWithRedirect(argv[0], argv, root = todo.instPath, + stdin = p[0], stdout = devnull) + os.close(p[0]) + os.close(p[1]) + os.close(devnull) + + def createCdrom(self): + list = isys.cdromList() + count = 0 + for device in list: + (device, descript) = device + cdname = "cdrom" + if (count): + cdname = "%s%d" % (cdname, count) + count = count + 1 + + os.symlink(device, self.instPath + "/dev/" + cdname) + mntpoint = "/mnt/" + cdname + self.mounts[mntpoint] = (cdname, "iso9660", 0) + + def setDefaultRunlevel (self): + inittab = open (self.instPath + '/etc/inittab', 'r') + 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 doInstall(self): + # make sure we have the header list and comps file + self.getHeaderList() + self.getCompsList() + + if self.x.server: + self.selectPackage ('XFree86-' + self.x.server) + + # 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.makeFilesystems (createSwap = 0) + else: + self.ddruid.save () + self.makeFilesystems () + else: + (drives, raid) = self.ddruid.partitionList() + + self.mountFilesystems () + + if self.upgrade: + w = self.intf.waitWindow(_("Rebuilding"), + _("Rebuilding RPM database...")) + rc = rpm.rebuilddb (self.instPath) + w.pop () + if rc: + intf.messageWindow (_("Error"), + _("Rebuild of RPM " + "database failed. You may be out of disk space?")); + # XXX do something sane here. + raise RuntimeError, "panic" + + self.method.targetFstab (self.mounts) + + if not self.installSystem: + return + + for i in [ '/var', '/var/lib', '/var/lib/rpm', '/tmp', '/dev' ]: + 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" + + for p in self.hdList.selected(): + ts.add(p.h, (p.h, self), how) + total = total + 1 + totalSize = totalSize + p.h[rpm.RPMTAG_SIZE] + + ts.order() + + if self.upgrade: + logname = '/tmp/upgrade.log' + else: + logname = '/tmp/install.log' + + self.instLog = open(self.instPath + logname, "w+") + syslog = Syslogd(root = self.instPath, output = self.instLog) + + 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") + + def instCallback(what, amount, total, key, intf): + if (what == rpm.RPMCALLBACK_INST_OPEN_FILE): + (h, self) = key + intf.setPackage(h) + intf.setPackageScale(0, 1) + self.instLog.write (self.modeText % (h[rpm.RPMTAG_NAME],)) + self.instLog.flush () + fn = self.method.getFilename(h) + self.rpmFD = os.open(fn, os.O_RDONLY) + fn = self.method.unlinkFilename(fn) + return self.rpmFD + elif (what == rpm.RPMCALLBACK_INST_PROGRESS): + intf.setPackageScale(amount, total) + elif (what == rpm.RPMCALLBACK_INST_CLOSE_FILE): + (h, self) = key + os.close (self.rpmFD) + intf.completePackage(h) + else: + pass + + rpm.errorSetCallback (self.rpmError) + + # XXX FIXME FIXME: -1 IGNORES all problems + ts.run(0, -1, instCallback, p) + + self.method.filesDone () + + del p + + self.instLog.close () + + w = self.intf.waitWindow(_("Post Install"), + _("Performing post install configuration...")) + + if not self.upgrade: + self.createCdrom() + self.writeFstab () + self.writeLanguage () + self.writeMouse () + self.writeKeyboard () + self.writeNetworkConfig () + self.writeRootPassword () + self.setupAuthentication () + self.createAccounts () + self.writeTimezone() + if (self.instClass.defaultRunlevel): + self.initlevel = self.instClass.defaultRunlevel + self.setDefaultRunlevel () + pcmcia.createPcmciaConfig(self.instPath + "/etc/sysconfig/pcmcia") + self.copyConfModules () + if not self.x.skip and self.x.server: + self.x.write (self.instPath + "/etc/X11/XF86Config") + os.symlink ("../../usr/X11R6/bin/XF86_" + self.x.server, + self.instPath + "/etc/X11/X") + self.setDefaultRunlevel () + + self.installLilo () + + if self.instClass.postScript: + if self.instClass.postInChroot: + path = self.instPath + "/tmp/ks-script" + else: + path = "/tmp/ks-script" + + f = open(path, "w") + f.write("#!/bin/sh\n\n") + f.write(self.instClass.postScript) + f.close() + + if self.instClass.postInChroot: + iutil.execWithRedirect ("/bin/sh", ["/bin/sh", + "/tmp/ks-script" ], root = self.instPath) + else: + iutil.execWithRedirect ("/bin/sh", ["/bin/sh", + "/tmp/ks-script"]) + + os.unlink(path) + + del syslog + + w.pop () + -- cgit