Update spec to 1.2.5
[archive/platform/upstream/libvirt.git] / run.in
1 #!/bin/sh
2 # libvirt 'run' programs locally script
3 # Copyright (C) 2012-2013 Red Hat, Inc.
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; If not, see
17 # <http://www.gnu.org/licenses/>.
18
19 #----------------------------------------------------------------------
20 #
21 # With this script you can run libvirt programs without needing to
22 # install them first.  You just have to do for example:
23 #
24 #   ./run ./tools/virsh [args ...]
25 #
26 # If you are already in the tools/ subdirectory, then the following
27 # command will also work:
28 #
29 #   ../run ./virsh [...]
30 #
31 # You can also run the C programs under valgrind like this:
32 #
33 #   ./run valgrind [valgrind opts...] ./program
34 #
35 # or under gdb:
36 #
37 #   ./run gdb --args ./program
38 #
39 # This also works with sudo (eg. if you need root access for libvirt):
40 #
41 #   sudo ./run ./tools/virsh list --all
42 #
43 #----------------------------------------------------------------------
44
45 # Find this script.
46 b=@abs_builddir@
47
48 library_path="$b/src/.libs"
49 if [ -z "$LD_LIBRARY_PATH" ]; then
50     LD_LIBRARY_PATH=$library_path
51 else
52     LD_LIBRARY_PATH="$library_path:$LD_LIBRARY_PATH"
53 fi
54 export LD_LIBRARY_PATH
55
56 export LIBVIRT_DRIVER_DIR="$b/src/.libs"
57 export LIBVIRT_LOCK_MANAGER_PLUGIN_DIR="$b/src/.libs"
58 export VIRTLOCKD_PATH="$b/src"
59 export LIBVIRTD_PATH="$b/daemon"
60
61 # This is a cheap way to find some use-after-free and uninitialized
62 # read problems when using glibc.
63 random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
64 export MALLOC_PERTURB_=$random_val
65
66 # Run the program.
67 exec $b/libtool --mode=execute "$@"