mtd/scripts patchin.xml,1.1,1.2 treewalk.py,1.1,1.2

gleixner at infradead.org gleixner at infradead.org
Mon Mar 14 04:55:01 EST 2005


Update of /home/cvs/mtd/scripts
In directory phoenix.infradead.org:/tmp/cvs-serv8564

Modified Files:
	patchin.xml treewalk.py 
Log Message:
Fix exclude processing. Use precompiled regular expressions. Fix XML doc

Index: patchin.xml
===================================================================
RCS file: /home/cvs/mtd/scripts/patchin.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- patchin.xml	13 Mar 2005 18:09:07 -0000	1.1
+++ patchin.xml	14 Mar 2005 09:54:57 -0000	1.2
@@ -5,9 +5,10 @@
 
 help: Helptext for this option
 
-Define commandline options for patchin.py
+Define commandline options for treewalk.py
 The options are given with -o opt1,opt2,opt3
 
+
 <CHECKTARGET file="Makefile" pattern="PATCHLEVEL = 6" 
 help="Linux-Kernel 2.6" />
 file:    Filename to check in the target directory
@@ -19,6 +20,7 @@
 The targetcheck(s) are processed before the update. If
 one of the checks fails, the processing is stopped.
 
+
 <ACTION name="bk" depends="bk" except="rm" location="dest">
 	rm -f $destfiles;
 	bk co -ql $destfiles;
@@ -50,10 +52,23 @@
 
            $options   Options given in the selection pattern
 
+
+<ACTIONORDER order="bk,rm,cp,ln" />
+order:     action processing order. Actions names seperated by ','
+
+Defines the processing order for default actions. Only the 
+actions in this config entity are available for default 
+action processing. You can override the default action per
+<SUBDIR>. Only enabled actions are eprocessed. Enabling 
+of an action happens by the config options and the depend/except 
+field in the <ACTION> config entity.
+
+
 <SUBDIR name="include" actions="cp" depends="jffs2" except="bk" recurse="no">
 name:      relative path name of the subdirectory
 
-actions:   actions in this subdir. If omitted defaults to all !
+actions:   actions in this subdir. If omitted the defaults are used
+           Actions are processed in the given order
 
 depends:   Dependency on option(s) seperated by ','
 
@@ -75,6 +90,8 @@
 options:   Options for the action
 </SUBDIR>
 
+
+For all entities which use depends/extend the following rules apply:
 If depends contains more than one option, then all options must be 
 set to make the rule valid (logical AND)
 If except contains more than one option, then one option set make 
@@ -90,7 +107,7 @@
 	<OPTION name="ln" help="link into target tree" />
 	<OPTION name="rm" help="remove the patched files" />
 
-	<CHECKTARGET file="Makefile" pattern="PATCHLEVEL = 6" 
+	<CHECKTARGET file="Makefile" pattern="PATCHLEVEL.=.6" 
 		help="Linux-Kernel 2.6" />
 
 	<ACTION name="bk" depends="bk" except="rm" mode="all">
@@ -134,10 +151,10 @@
 		<EXCLUDE pattern="jffs2-user.h$" except="jffs2" />
 	</SUBDIR>
 	<SUBDIR name="include/linux" depends="jffs2">
-		<UPDATE pattern="jffs2*\.h$" />
+		<UPDATE pattern="jffs2.*\.h$" />
 	</SUBDIR>
 	<SUBDIR name="include/linux" depends="jffs3">
-		<UPDATE pattern="jffs3*\.h$" />
+		<UPDATE pattern="jffs3.*\.h$" />
 	</SUBDIR>
 	<SUBDIR name="include/linux/mtd">
 		<UPDATE pattern=".*\.h$" />
@@ -158,6 +175,9 @@
 		<UPDATE pattern=".*\.[ch]$" />
 		<UPDATE pattern="Makefile.common" target="Makefile" />
 		<EXCLUDE pattern=".*v24.c$" />
+		<EXCLUDE pattern="crc.*" />
+		<EXCLUDE pattern="compr_lz.*" />
+		<EXCLUDE pattern="rbtree.*" />
 	</SUBDIR>
 	<SUBDIR name="fs/jffs3" actions="mkdir,rm,cp,ln" depends="jffs3">
 		<UPDATE pattern=".*\.[ch]$" />
@@ -169,5 +189,6 @@
 		<UPDATE pattern="Kconfig" />
 		<UPDATE pattern="Makefile.common" target="Makefile" />
 		<EXCLUDE pattern=".*24.c" />
+		<EXCLUDE pattern="ssfdc.c" depends="bk" />
 	</SUBDIR>
 </PATCHROOT>

Index: treewalk.py
===================================================================
RCS file: /home/cvs/mtd/scripts/treewalk.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- treewalk.py	13 Mar 2005 18:09:07 -0000	1.1
+++ treewalk.py	14 Mar 2005 09:54:57 -0000	1.2
@@ -220,7 +220,7 @@
 # Storage class for file patterns
 class treePattern:
 	def __init__(self, pattern, target, excepts, depends, options):
-		self.pattern = pattern
+		self.pattern = re.compile(pattern)
 		self.target = target
 		self.applies = treeApplies(excepts, depends)
 		self.options = options
@@ -299,8 +299,8 @@
 		elif name == 'CHECKTARGET':
 			i = len(targetchecks)
 			targetchecks[i:] = [
-				treePattern(attrs.get('file'),
-					     attrs.get('pattern'),
+				treePattern(attrs.get('pattern'),
+					     attrs.get('file'),
 					     attrs.get('except'),
 					     attrs.get('depends'),
 					     attrs.get('help'))]
@@ -366,25 +366,23 @@
 		dst_update = []
 
 		# Select files by selection pattern
-		pattern = re.compile(upd.getPattern())
 		for file in srcfiles:
-			if pattern.match(file):
+			if upd.getPattern().match(file):
 				update[len(update):] = [file]
 
 		# Process excludes
-		for excl in dir.getExcludes():
-			# skip inactive rules
-			if excl.isActive() == 0:
+		for file in update:
+			try:
+				for excl in dir.getExcludes():
+					# skip inactive rules
+					if excl.isActive() == 0:
+						continue
+					# Check exclude pattern
+					if excl.getPattern().match(file):
+						raise exception(0)
+				src_update[len(src_update):] = [file]
+			except:
 				continue
-			# Get exclude pattern
-			pat = re.compile(excl.getPattern())
-			for file in update:
-				if not pat.match(file):
-					src_update[len(src_update):] = [file]
-
-		# If no excludes given, process all source matches			
-		if len(dir.getExcludes()) == 0:
-			src_update = update
 
 		# Updates available ?	
 		if len(src_update) == 0:
@@ -394,7 +392,7 @@
 		repl = upd.getTarget() 
 		for file in src_update:
 			if repl:
-				dstfile = pattern.sub(repl,file)
+				dstfile = upd.getPattern().sub(repl,file)
 			else:
 				dstfile = file
 			verbose_print(2, dstfile)
@@ -519,12 +517,12 @@
 # Do target checks
 for check in targetchecks:
 	try:
-		fd = open(os.path.join(dstbase,check.getPattern()))
+		fd = open(os.path.join(dstbase,check.getTarget()))
 		lines = fd.readlines()
 		fd.close()
 		found = 0
 		for line in lines:
-			if line.find(check.getTarget()) >= 0:
+			if check.getPattern().search(line):
 				found = 1
 				break;
 		if found == 0:





More information about the linux-mtd-cvs mailing list