diff mbox series

[2/2] scripts/env_use_destdir: propagate PREFIX, LIBDIR, BINDIR, etc.

Message ID 20200501092929.1162708-2-nicolas.iooss@m4x.org (mailing list archive)
State Accepted
Headers show
Series [1/2] scripts/env_use_destdir: fix Fedora support | expand

Commit Message

Nicolas Iooss May 1, 2020, 9:29 a.m. UTC
On systems using non-default `PREFIX`, `LIBDIR`, `SHLIBDIR`, `BINDIR`
or `SBINDIR`, running
`DESTDIR=/path/to/destdir ./scripts/env_use_destdir make test`
does not perform the intended behavior, because the testing programs and
libraries are installed into locations that are not added to
`LD_LIBRARY_PATH` nor `PATH`.

More precisely, with `LIBDIR=/usr/lib64 SHLIBDIR=/lib64`, `env_use_destdir`
does not work. Fix this by adding the installation directories relative
to `DESTDIR` in `LD_LIBRARY_PATH` and `PATH`.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 scripts/env_use_destdir | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Petr Lautrbach May 4, 2020, 12:31 p.m. UTC | #1
On Fri, May 01, 2020 at 11:29:29AM +0200, Nicolas Iooss wrote:
> On systems using non-default `PREFIX`, `LIBDIR`, `SHLIBDIR`, `BINDIR`
> or `SBINDIR`, running
> `DESTDIR=/path/to/destdir ./scripts/env_use_destdir make test`
> does not perform the intended behavior, because the testing programs and
> libraries are installed into locations that are not added to
> `LD_LIBRARY_PATH` nor `PATH`.
> 
> More precisely, with `LIBDIR=/usr/lib64 SHLIBDIR=/lib64`, `env_use_destdir`
> does not work. Fix this by adding the installation directories relative
> to `DESTDIR` in `LD_LIBRARY_PATH` and `PATH`.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

For both patches:

Acked-by: Petr Lautrbach <plautrba@redhat.com>

> ---
>  scripts/env_use_destdir | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/scripts/env_use_destdir b/scripts/env_use_destdir
> index 491da58f9207..8274013e9cf0 100755
> --- a/scripts/env_use_destdir
> +++ b/scripts/env_use_destdir
> @@ -22,7 +22,26 @@ if [ -z "${DESTDIR:-}" ] ; then
>  fi
>  
>  export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
> +if [ -n "${PREFIX:-}" ] ; then
> +    LD_LIBRARY_PATH="$DESTDIR$PREFIX/lib:$LD_LIBRARY_PATH"
> +fi
> +if [ -n "${LIBDIR:-}" ] ; then
> +    LD_LIBRARY_PATH="$DESTDIR$LIBDIR:$LD_LIBRARY_PATH"
> +fi
> +if [ -n "${SHLIBDIR:-}" ] ; then
> +    LD_LIBRARY_PATH="$DESTDIR$SHLIBDIR:$LD_LIBRARY_PATH"
> +fi
> +
>  export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
> +if [ -n "${PREFIX:-}" ] ; then
> +    PATH="$DESTDIR$PREFIX/sbin:$DESTDIR$PREFIX/bin:$LD_LIBRARY_PATH"
> +fi
> +if [ -n "${BINDIR:-}" ] ; then
> +    PATH="$DESTDIR$BINDIR:$PATH"
> +fi
> +if [ -n "${SBINDIR:-}" ] ; then
> +    PATH="$DESTDIR$SBINDIR:$PATH"
> +fi
>  
>  NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(plat_specific=1, prefix='/usr'))"):$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
>  if [ -n "${PYTHONPATH:-}" ] ; then
> -- 
> 2.26.2
>
Petr Lautrbach May 5, 2020, 1:19 p.m. UTC | #2
On Mon, May 04, 2020 at 02:31:52PM +0200, Petr Lautrbach wrote:
> On Fri, May 01, 2020 at 11:29:29AM +0200, Nicolas Iooss wrote:
> > On systems using non-default `PREFIX`, `LIBDIR`, `SHLIBDIR`, `BINDIR`
> > or `SBINDIR`, running
> > `DESTDIR=/path/to/destdir ./scripts/env_use_destdir make test`
> > does not perform the intended behavior, because the testing programs and
> > libraries are installed into locations that are not added to
> > `LD_LIBRARY_PATH` nor `PATH`.
> > 
> > More precisely, with `LIBDIR=/usr/lib64 SHLIBDIR=/lib64`, `env_use_destdir`
> > does not work. Fix this by adding the installation directories relative
> > to `DESTDIR` in `LD_LIBRARY_PATH` and `PATH`.
> > 
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> 
> For both patches:
> 
> Acked-by: Petr Lautrbach <plautrba@redhat.com>

Both applied.

> > ---
> >  scripts/env_use_destdir | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/scripts/env_use_destdir b/scripts/env_use_destdir
> > index 491da58f9207..8274013e9cf0 100755
> > --- a/scripts/env_use_destdir
> > +++ b/scripts/env_use_destdir
> > @@ -22,7 +22,26 @@ if [ -z "${DESTDIR:-}" ] ; then
> >  fi
> >  
> >  export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
> > +if [ -n "${PREFIX:-}" ] ; then
> > +    LD_LIBRARY_PATH="$DESTDIR$PREFIX/lib:$LD_LIBRARY_PATH"
> > +fi
> > +if [ -n "${LIBDIR:-}" ] ; then
> > +    LD_LIBRARY_PATH="$DESTDIR$LIBDIR:$LD_LIBRARY_PATH"
> > +fi
> > +if [ -n "${SHLIBDIR:-}" ] ; then
> > +    LD_LIBRARY_PATH="$DESTDIR$SHLIBDIR:$LD_LIBRARY_PATH"
> > +fi
> > +
> >  export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
> > +if [ -n "${PREFIX:-}" ] ; then
> > +    PATH="$DESTDIR$PREFIX/sbin:$DESTDIR$PREFIX/bin:$LD_LIBRARY_PATH"
> > +fi
> > +if [ -n "${BINDIR:-}" ] ; then
> > +    PATH="$DESTDIR$BINDIR:$PATH"
> > +fi
> > +if [ -n "${SBINDIR:-}" ] ; then
> > +    PATH="$DESTDIR$SBINDIR:$PATH"
> > +fi
> >  
> >  NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(plat_specific=1, prefix='/usr'))"):$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
> >  if [ -n "${PYTHONPATH:-}" ] ; then
> > -- 
> > 2.26.2
> > 
> 
> -- 
> ()  ascii ribbon campaign - against html e-mail 
> /\  www.asciiribbon.org   - against proprietary attachments
diff mbox series

Patch

diff --git a/scripts/env_use_destdir b/scripts/env_use_destdir
index 491da58f9207..8274013e9cf0 100755
--- a/scripts/env_use_destdir
+++ b/scripts/env_use_destdir
@@ -22,7 +22,26 @@  if [ -z "${DESTDIR:-}" ] ; then
 fi
 
 export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
+if [ -n "${PREFIX:-}" ] ; then
+    LD_LIBRARY_PATH="$DESTDIR$PREFIX/lib:$LD_LIBRARY_PATH"
+fi
+if [ -n "${LIBDIR:-}" ] ; then
+    LD_LIBRARY_PATH="$DESTDIR$LIBDIR:$LD_LIBRARY_PATH"
+fi
+if [ -n "${SHLIBDIR:-}" ] ; then
+    LD_LIBRARY_PATH="$DESTDIR$SHLIBDIR:$LD_LIBRARY_PATH"
+fi
+
 export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
+if [ -n "${PREFIX:-}" ] ; then
+    PATH="$DESTDIR$PREFIX/sbin:$DESTDIR$PREFIX/bin:$LD_LIBRARY_PATH"
+fi
+if [ -n "${BINDIR:-}" ] ; then
+    PATH="$DESTDIR$BINDIR:$PATH"
+fi
+if [ -n "${SBINDIR:-}" ] ; then
+    PATH="$DESTDIR$SBINDIR:$PATH"
+fi
 
 NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(plat_specific=1, prefix='/usr'))"):$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
 if [ -n "${PYTHONPATH:-}" ] ; then