Skip to content

Commit

Permalink
env.sh now supports DESTDIR
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jul 20, 2015
1 parent 1122bc1 commit f292e82
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions env.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/bin/sh

pfx=$(readlink --canonicalize "$1")
pfx="$1"
if [ -z "$pfx" ]; then
echo "Usage: ./env.sh [path-to-prefix] [program]"
echo "Usage: ./env.sh [destdir|prefix] [program]"
exit 1
fi

if [ ! -d "$pfx" ]; then
echo "Cannot find $pfx directory"
exit 1
fi

# Support DESTDIR
if [ -d "$pfx/usr/bin" ]; then
pfx="$pfx/usr"
fi

new_env='
LIBR_PLUGINS=${pfx}/lib/radare2
PATH=$pfx/bin:${PATH}
Expand All @@ -14,19 +24,22 @@ DYLD_LIBRARY_PATH=$pfx/lib:$DYLD_LIBRARY_PATH
PKG_CONFIG_PATH=$pfx/lib/pkgconfig:$PKG_CONFIG_PATH
'

[ -n "$2" ] && SHELL=$2

#echo
#echo "==> Entering radare2 environment shell..."
#echo
#echo $new_env $SHELL \
# | sed -e 's, ,\n,g' \
# | sed -e 's,^, ,g' \
# | sed -e 's,$, \\,'
#echo
shift

eval $new_env $SHELL

#echo
#echo "==> Back to system shell..."
#echo
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
eval $new_env $*
fi

0 comments on commit f292e82

Please sign in to comment.