[pacman-dev] [PATCH 5/5] meson-make-symlink.sh: Make compatible with non-GNU ln

Mark Weiman mark.weiman at markzz.com
Sat Apr 17 03:45:24 UTC 2021


The "-T" flag is something available with GNU ln, but on other
implementations of ln, "-T" is not an option. So, to make this script
more portable, a strings check of ln for "GNU coreutils" is done to
determine if "-T" should be used.

Signed-off-by: Mark Weiman <mark.weiman at markzz.com>
---
 build-aux/meson-make-symlink.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/build-aux/meson-make-symlink.sh b/build-aux/meson-make-symlink.sh
index 501cd43d..24a0dd2c 100644
--- a/build-aux/meson-make-symlink.sh
+++ b/build-aux/meson-make-symlink.sh
@@ -4,9 +4,13 @@ set -eu
 # this is needed mostly because $DESTDIR is provided as a variable,
 # and we need to create the target directory...
 
+# test if ln is GNU or not
+LN_FLAG="-T"
+strings /bin/ln | grep -q 'GNU coreutils' || LN_FLAG=""
+
 mkdir -vp "$(dirname "${DESTDIR:-}$2")"
 if [ "$(dirname $1)" = . ]; then
-        ln -vfs -T "$1" "${DESTDIR:-}$2"
+        ln -vfs ${LN_FLAG} "$1" "${DESTDIR:-}$2"
 else
-        ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2"
+        ln -vfs ${LN_FLAG} --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2"
 fi
-- 
2.31.1


More information about the pacman-dev mailing list