From dff0ccbeb027e1ff1af7906501e6cadfb3b3e327 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 22 Dec 2014 04:50:08 +0100 Subject: [PATCH] Add `user-install` and `user-uninstall` make targets - Add sys/user.sh to install r2 at home --- Makefile | 12 ++++++++++++ env.sh | 26 ++++++++++++++------------ sys/user.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) create mode 100755 sys/user.sh diff --git a/Makefile b/Makefile index 339ce5f28247e..3f914e3973069 100644 --- a/Makefile +++ b/Makefile @@ -179,6 +179,18 @@ purge-doc: cd man ; for a in *.1 ; do rm -f "${MDR}/man1/$$a" ; done rm -f ${MDR}/man1/r2.1 +user-wrap=echo "\#!/bin/sh" > ~/bin/$1 \ +; echo "${PWD}/env.sh ${PREFIX} $1" >> ~/bin/$1 \ +; chmod +x ~/bin/$1 ; + +user-install: + mkdir -p ~/bin + $(foreach mod,$(R2BINS),$(call user-wrap,$(mod))) + +user-uninstall: + $(foreach mod,$(R2BINS),rm -f ~/bin/$(mod)) + -rmdir ~/bin + purge-dev: rm -f ${DESTDIR}/${LIBDIR}/libr_*.${EXT_AR} rm -f ${DESTDIR}/${LIBDIR}/pkgconfig/r_*.pc diff --git a/env.sh b/env.sh index f0b027807e23d..a08bf425032e1 100755 --- a/env.sh +++ b/env.sh @@ -2,7 +2,7 @@ pfx=$1 if [ -z "$pfx" ]; then - echo "Usage: ./env.sh [path-to-prefix]" + echo "Usage: ./env.sh [path-to-prefix] [program]" exit 1 fi @@ -14,17 +14,19 @@ DYLD_LIBRARY_PATH=$pfx/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$PWD/libr/ ' -echo -echo "==> Entering radare2 environment shell..." -echo -echo $new_env $SHELL \ - | sed -e 's, ,\n,g' \ - | sed -e 's,^, ,g' \ - | sed -e 's,$, \\,' -echo +[ -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 eval $new_env $SHELL -echo -echo "==> Back to system shell..." -echo +#echo +#echo "==> Back to system shell..." +#echo diff --git a/sys/user.sh b/sys/user.sh new file mode 100755 index 0000000000000..b7e760779863d --- /dev/null +++ b/sys/user.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +MAKE=make +gmake --help >/dev/null 2>&1 +[ $? = 0 ] && MAKE=gmake + +# find root +cd `dirname $PWD/$0` ; cd .. + +# update +if [ "$1" != "--without-pull" ]; then + if [ -d .git ]; then + git branch | grep "^\* master" > /dev/null + if [ $? = 0 ]; then + echo "WARNING: Updating from remote repository" + git pull + fi + fi +else + shift +fi + +if [ -z "${HOME}" ]; then + echo "HOME not set" + exit 1 +fi + +if [ ! -d "${HOME}" ]; then + echo "HOME is not a directory" + exit 1 +fi + +ROOT=${HOME}/.radare2-prefix + +if [ "${HARDEN}" = 1 ]; then + ./sys/build-harden.sh ${ROOT} && ${MAKE} symstall +else + ./sys/build.sh ${ROOT} && ${MAKE} symstall +fi +${MAKE} user-install +echo +echo radare2 is now installed in ~/.radare2-prefix +echo +echo Now add ${HOME}/bin to your ${PATH} +echo