Linux Audio

Check our new training course

Loading...
v3.1
  1#! /bin/sh
 
  2# Script to apply kernel patches.
  3#   usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
  4#     The source directory defaults to /usr/src/linux, and the patch
  5#     directory defaults to the current directory.
  6# e.g.
  7#   scripts/patch-kernel . ..
  8#      Update the kernel tree in the current directory using patches in the
  9#      directory above to the latest Linus kernel
 10#   scripts/patch-kernel . .. -ac
 11#      Get the latest Linux kernel and patch it with the latest ac patch
 12#   scripts/patch-kernel . .. 2.4.9
 13#      Gets standard kernel 2.4.9
 14#   scripts/patch-kernel . .. 2.4.9 -ac
 15#      Gets 2.4.9 with latest ac patches
 16#   scripts/patch-kernel . .. 2.4.9 -ac11
 17#      Gets 2.4.9 with ac patch ac11
 18#   Note: It uses the patches relative to the Linus kernels, not the
 19#   ac to ac relative patches
 20#
 21# It determines the current kernel version from the top-level Makefile.
 22# It then looks for patches for the next sublevel in the patch directory.
 23# This is applied using "patch -p1 -s" from within the kernel directory.
 24# A check is then made for "*.rej" files to see if the patch was
 25# successful.  If it is, then all of the "*.orig" files are removed.
 26#
 27#       Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
 28#
 29# Added support for handling multiple types of compression. What includes
 30# gzip, bzip, bzip2, zip, compress, and plaintext. 
 31#
 32#       Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
 33#
 34# Added ability to stop at a given version number
 35# Put the full version number (i.e. 2.3.31) as the last parameter
 36#       Dave Gilbert <linux@treblig.org>, 11th December 1999.
 37
 38# Fixed previous patch so that if we are already at the correct version
 39# not to patch up.
 40#
 41# Added -ac option, use -ac or -ac9 (say) to stop at a particular version
 42#       Dave Gilbert <linux@treblig.org>, 29th September 2001.
 43#
 44# Add support for (use of) EXTRAVERSION (to support 2.6.8.x, e.g.);
 45# update usage message;
 46# fix some whitespace damage;
 47# be smarter about stopping when current version is larger than requested;
 48#	Randy Dunlap <rdunlap@xenotime.net>, 2004-AUG-18.
 49#
 50# Add better support for (non-incremental) 2.6.x.y patches;
 51# If an ending version number if not specified, the script automatically
 52# increments the SUBLEVEL (x in 2.6.x.y) until no more patch files are found;
 53# however, EXTRAVERSION (y in 2.6.x.y) is never automatically incremented
 54# but must be specified fully.
 55#
 56# patch-kernel does not normally support reverse patching, but does so when
 57# applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z
 58# is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z).
 59#	Randy Dunlap <rdunlap@xenotime.net>, 2005-APR-08.
 60
 61PNAME=patch-kernel
 62
 63# Set directories from arguments, or use defaults.
 64sourcedir=${1-/usr/src/linux}
 65patchdir=${2-.}
 66stopvers=${3-default}
 67
 68if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then
 69cat << USAGE
 70usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
 71  source directory defaults to /usr/src/linux,
 72  patch directory defaults to the current directory,
 73  stopversion defaults to <all in patchdir>.
 74USAGE
 75exit 1
 76fi
 77
 78# See if we have any -ac options
 79for PARM in $*
 80do
 81  case $PARM in
 82	  -ac*)
 83		  gotac=$PARM;
 84
 85	esac;
 86done
 87
 88# ---------------------------------------------------------------------------
 89# arg1 is filename
 90noFile () {
 91	echo "cannot find patch file: ${patch}"
 92	exit 1
 93}
 94
 95# ---------------------------------------------------------------------------
 96backwards () {
 97	echo "$PNAME does not support reverse patching"
 98	exit 1
 99}
100
101# ---------------------------------------------------------------------------
102# Find a file, first parameter is basename of file
103# it tries many compression mechanisms and sets variables to say how to get it
104findFile () {
105  filebase=$1;
106
107  if [ -r ${filebase}.gz ]; then
108		ext=".gz"
109		name="gzip"
110		uncomp="gunzip -dc"
111  elif [ -r ${filebase}.bz  ]; then
112		ext=".bz"
113		name="bzip"
114		uncomp="bunzip -dc"
115  elif [ -r ${filebase}.bz2 ]; then
116		ext=".bz2"
117		name="bzip2"
118		uncomp="bunzip2 -dc"
 
 
 
 
119  elif [ -r ${filebase}.zip ]; then
120		ext=".zip"
121		name="zip"
122		uncomp="unzip -d"
123  elif [ -r ${filebase}.Z ]; then
124		ext=".Z"
125		name="uncompress"
126		uncomp="uncompress -c"
127  elif [ -r ${filebase} ]; then
128		ext=""
129		name="plaintext"
130		uncomp="cat"
131  else
132	return 1;
133  fi
134
135  return 0;
136}
137
138# ---------------------------------------------------------------------------
139# Apply a patch and check it goes in cleanly
140# First param is patch name (e.g. patch-2.4.9-ac5) - without path or extension
141
142applyPatch () {
143  echo -n "Applying $1 (${name})... "
144  if $uncomp ${patchdir}/$1${ext} | patch -p1 -s -N -E -d $sourcedir
145  then
146    echo "done."
147  else
148    echo "failed.  Clean up yourself."
149    return 1;
150  fi
151  if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
152  then
153    echo "Aborting.  Reject files found."
154    return 1;
155  fi
156  # Remove backup files
157  find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
158 
159  return 0;
160}
161
162# ---------------------------------------------------------------------------
163# arg1 is patch filename
164reversePatch () {
165	echo -n "Reversing $1 (${name}) ... "
166	if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir
167	then
168		echo "done."
169	else
170		echo "failed.  Clean it up."
171		exit 1
172	fi
173	if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
174	then
175		echo "Aborting.  Reject files found."
176		return 1
177	fi
178	# Remove backup files
179	find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
180
181	return 0
182}
183
184# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
185# force $TMPFILEs below to be in local directory: a slash character prevents
186# the dot command from using the search path.
187TMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
188grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
189tr -d [:blank:] < $TMPFILE > $TMPFILE.1
190. $TMPFILE.1
191rm -f $TMPFILE*
192if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
193then
194    echo "unable to determine current kernel version" >&2
195    exit 1
196fi
197
198NAME=`grep ^NAME $sourcedir/Makefile`
199NAME=${NAME##*=}
200
201echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($NAME)"
202
203# strip EXTRAVERSION to just a number (drop leading '.' and trailing additions)
204EXTRAVER=
205if [ x$EXTRAVERSION != "x" ]
206then
207	EXTRAVER=${EXTRAVERSION#.}
208	EXTRAVER=${EXTRAVER%%[[:punct:]]*}
209	#echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
210fi
211
212#echo "stopvers=$stopvers"
213if [ $stopvers != "default" ]; then
214	STOPSUBLEVEL=`echo $stopvers | cut -d. -f3`
215	STOPEXTRA=`echo $stopvers | cut -d. -f4`
216	STOPFULLVERSION=${stopvers%%.$STOPEXTRA}
217	#echo "#___STOPSUBLEVEL=/$STOPSUBLEVEL/, STOPEXTRA=/$STOPEXTRA/"
218else
219	STOPSUBLEVEL=9999
220	STOPEXTRA=9999
221fi
222
223# This all assumes a 2.6.x[.y] kernel tree.
224# Don't allow backwards/reverse patching.
225if [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then
226	backwards
227fi
228
229if [ x$EXTRAVER != "x" ]; then
230	CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER"
231else
232	CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
233fi
234
235if [ x$EXTRAVER != "x" ]; then
236	echo "backing up to: $VERSION.$PATCHLEVEL.$SUBLEVEL"
237	patch="patch-${CURRENTFULLVERSION}"
238	findFile $patchdir/${patch} || noFile ${patch}
239	reversePatch ${patch} || exit 1
240fi
241
242# now current is 2.6.x, with no EXTRA applied,
243# so update to target SUBLEVEL (2.6.SUBLEVEL)
244# and then to target EXTRAVER (2.6.SUB.EXTRAVER) if requested.
245# If not ending sublevel is specified, it is incremented until
246# no further sublevels are found.
247
248if [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then
249while :				# incrementing SUBLEVEL (s in v.p.s)
250do
251    CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
252    EXTRAVER=
253    if [ x$STOPFULLVERSION = x$CURRENTFULLVERSION ]; then
254        echo "Stopping at $CURRENTFULLVERSION base as requested."
255        break
256    fi
257
258    SUBLEVEL=$(($SUBLEVEL + 1))
259    FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
260    #echo "#___ trying $FULLVERSION ___"
261
262    if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then
263	echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
264	exit 1
265    fi
266
267    patch=patch-$FULLVERSION
268    # See if the file exists and find extension
269    findFile $patchdir/${patch} || noFile ${patch}
270
271    # Apply the patch and check all is OK
272    applyPatch $patch || break
273done
274#echo "#___sublevel all done"
275fi
276
277# There is no incremental searching for extraversion...
278if [ "$STOPEXTRA" != "" ]; then
279while :				# just to allow break
280do
281# apply STOPEXTRA directly (not incrementally) (x in v.p.s.x)
282	FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$STOPEXTRA"
283	#echo "#... trying $FULLVERSION ..."
284	patch=patch-$FULLVERSION
285
286	# See if the file exists and find extension
287	findFile $patchdir/${patch} || noFile ${patch}
288
289	# Apply the patch and check all is OK
290	applyPatch $patch || break
291	#echo "#___extraver all done"
292	break
293done
294fi
295
296if [ x$gotac != x ]; then
297  # Out great user wants the -ac patches
298	# They could have done -ac (get latest) or -acxx where xx=version they want
299	if [ $gotac = "-ac" ]; then
300	  # They want the latest version
301		HIGHESTPATCH=0
302		for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*
303		do
304			ACVALUE=`echo $PATCHNAMES | sed -e 's/^.*patch-[0-9.]*-ac\([0-9]*\).*/\1/'`
305			# Check it is actually a recognised patch type
306			findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${ACVALUE} || break
307
308		  if [ $ACVALUE -gt $HIGHESTPATCH ]; then
309			  HIGHESTPATCH=$ACVALUE
310		  fi
311		done
312
313		if [ $HIGHESTPATCH -ne 0 ]; then
314			findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break
315			applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH}
316		else
317		  echo "No -ac patches found"
318		fi
319	else
320	  # They want an exact version
321		findFile $patchdir/patch-${CURRENTFULLVERSION}${gotac} || {
322		  echo "Sorry, I couldn't find the $gotac patch for $CURRENTFULLVERSION.  Hohum."
323			exit 1
324		}
325		applyPatch patch-${CURRENTFULLVERSION}${gotac}
326	fi
327fi
v6.13.7
  1#! /bin/sh
  2# SPDX-License-Identifier: GPL-2.0
  3# Script to apply kernel patches.
  4#   usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
  5#     The source directory defaults to /usr/src/linux, and the patch
  6#     directory defaults to the current directory.
  7# e.g.
  8#   scripts/patch-kernel . ..
  9#      Update the kernel tree in the current directory using patches in the
 10#      directory above to the latest Linus kernel
 11#   scripts/patch-kernel . .. -ac
 12#      Get the latest Linux kernel and patch it with the latest ac patch
 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
 19#   Note: It uses the patches relative to the Linus kernels, not the
 20#   ac to ac relative patches
 21#
 22# It determines the current kernel version from the top-level Makefile.
 23# It then looks for patches for the next sublevel in the patch directory.
 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
 26# successful.  If it is, then all of the "*.orig" files are removed.
 27#
 28#       Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
 29#
 30# Added support for handling multiple types of compression. What includes
 31# gzip, bzip, bzip2, zip, compress, and plaintext.
 32#
 33#       Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
 34#
 35# Added ability to stop at a given version number
 36# Put the full version number (i.e. 2.3.31) as the last parameter
 37#       Dave Gilbert <linux@treblig.org>, 11th December 1999.
 38
 39# Fixed previous patch so that if we are already at the correct version
 40# not to patch up.
 41#
 42# Added -ac option, use -ac or -ac9 (say) to stop at a particular version
 43#       Dave Gilbert <linux@treblig.org>, 29th September 2001.
 44#
 45# Add support for (use of) EXTRAVERSION (to support 2.6.8.x, e.g.);
 46# update usage message;
 47# fix some whitespace damage;
 48# be smarter about stopping when current version is larger than requested;
 49#	Randy Dunlap <rdunlap@xenotime.net>, 2004-AUG-18.
 50#
 51# Add better support for (non-incremental) 2.6.x.y patches;
 52# If an ending version number if not specified, the script automatically
 53# increments the SUBLEVEL (x in 2.6.x.y) until no more patch files are found;
 54# however, EXTRAVERSION (y in 2.6.x.y) is never automatically incremented
 55# but must be specified fully.
 56#
 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.
 61
 62PNAME=patch-kernel
 63
 64# Set directories from arguments, or use defaults.
 65sourcedir=${1-/usr/src/linux}
 66patchdir=${2-.}
 67stopvers=${3-default}
 68
 69if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then
 70cat << USAGE
 71usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
 72  source directory defaults to /usr/src/linux,
 73  patch directory defaults to the current directory,
 74  stopversion defaults to <all in patchdir>.
 75USAGE
 76exit 1
 77fi
 78
 79# See if we have any -ac options
 80for PARM in $*
 81do
 82  case $PARM in
 83	  -ac*)
 84		  gotac=$PARM;
 85
 86	esac;
 87done
 88
 89# ---------------------------------------------------------------------------
 90# arg1 is filename
 91noFile () {
 92	echo "cannot find patch file: ${patch}"
 93	exit 1
 94}
 95
 96# ---------------------------------------------------------------------------
 97backwards () {
 98	echo "$PNAME does not support reverse patching"
 99	exit 1
100}
101
102# ---------------------------------------------------------------------------
103# Find a file, first parameter is basename of file
104# it tries many compression mechanisms and sets variables to say how to get it
105findFile () {
106  filebase=$1;
107
108  if [ -r ${filebase}.gz ]; then
109		ext=".gz"
110		name="gzip"
111		uncomp="gunzip -dc"
112  elif [ -r ${filebase}.bz  ]; then
113		ext=".bz"
114		name="bzip"
115		uncomp="bunzip -dc"
116  elif [ -r ${filebase}.bz2 ]; then
117		ext=".bz2"
118		name="bzip2"
119		uncomp="bunzip2 -dc"
120  elif [ -r ${filebase}.xz ]; then
121                ext=".xz"
122                name="xz"
123                uncomp="xz -dc"
124  elif [ -r ${filebase}.zip ]; then
125		ext=".zip"
126		name="zip"
127		uncomp="unzip -d"
128  elif [ -r ${filebase}.Z ]; then
129		ext=".Z"
130		name="uncompress"
131		uncomp="uncompress -c"
132  elif [ -r ${filebase} ]; then
133		ext=""
134		name="plaintext"
135		uncomp="cat"
136  else
137	return 1;
138  fi
139
140  return 0;
141}
142
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
146
147applyPatch () {
148  echo -n "Applying $1 (${name})... "
149  if $uncomp ${patchdir}/$1${ext} | patch -p1 -s -N -E -d $sourcedir
150  then
151    echo "done."
152  else
153    echo "failed.  Clean up yourself."
154    return 1;
155  fi
156  if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
157  then
158    echo "Aborting.  Reject files found."
159    return 1;
160  fi
161  # Remove backup files
162  find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
163
164  return 0;
165}
166
167# ---------------------------------------------------------------------------
168# arg1 is patch filename
169reversePatch () {
170	echo -n "Reversing $1 (${name}) ... "
171	if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir
172	then
173		echo "done."
174	else
175		echo "failed.  Clean it up."
176		exit 1
177	fi
178	if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
179	then
180		echo "Aborting.  Reject files found."
181		return 1
182	fi
183	# Remove backup files
184	find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
185
186	return 0
187}
188
189# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
190# force $TMPFILEs below to be in local directory: a slash character prevents
191# the dot command from using the search path.
192TMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
193grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
194tr -d [:blank:] < $TMPFILE > $TMPFILE.1
195. $TMPFILE.1
196rm -f $TMPFILE*
197if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
198then
199    echo "unable to determine current kernel version" >&2
200    exit 1
201fi
202
203NAME=`grep ^NAME $sourcedir/Makefile`
204NAME=${NAME##*=}
205
206echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($NAME)"
207
208# strip EXTRAVERSION to just a number (drop leading '.' and trailing additions)
209EXTRAVER=
210if [ x$EXTRAVERSION != "x" ]
211then
212	EXTRAVER=${EXTRAVERSION#.}
213	EXTRAVER=${EXTRAVER%%[[:punct:]]*}
214	#echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
215fi
216
217#echo "stopvers=$stopvers"
218if [ $stopvers != "default" ]; then
219	STOPSUBLEVEL=`echo $stopvers | cut -d. -f3`
220	STOPEXTRA=`echo $stopvers | cut -d. -f4`
221	STOPFULLVERSION=${stopvers%%.$STOPEXTRA}
222	#echo "#___STOPSUBLEVEL=/$STOPSUBLEVEL/, STOPEXTRA=/$STOPEXTRA/"
223else
224	STOPSUBLEVEL=9999
225	STOPEXTRA=9999
226fi
227
228# This all assumes a 2.6.x[.y] kernel tree.
229# Don't allow backwards/reverse patching.
230if [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then
231	backwards
232fi
233
234if [ x$EXTRAVER != "x" ]; then
235	CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER"
236else
237	CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
238fi
239
240if [ x$EXTRAVER != "x" ]; then
241	echo "backing up to: $VERSION.$PATCHLEVEL.$SUBLEVEL"
242	patch="patch-${CURRENTFULLVERSION}"
243	findFile $patchdir/${patch} || noFile ${patch}
244	reversePatch ${patch} || exit 1
245fi
246
247# now current is 2.6.x, with no EXTRA applied,
248# so update to target SUBLEVEL (2.6.SUBLEVEL)
249# and then to target EXTRAVER (2.6.SUB.EXTRAVER) if requested.
250# If not ending sublevel is specified, it is incremented until
251# no further sublevels are found.
252
253if [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then
254while :				# incrementing SUBLEVEL (s in v.p.s)
255do
256    CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
257    EXTRAVER=
258    if [ x$STOPFULLVERSION = x$CURRENTFULLVERSION ]; then
259        echo "Stopping at $CURRENTFULLVERSION base as requested."
260        break
261    fi
262
263    SUBLEVEL=$(($SUBLEVEL + 1))
264    FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
265    #echo "#___ trying $FULLVERSION ___"
266
267    if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then
268	echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
269	exit 1
270    fi
271
272    patch=patch-$FULLVERSION
273    # See if the file exists and find extension
274    findFile $patchdir/${patch} || noFile ${patch}
275
276    # Apply the patch and check all is OK
277    applyPatch $patch || break
278done
279#echo "#___sublevel all done"
280fi
281
282# There is no incremental searching for extraversion...
283if [ "$STOPEXTRA" != "" ]; then
284while :				# just to allow break
285do
286# apply STOPEXTRA directly (not incrementally) (x in v.p.s.x)
287	FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$STOPEXTRA"
288	#echo "#... trying $FULLVERSION ..."
289	patch=patch-$FULLVERSION
290
291	# See if the file exists and find extension
292	findFile $patchdir/${patch} || noFile ${patch}
293
294	# Apply the patch and check all is OK
295	applyPatch $patch || break
296	#echo "#___extraver all done"
297	break
298done
299fi
300
301if [ x$gotac != x ]; then
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
305	  # They want the latest version
306		HIGHESTPATCH=0
307		for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*
308		do
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
312
313		  if [ $ACVALUE -gt $HIGHESTPATCH ]; then
314			  HIGHESTPATCH=$ACVALUE
315		  fi
316		done
317
318		if [ $HIGHESTPATCH -ne 0 ]; then
319			findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break
320			applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH}
321		else
322		  echo "No -ac patches found"
323		fi
324	else
325	  # They want an exact version
326		findFile $patchdir/patch-${CURRENTFULLVERSION}${gotac} || {
327		  echo "Sorry, I couldn't find the $gotac patch for $CURRENTFULLVERSION.  Hohum."
328			exit 1
329		}
330		applyPatch patch-${CURRENTFULLVERSION}${gotac}
331	fi
332fi