]> Sergey Matveev's repositories - public-inbox.git/commitdiff
build: add lei.sh + "make symlink-install" target
authorEric Wong <e@80x24.org>
Fri, 18 Dec 2020 05:21:27 +0000 (05:21 +0000)
committerEric Wong <e@80x24.org>
Sat, 19 Dec 2020 09:32:08 +0000 (09:32 +0000)
This could've been done ages ago, but I rarely invoked
public-inbox-* commands from an interactive terminal
like I would with lei.

MANIFEST
Makefile.PL
lei.sh [new file with mode: 0755]

index 1834e7bb0e510772f2c33172222d8d8494673224..e2d4ef72302613f3049fc5a005b3137c93d72476 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -102,6 +102,7 @@ examples/unsubscribe-psgi@.service
 examples/unsubscribe.milter
 examples/unsubscribe.psgi
 examples/varnish-4.vcl
+lei.sh
 lib/PublicInbox/Address.pm
 lib/PublicInbox/AddressPP.pm
 lib/PublicInbox/Admin.pm
index 57592378c76d554cda85daa343250a02f25bedb4..924e8dfd2b00cd4064247e23437699413a367717 100644 (file)
@@ -223,5 +223,16 @@ Makefile.PL : MANIFEST
        touch -r MANIFEST \$@
        \$(PERLRUN) \$@
 
+# Install symlinks to ~/bin (which is hopefuly in PATH) which point to
+# this source tree.
+# prefix + bindir matches git.git Makefile:
+prefix = \$(HOME)
+bindir = \$(prefix)/bin
+symlink-install :
+       mkdir -p \$(bindir)
+       lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\
+       for x in \$(EXE_FILES); do \\
+               ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\
+       done
 EOF
 }
diff --git a/lei.sh b/lei.sh
new file mode 100755 (executable)
index 0000000..f1510a7
--- /dev/null
+++ b/lei.sh
@@ -0,0 +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=$(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