Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[platform/upstream/dbus.git] / tools / run-with-tmp-session-bus.sh
1 #! /bin/sh
2
3 SCRIPTNAME="$0"
4 WRAPPED_SCRIPT="$1"
5 shift
6
7 die ()
8 {
9     echo "$SCRIPTNAME: $*" >&2
10     exit 1
11 }
12
13 if test -z "$DBUS_TOP_BUILDDIR" ; then
14     die "Must set DBUS_TOP_BUILDDIR"
15 fi
16
17 CONFIG_FILE=./run-with-tmp-session-bus.conf
18 SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
19 ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
20 echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2
21
22 if test -z "$SOURCE_CONFIG_FILE"; then
23     SOURCE_CONFIG_FILE="$DBUS_TOP_BUILDDIR/bus/session.conf";
24 fi
25 ## create a configuration file based on the standard session.conf
26 cat $SOURCE_CONFIG_FILE |  \
27     sed -e 's/<standard_session_servicedirs.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
28     sed -e 's/<include.*$//g'                \
29   > $CONFIG_FILE
30
31 echo "Created configuration file $CONFIG_FILE" >&2
32
33 if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
34     die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
35 fi
36
37 PATH="$DBUS_TOP_BUILDDIR"/bus:$PATH
38 export PATH
39
40 ## the libtool script found by the path search should already do this, but
41 LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
42 export LD_LIBRARY_PATH
43 unset DBUS_SESSION_BUS_ADDRESS
44 unset DBUS_SESSION_BUS_PID
45
46 # this does not actually affect dbus-run-session any more, but could be
47 # significant for dbus-launch as used by the autolaunch test
48 DBUS_USE_TEST_BINARY=1
49 export DBUS_USE_TEST_BINARY
50
51 exec $DBUS_TOP_BUILDDIR/tools/dbus-run-session \
52     --config-file="$CONFIG_FILE" \
53     --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \
54     -- \
55     "$WRAPPED_SCRIPT" "$@"