Do not use `realpath` to get absolute paths
There are two reasons to avoid using `realpath` in our scripts:
(a) It resolves symlinks by default. This can be avoided with a flag.
(b) It is not installed by default on some Linux distros.
Use the `$(cd <dir> && pwd)` trick instead.
This is necessary for checking out Hafnium using repo.
Change-Id: I5dd11d91a55054728723648e5c4192f8f1095b6b
diff --git a/build/docker/build.sh b/build/docker/build.sh
index 5972038..6ba9467 100755
--- a/build/docker/build.sh
+++ b/build/docker/build.sh
@@ -14,7 +14,7 @@
# limitations under the License.
set -euo pipefail
-SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.inc"
${DOCKER} build \
diff --git a/build/docker/publish.sh b/build/docker/publish.sh
index 96ec2f1..57ad16a 100755
--- a/build/docker/publish.sh
+++ b/build/docker/publish.sh
@@ -14,7 +14,7 @@
# limitations under the License.
set -euo pipefail
-SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.inc"
# Requires for the user to be an owner of the GCP 'hafnium-build' project and
diff --git a/build/run_in_container.sh b/build/run_in_container.sh
index cfb8629..4090c38 100755
--- a/build/run_in_container.sh
+++ b/build/run_in_container.sh
@@ -14,8 +14,8 @@
# limitations under the License.
set -euo pipefail
-SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
-ROOT_DIR="$(realpath ${SCRIPT_DIR}/..)"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT_DIR="$(dirname ${SCRIPT_DIR})"
source "${SCRIPT_DIR}/docker/common.inc"
@@ -114,4 +114,4 @@
${DOCKER} run \
${ARGS[@]} \
"${IMAGE_ID}" \
- /bin/bash -c "$*"
\ No newline at end of file
+ /bin/bash -c "$*"
diff --git a/build/strace_open.sh b/build/strace_open.sh
index e960daf..9a9f431 100755
--- a/build/strace_open.sh
+++ b/build/strace_open.sh
@@ -16,13 +16,13 @@
set -euxo pipefail
-SCRIPT_NAME="$(realpath "${BASH_SOURCE[0]}")"
-SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+SCRIPT_PATH="${SCRIPT_DIR}/$(basename "${BASH_SOURCE[0]}")"
ROOT_DIR="$(realpath ${SCRIPT_DIR}/..)"
if [ "${HAFNIUM_HERMETIC_BUILD:-}" == "true" ]
then
- exec "${ROOT_DIR}/build/run_in_container.sh" -p ${SCRIPT_NAME} $@
+ exec "${ROOT_DIR}/build/run_in_container.sh" -p ${SCRIPT_PATH} $@
fi
if [ $# != 1 ]
diff --git a/kokoro/ubuntu/build.sh b/kokoro/ubuntu/build.sh
index bbe1e5a..ecedad6 100755
--- a/kokoro/ubuntu/build.sh
+++ b/kokoro/ubuntu/build.sh
@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-SCRIPT_NAME="$(realpath "${BASH_SOURCE[0]}")"
-ROOT_DIR="$(realpath $(dirname "${SCRIPT_NAME}")/../..)"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+SCRIPT_PATH="${SCRIPT_DIR}/$(basename "${BASH_SOURCE[0]}")"
+ROOT_DIR="$(dirname $(dirname "${SCRIPT_DIR}"))"
REPO="${ROOT_DIR}/prebuilts/generic/repo/repo"
@@ -67,7 +68,7 @@
# avoid recursion.
if [ "${HAFNIUM_HERMETIC_BUILD}" == "true" ]
then
- exec "${ROOT_DIR}/build/run_in_container.sh" ${SCRIPT_NAME} $@
+ exec "${ROOT_DIR}/build/run_in_container.sh" ${SCRIPT_PATH} $@
fi
USE_FVP=false