2 # Script to apply kernel patches.
3 # usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] ] ]
4 # The source directory defaults to /usr/src/linux, and the patch
5 # directory defaults to the current directory.
7 # It determines the current kernel version from the top-level Makefile.
8 # It then looks for patches for the next sublevel in the patch directory.
9 # This is applied using "patch -p1 -s" from within the kernel directory.
10 # A check is then made for "*.rej" files to see if the patch was
11 # successful. If it is, then all of the "*.orig" files are removed.
13 # Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
15 # Added support for handling multiple types of compression. What includes
16 # gzip, bzip, bzip2, zip, compress, and plaintext.
18 # Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
20 # Added ability to stop at a given version number
21 # Put the full version number (i.e. 2.3.31) as the last parameter
22 # Dave Gilbert <linux@treblig.org>, 11th December 1999.
24 # Set directories from arguments, or use defaults.
25 sourcedir
=${1-/usr/src/linux}
27 stopvers
=${3-imnotaversion}
29 # set current VERSION, PATCHLEVEL, SUBLEVEL
30 eval `sed -n 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' $sourcedir/Makefile`
31 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
33 echo "unable to determine current kernel version" >&2
37 echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL"
41 SUBLEVEL
=`expr $SUBLEVEL + 1`
42 FULLVERSION
="$VERSION.$PATCHLEVEL.$SUBLEVEL"
44 patch=patch-
$FULLVERSION
45 if [ -r $patchdir/${patch}.gz
]; then
49 elif [ -r $patchdir/${patch}.bz
]; then
53 elif [ -r $patchdir/${patch}.bz2
]; then
57 elif [ -r $patchdir/${patch}.
zip ]; then
61 elif [ -r $patchdir/${patch}.Z
]; then
64 uncomp
="uncompress -c"
65 elif [ -r $patchdir/${patch} ]; then
73 echo -n "Applying ${patch} (${name})... "
74 if $uncomp ${patchdir}/${patch}${ext} |
patch -p1 -s -N -E -d $sourcedir
78 echo "failed. Clean up yourself."
81 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
83 echo "Aborting. Reject files found."
87 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \
;
89 if [ $stopvers = $FULLVERSION ]
91 echo "Stoping at $FULLVERSION as requested. Enjoy."