Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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