9
0
Fork 0

genenv: fix tempdir creation when target is a relative path

when $target is a path relative to $objtree the script fails.
This is because we cd to $basedir and then copy to $tempdir which
then is no longer valid. Fix this by converting $tempdir to an
absolute path first.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Christoph Fritz <chf.fritz@googlemail.com>
This commit is contained in:
Sascha Hauer 2014-04-28 12:46:06 +02:00
parent 0af79fbb67
commit 4905948695
1 changed files with 20 additions and 1 deletions

View File

@ -10,7 +10,26 @@ basedir=$1
target=$3
shift 3
tempdir="${target}.genenv.tmp"
abspath() {
local fn dn
if [ $# -ne 1 ]; then
echo "usage: ptxd_abspath <path>"
exit 1
fi
if [ -d "${1}" ]; then
fn=""
dn="${1}"
else
fn="/$(basename "${1}")"
dn="$(dirname "${1}")"
fi
[ ! -d "${dn}" ] && exit 1
echo "$(cd "${dn}" && pwd)${fn}"
}
export -f abspath
tempdir=$(abspath "${target}.genenv.tmp")
tmpfile="$(mktemp)"
mkdir -p "$tempdir"