[Libguestfs] [libnbd PATCH 03/20] nbdsh: Check for python-exec2c installations
Richard W.M. Jones
rjones at redhat.com
Tue Jun 8 09:50:35 UTC 2021
On Tue, Jun 08, 2021 at 09:53:44AM +0200, Martin Kletzander wrote:
> Platforms that utilise python-exec [0] wrapper scripts (mainly Gentoo) utilise
Did you mean "[0]" to reference a URL?
> basenames of python scripts and executables to decide which python
> implementation to use for running that particular command. That
> makes the nbdsh "hack" in sh/nbdsh.in not work, even if 'exec -a' is
> supported by sh.
It's annoying that we have to work around Gentoo here by adding a
dependency on coreutils. I suppose FreeBSD does have readlink(1).
But my feeling is that the Gentoo script is broken if it cannot cope
with an unexpected basename.
Would a configure-time test be better here? It seems like it would
have less chance of breaking on the end-user machine (I know that on
Gentoo, "end-user" is a distinction without a difference but it would
make nbdsh more robust on non-Gentoo). Also it would mean the package
didn't need to depend on coreutils.
Rich.
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
> sh/nbdsh.in | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sh/nbdsh.in b/sh/nbdsh.in
> index d10f0c1b6b26..333c2d5f8b96 100644
> --- a/sh/nbdsh.in
> +++ b/sh/nbdsh.in
> @@ -19,7 +19,8 @@
>
> # Test if /bin/sh supports exec -a option (only supported in bash 4.2
> # and above, and not part of POSIX).
> -if /bin/sh -c 'exec -a test true' 2>/dev/null; then
> +if /bin/sh -c 'exec -a test true' 2>/dev/null && \
> + test $(readlink $(which @PYTHON@)) != python-exec2c; then
> exec -a nbdsh @PYTHON@ -mnbd "$@"
> else
> exec @PYTHON@ -mnbd "$@"
> --
> 2.31.1
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://listman.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the Libguestfs
mailing list