2 # Script to apply kernel patches.
3 # usage: patch-kernel [ sourcedir [ patchdir ] ]
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 # Set directories from arguments, or use defaults.
21 sourcedir
=${1-/usr/src/linux}
24 # set current VERSION, PATCHLEVEL, SUBLEVEL
25 eval `sed -n 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' $sourcedir/Makefile`
26 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
28 echo "unable to determine current kernel version" >&2
32 echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL"
36 SUBLEVEL
=`expr $SUBLEVEL + 1`
37 patch=patch-
$VERSION.
$PATCHLEVEL.
$SUBLEVEL
38 if [ -r $patchdir/${patch}.gz
]; then
42 elif [ -r $patchdir/${patch}.bz
]; then
46 elif [ -r $patchdir/${patch}.bz2
]; then
50 elif [ -r $patchdir/${patch}.
zip ]; then
54 elif [ -r $patchdir/${patch}.Z
]; then
57 uncomp
="uncompress -c"
58 elif [ -r $patchdir/${patch} ]; then
66 echo -n "Applying ${patch} (${name})... "
67 if $uncomp ${patchdir}/${patch}${ext} |
patch -p1 -s -N -E -d $sourcedir
71 echo "failed. Clean up yourself."
74 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
76 echo "Aborting. Reject files found."
80 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \
;