1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#! /bin/sh
# Script to apply kernel patches.
# usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] ] ]
# The source directory defaults to /usr/src/linux, and the patch
# directory defaults to the current directory.
#
# It determines the current kernel version from the top-level Makefile.
# It then looks for patches for the next sublevel in the patch directory.
# This is applied using "patch -p1 -s" from within the kernel directory.
# A check is then made for "*.rej" files to see if the patch was
# successful. If it is, then all of the "*.orig" files are removed.
#
# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
#
# Added support for handling multiple types of compression. What includes
# gzip, bzip, bzip2, zip, compress, and plaintext.
#
# Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
#
# Added ability to stop at a given version number
# Put the full version number (i.e. 2.3.31) as the last parameter
# Dave Gilbert <linux@treblig.org>, 11th December 1999.
# Set directories from arguments, or use defaults.
sourcedir=${1-/usr/src/linux}
patchdir=${2-.}
stopvers=${3-imnotaversion}
# set current VERSION, PATCHLEVEL, SUBLEVEL
eval `sed -n 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' $sourcedir/Makefile`
if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
then
echo "unable to determine current kernel version" >&2
exit 1
fi
echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL"
while :
do
SUBLEVEL=`expr $SUBLEVEL + 1`
FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
patch=patch-$FULLVERSION
if [ -r $patchdir/${patch}.gz ]; then
ext=".gz"
name="gzip"
uncomp="gunzip -dc"
elif [ -r $patchdir/${patch}.bz ]; then
ext=".bz"
name="bzip"
uncomp="bunzip -dc"
elif [ -r $patchdir/${patch}.bz2 ]; then
ext=".bz2"
name="bzip2"
uncomp="bunzip2 -dc"
elif [ -r $patchdir/${patch}.zip ]; then
ext=".zip"
name="zip"
uncomp="unzip -d"
elif [ -r $patchdir/${patch}.Z ]; then
ext=".Z"
name="uncompress"
uncomp="uncompress -c"
elif [ -r $patchdir/${patch} ]; then
ext=""
name="plaintext"
uncomp="cat"
else
break
fi
echo -n "Applying ${patch} (${name})... "
if $uncomp ${patchdir}/${patch}${ext} | patch -p1 -s -N -E -d $sourcedir
then
echo "done."
else
echo "failed. Clean up yourself."
break
fi
if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
then
echo "Aborting. Reject files found."
break
fi
# Remove backup files
find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
if [ $stopvers = $FULLVERSION ]
then
echo "Stoping at $FULLVERSION as requested. Enjoy."
break
fi
done
|