[commit: ghc] wip/nfs-locking: Add rl function to the cabal build file as well. (2c635d5)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:37:45 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/2c635d55d07ddeb2f827dd5d3007fc9b362b043a/ghc
>---------------------------------------------------------------
commit 2c635d55d07ddeb2f827dd5d3007fc9b362b043a
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date: Tue Jan 5 20:58:07 2016 +0800
Add rl function to the cabal build file as well.
>---------------------------------------------------------------
2c635d55d07ddeb2f827dd5d3007fc9b362b043a
build.cabal.sh | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/build.cabal.sh b/build.cabal.sh
index cf165b8..8add516 100755
--- a/build.cabal.sh
+++ b/build.cabal.sh
@@ -2,7 +2,33 @@
set -euo pipefail
-absoltueRoot="$(dirname "$(readlink -f "$0")")"
+# readlink on os x, doesn't support -f, to prevent the
+# need of installing coreutils (e.g. through brew, just
+# for readlink, we use the follownig substitute.
+#
+# source: http://stackoverflow.com/a/1116890
+function rl {
+ TARGET_FILE="$1"
+
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$TARGET_FILE" ]
+ do
+ TARGET_FILE="$(readlink "$TARGET_FILE")"
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ PHYS_DIR="$(pwd -P)"
+ RESULT="$PHYS_DIR/$TARGET_FILE"
+ echo "$RESULT"
+}
+
+absoltueRoot="$(dirname "$(rl "$0")")"
cd "$absoltueRoot"
# Initialize sandbox if necessary
More information about the ghc-commits
mailing list