2015-08-22 05:39:42 +00:00
|
|
|
#!/bin/sh
|
2009-02-05 21:28:33 +00:00
|
|
|
|
2015-08-22 05:37:47 +00:00
|
|
|
getabsolutepath() {
|
2015-08-13 18:44:12 +00:00
|
|
|
[ -d "$1" ] && { cd "$1"; echo "$(pwd -P)"; } ||
|
|
|
|
{ cd "$(dirname "$1")"; echo "$(pwd -P)/$(basename "$1")"; }
|
|
|
|
}
|
2015-08-13 18:42:06 +00:00
|
|
|
|
2015-08-13 18:44:12 +00:00
|
|
|
pfx=$(getabsolutepath "$1")
|
2015-08-13 18:23:59 +00:00
|
|
|
|
2016-01-22 21:35:18 +00:00
|
|
|
if [ -z "$1" ]; then
|
2015-07-20 20:50:33 +00:00
|
|
|
echo "Usage: ./env.sh [destdir|prefix] [program]"
|
2011-07-19 10:52:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-07-20 20:50:33 +00:00
|
|
|
if [ ! -d "$pfx" ]; then
|
|
|
|
echo "Cannot find $pfx directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Support DESTDIR
|
|
|
|
if [ -d "$pfx/usr/bin" ]; then
|
|
|
|
pfx="$pfx/usr"
|
|
|
|
fi
|
|
|
|
|
2009-02-05 21:28:33 +00:00
|
|
|
new_env='
|
2011-07-19 10:52:51 +00:00
|
|
|
LIBR_PLUGINS=${pfx}/lib/radare2
|
|
|
|
PATH=$pfx/bin:${PATH}
|
|
|
|
LD_LIBRARY_PATH=$pfx/lib:$LD_LIBRARY_PATH
|
2015-06-23 14:38:46 +00:00
|
|
|
DYLD_LIBRARY_PATH=$pfx/lib:$DYLD_LIBRARY_PATH
|
|
|
|
PKG_CONFIG_PATH=$pfx/lib/pkgconfig:$PKG_CONFIG_PATH
|
2009-02-05 21:28:33 +00:00
|
|
|
'
|
|
|
|
|
2015-07-20 20:50:33 +00:00
|
|
|
shift
|
2009-02-05 21:28:33 +00:00
|
|
|
|
2015-07-20 20:50:33 +00:00
|
|
|
if [ -z "$*" ]; then
|
|
|
|
echo
|
|
|
|
echo "==> Entering radare2 environment shell..."
|
|
|
|
echo
|
|
|
|
echo $new_env $* \
|
|
|
|
| sed -e 's, ,\n,g' \
|
|
|
|
| sed -e 's,^, ,g' \
|
|
|
|
| sed -e 's,$, \\,'
|
|
|
|
echo
|
|
|
|
export PS1="r2env.sh$ "
|
|
|
|
eval $new_env $SHELL
|
|
|
|
echo
|
|
|
|
echo "==> Back to system shell..."
|
|
|
|
echo
|
|
|
|
else
|
2015-10-31 19:50:49 +00:00
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
par=""
|
2015-11-05 03:03:49 +00:00
|
|
|
if command -v seq >/dev/null; then
|
|
|
|
for p in `seq 1 $(($#-1))`; do par=$par"\$$p "; done
|
|
|
|
elif
|
|
|
|
command -v jot >/dev/null; then
|
|
|
|
for p in `jot $(($#-1)) 1`; do par=$par"\$$p "; done
|
|
|
|
fi
|
2015-10-31 19:50:49 +00:00
|
|
|
eval $new_env $par "\"\$$#\""
|
|
|
|
else
|
|
|
|
eval $new_env $*
|
|
|
|
fi
|
2015-07-20 20:50:33 +00:00
|
|
|
fi
|