annotate patch-ker.sh @ 174:7d11ae6795e4

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