qemu-patch-raspberry4/make_device_config.sh
Stefan Weil 0601740a5d make_device_config: Fix non-fatal error message with dash and other shells
ORS=" " adds a blank to the name of the include file.
Some shells (e.g. dash) don't accept input redirection
(tr -d '\r' < $f) when $f ends with a blank, so they
print an error message instead of reading pci.mak.
This is a non-fatal error because pci.mak does not
contain an include line. It was introduced by commit
5d6b423c5c.

Using printf avoids adding a blank and is also supported
by older awk versions (this solution was suggested by
Paolo Bonzini, thank you).

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Tested-by: Andreas Färber <andreas.faerber@web.de>
2011-01-14 22:00:07 +00:00

29 lines
638 B
Bash

#! /bin/sh
# Construct a target device config file from a default, pulling in any
# files from include directives.
dest=$1.tmp
dep=$1.d
src=$2
src_dir=`dirname $src`
all_includes=
process_includes () {
cat $1 | grep '^include' | \
while read include file ; do
all_includes="$all_includes $src_dir/$file"
process_includes $src_dir/$file
done
}
f=$src
while [ -n "$f" ] ; do
f=`tr -d '\r' < $f | awk '/^include / {printf "'$src_dir'/%s", $2}'`
[ $? = 0 ] || exit 1
all_includes="$all_includes $f"
done
process_includes $src > $dest
cat $src $all_includes | grep -v '^include' > $dest
echo "$1: $all_includes" > $dep