annotate patch-ker.sh @ 50:bcf056049698

Added files that support the ability to "patchin" yaffs2 into the 2.6 kernel tree so that it can be compiled there. Makefile.kernel and patch-ker.sh will need to be edited when the source tree is reorganized.
author marty <marty>
date Sun, 31 Jul 2005 09:04:13 +0000
parents
children b8f20fdc3a58
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
1 #!/bin/sh
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
2 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
3 # YAFFS: Yet another FFS. A NAND-flash specific file system.
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
4 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
5 # Copyright (C) 2002 Aleph One Ltd.
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
6 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
7 # Created by Charles Manning <charles@aleph1.co.uk>
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
8 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
10 # it under the terms of the GNU General Public License version 2 as
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
11 # published by the Free Software Foundation.
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
12 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
13 # Patch YAFFS into the kernel
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
14 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
15 # args: kpath : Full path to kernel sources to be patched
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
16 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
17 # Somewhat "inspired by" the mtd patchin script
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
18 #
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
19 # $Id: patch-ker.sh,v 1.1 2005-07-31 09:04:13 marty Exp $
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
20
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
21 VERSION=0
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
22 PATCHLEVEL=0
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
23 SUBLEVEL=0
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
24 LINUXDIR=$1
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
25
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
26 # To be a Linux directory, it must have a Makefile
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
27
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
28
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
29 # Display usage of this script
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
30 usage () {
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
31 echo "usage: $0 kernelpath"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
32 exit 1
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
33 }
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
34
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
35
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
36
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
37 if [ -z $LINUXDIR ]
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
38 then
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
39 usage;
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
40 fi
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
41
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
42 # Check if kerneldir contains a Makefile
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
43 if [ ! -f $LINUXDIR/Makefile ]
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
44 then
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
45 echo "Directory $LINUXDIR does not exist or is not a kernel source directory";
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
46 exit 1;
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
47 fi
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
48
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
49 # Get kernel version
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
50 VERSION=`grep -s VERSION <$LINUXDIR/Makefile | head -n 1 | sed s/'VERSION = '//`
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
51 PATCHLEVEL=`grep -s PATCHLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'PATCHLEVEL = '//`
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
52 SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = '//`
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
53
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
54 # Can we handle this version?
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
55 if [ $VERSION -ne 2 -o $PATCHLEVEL -lt 6 ]
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
56 then
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
57 echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
58 exit 1;
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
59 fi
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
60
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
61
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
62 KCONFIG=$LINUXDIR/fs/Kconfig
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
63 KCONFIGOLD=$LINUXDIR/fs/Kconfig.pre.yaffs
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
64 YAFFS_PATCHED_STRING=`grep -s yaffs <$KCONFIG | head -n 1`
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
65
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
66 MAKEFILE=$LINUXDIR/fs/Makefile
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
67 MAKEFILEOLD=$LINUXDIR/fs/Makefile.pre.yaffs
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
68
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
69 if [ ! -z "$YAFFS_PATCHED_STRING" ]
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
70 then
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
71 YAFFS_PATCHED=0
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
72 echo "$KCONFIG already mentions YAFFS, so we will not change it"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
73 else
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
74 # Change the fs/Kconfig file
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
75 # Save the old Kconfig
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
76 # Copy all stuff up to JFFS
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
77 # Insert some YAFFS stuff
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
78 # Copy all the rest of the stuff
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
79
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
80 YAFFS_PATCHED=1
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
81 echo "Updating $KCONFIG"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
82 mv -f $KCONFIG $KCONFIGOLD
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
83 sed -n -e "/JFFS/,99999 ! p" $KCONFIGOLD >$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
84 echo "">>$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
85 echo "# Patched by YAFFS" >>$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
86 echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
87 echo "">>$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
88 sed -n -e "/JFFS/,99999 p" $KCONFIGOLD >>$KCONFIG
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
89
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
90 # now do fs/Makefile -- simply add the target at the end
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
91 echo "Updating $MAKEFILE"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
92 cp -f $MAKEFILE $MAKEFILEOLD
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
93 echo "">>$MAKEFILE
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
94 echo "# Patched by YAFFS" >>$MAKEFILE
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
95 echo "obj-\$(CONFIG_YAFFS_FS) += yaffs2/" >>$MAKEFILE
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
96
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
97 fi
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
98
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
99 YAFFSDIR=$LINUXDIR/fs/yaffs2
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
100
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
101 if [ -e $YAFFSDIR ]
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
102 then
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
103 echo "$YAFFSDIR exists, not patching"
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
104 else
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
105 mkdir $LINUXDIR/fs/yaffs2
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
106 cp Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
107 cp Kconfig $LINUXDIR/fs/yaffs2
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
108 cp *.c *.h $LINUXDIR/fs/yaffs2
bcf056049698 Added files that support the ability to "patchin" yaffs2 into the 2.6
marty <marty>
parents:
diff changeset
109 fi