unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* RFC: Install scripts with absolute paths by default
@ 2018-09-09 15:40 David Bremner
  2018-09-09 15:40 ` [PATCH 1/2] configure: absolute path of bash David Bremner
  2018-09-09 15:40 ` [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: David Bremner @ 2018-09-09 15:40 UTC (permalink / raw)
  To: notmuch

I know this is a sortof revert of some changes we have made over the
years, but Linux distros are going to (increasingly?) insist on
absolute paths in shebangs [1]. We could just punt that on to the
distro maintainers, but in the case of Debian that is basically me.

I'm thinking a reasonable compromise is to leave /usr/bin/env in the
source (to allow testing without configure or with a broken
configure), and substitute on install. Thoughts?

If the general approach sounds plausible, then we can move on to
nitpicking my Make/shell

[1]: See e.g. https://pagure.io/packaging-committee/issue/700, or
https://www.debian.org/doc/debian-policy/ch-files.html#scripts

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] configure: absolute path of bash
  2018-09-09 15:40 RFC: Install scripts with absolute paths by default David Bremner
@ 2018-09-09 15:40 ` David Bremner
  2018-09-09 15:40 ` [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2018-09-09 15:40 UTC (permalink / raw)
  To: notmuch

This can be used to set shebang lines during install.
---
 configure | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/configure b/configure
index ab7e1610..20961763 100755
--- a/configure
+++ b/configure
@@ -53,6 +53,7 @@ fi
 
 # Set several defaults (optionally specified by the user in
 # environment variables)
+BASH=${BASH:-bash}
 CC=${CC:-cc}
 CXX=${CXX:-c++}
 CFLAGS=${CFLAGS:--g -O2}
@@ -557,6 +558,16 @@ else
     errors=$((errors + 1))
 fi
 
+printf "Checking for bash... "
+if command -v ${BASH} > /dev/null; then
+    have_bash=1
+    bash_absolute=$(command -v ${BASH})
+    printf "Yes (%s).\n" "$bash_absolute"
+else
+    have_bash=0
+    printf "No. (%s not found)\n" "${BASH}"
+fi
+
 printf "Checking for python... "
 have_python=0
 
@@ -1081,6 +1092,10 @@ emacslispdir=${EMACSLISPDIR}
 # be installed
 emacsetcdir=${EMACSETCDIR}
 
+# Whether bash exists, and if so where
+HAVE_BASH = ${have_bash}
+BASH_ABSOLUTE = ${bash_absolute}
+
 # Whether there's an emacs binary available for byte-compiling
 HAVE_EMACS = ${have_emacs}
 
@@ -1262,6 +1277,10 @@ NOTMUCH_DEFAULT_XAPIAN_BACKEND=${default_xapian_backend}
 # do we have man pages?
 NOTMUCH_HAVE_MAN=$((have_sphinx))
 
+# Whether bash exists, and if so where
+NOTMUCH_HAVE_BASH=${have_bash}
+NOTMUCH_BASH_ABSOLUTE=${bash_absolute}
+
 # Name of python interpreter
 NOTMUCH_PYTHON=${python}
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang
  2018-09-09 15:40 RFC: Install scripts with absolute paths by default David Bremner
  2018-09-09 15:40 ` [PATCH 1/2] configure: absolute path of bash David Bremner
@ 2018-09-09 15:40 ` David Bremner
  2018-09-13 21:29   ` Tomi Ollila
  1 sibling, 1 reply; 4+ messages in thread
From: David Bremner @ 2018-09-09 15:40 UTC (permalink / raw)
  To: notmuch

Follow distro-centric rules to reduce the chance of surprising
behaviour due to PATH changes
---
 emacs/Makefile.local | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 1b3ef584..3ec381e3 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -110,7 +110,10 @@ endif
 	mkdir -p "$(DESTDIR)$(emacsetcdir)"
 	install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)"
 	mkdir -p "$(DESTDIR)$(prefix)/bin/"
-	install $(emacs_mua) "$(DESTDIR)$(prefix)/bin"
+ifeq ($(HAVE_BASH),1)
+	sed "1s|^#!.*$$|#! $(BASH_ABSOLUTE)|" < $(emacs_mua) > $(DESTDIR)$(prefix)/bin/notmuch-emacs-mua
+	chmod 755 $(DESTDIR)$(prefix)/bin/notmuch-emacs-mua
+endif
 ifeq ($(WITH_DESKTOP),1)
 	mkdir -p "$(DESTDIR)$(desktop_dir)"
 	desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" $(emacs_mua_desktop)
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang
  2018-09-09 15:40 ` [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang David Bremner
@ 2018-09-13 21:29   ` Tomi Ollila
  0 siblings, 0 replies; 4+ messages in thread
From: Tomi Ollila @ 2018-09-13 21:29 UTC (permalink / raw)
  To: David Bremner, notmuch

On Sun, Sep 09 2018, David Bremner wrote:

> Follow distro-centric rules to reduce the chance of surprising
> behaviour due to PATH changes
> ---
>  emacs/Makefile.local | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/Makefile.local b/emacs/Makefile.local
> index 1b3ef584..3ec381e3 100644
> --- a/emacs/Makefile.local
> +++ b/emacs/Makefile.local
> @@ -110,7 +110,10 @@ endif
>  	mkdir -p "$(DESTDIR)$(emacsetcdir)"
>  	install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)"
>  	mkdir -p "$(DESTDIR)$(prefix)/bin/"
> -	install $(emacs_mua) "$(DESTDIR)$(prefix)/bin"
> +ifeq ($(HAVE_BASH),1)
> +	sed "1s|^#!.*$$|#! $(BASH_ABSOLUTE)|" < $(emacs_mua) > $(DESTDIR)$(prefix)/bin/notmuch-emacs-mua

1/2 is OK(*). This change is OK too -- although the trailing $$ could be
dropped -- regexps are greedy by default so .* will consume rest of
the input anyway.

Tomi

(*) we have not cared $IFS characters in user input, as there is no danger
users shooting themselves this way ;D





> +	chmod 755 $(DESTDIR)$(prefix)/bin/notmuch-emacs-mua
> +endif
>  ifeq ($(WITH_DESKTOP),1)
>  	mkdir -p "$(DESTDIR)$(desktop_dir)"
>  	desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" $(emacs_mua_desktop)
> -- 
> 2.18.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-13 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-09 15:40 RFC: Install scripts with absolute paths by default David Bremner
2018-09-09 15:40 ` [PATCH 1/2] configure: absolute path of bash David Bremner
2018-09-09 15:40 ` [PATCH 2/2] build: install notmuch-emacs-mua with absolute shebang David Bremner
2018-09-13 21:29   ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).