diff options
author | Andreas Mohr <andi@lisas.de> | 2007-11-17 15:51:25 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-01-28 17:14:37 -0500 |
commit | 22d6a6a018d897c9c77c6af164722926e70108fa (patch) | |
tree | cc60f1f56aa40220fdbfccd3c561eaec59a067cd /scripts/patch-kernel | |
parent | 7491a76b23f5100823098b9d5d74ef18a2ca0dc1 (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/patch-kernel')
-rwxr-xr-x | scripts/patch-kernel | 22 |
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} | |||
65 | patchdir=${2-.} | 65 | patchdir=${2-.} |
66 | stopvers=${3-default} | 66 | stopvers=${3-default} |
67 | 67 | ||
68 | if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then | 68 | if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then |
69 | cat << USAGE | 69 | cat << USAGE |
70 | usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] | 70 | usage: $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 |
185 | TMPFILE=`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. | ||
187 | TMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } | ||
186 | grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE | 188 | grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE |
187 | tr -d [:blank:] < $TMPFILE > $TMPFILE.1 | 189 | tr -d [:blank:] < $TMPFILE > $TMPFILE.1 |
188 | source $TMPFILE.1 | 190 | . $TMPFILE.1 |
189 | rm -f $TMPFILE* | 191 | rm -f $TMPFILE* |
190 | if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] | 192 | if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] |
191 | then | 193 | then |
@@ -202,11 +204,7 @@ echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($ | |||
202 | EXTRAVER= | 204 | EXTRAVER= |
203 | if [ x$EXTRAVERSION != "x" ] | 205 | if [ x$EXTRAVERSION != "x" ] |
204 | then | 206 | then |
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" |
212 | fi | 210 | fi |
@@ -251,16 +249,16 @@ while : # incrementing SUBLEVEL (s in v.p.s) | |||
251 | do | 249 | do |
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 | |||
297 | if [ x$gotac != x ]; then | 295 | if [ 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*\.* |