You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by uc...@apache.org on 2015/08/26 17:37:48 UTC
flink git commit: [scripts] resolve base path of symlinked executable
Repository: flink
Updated Branches:
refs/heads/master b264b0100 -> e02c3019d
[scripts] resolve base path of symlinked executable
- also adapt config.sh to use the same cross-platform compatible mechanism
This closes #1049.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/e02c3019
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/e02c3019
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/e02c3019
Branch: refs/heads/master
Commit: e02c3019dd6b09b51770b4878360a1c82ebecac6
Parents: b264b01
Author: Maximilian Michels <mx...@apache.org>
Authored: Mon Aug 24 14:40:47 2015 +0200
Committer: Ufuk Celebi <uc...@apache.org>
Committed: Wed Aug 26 17:37:35 2015 +0200
----------------------------------------------------------------------
flink-dist/src/main/flink-bin/bin/config.sh | 34 +++++++++++++-----------
flink-dist/src/main/flink-bin/bin/flink | 20 ++++++++++++--
2 files changed, 36 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/e02c3019/flink-dist/src/main/flink-bin/bin/config.sh
----------------------------------------------------------------------
diff --git a/flink-dist/src/main/flink-bin/bin/config.sh b/flink-dist/src/main/flink-bin/bin/config.sh
index 695531d..1d31493 100755
--- a/flink-dist/src/main/flink-bin/bin/config.sh
+++ b/flink-dist/src/main/flink-bin/bin/config.sh
@@ -101,26 +101,28 @@ KEY_ZK_HEAP_MB="zookeeper.heap.mb"
# PATHS AND CONFIG
########################################################################################################################
-# Resolve links
-this="$0"
-while [ -h "$this" ]; do
- ls=`ls -ld "$this"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- this="$link"
- else
- this=`dirname "$this"`/"$link"
- fi
+target="$0"
+# For the case, the executable has been directly symlinked, figure out
+# the correct bin path by following its symlink up to an upper bound.
+# Note: we can't use the readlink utility here if we want to be POSIX
+# compatible.
+iteration=0
+while [ -L "$target" ]; do
+ if [ "$iteration" -gt 100 ]; then
+ echo "Cannot resolve path: You have a cyclic symlink in $target."
+ break
+ fi
+ ls=`ls -ld -- "$target"`
+ target=`expr "$ls" : '.* -> \(.*\)$'`
+ iteration=$((iteration + 1))
done
-# Convert relative path to absolute path
-bin=`dirname "$this"`
-script=`basename "$this"`
-bin=`cd "$bin"; pwd`
-this="$bin/$script"
+# Convert relative path to absolute path and resolve directory symlinks
+bin=`dirname "$target"`
+SYMLINK_RESOLVED_BIN=`cd "$bin"; pwd -P`
# Define the main directory of the flink installation
-FLINK_ROOT_DIR=`dirname "$this"`/..
+FLINK_ROOT_DIR=`dirname "$SYMLINK_RESOLVED_BIN"`
FLINK_LIB_DIR=$FLINK_ROOT_DIR/lib
# These need to be mangled because they are directly passed to java.
http://git-wip-us.apache.org/repos/asf/flink/blob/e02c3019/flink-dist/src/main/flink-bin/bin/flink
----------------------------------------------------------------------
diff --git a/flink-dist/src/main/flink-bin/bin/flink b/flink-dist/src/main/flink-bin/bin/flink
index eb8bca0..7074434 100644
--- a/flink-dist/src/main/flink-bin/bin/flink
+++ b/flink-dist/src/main/flink-bin/bin/flink
@@ -17,8 +17,24 @@
# limitations under the License.
################################################################################
-bin=`dirname "$0"`
-bin=`cd "$bin"; pwd`
+target="$0"
+# For the case, the executable has been directly symlinked, figure out
+# the correct bin path by following its symlink up to an upper bound.
+# Note: we can't use the readlink utility here if we want to be POSIX
+# compatible.
+iteration=0
+while [ -L "$target" ]; do
+ if [ "$iteration" -gt 100 ]; then
+ echo "Cannot resolve path: You have a cyclic symlink in $target."
+ break
+ fi
+ ls=`ls -ld -- "$target"`
+ target=`expr "$ls" : '.* -> \(.*\)$'`
+ iteration=$((iteration + 1))
+done
+
+# Convert relative path to absolute path
+bin=`dirname "$target"`
# get flink config
. "$bin"/config.sh