summaryrefslogtreecommitdiff
path: root/run.in
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-09-14 10:08:54 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-09-18 10:59:16 +0100
commit5090c576e3a76727c39a9b3221b2e82b545bc983 (patch)
tree8cc8b6b146b02fca04c0d20c346feef46b05d589 /run.in
parent24f03aa8e4000029831a1235b554a00879bd9ba0 (diff)
downloadlibvirt-5090c576e3a76727c39a9b3221b2e82b545bc983.tar.gz
Add a ./run script for running programs from the local directory.
With this script you can run libvirt programs without needing to install them first. You just have to do for example: ./run ./tools/virsh [args ...] If you are already in the tools/ subdirectory, then the following command will also work: ../run ./virsh [...] You can also run the C programs under valgrind like this: ./run valgrind [valgrind opts...] ./program or under gdb: ./run gdb --args ./program This also works with sudo (eg. if you need root access for libvirt): sudo ./run ./tools/virsh list --all Derived from libguestfs and simplified. The ./run script in libguestfs is much more sophisticated: https://github.com/libguestfs/libguestfs/blob/master/run.in
Diffstat (limited to 'run.in')
-rw-r--r--run.in74
1 files changed, 74 insertions, 0 deletions
diff --git a/run.in b/run.in
new file mode 100644
index 0000000000..7700e5240d
--- /dev/null
+++ b/run.in
@@ -0,0 +1,74 @@
+#!/bin/bash -
+# libvirt 'run' programs locally script
+# Copyright (C) 2012 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+#----------------------------------------------------------------------
+#
+# With this script you can run libvirt programs without needing to
+# install them first. You just have to do for example:
+#
+# ./run ./tools/virsh [args ...]
+#
+# If you are already in the tools/ subdirectory, then the following
+# command will also work:
+#
+# ../run ./virsh [...]
+#
+# You can also run the C programs under valgrind like this:
+#
+# ./run valgrind [valgrind opts...] ./program
+#
+# or under gdb:
+#
+# ./run gdb --args ./program
+#
+# This also works with sudo (eg. if you need root access for libvirt):
+#
+# sudo ./run ./tools/virsh list --all
+#
+#----------------------------------------------------------------------
+
+# Find this script.
+b=@abs_builddir@
+
+library_path="$b/src/.libs"
+if [ -z "$LD_LIBRARY_PATH" ]; then
+ LD_LIBRARY_PATH=$library_path
+else
+ LD_LIBRARY_PATH="$library_path:$LD_LIBRARY_PATH"
+fi
+export LD_LIBRARY_PATH
+
+export LIBVIRT_DRIVER_DIR="$b/src/.libs"
+export LIBVIRTD_PATH="$b/daemon/libvirtd"
+
+# For Python.
+export PYTHON=@PYTHON@
+if [ -z "$PYTHONPATH" ]; then
+ PYTHONPATH="$b/python:$b/python/.libs"
+else
+ PYTHONPATH="$b/python:$b/python/.libs:$PYTHONPATH"
+fi
+export PYTHONPATH
+
+# This is a cheap way to find some use-after-free and uninitialized
+# read problems when using glibc.
+random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
+export MALLOC_PERTURB_=$random_val
+
+# Run the program.
+exec $b/libtool --mode=execute "$@"