You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by av...@apache.org on 2025/01/02 04:54:13 UTC
(cloudberry) 03/15: Set the GPHOME_CLIENTS correctly in the script (#14732)
This is an automated email from the ASF dual-hosted git repository.
avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit a94f48956ce004c335b9c1ae709e6ffc5eb5bbf3
Author: Adam Lee <ad...@vmware.com>
AuthorDate: Tue Jan 10 10:40:49 2023 +0800
Set the GPHOME_CLIENTS correctly in the script (#14732)
The greenplum_clients_path.sh could not be sourced in other directories
before, copy greenplum_path.sh's codes to fix it.
```
$ cat /usr/local/greenplum-clients-devel/greenplum_clients_path.sh
GPHOME_CLIENTS=`pwd`
PATH=${GPHOME_CLIENTS}/bin:${GPHOME_CLIENTS}/ext/python/bin:${PATH}
...
$ set -x
$ . /usr/local/greenplum-clients-devel/greenplum_clients_path.sh
+ . /usr/local/greenplum-clients-devel/greenplum_clients_path.sh
+++ pwd
++ GPHOME_CLIENTS=/tmp/build/b251a50d
++ PATH=/tmp/build/b251a50d/bin:/tmp/build/b251a50d/ext/python/bin:...
...
```
---
gpAux/client/scripts/greenplum_clients_path.sh | 30 +++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/gpAux/client/scripts/greenplum_clients_path.sh b/gpAux/client/scripts/greenplum_clients_path.sh
index 89eb913bb2..a42d135c9a 100644
--- a/gpAux/client/scripts/greenplum_clients_path.sh
+++ b/gpAux/client/scripts/greenplum_clients_path.sh
@@ -1,4 +1,27 @@
-GPHOME_CLIENTS=`pwd`
+if test -n "${ZSH_VERSION:-}"; then
+ # zsh
+ SCRIPT_PATH="${(%):-%x}"
+elif test -n "${BASH_VERSION:-}"; then
+ # bash
+ SCRIPT_PATH="${BASH_SOURCE[0]}"
+else
+ # Unknown shell, hope below works.
+ # Tested with dash
+ result=$(lsof -p $$ -Fn | tail --lines=1 | xargs --max-args=2 | cut --delimiter=' ' --fields=2)
+ SCRIPT_PATH=${result#n}
+fi
+
+if test -z "$SCRIPT_PATH"; then
+ echo "The shell cannot be identified. \$GPHOME_CLIENTS may not be set correctly." >&2
+fi
+SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
+
+if [ ! -L "${SCRIPT_DIR}" ]; then
+ GPHOME_CLIENTS=${SCRIPT_DIR}
+else
+ GPHOME_CLIENTS=$(readlink "${SCRIPT_DIR}")
+fi
+
PATH=${GPHOME_CLIENTS}/bin:${PATH}
PYTHONPATH=${GPHOME_CLIENTS}/bin/ext:${PYTHONPATH}
@@ -19,8 +42,5 @@ else
fi
if [ "$1" != "-q" ]; then
- type python >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "Warning: Python not found. Python-2.5.1 or better is required to run gpload."
- fi
+ command -v python3 >/dev/null || echo "Warning: Python 3 not found, which is required to run gpload."
fi
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org