File: user.sh

package info (click to toggle)
radare2 6.0.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 78,360 kB
  • sloc: ansic: 903,263; sh: 8,137; javascript: 7,911; makefile: 5,503; python: 2,730; cpp: 789; perl: 404; lisp: 122; sed: 85; asm: 57; cs: 37; xml: 32; ruby: 29; java: 21
file content (108 lines) | stat: -rwxr-xr-x 1,958 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

MAKE=make
export CFLAGS="${CFLAGS} -fPIC"
gmake --help >/dev/null 2>&1
[ $? = 0 ] && MAKE=gmake

${MAKE} --help 2>&1 | grep -q gnu
if [ $? != 0 ]; then
	echo "You need GNU Make to build me"
	exit 1
fi

# find root
cd "$(dirname "$0")" ; cd ..

export WITHOUT_PULL=0
PREFIX="${HOME}/.local"

abspath() {
	echo "$1" | grep -q ^/
	if [ $? = 0 ]; then
		echo "$1"
	else
		echo "`pwd`/$1"
	fi
}

ARGS=""
while [ $# -gt 0 ]
do
	case "$1" in
	"--without-pull")
		WITHOUT_PULL=1
		;;
	"--install-path")
		shift
		if [ -n "$1" ]; then
			PREFIX="`abspath $1`"
			BINDIR="$PREFIX/bin"
		else
			echo "ERROR: install-path must not be empty"
			exit 1
		fi
		;;
	*)
		ARGS="${ARGS} $1"
		;;
	esac
	shift
done

ARGS="${ARGS} --with-rpath"

# update
if [ $WITHOUT_PULL -eq 0 ]; then
	if [ -e .git ]; then
		git branch | grep "^\* master" > /dev/null
		if [ $? = 0 ]; then
			echo "WARNING: Updating from remote repository"
			# Attempt to update from an existing remote
			UPSTREAM_REMOTE=$(git remote -v | grep 'radareorg/radare2\(\.git\)\? (fetch)' | cut -f1 | head -n1)
			if [ -n "$UPSTREAM_REMOTE" ]; then
				git pull "$UPSTREAM_REMOTE" master
			else
				git pull https://github.com/radareorg/radare2 master
			fi
		fi
	fi
fi

if [ -z "${PREFIX}" ]; then
	if [ -z "${HOME}" ]; then
		echo "HOME not set"
		exit 1
	fi
	if [ ! -d "${HOME}" ]; then
		echo "HOME is not a directory"
		exit 1
	fi
	PREFIX="${HOME}/.local"
	# PREFIX="${PREFIX}/bin/prefix/radare2"
fi

if [ -z "${BINDIR}" ]; then
	BINDIR="${PREFIX}/bin"
fi

mkdir -p "${PREFIX}/lib"

if [ "${M32}" = 1 ]; then
	./sys/build-m32.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
elif [ "${HARDEN}" = 1 ]; then
	./sys/build-harden.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
else
	./sys/build.sh "${PREFIX}" ${ARGS} && ${MAKE} symstall
fi
if [ $? != 0 ]; then
	echo "Oops"
	exit 1
fi
${MAKE} symstall
S='$'
echo
echo "radare2 is now installed in ${PREFIX}"
echo
echo "export PATH=${BINDIR}:${S}PATH"
echo