mtd/patches patchin.sh,1.10,1.11

gleixner at infradead.org gleixner at infradead.org
Sat Mar 8 13:31:48 EST 2003


Update of /home/cvs/mtd/patches
In directory phoenix.infradead.org:/tmp/cvs-serv30657

Modified Files:
	patchin.sh 
Log Message:
moved filelist to variables and added an option to copy files instead of linking

Index: patchin.sh
===================================================================
RCS file: /home/cvs/mtd/patches/patchin.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- patchin.sh	10 Feb 2003 10:55:55 -0000	1.10
+++ patchin.sh	8 Mar 2003 18:31:45 -0000	1.11
@@ -10,7 +10,7 @@
 # Works for Kernels >= 2.4 and <= 2.4.10 partly (JFFS2 support is missing)
 # For 2.2 Kernels it's actually disabled, as I have none to test it.
 #
-# Your can use it for pristine kernels and for already patches kernels too.
+# You can use it for pristine kernels and for already patches kernels too.
 #
 # Detects Kernelversion and applies neccecary modifications
 # For Kernelversions < 2.4.20 ZLIB-Patch is applied, if 
@@ -24,28 +24,73 @@
 # $Id$
 #
 # 02-10-2003 tglx replaced grep -m by head -n 1, as older grep versions don't support -m	
-#
-# Keep usage here, easier to find :)
-usage () {
-	echo "usage:  $0 [-j] kernelpath"
-	echo "-j include jffs(2) filesystems" 
-	exit 1
-}
+# 03-08-2003 tglx -c option for copying files to kernel tree instead of linking
+#		  moved file selection to variables
 
 # Preset variables
-LINUXDIR=
-FILESYSTEMS=no
+FILESYSTEMS="no"
 VERSION=0
 PATCHLEVEL=0
 SUBLEVEL=0
-ZLIBPATCH=no
-CONFIG=Config.in
+ZLIBPATCH="no"
+CONFIG="Config.in"
+LNCP="ln -sf"
+METHOD="Link"
+
+# MTD - files and directories
+MTD_DIRS="drivers/mtd drivers/mtd/chips drivers/mtd/devices drivers/mtd/maps drivers/mtd/nand include/linux/mtd"
+MTD_FILES="*.[ch] Makefile Rules.make"
+
+# JFFSx files and directories
+FS_DIRS="fs/jffs fs/jffs2"
+FS_FILES="*.[ch] Makefile Rules.make"
+# kernel version < 2.4.20 needs zlib headers
+FS_INC_BEL2420="jffs2*.h workqueue.h z*.h rb*.h"
+# kernel version < 2.5.x
+FS_INC_BEL25="jffs2*.h workqueue.h rb*.h"
+# kernelversion >= 2.5
+FS_INC_25="jffs2*.h"
+FS_INC_DIR="include/linux"
+
+# shared ZLIB patch
+ZLIB_DIRS="lib/zlib_deflate lib/zlib_inflate"
+ZLIB_FILES="*.[ch] Makefile"
+
+
+# Display usage of this script
+usage () {
+	echo "usage:  $0 [-c] [-j] kernelpath"
+	echo "-c copy files to kernel tree instead of building links"
+	echo "-j include jffs(2) filesystems" 
+	exit 1
+}
+
+# Function to patch kernel source
+patchit () {
+for DIR in $PATCH_DIRS 
+do
+	echo $DIR
+	mkdir -p $DIR
+	cd $TOPDIR/$DIR
+	FILES=`ls $PATCH_FILES 2>/dev/null`
+	for FILE in $FILES 
+	do
+		rm -f $LINUXDIR/$DIR/$FILE
+		$LNCP $TOPDIR/$DIR/$FILE $LINUXDIR/$DIR
+	done
+done	
+cd $LINUXDIR
+}
+
+
+# Start of script
 
 # Get commandline options
-while getopts j opt
+while getopts cj opt
 do
     case "$opt" in
       j)  FILESYSTEMS=yes;;
+      c)  LNCP="cp -f"; METHOD="Copy";;
       \?)
 	  usage;
     esac
@@ -75,8 +120,9 @@
 # Use Kconfig instead of Config.in for Kernels >= 2.5
 if test $PATCHLEVEL -gt 4
 then
-	CONFIG=Kconfig;
+	CONFIG="Kconfig";
 fi
+MTD_FILES="$MTD_FILES $CONFIG"
 
 # Have we to use ZLIB PATCH ? 
 if [ "$FILESYSTEMS" = "yes" ]
@@ -91,30 +137,26 @@
 	fi
 fi
 
-# Here we go
-cd `dirname $0`
-THISDIR=`pwd`
-TOPDIR=`dirname $THISDIR`
-
 # Check which header files we need depending on kernel version
-HDIR="$TOPDIR/include/linux"
+HDIR="include/linux"
 if test $PATCHLEVEL -eq 4 
 then	
 	# 2.4 below 2.4.20 zlib headers are neccecary
 	if test $SUBLEVEL -lt 20
 	then
-		JFFS2_H="$HDIR/jffs2*.h $HDIR/workqueue.h $HDIR/z*.h $HDIR/rb*.h"
+		JFFS2_H=$FS_INC_BEL2420
 	else
-		JFFS2_H="$HDIR/jffs2*.h $HDIR/workqueue.h $HDIR/rb*.h"
+		JFFS2_H=$FS_INC_BEL25
 	fi
 else
 	#	>= 2.5
-	JFFS2_H="$HDIR/jffs2*.h "
+	JFFS2_H=$FS_INC_25
 fi
 
 echo Patching $LINUXDIR 
 echo Include Filesytems: $FILESYSTEMS
 echo Zlib-Patch needed: $ZLIBPATCH
+echo Method: $METHOD
 read -p "Can we start now ? [y/N]" ANSWER
 echo ""
 
@@ -124,38 +166,34 @@
 	exit 1;
 fi
 
+# Here we go
+cd `dirname $0`
+THISDIR=`pwd`
+TOPDIR=`dirname $THISDIR`
+
 cd $LINUXDIR
 
-#	make symlinks
-mkdir -p drivers/mtd
-mkdir -p drivers/mtd/chips
-mkdir -p drivers/mtd/devices
-mkdir -p drivers/mtd/maps
-mkdir -p drivers/mtd/nand
-mkdir -p include/linux/mtd
-ln -sf $TOPDIR/drivers/mtd/*.[ch] drivers/mtd
-ln -sf $TOPDIR/drivers/mtd/Makefile $TOPDIR/drivers/mtd/Rules.make $TOPDIR/drivers/mtd/$CONFIG drivers/mtd
-ln -sf $TOPDIR/drivers/mtd/chips/*.[ch] drivers/mtd/chips
-ln -sf $TOPDIR/drivers/mtd/chips/Makefile $TOPDIR/drivers/mtd/chips/$CONFIG drivers/mtd/chips
-ln -sf $TOPDIR/drivers/mtd/devices/*.[ch] drivers/mtd/devices
-ln -sf $TOPDIR/drivers/mtd/devices/Makefile $TOPDIR/drivers/mtd/devices/$CONFIG drivers/mtd/devices
-ln -sf $TOPDIR/drivers/mtd/maps/*.[ch] drivers/mtd/maps
-ln -sf $TOPDIR/drivers/mtd/maps/Makefile $TOPDIR/drivers/mtd/maps/$CONFIG drivers/mtd/maps
-ln -sf $TOPDIR/drivers/mtd/nand/*.[ch] drivers/mtd/nand
-ln -sf $TOPDIR/drivers/mtd/nand/Makefile $TOPDIR/drivers/mtd/nand/$CONFIG drivers/mtd/nand
-ln -sf $TOPDIR/include/linux/mtd/*.h include/linux/mtd
+# make directories, if neccecary
+# remove existing files/links and link/copy the new ones
+echo "Patching MTD"
+PATCH_DIRS=$MTD_DIRS
+PATCH_FILES=$MTD_FILES
+patchit;
 
+# check, if we have to include JFFS(2)
 if [ "$FILESYSTEMS" = "yes" ]
 then
-	mkdir -p fs/jffs
-	mkdir -p fs/jffs2
-	ln -sf $TOPDIR/fs/jffs/*.[ch] fs/jffs
-	ln -sf $TOPDIR/fs/jffs/Makefile fs/jffs
-	ln -sf $TOPDIR/fs/jffs2/*.[ch] fs/jffs2
-	ln -sf $TOPDIR/fs/jffs2/Makefile fs/jffs2
-	ln -sf $TOPDIR/include/linux/jffs.h include/linux
-	ln -sf $JFFS2_H include/linux
+	echo "Patching JFFS(2)"
 	
+	PATCH_DIRS=$FS_DIRS
+	PATCH_FILES=$FS_FILES
+	patchit;
+
+	PATCH_DIRS=$FS_INC_DIR
+	PATCH_FILES=$JFFS2_H
+	patchit;
+
+	# this is the ugly part	
 	PATCHDONE=`grep -s jffs2 fs/Makefile | head -n 1`
 	if [ "$PATCHDONE" = "" ]
 	then
@@ -178,7 +216,7 @@
 				CRC32=`grep -s 'crc32(' include/linux/crc32.h | head -n 1`
 				if [ "$CRC32" = "" ]
 				then
-					# patch in header form fs/jffs2
+					# patch in header from fs/jffs2
 					LASTLINE=`grep -n '#endif' include/linux/crc32.h | head -n 1 | sed s/:.*//`
 					let LASTLINE=LASTLINE-1
 					sed "$LASTLINE"q include/linux/crc32.h >Crc32.tmp
@@ -187,7 +225,8 @@
 					mv -f Crc32.tmp include/linux/crc32.h
 				fi
 			else
-				ln -sf $TOPDIR/fs/jffs2/crc32.h include/linux
+				rm -f include/linux/crc32.h
+				$LNCP $TOPDIR/fs/jffs2/crc32.h include/linux
 			fi
 		fi
 	fi
@@ -195,12 +234,12 @@
 
 if [ "$ZLIBPATCH" = "yes" ]
 then
-	mkdir -p lib/zlib_deflate
-	mkdir -p lib/zlib_inflate
-	ln -sf $TOPDIR/lib/zlib_deflate/*.[ch] lib/zlib_deflate
-	ln -sf $TOPDIR/lib/zlib_deflate/Makefile lib/zlib_deflate
-	ln -sf $TOPDIR/lib/zlib_inflate/*.[ch] lib/zlib_inflate
-	ln -sf $TOPDIR/lib/zlib_inflate/Makefile lib/zlib_inflate
+	echo "Patching ZLIB"
+	
+	PATCH_DIRS=$ZLIB_DIRS
+	PATCH_FILES=$ZLIB_FILES
+	patchit;
+
 	patch -p1 -i $TOPDIR/lib/patch-Makefile
 fi
 





More information about the linux-mtd-cvs mailing list