Re: When was "include" directive introduced?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 10, 2006 at 11:10:57AM -0400, Lazarev, Roman wrote:
> That hack didn't work ;( However I got a bit closer. Notice a change in
> readKickstart arguments and in "if" I'm trying to ignore this section
> until all the items are processes in %pre section.

This patch might get you going in the right direction.  I've not tried
to apply it against anything, though.

Cheers,

Matt
-- 
Matt Wilson
Founding Engineer
rPath, Inc.
msw@xxxxxxxxx
Index: kickstart.py
===================================================================
RCS file: /usr/local/CVS/anaconda/kickstart.py,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- kickstart.py	22 Feb 2002 23:36:19 -0000	1.140
+++ kickstart.py	28 Feb 2002 20:11:09 -0000	1.141
@@ -444,7 +444,9 @@
     def doAutoStep(self, id, args):
         flags.autostep = 1
 
-    def readKickstart(self, id, file):
+    # read the kickstart config...  if parsePre is set, only parse
+    # the %pre, otherwise ignore the %pre.  assume we're starting in where
+    def readKickstart(self, id, file, parsePre = 0, where = "commands"):
 	handlers = { 
 		     "auth"		: self.doAuthconfig	,
 		     "authconfig"	: self.doAuthconfig	,
@@ -482,7 +484,6 @@
                      "autostep"         : self.doAutoStep       ,
 		   }
 
-	where = "commands"
 	packages = []
 	groups = []
         excludedPackages = []
@@ -494,10 +495,11 @@
 		if not args or args[0][0] == '#': continue
 
 	    if args and (args[0] == "%post" or args[0] == "%pre"):
-		if where =="pre" or where == "post":
+		if ((where =="pre" and parsePre) or
+                    (where == "post" and not parsePre)):
 		    s = Script(script, scriptInterp, scriptChroot)
 		    if where == "pre":
-			self.preScripts.append(s)
+                        self.preScripts.append(s)
 		    else:
 			self.postScripts.append(s)
 
@@ -525,24 +527,39 @@
 		    elif str == "--interpreter":
 			scriptInterp = arg
 
-	    elif args and args[0] == "%packages":
-                if len(args) > 1:
-                    if args[1] == "--resolvedeps":
-                        id.handleDeps = RESOLVE_DEPS
-                    elif args[1] == "--ignoredeps":
-                        id.handleDeps = IGNORE_DEPS
-                
-		if where =="pre" or where == "post":
+            elif args and args[0] == "%include" and not parsePre:
+                if len(args) < 2:
+                    raise RuntimeError, "Invalid %include line"
+                else:
+                    # read in the included file and set our where appropriately
+                    where = self.readKickstart(id, args[1], where = where)
+            elif args and args[0] == "%packages":
+		if ((where =="pre" and parsePre) or
+                    (where == "post" and not parsePre)):
 		    s = Script(script, scriptInterp, scriptChroot)
 		    if where == "pre":
 			self.preScripts.append(s)
 		    else:
 			self.postScripts.append(s)
 
+                # if we're parsing the %pre, we don't need to continue
+                if parsePre:
+                    continue
+
+                if len(args) > 1:
+                    if args[1] == "--resolvedeps":
+                        id.handleDeps = RESOLVE_DEPS
+                    elif args[1] == "--ignoredeps":
+                        id.handleDeps = IGNORE_DEPS
+                
 		where = "packages"
 	    else:
-		if where == "packages":
-                    #Scan for comments in package list...drop off everything after "#" mark
+                # if we're parsing the %pre and not in the pre, continue
+                if parsePre and where != "pre":
+                    continue
+		elif where == "packages":
+                    #Scan for comments in package list...drop off
+                    #everything after "#" mark
                     try:
                         ind = string.index(n, "#")
                         n = n[:ind]
@@ -585,13 +602,16 @@
 		    #if int(dev[-1:]) > 4:
 			#raise RuntimeError, "Clearpart and --onpart on non-primary partition %s not allowed" % dev
                 
-	if where =="pre" or where == "post":
+	if ((where =="pre" and parsePre) or
+            (where == "post" and not parsePre)):
 	    s = Script(script, scriptInterp, scriptChroot)
 	    if where == "pre":
 		self.preScripts.append(s)
 	    else:
 		self.postScripts.append(s)
 
+        return where
+
     def doClearPart(self, id, args):
         type = CLEARPART_TYPE_NONE
         drives = None
@@ -873,10 +893,15 @@
 
 	self.installType = "install"
         self.id = id
-	self.readKickstart(id, self.file)
+
+        # parse the %pre
+	self.readKickstart(id, self.file, parsePre = 1)
 
 	for script in self.preScripts:
 	    script.run("/", self.serial)
+
+        # now read the kickstart file for real
+	self.readKickstart(id, self.file)            
 
     # Note that this assumes setGroupSelection() is called after
     # setPackageSelection()

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux