1RPMLIBDIR="@usrlibdir@"
2LD_LIBRARY_PATH="${abs_builddir}/testing/${RPMLIBDIR}"
3export LD_LIBRARY_PATH
4export RPMLIBDIR
5PATH="${abs_builddir}/testing@rpmbindir@:${abs_builddir}/testing@usrbindir@:${abs_builddir}/testing@usrlibexecdir@:$PATH"
6export PATH
7
8PYTHON=@PYTHON@
9if test "${PYTHON}"; then
10    PYLIBDIR=$(${PYTHON} -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1,0,'@execprefix@'))")
11    PYTHONPATH="${abs_builddir}/testing${PYLIBDIR}"
12    export PYTHONPATH
13fi
14
15RPMTEST="${abs_builddir}/testing"
16RPMDATA="${abs_srcdir}/data/"
17
18RPM_CONFIGDIR="${RPMTEST}/@RPMCONFIGDIR@"
19RPM_POPTEXEC_PATH="${RPMTEST}/@usrbindir@"
20export RPM_CONFIGDIR RPM_POPTEXEC_PATH
21
22DBFORMAT=$(awk '/^%_db_backend/{print $2}' "${RPM_CONFIGDIR}/macros")
23export DBFORMAT
24
25# Popt looks into $HOME
26HOME="${PWD}"
27export HOME
28
29TZ=UTC
30export TZ
31
32unset SOURCE_DATE_EPOCH
33
34TOPDIR="${HOME}/build"
35
36RPM_XFAIL=${RPM_XFAIL-1}
37if grep -q 'WITH_LUA 1' "${abs_top_builddir}/config.h"; then
38    LUA_DISABLED=false;
39else
40    LUA_DISABLED=true;
41fi
42if test "${PYTHON}"; then
43    PYTHON_DISABLED=false;
44else
45    PYTHON_DISABLED=true;
46fi
47if grep -q '#define WITH_CAP 1' "${abs_top_builddir}/config.h"; then
48    CAP_DISABLED=false;
49else
50    CAP_DISABLED=true;
51fi
52
53function setup_env()
54{
55    if [ -d testing ]; then
56        RPMTEST=${PWD}/testing
57        HOME=${RPMTEST}
58        RPM_CONFIGDIR=${RPMTEST}/@RPMCONFIGDIR@
59        export RPMTEST HOME RPM_CONFIGDIR
60    fi
61}
62
63function run()
64{
65    setup_env
66    "$@" --define "_buildhost testhost" --define "_tmppath ${RPMTEST}/tmp" --define "_topdir ${TOPDIR}" --define "_db_backend ${DBFORMAT}" --dbpath="${RPMTEST}/var/lib/rpm/"
67}
68
69function rundebug()
70{
71    setup_env
72    cp ${RPMDATA}/macros.debug ${RPM_CONFIGDIR}/macros.d/
73    "$@" --define "_buildhost testhost" --define "_tmppath ${RPMTEST}/tmp" --define "_topdir ${TOPDIR}" --define "_db_backend ${DBFORMAT}" --dbpath="${RPMTEST}/var/lib/rpm/"
74    rm -f ${RPM_CONFIGDIR}/macros.d/macros.debug
75}
76
77function runroot()
78{
79    setup_env
80    (unset RPM_CONFIGDIR RPM_POPTEXEC_PATH; cd ${RPMTEST} && \
81     MAGIC="/magic/magic" FAKECHROOT_BASE="${RPMTEST}" fakechroot "$@" --define "_buildhost testhost" --define "_topdir /build" --noplugins --nouserns
82    )
83}
84
85function runroot_other()
86{
87    setup_env
88    (unset RPM_CONFIGDIR RPM_POPTEXEC_PATH; cd ${RPMTEST} && \
89     FAKECHROOT_BASE="${RPMTEST}" fakechroot "$@"
90    )
91}
92