/[smeserver]/cdrom.image/updates/smeupgradeclass.py
ViewVC logotype

Diff of /cdrom.image/updates/smeupgradeclass.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.1 by slords, Sat Jul 30 07:28:39 2005 UTC Revision 1.6 by gordonr, Fri Oct 7 20:55:54 2005 UTC
# Line 1  Line 1 
1  from installclass import BaseInstallClass  from installclass import BaseInstallClass
2  from rhpl.translate import N_, _  from rhpl.translate import N_, _
3  from rhpl.log import log  from rhpl.log import log
4    from constants import *
5    
6  import os  import os
7    import string
8  import iutil  import iutil
9    import security
10    
11    class Script:
12        def __repr__(self):
13            str = ("(s: '%s' i: %s c: %d)") %  \
14                (self.script, self.interp, self.inChroot)
15            return string.replace(str, "\n", "|")
16    
17        def __init__(self, script, interp, inChroot, logfile = None):
18            self.script = script
19            self.interp = interp
20            self.inChroot = inChroot
21            self.logfile = logfile
22    
23        def run(self, chroot, serial):
24            scriptRoot = "/"
25            if self.inChroot:
26                scriptRoot = chroot
27    
28            path = scriptRoot + "/tmp/sme-script"
29    
30            f = open(path, "w")
31            f.write(self.script)
32            f.close()
33            os.chmod(path, 0700)
34    
35            if self.logfile is not None:
36                messages = self.logfile
37            elif serial:
38                messages = "/tmp/sme-script.log"
39            else:
40                messages = "/dev/tty3"
41    
42            rc = iutil.execWithRedirect(self.interp,
43                                        [self.interp,"/tmp/sme-script"],
44                                        stdout = messages, stderr = messages,
45                                        root = scriptRoot)
46    
47            if rc != 0:
48                log("WARNING - Error code %s encountered running a sme script", rc)
49    
50            os.unlink(path)
51    
52  class InstallClass(BaseInstallClass):  class InstallClass(BaseInstallClass):
53      name = N_("Upgrade Existing System")      name = N_("Upgrade Existing System")
# Line 20  class InstallClass(BaseInstallClass): Line 64  class InstallClass(BaseInstallClass):
64                      "language",                      "language",
65                      "keyboard",                      "keyboard",
66                      "findrootparts",                      "findrootparts",
67                        "findinstall",
68                        "installtype",
69                      "partitionobjinit",                      "partitionobjinit",
70                      "upgrademount",                      "upgrademount",
71                      "upgrademigfind",                      "upgrademigfind",
72                      "upgrademigratefs",                      "upgrademigratefs",
73                      "upgradecontinue",                      "upgradecontinue",
74                        "bootloadersetup",
75                      "readcomps",                      "readcomps",
76                      "findpackages",                      "findpackages",
77                      "checkdeps",                      "checkdeps",
# Line 42  class InstallClass(BaseInstallClass): Line 89  class InstallClass(BaseInstallClass):
89                  )                  )
90    
91      def postAction(self, rootPath, serial):      def postAction(self, rootPath, serial):
92          if serial:          script = ( "/sbin/syslogd &\n"
93              messages = "/tmp/postupgrade.log"                     "sleep 2\n"
94          else:                     "/sbin/e-smith/signal-event post-upgrade\n" )
95              messages = "/dev/tty3"          s = Script(script, interp="/bin/sh", inChroot=1)
96          args = [ "/usr/sbin/lokkit", "--quiet", "--nostart", "--selinux=disabled"]          log("%s", s)
97            s.run(rootPath, serial)
         try:  
             iutil.execWithRedirect(args[0], args, root=rootPath,  
                                    stdout=messages, stderr=messages)  
         except RuntimeError, msg:  
             log ("lokkit run failed: %s", msg)  
         except OSError, (errno, msg):  
             log ("lokkit run failed: %s", msg)  
   
         path = rootPath + "/tmp/postupgrade.sh"  
         cmds = ["/sbin/syslogd &", "sleep 2", "/sbin/e-smith/signal-event post-upgrade"]  
   
         f = open(path, "w")  
         f.writelines(cmds)  
         f.close  
         os.chmod(path, 0700)  
   
         rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postupgrade.sh"],  
                        stdout=messages, stderr=messages, root=rootPath)  
         if rc != 0:  
             log("WARNING - Error code %s encountered running postupgrade script", rc)  
         os.unlink(path)  
98    
99      def setInstallData(self, id):      def setInstallData(self, id):
100          BaseInstallClass.setInstallData(self, id)          BaseInstallClass.setInstallData(self, id)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed