18c2ecf20Sopenharmony_ci#! /bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci# Script to apply kernel patches. 48c2ecf20Sopenharmony_ci# usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] 58c2ecf20Sopenharmony_ci# The source directory defaults to /usr/src/linux, and the patch 68c2ecf20Sopenharmony_ci# directory defaults to the current directory. 78c2ecf20Sopenharmony_ci# e.g. 88c2ecf20Sopenharmony_ci# scripts/patch-kernel . .. 98c2ecf20Sopenharmony_ci# Update the kernel tree in the current directory using patches in the 108c2ecf20Sopenharmony_ci# directory above to the latest Linus kernel 118c2ecf20Sopenharmony_ci# scripts/patch-kernel . .. -ac 128c2ecf20Sopenharmony_ci# Get the latest Linux kernel and patch it with the latest ac patch 138c2ecf20Sopenharmony_ci# scripts/patch-kernel . .. 2.4.9 148c2ecf20Sopenharmony_ci# Gets standard kernel 2.4.9 158c2ecf20Sopenharmony_ci# scripts/patch-kernel . .. 2.4.9 -ac 168c2ecf20Sopenharmony_ci# Gets 2.4.9 with latest ac patches 178c2ecf20Sopenharmony_ci# scripts/patch-kernel . .. 2.4.9 -ac11 188c2ecf20Sopenharmony_ci# Gets 2.4.9 with ac patch ac11 198c2ecf20Sopenharmony_ci# Note: It uses the patches relative to the Linus kernels, not the 208c2ecf20Sopenharmony_ci# ac to ac relative patches 218c2ecf20Sopenharmony_ci# 228c2ecf20Sopenharmony_ci# It determines the current kernel version from the top-level Makefile. 238c2ecf20Sopenharmony_ci# It then looks for patches for the next sublevel in the patch directory. 248c2ecf20Sopenharmony_ci# This is applied using "patch -p1 -s" from within the kernel directory. 258c2ecf20Sopenharmony_ci# A check is then made for "*.rej" files to see if the patch was 268c2ecf20Sopenharmony_ci# successful. If it is, then all of the "*.orig" files are removed. 278c2ecf20Sopenharmony_ci# 288c2ecf20Sopenharmony_ci# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995. 298c2ecf20Sopenharmony_ci# 308c2ecf20Sopenharmony_ci# Added support for handling multiple types of compression. What includes 318c2ecf20Sopenharmony_ci# gzip, bzip, bzip2, zip, compress, and plaintext. 328c2ecf20Sopenharmony_ci# 338c2ecf20Sopenharmony_ci# Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997. 348c2ecf20Sopenharmony_ci# 358c2ecf20Sopenharmony_ci# Added ability to stop at a given version number 368c2ecf20Sopenharmony_ci# Put the full version number (i.e. 2.3.31) as the last parameter 378c2ecf20Sopenharmony_ci# Dave Gilbert <linux@treblig.org>, 11th December 1999. 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci# Fixed previous patch so that if we are already at the correct version 408c2ecf20Sopenharmony_ci# not to patch up. 418c2ecf20Sopenharmony_ci# 428c2ecf20Sopenharmony_ci# Added -ac option, use -ac or -ac9 (say) to stop at a particular version 438c2ecf20Sopenharmony_ci# Dave Gilbert <linux@treblig.org>, 29th September 2001. 448c2ecf20Sopenharmony_ci# 458c2ecf20Sopenharmony_ci# Add support for (use of) EXTRAVERSION (to support 2.6.8.x, e.g.); 468c2ecf20Sopenharmony_ci# update usage message; 478c2ecf20Sopenharmony_ci# fix some whitespace damage; 488c2ecf20Sopenharmony_ci# be smarter about stopping when current version is larger than requested; 498c2ecf20Sopenharmony_ci# Randy Dunlap <rdunlap@xenotime.net>, 2004-AUG-18. 508c2ecf20Sopenharmony_ci# 518c2ecf20Sopenharmony_ci# Add better support for (non-incremental) 2.6.x.y patches; 528c2ecf20Sopenharmony_ci# If an ending version number if not specified, the script automatically 538c2ecf20Sopenharmony_ci# increments the SUBLEVEL (x in 2.6.x.y) until no more patch files are found; 548c2ecf20Sopenharmony_ci# however, EXTRAVERSION (y in 2.6.x.y) is never automatically incremented 558c2ecf20Sopenharmony_ci# but must be specified fully. 568c2ecf20Sopenharmony_ci# 578c2ecf20Sopenharmony_ci# patch-kernel does not normally support reverse patching, but does so when 588c2ecf20Sopenharmony_ci# applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z 598c2ecf20Sopenharmony_ci# is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z). 608c2ecf20Sopenharmony_ci# Randy Dunlap <rdunlap@xenotime.net>, 2005-APR-08. 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciPNAME=patch-kernel 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci# Set directories from arguments, or use defaults. 658c2ecf20Sopenharmony_cisourcedir=${1-/usr/src/linux} 668c2ecf20Sopenharmony_cipatchdir=${2-.} 678c2ecf20Sopenharmony_cistopvers=${3-default} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciif [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then 708c2ecf20Sopenharmony_cicat << USAGE 718c2ecf20Sopenharmony_ciusage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] 728c2ecf20Sopenharmony_ci source directory defaults to /usr/src/linux, 738c2ecf20Sopenharmony_ci patch directory defaults to the current directory, 748c2ecf20Sopenharmony_ci stopversion defaults to <all in patchdir>. 758c2ecf20Sopenharmony_ciUSAGE 768c2ecf20Sopenharmony_ciexit 1 778c2ecf20Sopenharmony_cifi 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci# See if we have any -ac options 808c2ecf20Sopenharmony_cifor PARM in $* 818c2ecf20Sopenharmony_cido 828c2ecf20Sopenharmony_ci case $PARM in 838c2ecf20Sopenharmony_ci -ac*) 848c2ecf20Sopenharmony_ci gotac=$PARM; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci esac; 878c2ecf20Sopenharmony_cidone 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci# --------------------------------------------------------------------------- 908c2ecf20Sopenharmony_ci# arg1 is filename 918c2ecf20Sopenharmony_cinoFile () { 928c2ecf20Sopenharmony_ci echo "cannot find patch file: ${patch}" 938c2ecf20Sopenharmony_ci exit 1 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci# --------------------------------------------------------------------------- 978c2ecf20Sopenharmony_cibackwards () { 988c2ecf20Sopenharmony_ci echo "$PNAME does not support reverse patching" 998c2ecf20Sopenharmony_ci exit 1 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci# --------------------------------------------------------------------------- 1038c2ecf20Sopenharmony_ci# Find a file, first parameter is basename of file 1048c2ecf20Sopenharmony_ci# it tries many compression mechanisms and sets variables to say how to get it 1058c2ecf20Sopenharmony_cifindFile () { 1068c2ecf20Sopenharmony_ci filebase=$1; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci if [ -r ${filebase}.gz ]; then 1098c2ecf20Sopenharmony_ci ext=".gz" 1108c2ecf20Sopenharmony_ci name="gzip" 1118c2ecf20Sopenharmony_ci uncomp="gunzip -dc" 1128c2ecf20Sopenharmony_ci elif [ -r ${filebase}.bz ]; then 1138c2ecf20Sopenharmony_ci ext=".bz" 1148c2ecf20Sopenharmony_ci name="bzip" 1158c2ecf20Sopenharmony_ci uncomp="bunzip -dc" 1168c2ecf20Sopenharmony_ci elif [ -r ${filebase}.bz2 ]; then 1178c2ecf20Sopenharmony_ci ext=".bz2" 1188c2ecf20Sopenharmony_ci name="bzip2" 1198c2ecf20Sopenharmony_ci uncomp="bunzip2 -dc" 1208c2ecf20Sopenharmony_ci elif [ -r ${filebase}.xz ]; then 1218c2ecf20Sopenharmony_ci ext=".xz" 1228c2ecf20Sopenharmony_ci name="xz" 1238c2ecf20Sopenharmony_ci uncomp="xz -dc" 1248c2ecf20Sopenharmony_ci elif [ -r ${filebase}.zip ]; then 1258c2ecf20Sopenharmony_ci ext=".zip" 1268c2ecf20Sopenharmony_ci name="zip" 1278c2ecf20Sopenharmony_ci uncomp="unzip -d" 1288c2ecf20Sopenharmony_ci elif [ -r ${filebase}.Z ]; then 1298c2ecf20Sopenharmony_ci ext=".Z" 1308c2ecf20Sopenharmony_ci name="uncompress" 1318c2ecf20Sopenharmony_ci uncomp="uncompress -c" 1328c2ecf20Sopenharmony_ci elif [ -r ${filebase} ]; then 1338c2ecf20Sopenharmony_ci ext="" 1348c2ecf20Sopenharmony_ci name="plaintext" 1358c2ecf20Sopenharmony_ci uncomp="cat" 1368c2ecf20Sopenharmony_ci else 1378c2ecf20Sopenharmony_ci return 1; 1388c2ecf20Sopenharmony_ci fi 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci return 0; 1418c2ecf20Sopenharmony_ci} 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci# --------------------------------------------------------------------------- 1448c2ecf20Sopenharmony_ci# Apply a patch and check it goes in cleanly 1458c2ecf20Sopenharmony_ci# First param is patch name (e.g. patch-2.4.9-ac5) - without path or extension 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciapplyPatch () { 1488c2ecf20Sopenharmony_ci echo -n "Applying $1 (${name})... " 1498c2ecf20Sopenharmony_ci if $uncomp ${patchdir}/$1${ext} | patch -p1 -s -N -E -d $sourcedir 1508c2ecf20Sopenharmony_ci then 1518c2ecf20Sopenharmony_ci echo "done." 1528c2ecf20Sopenharmony_ci else 1538c2ecf20Sopenharmony_ci echo "failed. Clean up yourself." 1548c2ecf20Sopenharmony_ci return 1; 1558c2ecf20Sopenharmony_ci fi 1568c2ecf20Sopenharmony_ci if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] 1578c2ecf20Sopenharmony_ci then 1588c2ecf20Sopenharmony_ci echo "Aborting. Reject files found." 1598c2ecf20Sopenharmony_ci return 1; 1608c2ecf20Sopenharmony_ci fi 1618c2ecf20Sopenharmony_ci # Remove backup files 1628c2ecf20Sopenharmony_ci find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci return 0; 1658c2ecf20Sopenharmony_ci} 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci# --------------------------------------------------------------------------- 1688c2ecf20Sopenharmony_ci# arg1 is patch filename 1698c2ecf20Sopenharmony_cireversePatch () { 1708c2ecf20Sopenharmony_ci echo -n "Reversing $1 (${name}) ... " 1718c2ecf20Sopenharmony_ci if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir 1728c2ecf20Sopenharmony_ci then 1738c2ecf20Sopenharmony_ci echo "done." 1748c2ecf20Sopenharmony_ci else 1758c2ecf20Sopenharmony_ci echo "failed. Clean it up." 1768c2ecf20Sopenharmony_ci exit 1 1778c2ecf20Sopenharmony_ci fi 1788c2ecf20Sopenharmony_ci if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] 1798c2ecf20Sopenharmony_ci then 1808c2ecf20Sopenharmony_ci echo "Aborting. Reject files found." 1818c2ecf20Sopenharmony_ci return 1 1828c2ecf20Sopenharmony_ci fi 1838c2ecf20Sopenharmony_ci # Remove backup files 1848c2ecf20Sopenharmony_ci find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci return 0 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION 1908c2ecf20Sopenharmony_ci# force $TMPFILEs below to be in local directory: a slash character prevents 1918c2ecf20Sopenharmony_ci# the dot command from using the search path. 1928c2ecf20Sopenharmony_ciTMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } 1938c2ecf20Sopenharmony_cigrep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE 1948c2ecf20Sopenharmony_citr -d [:blank:] < $TMPFILE > $TMPFILE.1 1958c2ecf20Sopenharmony_ci. $TMPFILE.1 1968c2ecf20Sopenharmony_cirm -f $TMPFILE* 1978c2ecf20Sopenharmony_ciif [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] 1988c2ecf20Sopenharmony_cithen 1998c2ecf20Sopenharmony_ci echo "unable to determine current kernel version" >&2 2008c2ecf20Sopenharmony_ci exit 1 2018c2ecf20Sopenharmony_cifi 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ciNAME=`grep ^NAME $sourcedir/Makefile` 2048c2ecf20Sopenharmony_ciNAME=${NAME##*=} 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ciecho "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($NAME)" 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci# strip EXTRAVERSION to just a number (drop leading '.' and trailing additions) 2098c2ecf20Sopenharmony_ciEXTRAVER= 2108c2ecf20Sopenharmony_ciif [ x$EXTRAVERSION != "x" ] 2118c2ecf20Sopenharmony_cithen 2128c2ecf20Sopenharmony_ci EXTRAVER=${EXTRAVERSION#.} 2138c2ecf20Sopenharmony_ci EXTRAVER=${EXTRAVER%%[[:punct:]]*} 2148c2ecf20Sopenharmony_ci #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER" 2158c2ecf20Sopenharmony_cifi 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci#echo "stopvers=$stopvers" 2188c2ecf20Sopenharmony_ciif [ $stopvers != "default" ]; then 2198c2ecf20Sopenharmony_ci STOPSUBLEVEL=`echo $stopvers | cut -d. -f3` 2208c2ecf20Sopenharmony_ci STOPEXTRA=`echo $stopvers | cut -d. -f4` 2218c2ecf20Sopenharmony_ci STOPFULLVERSION=${stopvers%%.$STOPEXTRA} 2228c2ecf20Sopenharmony_ci #echo "#___STOPSUBLEVEL=/$STOPSUBLEVEL/, STOPEXTRA=/$STOPEXTRA/" 2238c2ecf20Sopenharmony_cielse 2248c2ecf20Sopenharmony_ci STOPSUBLEVEL=9999 2258c2ecf20Sopenharmony_ci STOPEXTRA=9999 2268c2ecf20Sopenharmony_cifi 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci# This all assumes a 2.6.x[.y] kernel tree. 2298c2ecf20Sopenharmony_ci# Don't allow backwards/reverse patching. 2308c2ecf20Sopenharmony_ciif [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then 2318c2ecf20Sopenharmony_ci backwards 2328c2ecf20Sopenharmony_cifi 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ciif [ x$EXTRAVER != "x" ]; then 2358c2ecf20Sopenharmony_ci CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER" 2368c2ecf20Sopenharmony_cielse 2378c2ecf20Sopenharmony_ci CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 2388c2ecf20Sopenharmony_cifi 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ciif [ x$EXTRAVER != "x" ]; then 2418c2ecf20Sopenharmony_ci echo "backing up to: $VERSION.$PATCHLEVEL.$SUBLEVEL" 2428c2ecf20Sopenharmony_ci patch="patch-${CURRENTFULLVERSION}" 2438c2ecf20Sopenharmony_ci findFile $patchdir/${patch} || noFile ${patch} 2448c2ecf20Sopenharmony_ci reversePatch ${patch} || exit 1 2458c2ecf20Sopenharmony_cifi 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci# now current is 2.6.x, with no EXTRA applied, 2488c2ecf20Sopenharmony_ci# so update to target SUBLEVEL (2.6.SUBLEVEL) 2498c2ecf20Sopenharmony_ci# and then to target EXTRAVER (2.6.SUB.EXTRAVER) if requested. 2508c2ecf20Sopenharmony_ci# If not ending sublevel is specified, it is incremented until 2518c2ecf20Sopenharmony_ci# no further sublevels are found. 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ciif [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then 2548c2ecf20Sopenharmony_ciwhile : # incrementing SUBLEVEL (s in v.p.s) 2558c2ecf20Sopenharmony_cido 2568c2ecf20Sopenharmony_ci CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 2578c2ecf20Sopenharmony_ci EXTRAVER= 2588c2ecf20Sopenharmony_ci if [ x$STOPFULLVERSION = x$CURRENTFULLVERSION ]; then 2598c2ecf20Sopenharmony_ci echo "Stopping at $CURRENTFULLVERSION base as requested." 2608c2ecf20Sopenharmony_ci break 2618c2ecf20Sopenharmony_ci fi 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci SUBLEVEL=$(($SUBLEVEL + 1)) 2648c2ecf20Sopenharmony_ci FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 2658c2ecf20Sopenharmony_ci #echo "#___ trying $FULLVERSION ___" 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then 2688c2ecf20Sopenharmony_ci echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)" 2698c2ecf20Sopenharmony_ci exit 1 2708c2ecf20Sopenharmony_ci fi 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci patch=patch-$FULLVERSION 2738c2ecf20Sopenharmony_ci # See if the file exists and find extension 2748c2ecf20Sopenharmony_ci findFile $patchdir/${patch} || noFile ${patch} 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci # Apply the patch and check all is OK 2778c2ecf20Sopenharmony_ci applyPatch $patch || break 2788c2ecf20Sopenharmony_cidone 2798c2ecf20Sopenharmony_ci#echo "#___sublevel all done" 2808c2ecf20Sopenharmony_cifi 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci# There is no incremental searching for extraversion... 2838c2ecf20Sopenharmony_ciif [ "$STOPEXTRA" != "" ]; then 2848c2ecf20Sopenharmony_ciwhile : # just to allow break 2858c2ecf20Sopenharmony_cido 2868c2ecf20Sopenharmony_ci# apply STOPEXTRA directly (not incrementally) (x in v.p.s.x) 2878c2ecf20Sopenharmony_ci FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$STOPEXTRA" 2888c2ecf20Sopenharmony_ci #echo "#... trying $FULLVERSION ..." 2898c2ecf20Sopenharmony_ci patch=patch-$FULLVERSION 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci # See if the file exists and find extension 2928c2ecf20Sopenharmony_ci findFile $patchdir/${patch} || noFile ${patch} 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci # Apply the patch and check all is OK 2958c2ecf20Sopenharmony_ci applyPatch $patch || break 2968c2ecf20Sopenharmony_ci #echo "#___extraver all done" 2978c2ecf20Sopenharmony_ci break 2988c2ecf20Sopenharmony_cidone 2998c2ecf20Sopenharmony_cifi 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ciif [ x$gotac != x ]; then 3028c2ecf20Sopenharmony_ci # Out great user wants the -ac patches 3038c2ecf20Sopenharmony_ci # They could have done -ac (get latest) or -acxx where xx=version they want 3048c2ecf20Sopenharmony_ci if [ $gotac = "-ac" ]; then 3058c2ecf20Sopenharmony_ci # They want the latest version 3068c2ecf20Sopenharmony_ci HIGHESTPATCH=0 3078c2ecf20Sopenharmony_ci for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.* 3088c2ecf20Sopenharmony_ci do 3098c2ecf20Sopenharmony_ci ACVALUE=`echo $PATCHNAMES | sed -e 's/^.*patch-[0-9.]*-ac\([0-9]*\).*/\1/'` 3108c2ecf20Sopenharmony_ci # Check it is actually a recognised patch type 3118c2ecf20Sopenharmony_ci findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${ACVALUE} || break 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci if [ $ACVALUE -gt $HIGHESTPATCH ]; then 3148c2ecf20Sopenharmony_ci HIGHESTPATCH=$ACVALUE 3158c2ecf20Sopenharmony_ci fi 3168c2ecf20Sopenharmony_ci done 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci if [ $HIGHESTPATCH -ne 0 ]; then 3198c2ecf20Sopenharmony_ci findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break 3208c2ecf20Sopenharmony_ci applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} 3218c2ecf20Sopenharmony_ci else 3228c2ecf20Sopenharmony_ci echo "No -ac patches found" 3238c2ecf20Sopenharmony_ci fi 3248c2ecf20Sopenharmony_ci else 3258c2ecf20Sopenharmony_ci # They want an exact version 3268c2ecf20Sopenharmony_ci findFile $patchdir/patch-${CURRENTFULLVERSION}${gotac} || { 3278c2ecf20Sopenharmony_ci echo "Sorry, I couldn't find the $gotac patch for $CURRENTFULLVERSION. Hohum." 3288c2ecf20Sopenharmony_ci exit 1 3298c2ecf20Sopenharmony_ci } 3308c2ecf20Sopenharmony_ci applyPatch patch-${CURRENTFULLVERSION}${gotac} 3318c2ecf20Sopenharmony_ci fi 3328c2ecf20Sopenharmony_cifi 333