Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:z

2 # SPDX-License-Identifier: GPL-2.0
4 # usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
8 # scripts/patch-kernel . ..
11 # scripts/patch-kernel . .. -ac
13 # scripts/patch-kernel . .. 2.4.9
14 # Gets standard kernel 2.4.9
15 # scripts/patch-kernel . .. 2.4.9 -ac
16 # Gets 2.4.9 with latest ac patches
17 # scripts/patch-kernel . .. 2.4.9 -ac11
18 # Gets 2.4.9 with ac patch ac11
22 # It determines the current kernel version from the top-level Makefile.
24 # This is applied using "patch -p1 -s" from within the kernel directory.
25 # A check is then made for "*.rej" files to see if the patch was
35 # Added ability to stop at a given version number
42 # Added -ac option, use -ac or -ac9 (say) to stop at a particular version
49 # Randy Dunlap <rdunlap@xenotime.net>, 2004-AUG-18.
51 # Add better support for (non-incremental) 2.6.x.y patches;
57 # patch-kernel does not normally support reverse patching, but does so when
58 # applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z
59 # is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z).
60 # Randy Dunlap <rdunlap@xenotime.net>, 2005-APR-08.
62 PNAME=patch-kernel
65 sourcedir=${1-/usr/src/linux}
66 patchdir=${2-.}
67 stopvers=${3-default}
69 if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then
71 usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
79 # See if we have any -ac options
83 -ac*)
89 # ---------------------------------------------------------------------------
96 # ---------------------------------------------------------------------------
102 # ---------------------------------------------------------------------------
103 # Find a file, first parameter is basename of file
108 if [ -r ${filebase}.gz ]; then
111 uncomp="gunzip -dc"
112 elif [ -r ${filebase}.bz ]; then
115 uncomp="bunzip -dc"
116 elif [ -r ${filebase}.bz2 ]; then
119 uncomp="bunzip2 -dc"
120 elif [ -r ${filebase}.xz ]; then
123 uncomp="xz -dc"
124 elif [ -r ${filebase}.zip ]; then
127 uncomp="unzip -d"
128 elif [ -r ${filebase}.Z ]; then
129 ext=".Z"
131 uncomp="uncompress -c"
132 elif [ -r ${filebase} ]; then
140 return 0;
143 # ---------------------------------------------------------------------------
144 # Apply a patch and check it goes in cleanly
145 # First param is patch name (e.g. patch-2.4.9-ac5) - without path or extension
148 echo -n "Applying $1 (${name})... "
149 if $uncomp ${patchdir}/$1${ext} | patch -p1 -s -N -E -d $sourcedir
156 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
162 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
164 return 0;
167 # ---------------------------------------------------------------------------
170 echo -n "Reversing $1 (${name}) ... "
171 if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir
178 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
184 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
186 return 0
190 # force $TMPFILEs below to be in local directory: a slash character prevents
193 grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
194 tr -d [:blank:] < $TMPFILE > $TMPFILE.1
196 rm -f $TMPFILE*
197 if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
208 # strip EXTRAVERSION to just a number (drop leading '.' and trailing additions)
219 STOPSUBLEVEL=`echo $stopvers | cut -d. -f3`
220 STOPEXTRA=`echo $stopvers | cut -d. -f4`
228 # This all assumes a 2.6.x[.y] kernel tree.
230 if [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then
242 patch="patch-${CURRENTFULLVERSION}"
253 if [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then
267 if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then
268 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
272 patch=patch-$FULLVERSION
289 patch=patch-$FULLVERSION
302 # Out great user wants the -ac patches
303 # They could have done -ac (get latest) or -acxx where xx=version they want
304 if [ $gotac = "-ac" ]; then
306 HIGHESTPATCH=0
307 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*
309 ACVALUE=`echo $PATCHNAMES | sed -e 's/^.*patch-[0-9.]*-ac\([0-9]*\).*/\1/'`
310 # Check it is actually a recognised patch type
311 findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${ACVALUE} || break
313 if [ $ACVALUE -gt $HIGHESTPATCH ]; then
318 if [ $HIGHESTPATCH -ne 0 ]; then
319 findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break
320 applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH}
322 echo "No -ac patches found"
326 findFile $patchdir/patch-${CURRENTFULLVERSION}${gotac} || {
330 applyPatch patch-${CURRENTFULLVERSION}${gotac}