diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-09-20 01:31:41 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-09-21 15:16:15 +0300 |
commit | 4ca6eb91c2faf550f251863429f333bfdbd89fec (patch) | |
tree | 055fa1cb7f1b4abe96e0a8d79908a0c8916dedab /build.sh | |
parent | 8e6b798c8ca1f9125e2a0cb8eb3aed918bffa21d (diff) |
Convert relative installation directory path to absolute in build scripts
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -225,6 +225,12 @@ if test -n "$make"; then fi fi +# If the installation directory is unspecified, then assume it is /usr/local. +# Otherwise, if it is a relative path, then convert it to an absolute path, +# unless the realpath program is not present on the system or doesn't +# recognize any of the options we pass, in which case fail, advising to +# specify an absolute installation directory. +# if test -z "$idir"; then idir=/usr/local private=config.install.private=build2 @@ -235,6 +241,21 @@ if test -z "$idir"; then if test -z "$sudo"; then sudo="sudo" fi +elif test -n "$(echo "$idir" | sed -n 's#^[^/].*$#true#p')"; then + + if ! command -v realpath >/dev/null 2>&1; then + diag "error: unable to execute realpath: command not found" + diag " info: specify absolute installation directory path" + exit 1 + fi + + # Don't resolve symlinks and allow non-existent path components. + # + if ! idir="$(realpath -s -m "$idir" 2>/dev/null)"; then + diag "error: realpath does not recognize -s -m" + diag " info: specify absolute installation directory path" + exit 1 + fi fi if test "$sudo" = false; then |