1#!/bin/sh 2# Set-up environment variables to run programs which are built in DESTDIR folder 3# 4# Usage example to use variables in the current shell: 5# $ export DESTDIR=$HOME/selinux-destdir 6# $ make install install-pywrap install-rubywrap 7# $ . ./scripts/env_use_destdir 8# $ make test 9# 10# Or to use variables in a subcommand, for example to run tests: 11# $ export DESTDIR=$HOME/selinux-destdir 12# $ make install install-pywrap install-rubywrap 13# $ ./scripts/env_use_destdir secilc ... 14# $ ./scripts/env_use_destdir make test 15 16if [ -z "${DESTDIR:-}" ] ; then 17 echo >&2 "Error: variable DESTDIR needs to be defined in order to use this script." 18 echo >&2 "Example:" 19 # shellcheck disable=SC2164 20 echo >&2 " DESTDIR=$(cd "$(dirname -- "$0")/.." ; pwd)/DESTDIR . $0" 21 exit 1 22fi 23 24export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" 25export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" 26 27# shellcheck disable=SC2155 28export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" 29 30# shellcheck disable=SC2155 31export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')" 32 33# Run the command given on the command line 34if [ $# -gt 0 ] ; then 35 exec "$@" 36fi 37