selinux/scripts/env_use_destdir
Petr Lautrbach 1952be65dc Switch to python3 by default
- Python 2.7 is planned to be the last of the 2.x releases
- It's generally advised to use Python 3
- Majority of python/ scripts are already switched python3
- Users with python 2 only can still use:

$ make PYTHON=/usr/bin/python ....

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
2019-02-20 16:43:27 +01:00

37 lines
1.3 KiB
Bash
Executable File

#!/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"
export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
# shellcheck disable=SC2155
export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
# shellcheck disable=SC2155
export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
# Run the command given on the command line
if [ $# -gt 0 ] ; then
exec "$@"
fi