From 3e4fa5a742dc5194c39b1ed8200b3580fc3f13c4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 26 Dec 2013 16:53:02 -0800 Subject: [PATCH] build.sh: Allow readlink for path-canonicalization Debian doesn't have realpath installed by default [1], so fall back to the more widely available readlink [2]. [1]: http://packages.debian.org/unstable/utils/realpath [2]: http://www.gnu.org/software/coreutils/manual/html_node/readlink-invocation.html --- build.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9c72780..a21392b 100755 --- a/build.sh +++ b/build.sh @@ -54,6 +54,16 @@ die() exit 1 } +REALPATH="${REALPATH:-$(command -v realpath)}" +if [ -z "${REALPATH}" ]; then + READLINK="${READLINK:-$(command -v readlink)}" + if [ -n "${READLINK}" ]; then + REALPATH="${READLINK} -f" + else + die "need realpath or readlink to canonicalize paths" + fi +fi + STAGE3_IMAGES=$(docker images "${NAMESPACE}/gentoo") STAGE3_MATCHES=$(echo "${STAGE3_IMAGES}" | grep "${DATE}") if [ -z "${STAGE3_MATCHES}" ]; then @@ -97,7 +107,7 @@ fi docker tag -f "${NAMESPACE}/portage-import:${DATE}" "${NAMESPACE}/portage-import:latest" || die "failed to tag" # extract Busybox for the portage image -THIS_DIR=$(dirname $(realpath $0)) +THIS_DIR=$(dirname $($REALPATH $0)) CONTAINER="${NAMESPACE}-gentoo-${DATE}-extract-busybox" docker run -name "${CONTAINER}" -v "${THIS_DIR}/portage/":/tmp "${NAMESPACE}/gentoo:${DATE}" cp /bin/busybox /tmp/ docker rm "${CONTAINER}" -- 2.26.2