]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Worked on installer.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Aug 2008 16:58:00 +0000 (16:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Aug 2008 16:58:00 +0000 (16:58 +0000)
We now do create the initramfs after extraction.
This looks just nicer...
Additionally I reformated the code a little bit
and removed unused parts.

src/pomona/src/bootloader.py
src/pomona/src/exception.py
src/pomona/src/fsset.py
src/pomona/src/installer.py
src/pomona/src/pakfireinstall.py

index 6b51dc90bb9ce906487efbdd65ccf7156e3a5ace..3e6114f0bd8ba8824866dd56448c7e096c6e6094 100644 (file)
@@ -392,7 +392,7 @@ class x86BootloaderInfo(bootloaderInfo):
         f.write('#          root %s\n' % self.grubbyPartitionName(bootDevs[0]))
         f.write("#          kernel %svmlinuz-version ro "
                 "root=/dev/%s\n" % (cfPath, rootDev))
-        f.write("#          initrd %sinitrd-version.img\n" % (cfPath))
+        f.write("#          initrd %sinitramfs-version.img\n" % (cfPath))
         f.write("#boot=/dev/%s\n" % (grubTarget))
 
         # keep track of which devices are used for the device.map
@@ -422,14 +422,7 @@ class x86BootloaderInfo(bootloaderInfo):
         for (kernelName, kernelVersion, kernelTag, kernelDesc) in kernelList:
             kernelFile = "%s%skernel%s" % (cfPath, sname, kernelTag,)
 
-            initrd = "/boot/initrd-%s%s.img" % (kernelVersion, kernelTag,)
-
-            # make initramfs
-            pyfire.executil.execWithRedirect("/sbin/mkinitramfs",
-                                         ["/sbin/mkinitramfs", "-v", "-f", "%s" % initrd,
-                                          "%s%s" % (kernelVersion, kernelTag,), ],
-                                         stdout = "/dev/tty5", stderr = "/dev/tty5",
-                                         root = instRoot)
+            initrd = "/boot/initramfs-%s%s.img" % (kernelVersion, kernelTag,)
 
             f.write('title %s (%s - %s)\n' % (name, kernelDesc, kernelVersion))
             f.write('\troot %s\n' % self.grubbyPartitionName(bootDevs[0]))
@@ -443,7 +436,8 @@ class x86BootloaderInfo(bootloaderInfo):
             f.write('\n')
 
             if os.access (instRoot + initrd, os.R_OK):
-                f.write('\tinitrd %sinitrd-%s%s.img\n' % (cfPath, kernelVersion, kernelTag,))
+                # initrd is built in backend.postInstall
+                f.write('\tinitrd %sinitramfs-%s%s.img\n' % (cfPath, kernelVersion, kernelTag,))
 
         for (label, longlabel, device) in chainList:
             if ((not longlabel) or (longlabel == "")):
index 76610c2760f7f77f838eb0786304a3b99710e583..ad45525bfc921e43e5a90390a3c243c9d088e847 100644 (file)
@@ -100,10 +100,10 @@ def dumpException(out, text, tb, pomona):
         while trace.tb_next:
             trace = trace.tb_next
         frame = trace.tb_frame
-        out.write ("\nLocal variables in innermost frame:\n")
+        out.write("\nLocal variables in innermost frame:\n")
         try:
             for (key, value) in frame.f_locals.items():
-                out.write ("%s: %s\n" % (key, value))
+                out.write("%s: %s\n" % (key, value))
         except:
             pass
 
@@ -128,92 +128,9 @@ def dumpException(out, text, tb, pomona):
             out.write("\nException occurred during %s file copy:\n" % (file,))
             traceback.print_exc(None, out)
 
-# Returns 0 on success, 1 on cancel, 2 on error.
-def copyExceptionToRemote(intf):
-    import pty
-
-    scpWin = intf.scpWindow()
-    while 1:
-        # Bail if they hit the cancel button.
-        scpWin.run()
-        scpInfo = scpWin.getrc()
-
-        if scpInfo == None:
-            scpWin.pop()
-            return 1
-
-        (host, path, user, password) = scpInfo
-
-        if host.find(":") != -1:
-            (host, port) = host.split(":")
-
-            # Try to convert the port to an integer just as a check to see
-            # if it's a valid port number.  If not, they'll get a chance to
-            # correct the information when scp fails.
-            try:
-                int(port)
-                portArgs = ["-P", port]
-            except ValueError:
-                portArgs = []
-        else:
-            portArgs = []
-
-        # Thanks to Will Woods <wwoods@redhat.com> for the scp control
-        # here and in scpAuthenticate.
-
-        # Fork ssh into its own pty
-        (childpid, master) = pty.fork()
-        if childpid < 0:
-            log.critical("Could not fork process to run scp")
-            scpWin.pop()
-            return 2
-        elif childpid == 0:
-            # child process - run scp
-            args = ["scp", "-oNumberOfPasswordPrompts=1",
-                    "-oStrictHostKeyChecking=no"] + portArgs + \
-                   ["/tmp/anacdump.txt", "%s@%s:%s" % (user, host, path)]
-            os.execvp("scp", args)
-
-            # parent process
-            try:
-                childstatus = scpAuthenticate(master, childpid, password)
-            except OSError:
-                scpWin.pop()
-                return 2
-
-        os.close(master)
-
-        if os.WIFEXITED(childstatus) and os.WEXITSTATUS(childstatus) == 0:
-            return 0
-        else:
-            scpWin.pop()
-            return 2
-
-def scpAuthenticate(master, childpid, password):
-    while 1:
-        # Read up to password prompt.  Propagate OSError exceptions, which
-        # can occur for anything that causes scp to immediately die (bad
-        # hostname, host down, etc.)
-        buf = os.read(master, 4096)
-        if buf.find("'s password: ") != -1:
-            os.write(master, password+"\n")
-            # read the space and newline that get echoed back
-            os.read(master, 2)
-            break
-
-    while 1:
-        buf = ""
-        try:
-            buf = os.read(master, 4096)
-        except (OSError, EOFError):
-            break
-
-    (pid, childstatus) = os.waitpid (childpid, 0)
-    return childstatus
-
 # Reverse the order that tracebacks are printed so people will hopefully quit
 # giving us the least useful part of the exception in bug reports.
-def formatException (type, value, tb):
+def formatException(type, value, tb):
     lst = traceback.format_tb(tb)
     lst.reverse()
     lst.insert(0, 'Traceback (most recent call first):\n')
@@ -228,12 +145,12 @@ def handleException(pomona, (type, value, tb)):
     sys.excepthook = sys.__excepthook__
 
     # get traceback information
-    list = formatException (type, value, tb)
-    text = joinfields (list, "")
+    list = formatException(type, value, tb)
+    text = joinfields(list, "")
 
     # save to local storage first
     out = open("/tmp/instdump.txt", "w")
-    dumpException (out, text, tb, pomona)
+    dumpException(out, text, tb, pomona)
     out.close()
 
     win = pomona.intf.exceptionWindow(text, "/tmp/instdump.txt")
@@ -246,22 +163,5 @@ def handleException(pomona, (type, value, tb)):
         rc = win.getrc()
 
         if rc == 0:
-            pomona.intf.__del__ ()
+            pomona.intf.__del__()
             os.kill(os.getpid(), signal.SIGKILL)
-        elif rc == 1:
-            scpRc = copyExceptionToRemote(pomona.intf)
-
-            if scpRc == 0:
-                pomona.intf.messageWindow(_("Dump Written"),
-                                          _("Your system's state has been successfully written to "
-                                            "the remote host.  Your system will now be rebooted."),
-                                          type="custom", custom_icon="info",
-                                          custom_buttons=[_("_Reboot")])
-                sys.exit(0)
-            elif scpRc == 1:
-                continue
-            elif scpRc == 2:
-                pomona.intf.messageWindow(_("Dump Not Written"),
-                                          _("There was a problem writing the system state to the "
-                                            "remote host."))
-                continue
index bc03e8bc654372e8a50d32fe7d86b6799e51af0c..d05650629815f8e66c67c3c487d5c97c2cc581c2 100644 (file)
@@ -153,7 +153,6 @@ class FileSystemType:
         self.migratetofs = None
         self.extraFormatArgs = []
         self.maxLabelChars = 16
-        self.packages = []
 
     def isKernelFS(self):
         """Returns True if this is an in-kernel pseudo-filesystem."""
@@ -376,7 +375,6 @@ class reiserfsFileSystem(FileSystemType):
         self.linuxnativefs = 1
         self.supported = -1
         self.name = "reiserfs"
-        self.packages = [ "reiserfs-utils" ] ### XXX do we need this?
 
         self.maxSizeMB = 8 * 1024 * 1024
 
@@ -419,7 +417,6 @@ class xfsFileSystem(FileSystemType):
         self.maxSizeMB = 16 * 1024 * 1024
         self.maxLabelChars = 12
         self.supported = -1
-        self.packages = [ "xfsprogs" ] ### XXX do we need this?
 
     def formatDevice(self, entry, progress, chroot='/'):
         devicePath = entry.device.setupDevice(chroot)
@@ -455,7 +452,6 @@ class extFileSystem(FileSystemType):
         self.checked = 1
         self.linuxnativefs = 1
         self.maxSizeMB = 8 * 1024 * 1024
-        self.packages = [ "e2fsprogs" ] ### XXX do we need this?
 
     def labelDevice(self, entry, chroot):
         devicePath = entry.device.setupDevice(chroot)
@@ -548,9 +544,9 @@ class ext2FileSystem(extFileSystem):
                              % (devicePath, devicePath), type = "yesno")
                 if rc == 0:
                     sys.exit(0)
-                    entry.fsystem = entry.origfsystem ### XXX what is this?
-                else:
-                    extFileSystem.setExt3Options(self, entry, message, chroot)
+            entry.fsystem = entry.origfsystem ### XXX what is this?
+        else:
+            extFileSystem.setExt3Options(self, entry, message, chroot)
 
 fileSystemTypeRegister(ext2FileSystem())
 
@@ -663,23 +659,10 @@ class FATFileSystem(FileSystemType):
     def __init__(self):
         FileSystemType.__init__(self)
         self.partedFileSystemType = parted.file_system_type_get("fat32")
-        self.formattable = 1
+        self.formattable = 0
         self.checked = 0
         self.maxSizeMB = 1024 * 1024
         self.name = "vfat"
-        self.packages = [ "dosfstools" ]
-
-    def formatDevice(self, entry, progress, chroot='/'):
-        devicePath = entry.device.setupDevice(chroot)
-        devArgs = self.getDeviceArgs(entry.device)
-        args = [ devicePath ]
-        args.extend(devArgs)
-
-        rc = inutil.execWithRedirect("mkdosfs", args,
-                                     stdout = "/dev/tty5",
-                                     stderr = "/dev/tty5", searchPath = 1)
-        if rc:
-            raise SystemError
 
 fileSystemTypeRegister(FATFileSystem())
 
@@ -758,10 +741,6 @@ class AutoFileSystem(PsudoFileSystem):
         if not self.isMountable():
             return
         inutil.mkdirChain("%s/%s" %(instroot, mountpoint))
-        if flags.selinux:
-            ret = isys.resetFileContext(mountpoint, instroot)
-            log.info("set SELinux context for mountpoint %s to %s" %(mountpoint, ret))
-
         for fs in getFStoTry (device):
             try:
                 isys.mount (device, mountpoint, fstype = fs, readOnly = readOnly,
index 04ac081e9cb5012c7270bff7bb1f84c1048eca76..517db8f65bb985679b0a3d1c14979c513c28785b 100644 (file)
@@ -148,17 +148,15 @@ if __name__ == "__main__":
         pdb.set_trace()
 
     log.info (_("Starting text installation..."))
-    import instdata
-    from tui import InstallInterface
-    from exception import handleException
-    import warnings, signal
 
     instClass = getInstClass()
 
     checkMemory()
 
+    from tui import InstallInterface
     pomona.intf = InstallInterface()
 
+    import warnings, signal
     warnings.showwarning = PomonaShowWarning
 
     # reset python's default SIGINT handler
@@ -184,6 +182,7 @@ if __name__ == "__main__":
     #       anaconda.dispatch.skipStep("keyboard", permanent = 1)
     #       instClass.setKeyboard(anaconda.id, opts.keymap)
 
+    from exception import handleException
     sys.excepthook = lambda type, value, tb, pomona=pomona: handleException(pomona, (type, value, tb))
 
     try:
index eb856a06254aea7e637b808fd8eea162a06b60e9..c395a26dd0739f70fcb43f3d88c1a291b8c44abc 100644 (file)
@@ -34,6 +34,7 @@ urlparse.uses_fragment.append('media')
 
 import inutil
 import isys
+import pyfire
 
 def size_string(size):
     def number_format(s):
@@ -206,18 +207,27 @@ class PakfireBackend(PomonaBackend):
         # installer /dev
         isys.mount("/dev", "%s/dev" %(pomona.rootPath,), bindMount = 1)
 
-        PomonaBackend.doPostInstall(self, pomona)
-        w.pop()
-
-        ### XXX this is from pre
         # write out the fstab
         pomona.id.fsset.write(pomona.rootPath)
         # rootpath mode doesn't have this file around
         if os.access("/tmp/modprobe.conf", os.R_OK):
             shutil.copyfile("/tmp/modprobe.conf",
                             pomona.rootPath + "/etc/modprobe.conf")
+
         ### XXX pomona.id.network.write(pomona.rootPath)
 
+        for (kernelName, kernelVersion, kernelTag, kernelDesc) in self.kernelVersionList(pomona):
+            initrd = "/boot/initramfs-%s%s.img" % (kernelVersion, kernelTag,)
+            log.info("mkinitramfs: creating %s" % initrd)
+            pyfire.executil.execWithRedirect("/sbin/mkinitramfs",
+                                            ["/sbin/mkinitramfs", "-v", "-f", "%s" % initrd,
+                                             "%s%s" % (kernelVersion, kernelTag,), ],
+                                            stdout = "/dev/tty5", stderr = "/dev/tty5",
+                                            root = pomona.rootPath)
+
+        PomonaBackend.doPostInstall(self, pomona)
+        w.pop()
+
     def kernelVersionList(self, pomona):
         kernelVersions = []