forked from aaSSfxxx/r2-regressions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
r2-v
executable file
·171 lines (158 loc) · 3.22 KB
/
r2-v
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
if test -z "${R2_MASTER}"; then
R2_MASTER=~/radare2/
fi
COPIES=~/prg/r2-v
if ! test -d "${R2_MASTER}"; then
echo "Cannot find master copy of r2 at R2_MASTER=${R2_MASTER}"
exit 1
fi
if ! mkdir -p "${COPIES}"; then
echo "Cannot create COPIES=${COPIES}"
exit 1
fi
echo "Using R2_MASTER ${R2_MASTER}"
echo "Using COPIES ${COPIES}"
Fail() {
printf "%s" "$1\n"
exit 1
}
Head() {
cd ${R2_MASTER} || Fail "cannot chdir to ${R2_MASTER}"
git rev-list HEAD | head -n1
}
Next() {
cd ${R2_MASTER} || Fail "cannot chdir to ${R2_MASTER}"
git rev-list HEAD | grep -C 1 $1 |head -n1
}
Prev() {
cd ${R2_MASTER} || Fail "cannot chdir to ${R2_MASTER}"
git rev-list HEAD | grep -C 1 $1 |tail -n1
}
Cur() {
if test -f ${COPIES}/cur; then
cat ${COPIES}/cur
else
echo "Run init first"
fi
}
Note() {
if test -n "$1"; then
if test -n "$2"; then
echo "$2" > ${COPIES}/radare2-$1.note
else
cat ${COPIES}/radare2-$1.note
fi
else
echo "Missing argument"
fi
}
Clone() {
cd ${COPIES} || exit 1
if [ ! -d ${COPIES}/radare2-${1} ]; then
echo "$1 git clone"
git clone ${R2_MASTER} radare2-${1} > /dev/null 2>&1
fi
if [ ! -d ${COPIES}/radare2-${1} ]; then
echo "Cant clone"
exit 1
fi
cd radare2-${1}
if [ -d .git ]; then
git reset --hard $1 || exit 1
mv .git _git
fi
if [ ! -f binr/radare2/radare2 ]; then
echo "$1 make"
sys/install.sh > ${COPIES}/radare2-${1}.log 2>&1 || exit 1
fi
echo "$1 symstall"
sudo make symstall >> ${COPIES}/radare2-${1}.log
echo $1 > ${COPIES}/cur
}
case "$1" in
init)
Clone `Head`
;;
log)
cd ${R2_MASTER} || Fail "cannot chdir to ${R2_MASTER}"
cur=`Cur`
for a in `git rev-list HEAD` ; do
NOTE=`cat ${COPIES}/radare2-${a}.note 2>/dev/null`
if [ "$cur" = "$a" ]; then
echo "$a [CUR] <<<< $NOTE"
elif [ -d "${COPIES}/radare2-${a}" ]; then
echo "$a [x] $NOTE"
else
echo "$a $NOTE"
fi
done
;;
head)
Head
;;
ls)
if [ -d "${COPIES}" ]; then
cd ${COPIES}
for a in radare2-* ; do
echo $a
done
else
echo "Run 'init' first"
fi
;;
up)
$0 use `Prev $(Cur)`
;;
cur)
Cur
;;
down)
$0 use `Next $(Cur)`
;;
rm)
if [ -n "$2" ]; then
if [ -d "${COPIES}/radare2-$2" ]; then
rm -rf "${COPIES}/radare2-$2"
else
echo "Invalid ref"
fi
else
echo "Usage rm [file]"
fi
;;
good)
Note `Cur` good
;;
bad)
Note `Cur` bad
;;
reset)
rm ${COPIES}/*.note
;;
note)
Note $2 $3
;;
diff)
cd ${R2_MASTER} || Fail "cannot chdir to ${R2_MASTER}"
git diff `Cur`^..`Cur`
;;
use)
Clone $2
;;
''|-h|help|-?)
echo "Usage: r2-v [cmd] ([arg]) - Radare2 Version Manager"
echo " init initialize r2-v repository"
echo " cur show current commit"
echo " head show last commit"
echo " ls list all build"
echo " log show log history with marks and notes"
echo " use [commit] build and install this commit"
echo " up build and install previous commit"
echo " down build and install next commit"
echo " rm [commit] remove build"
echo " reset reset/remove all notes"
echo " good | bad mark current commit as good or bad"
echo " note [commit] [msg] add note for given commit"
;;
esac