summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Walle <bernhard@bwalle.de>2012-03-13 12:30:23 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2012-03-13 14:12:54 +0100
commit1a437bcf795494a069fbbb8b9f90094b6a37dbb3 (patch)
tree7099f733953ff988b3076b1a8ab607d5a70a85e3
parentce02d97a00659868b77665fc7066a52a048faa9d (diff)
downloadptxdist-1a437bcf795494a069fbbb8b9f90094b6a37dbb3.tar.gz
ptxdist-1a437bcf795494a069fbbb8b9f90094b6a37dbb3.tar.xz
ptxdist: Check for GNU readlink
ptxdist heavily uses "readlink -f" which only works with GNU readlink. So add the usual check here. However, because "readlink -f" is also used before the symlinks in the ptxdist directory is added to the PATH, that "readlink -f" call is replaced by a bash-only implementation. This one is inspired from http://mailman.archlinux.org/pipermail/pacman-dev/2009-February/008130.html. Tested on Mac OS 10.7. Signed-off-by: Bernhard Walle <bernhard@bwalle.de> [mol: fixed some more quoting] Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--Makefile.in1
-rwxr-xr-xbin/ptxdist22
-rw-r--r--configure.ac1
3 files changed, 23 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in
index e62a2d97a..17a6ce6e2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -54,6 +54,7 @@ environment:
@ln -sf @GNU_stat@ "$(abs_srcdir)/bin/stat"
@ln -sf @GNU_mknod@ "$(abs_srcdir)/bin/mknod"
@ln -sf @GNU_tar@ "$(abs_srcdir)/bin/tar"
+ @ln -sf @GNU_readlink@ "$(abs_srcdir)/bin/readlink"
@ln -sf @PYTHON@ "$(abs_srcdir)/bin/python"
@ln -sf @SED@ "$(abs_srcdir)/bin/sed"
@ln -sf @XARGS@ "$(abs_srcdir)/bin/xargs"
diff --git a/bin/ptxdist b/bin/ptxdist
index 029939da7..440a7aa21 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -1843,6 +1843,26 @@ EOF
################ setup stuff only ################################
##################################################################
+#
+# bash implementation of realpath / readlink -f
+# arg1 - filename
+realpath()
+{
+ local fname oldfname
+
+ fname="${1%/}" # strips trailing '/'
+ while [ -L "${fname}" ]; do
+ oldfname="${fname}"
+ fname="$(readlink "${fname}")"
+ if [ "${fname}" = "." ] ; then
+ fname="$(dirname "${oldfname}")"
+ elif [ "${fname}" = "${fname#/}" ]; then
+ fname="$(dirname "${oldfname}")/${fname}"
+ fi
+ done
+
+ (cd "$(dirname "${fname}")"; echo $(pwd -P)/$(basename "${fname}"))
+}
#
# figure out PTXDIST_TOPDIR
@@ -1859,7 +1879,7 @@ EOF
setup_topdir() {
local ptxdist topdir
- ptxdist="$(readlink -f "${0}")" &&
+ ptxdist="$(realpath "${0}")" &&
topdir="$(cd "$(dirname "${ptxdist}")"/.. && pwd)" || return
#
diff --git a/configure.ac b/configure.ac
index 37a01ae9c..780bf28aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,7 @@ GNU_TOOL(mkdir, coreutils)
GNU_TOOL(install, coreutils)
GNU_TOOL(stat, coreutils)
GNU_TOOL(mknod, coreutils)
+GNU_TOOL(readlink, coreutils)
GNU_TOOL(tar, tar)
dnl Check for egrep