]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
makefile: symlink-install: do not depend on realpath
authorEric Wong <e@80x24.org>
Wed, 4 Oct 2023 17:46:35 +0000 (17:46 +0000)
committerEric Wong <e@80x24.org>
Wed, 4 Oct 2023 22:58:22 +0000 (22:58 +0000)
For the Makefile, we can use $(PWD) make macro from make(1posix)
as POSIX requires all environment variables be accessible as
macros, and $PWD is a standard sh(1) environment variable.

lei.sh must quiet the stderr of realpath before falling back to
readlink(1) which is available on NetBSD.

Makefile.PL
lei.sh

index 8bd39e6c5d1dd680373c395bc5268e26bb1ef142..38e030f556edba24b42efd8f1b33b5ddc74b10fd 100644 (file)
@@ -264,7 +264,7 @@ prefix = \$(HOME)
 bindir = \$(prefix)/bin
 symlink-install : lib/PublicInbox.pm
        mkdir -p \$(bindir)
-       lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\
+       lei="\$(PWD)/lei.sh" && cd \$(bindir) && \\
        for x in \$(EXE_FILES); do \\
                ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\
        done
diff --git a/lei.sh b/lei.sh
index f1510a731c09ad8cb3ac891ba858a6034a0fcd99..afb03f3ee58ca56b6497301b612a4c7fd5a4ba18 100755 (executable)
--- a/lei.sh
+++ b/lei.sh
@@ -1,7 +1,7 @@
 #!/bin/sh -e
 # symlink this file to a directory in PATH to run lei (or anything in script/*)
 # without needing perms to install globally.  Used by "make symlink-install"
-p=$(realpath "$0" || readlink "$0") # neither is POSIX, but common
+p=$(realpath "$0" 2>/dev/null || readlink "$0") # neither is POSIX, but common
 p=$(dirname "$p") c=$(basename "$0") # both are POSIX
 exec ${PERL-perl} -w -I"$p"/lib "$p"/script/"${c%.sh}" "$@"
 : this script is too short to copyright