X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=patch-ker.sh;h=58940874862e207d9741f801df8985d563d2bd33;hp=5c67f250cbd20d18471b58d250b279df15a9e6c9;hb=4d923d08d0a230185dc3f1ca443cc241a4fdf735;hpb=c898fad8c0b581688b4ebd9d7952c909379d6df7 diff --git a/patch-ker.sh b/patch-ker.sh index 5c67f25..5894087 100755 --- a/patch-ker.sh +++ b/patch-ker.sh @@ -2,33 +2,37 @@ # # YAFFS: Yet another FFS. A NAND-flash specific file system. # -# Copyright (C) 2002 Aleph One Ltd. -# +# Copyright (C) 2002-2010 Aleph One Ltd. +# # Created by Charles Manning -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # Patch YAFFS into the kernel # -# args: kpath : Full path to kernel sources to be patched +# args: l/c : link or copy +# kpath : Full path to kernel sources to be patched # # Somewhat "inspired by" the mtd patchin script # -# $Id: patch-ker.sh,v 1.1 2005-07-31 09:04:13 marty Exp $ VERSION=0 PATCHLEVEL=0 SUBLEVEL=0 -LINUXDIR=$1 +COPYORLINK=$1 +MULTIORSINGLE=$2 +LINUXDIR=$3 # To be a Linux directory, it must have a Makefile # Display usage of this script usage () { - echo "usage: $0 kernelpath" + echo "usage: $0 c/l m/s kernelpath" + echo " if c/l is c, then copy. If l then link" + echo " if m/s is m, then use multi version code. If s then use single version code" exit 1 } @@ -39,9 +43,36 @@ then usage; fi +if [ $COPYORLINK = l ]; then + CPY="ln -s" +elif [ $COPYORLINK = c ]; then + CPY="cp" +else + echo "unknown copy or link type" + usage; +fi + +if [ $MULTIORSINGLE = m ]; then + VFSGLUE="yaffs_vfs_multi.c" +elif [ $MULTIORSINGLE = s ]; then + VFSGLUE="yaffs_vfs.c" + echo "" + echo "*** Warning ***" + echo "You have chosen to use the single kernel variant of the yaffs VFS glue code" + echo "that only works with the latest Linux kernel tree. If you are using an older" + echo "version of Linux then you probably wanted to use the multi-version variant by" + echo "re-running the patch-ker.sh script using m as a the second argument." + echo " ie $0 $COPYORLINK m $LINUXDIR" + echo "" +else + echo "unknown multi/single version selection" + usage; +fi + + # Check if kerneldir contains a Makefile -if [ ! -f $LINUXDIR/Makefile ] -then +if [ ! -f $LINUXDIR/Makefile ] +then echo "Directory $LINUXDIR does not exist or is not a kernel source directory"; exit 1; fi @@ -53,7 +84,7 @@ SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = ' # Can we handle this version? if [ $VERSION -ne 2 -o $PATCHLEVEL -lt 6 ] -then +then echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher" exit 1; fi @@ -80,12 +111,12 @@ else YAFFS_PATCHED=1 echo "Updating $KCONFIG" mv -f $KCONFIG $KCONFIGOLD - sed -n -e "/JFFS/,99999 ! p" $KCONFIGOLD >$KCONFIG + sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 ! p" $KCONFIGOLD >$KCONFIG echo "">>$KCONFIG echo "# Patched by YAFFS" >>$KCONFIG echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG echo "">>$KCONFIG - sed -n -e "/JFFS/,99999 p" $KCONFIGOLD >>$KCONFIG + sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 p" $KCONFIGOLD >>$KCONFIG # now do fs/Makefile -- simply add the target at the end echo "Updating $MAKEFILE" @@ -100,10 +131,14 @@ YAFFSDIR=$LINUXDIR/fs/yaffs2 if [ -e $YAFFSDIR ] then - echo "$YAFFSDIR exists, not patching" + echo "$YAFFSDIR exists, so not patching. If you want to replace what is" + echo "already there then delete $YAFFSDIR and re-run this script" + echo " eg. \"rm -rf $YAFFSDIR\" " else mkdir $LINUXDIR/fs/yaffs2 - cp Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile - cp Kconfig $LINUXDIR/fs/yaffs2 - cp *.c *.h $LINUXDIR/fs/yaffs2 + $CPY $PWD/Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile + $CPY $PWD/Kconfig $LINUXDIR/fs/yaffs2 + $CPY $PWD/*.c $PWD/*.h $LINUXDIR/fs/yaffs2 + rm $LINUXDIR/fs/yaffs2/yaffs_vfs.c $LINUXDIR/fs/yaffs2/yaffs_vfs_multi.c + $CPY $PWD/$VFSGLUE $LINUXDIR/fs/yaffs2/yaffs_vfs_glue.c fi