-
Notifications
You must be signed in to change notification settings - Fork 41
/
run.in
executable file
·110 lines (93 loc) · 3.27 KB
/
run.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash -
# hivex 'run' programs locally script
# Copyright (C) 2011-2016 Red Hat Inc.
#
# @configure_input@
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; 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 all the hivex tools without needing to
# install them first. You just have to do for example:
#
# ./run hivexregedit [args ...]
#
# This works for any C program, hivex tool, and most non-C bindings.
#----------------------------------------------------------------------
# Function to intelligently prepend a path to an environment variable.
# See http://stackoverflow.com/a/9631350
prepend()
{
eval $1="$2\${$1:+:\$$1}"
}
# Source and build directories (absolute paths so this works from any
# directory).
s="$(cd @abs_srcdir@ && pwd)"
b="$(cd @abs_builddir@ && pwd)"
# Set PATH to contain all local programs.
prepend PATH "$b/xml"
prepend PATH "$b/regedit"
prepend PATH "$b/sh"
export PATH
# Set LD_LIBRARY_PATH to contain library.
prepend LD_LIBRARY_PATH "$b/lib/.libs"
export LD_LIBRARY_PATH
prepend DYLD_LIBRARY_PATH "$b/lib/.libs"
export DYLD_LIBRARY_PATH
# For Perl.
prepend PERL5LIB "$b/perl/blib/arch"
prepend PERL5LIB "$b/perl/blib/lib"
export PERL5LIB
# Enable Perl valgrinding.
# XXX Unclear if this actually makes any difference. It seems you
# have to recompile the Perl interpreter with debugging enabled.
export PERL_DEBUG=1
export PERL_VALGRIND=1
export PERL_DESTRUCT_LEVEL=2
# For Python.
export PYTHON="@PYTHON@"
prepend PYTHONPATH "$b/python/.libs"
prepend PYTHONPATH "$b/python"
prepend PYTHONPATH "$s/python"
export PYTHONPATH
# For Ruby.
export RUBY="@RUBY@"
export RAKE="@RAKE@"
prepend RUBYLIB "$b/ruby/ext/hivex"
prepend RUBYLIB "$s/ruby/lib"
export RUBYLIB
prepend LD_LIBRARY_PATH "$b/ruby/ext/hivex"
prepend DYLD_LIBRARY_PATH "$b/ruby/ext/hivex"
# For OCaml.
prepend CAML_LD_LIBRARY_PATH "$b/ocaml"
export CAML_LD_LIBRARY_PATH
# 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
# Allow dependent packages like libguestfs to be compiled against local hivex.
prepend PKG_CONFIG_PATH "$b/lib/local"
export PKG_CONFIG_PATH
prepend OCAMLPATH "$b/ocaml"
export OCAMLPATH
# Do we have libtool? If we have it then we can use it to make
# running valgrind simpler. However don't depend on it.
if libtool --help >/dev/null 2>&1; then
libtool="libtool --mode=execute"
fi
# Avoid GNOME keyring stupidity
export GNOME_KEYRING_CONTROL=
export GNOME_KEYRING_PID=
# Run the program.
exec $libtool "$@"