2019-01-20 19:19:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Set-up environment variables to run programs which are built in DESTDIR folder
|
|
|
|
#
|
|
|
|
# Usage example to use variables in the current shell:
|
|
|
|
# $ export DESTDIR=$HOME/selinux-destdir
|
|
|
|
# $ make install install-pywrap install-rubywrap
|
|
|
|
# $ . ./scripts/env_use_destdir
|
|
|
|
# $ make test
|
|
|
|
#
|
|
|
|
# Or to use variables in a subcommand, for example to run tests:
|
|
|
|
# $ export DESTDIR=$HOME/selinux-destdir
|
|
|
|
# $ make install install-pywrap install-rubywrap
|
|
|
|
# $ ./scripts/env_use_destdir secilc ...
|
|
|
|
# $ ./scripts/env_use_destdir make test
|
|
|
|
|
|
|
|
if [ -z "${DESTDIR:-}" ] ; then
|
|
|
|
echo >&2 "Error: variable DESTDIR needs to be defined in order to use this script."
|
|
|
|
echo >&2 "Example:"
|
|
|
|
# shellcheck disable=SC2164
|
|
|
|
echo >&2 " DESTDIR=$(cd "$(dirname -- "$0")/.." ; pwd)/DESTDIR . $0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
|
scripts/env_use_destdir: propagate PREFIX, LIBDIR, BINDIR, etc.
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>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
2020-05-01 09:29:29 +00:00
|
|
|
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
|
|
|
|
|
2019-01-20 19:19:33 +00:00
|
|
|
export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
|
scripts/env_use_destdir: propagate PREFIX, LIBDIR, BINDIR, etc.
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>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
2020-05-01 09:29:29 +00:00
|
|
|
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
|
2019-01-20 19:19:33 +00:00
|
|
|
|
2023-11-09 13:51:44 +00:00
|
|
|
if command -v "${PYTHON:-python3}" > /dev/null ; then
|
|
|
|
NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '/usr', 'base': '/usr'}))"):$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
|
|
|
|
if [ -n "${PYTHONPATH:-}" ] ; then
|
|
|
|
# Prefix the PYTHONPATH with the new directories
|
|
|
|
export PYTHONPATH="$NEW_PYTHONPATH:$PYTHONPATH"
|
|
|
|
else
|
|
|
|
# Define PYTHONPATH
|
|
|
|
export PYTHONPATH="$NEW_PYTHONPATH"
|
|
|
|
fi
|
2020-05-01 09:29:28 +00:00
|
|
|
fi
|
2019-01-20 19:19:33 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2155
|
2023-11-09 13:51:44 +00:00
|
|
|
if command -v "${RUBY:-ruby}" > /dev/null ; then
|
|
|
|
export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
|
|
|
|
fi
|
2019-01-20 19:19:33 +00:00
|
|
|
|
|
|
|
# Run the command given on the command line
|
|
|
|
if [ $# -gt 0 ] ; then
|
|
|
|
exec "$@"
|
|
|
|
fi
|