On 12/7/18 2:17 PM, Eric Blake wrote:
In general, autotooled packages are supposed to allow
'./configure --prefix=$HOME/subdir' as a way to then get
'make install' to run as non-root. In fact, 'make distcheck'
tests that this scenario works; alas, we fail due to:
/usr/bin/install -c -m 644 ../../../bash/nbdkit
'/usr/share/bash-completion/completions'
/usr/bin/install: cannot remove '/usr/share/bash-completion/completions/nbdkit':
Permission denied
The culprit? We use pkg-config to ask bash-completion where it
would install user completion scripts. bash-completion.pc states:
prefix=/usr
completionsdir=${prefix}/share/bash-completion/completions
but pkg-config --variable defaults to flattening the ${prefix}
in our use of the PKG_CHECK_VAR() macro, which in turn means
that './configure --prefix=$HOME/subdir' still uses an absolute
path pointing to a root-owned directory (rather than one relative
to our desired ${prefix}) in our definition of bashcompsdir.
The solution? Tell pkg-config to NOT flatten the prefix variable.
Well, it's _a_ solution. Another one would be to NOT ask pkg-config
ANYTHING, and just _always_ default to installing into ${sysconfdir},
since the patch already shows that to be our default if pkg-config is
not around:
AS_IF([test -z "$bashcompdir"], [
bashcompdir="${sysconfdir}/bash_completion.d"
But that has its own drawbacks - that expands to
/usr/local/etc/bash_completions.d by default (or to
/etc/bash_completion.d if you use --prefix=/usr with Fedora's
/usr/share/config.site), but that name does NOT match the pkg-config
name of /usr/share/bash-completion/completions (which would be more like
${datarootdir}/bash-completion/completions). Ultimately, we could still
punt the issue to the distro packagers, by stating:
"we will ALWAYS install relative to --prefix, and then leave it up to
you in your post-install munging to then move it into the location that
pkg-config recommends"
by merely doing this patch instead (compare it to my proposed patch for
fixing ocaml install, by just always picking a location relative to
--prefix):
diff --git i/configure.ac w/configure.ac
index 33ed4d5..4a3e5c9 100644
--- i/configure.ac
+++ w/configure.ac
@@ -335,15 +335,6 @@ AS_IF([test "x$enable_valgrind" = "xyes"],[
dnl Bash completion.
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
bash_completion=yes
- AC_MSG_CHECKING([for bash-completions directory])
- m4_ifdef([PKG_CHECK_VAR],[
- PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
- ])
- AS_IF([test -z "$bashcompdir"], [
- bashcompdir="${sysconfdir}/bash_completion.d"
- ])
- AC_MSG_RESULT([$bashcompdir])
- AC_SUBST([bashcompdir])
],[
bash_completion=no
AC_MSG_WARN([bash-completion not installed])
diff --git i/bash/Makefile.am w/bash/Makefile.am
index e46784c..3b20c1b 100644
--- i/bash/Makefile.am
+++ w/bash/Makefile.am
@@ -36,6 +36,8 @@ EXTRA_DIST = README
if HAVE_BASH_COMPLETION
+bashcompdir = $(sysconfdir)/bash_completion.d
+
dist_bashcomp_DATA = nbdkit
endif
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org