summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-04-28 12:46:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-29 07:57:24 +0200
commit49059486958c2f43a134ec08210c10cee209f596 (patch)
treefa18d0c18afa1bbf77bfa6cc23281771fe0912cf
parent0af79fbb6779921d3f1962773adb7fb57d3c89d4 (diff)
downloadbarebox-49059486958c2f43a134ec08210c10cee209f596.tar.gz
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>
-rwxr-xr-xscripts/genenv21
1 files changed, 20 insertions, 1 deletions
diff --git a/scripts/genenv b/scripts/genenv
index d0b0ffd..9f22ade 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -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"