aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndreas Mohr <andi@lisas.de>2007-11-17 15:51:25 -0500
committerSam Ravnborg <sam@ravnborg.org>2008-01-28 17:14:37 -0500
commit22d6a6a018d897c9c77c6af164722926e70108fa (patch)
treecc60f1f56aa40220fdbfccd3c561eaec59a067cd /scripts
parent7491a76b23f5100823098b9d5d74ef18a2ca0dc1 (diff)
kbuild: eradicate bashisms in scripts/patch-kernel
Make the patch-kernel shell script sufficiently compatible with POSIX shells, i.e., remove bashisms from scripts/patch-kernel. This means that it now also works on dash 0.5.3-5 and still works on bash 3.1dfsg-8. Full changelog: - replaced non-standard "==" by standard "=" - replaced non-standard "source" statement by POSIX "dot" command - use leading ./ on mktemp filename to force the tempfile to a local directory, so that the search path is not used - replace bash syntax to remove leading dot by similar POSIX syntax - added missing (optional/not required) $ signs to shell variable names Signed-off-by: Andreas Mohr <andi@lisas.de> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/patch-kernel22
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 67e4b1868e50..ece46ef0ba54 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -65,7 +65,7 @@ sourcedir=${1-/usr/src/linux}
65patchdir=${2-.} 65patchdir=${2-.}
66stopvers=${3-default} 66stopvers=${3-default}
67 67
68if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then 68if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then
69cat << USAGE 69cat << USAGE
70usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] 70usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
71 source directory defaults to /usr/src/linux, 71 source directory defaults to /usr/src/linux,
@@ -182,10 +182,12 @@ reversePatch () {
182} 182}
183 183
184# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION 184# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
185TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } 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; }
186grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE 188grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
187tr -d [:blank:] < $TMPFILE > $TMPFILE.1 189tr -d [:blank:] < $TMPFILE > $TMPFILE.1
188source $TMPFILE.1 190. $TMPFILE.1
189rm -f $TMPFILE* 191rm -f $TMPFILE*
190if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] 192if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
191then 193then
@@ -202,11 +204,7 @@ echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($
202EXTRAVER= 204EXTRAVER=
203if [ x$EXTRAVERSION != "x" ] 205if [ x$EXTRAVERSION != "x" ]
204then 206then
205 if [ ${EXTRAVERSION:0:1} == "." ]; then 207 EXTRAVER=${EXTRAVERSION#.}
206 EXTRAVER=${EXTRAVERSION:1}
207 else
208 EXTRAVER=$EXTRAVERSION
209 fi
210 EXTRAVER=${EXTRAVER%%[[:punct:]]*} 208 EXTRAVER=${EXTRAVER%%[[:punct:]]*}
211 #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER" 209 #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
212fi 210fi
@@ -251,16 +249,16 @@ while : # incrementing SUBLEVEL (s in v.p.s)
251do 249do
252 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 250 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
253 EXTRAVER= 251 EXTRAVER=
254 if [ $stopvers == $CURRENTFULLVERSION ]; then 252 if [ $stopvers = $CURRENTFULLVERSION ]; then
255 echo "Stopping at $CURRENTFULLVERSION base as requested." 253 echo "Stopping at $CURRENTFULLVERSION base as requested."
256 break 254 break
257 fi 255 fi
258 256
259 SUBLEVEL=$((SUBLEVEL + 1)) 257 SUBLEVEL=$(($SUBLEVEL + 1))
260 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 258 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
261 #echo "#___ trying $FULLVERSION ___" 259 #echo "#___ trying $FULLVERSION ___"
262 260
263 if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then 261 if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then
264 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)" 262 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
265 exit 1 263 exit 1
266 fi 264 fi
@@ -297,7 +295,7 @@ fi
297if [ x$gotac != x ]; then 295if [ x$gotac != x ]; then
298 # Out great user wants the -ac patches 296 # Out great user wants the -ac patches
299 # They could have done -ac (get latest) or -acxx where xx=version they want 297 # They could have done -ac (get latest) or -acxx where xx=version they want
300 if [ $gotac == "-ac" ]; then 298 if [ $gotac = "-ac" ]; then
301 # They want the latest version 299 # They want the latest version
302 HIGHESTPATCH=0 300 HIGHESTPATCH=0
303 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.* 301 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*