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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
|
#!/bin/sh
dialog -h 2> /dev/null
if [ $? != 0 ]; then
if [ "`uname`" = Darwin ]; then
brew install dialog || exit 1
else
echo "Cannot find dialog in PATH" >&2
exit 1
fi
fi
CaptureOutput="2>.nconfig.tmp"
GetOutput() {
cat .nconfig.tmp
}
Todo() {
dialog --infobox "$1" 0 0
sleep 2
}
MainMenu() {
while : ; do
#dialog --checklist foo 30 30 20 foo foo1 foo2 bar bar1 bar2
dialog --menu "radare2 build" 0 0 0 \
"Load plugins profile" . \
"Select plugins" . \
"Build & Install" . \
"Packages" . \
"Cleanup" . \
"Quit" . 2>.nconfig.tmp || exit 1
case $(GetOutput) in
Quit)
return
;;
"Build & Install")
BuildAndInstall
;;
"Select plugins")
SelectPlugin
;;
"Cleanup")
Cleanup
;;
"Packages")
Packages
;;
"Load plugins profile")
SelectConfig
;;
esac
done
}
SelectPlugin () {
SelectPluginStatic
SelectPluginShared
./configure-plugins
}
SelectPluginShared () {
PLUGINS="`diff plugins .static.plugins | grep "<" | awk '{print $2}'`"
ARGS=""
for a in ${PLUGINS} ; do
ARGS="${ARGS} $a . on"
done
dialog --checklist "Select Shared Plugins" 0 0 0 ${ARGS} 2> .nconfig.tmp
OPT=$(<.nconfig.tmp)
echo "SHARED=\"" >> plugins.cfg
echo $OPT >> plugins.cfg
echo "\"" >> plugins.cfg
rm .static.plugins
}
SelectPluginStatic() {
. ./dist/plugins-cfg/plugins.def.cfg
PLUGINS="${STATIC} ${SHARED}"
ARGS=""
for a in ${PLUGINS} ; do
ARGS="${ARGS} $a . on"
done
dialog --checklist "Select Static Plugins" 0 0 0 ${ARGS} 2> .nconfig.tmp
OPT=$(<.nconfig.tmp)
echo "STATIC=\"" > plugins.cfg
echo $OPT >> plugins.cfg
echo $OPT | tr " " "\n" > .static.plugins
echo "\"" >> plugins.cfg
}
Packages() {
while : ; do
dialog --menu "radare2 packages" 0 0 0 \
"Install packages" . \
"Uninstall packages" . \
"Update all packages" . \
"Quit" . 2>.nconfig.tmp || exit 1
case $(GetOutput) in
Quit)
return
;;
"Install packages")
PackagesInstall
;;
"Uninstall packages")
PackagesUninstall
;;
"Update all packages")
# TODO: add a flag for this
for a in `r2pm -l` ; do r2pm -i $a ; done
;;
esac
done
}
PackagesInstall() {
PLUGINS="`r2pm -lu`"
ARGS=""
for a in ${PLUGINS} ; do
ARGS="${ARGS} $a . off"
done
dialog --checklist "Select packages to install" 0 0 0 ${ARGS} 2> .nconfig.tmp
OPT=$(<.nconfig.tmp)
echo
if [ -n "${OPT}" ]; then
for a in ${OPT} ; do
r2pm -i "$a"
sleep 1
done
fi
}
PackagesUninstall() {
PLUGINS="`r2pm -l`"
ARGS=""
for a in ${PLUGINS} ; do
ARGS="${ARGS} $a . off"
done
dialog --checklist "Select packages to uninstall" 0 0 0 ${ARGS} 2> .nconfig.tmp
OPT=$(<.nconfig.tmp)
if [ -n "${OPT}" ]; then
for a in ${OPT} ; do
r2pm -u "$a"
sleep 1
done
fi
}
Cleanup() {
while : ; do
dialog --menu "radare2 build" 0 0 0 \
"Uninstall" . \
"Purge previous installations" . \
"make clean" . \
"make mrproper" . \
"git clean -xdf" . \
"Quit" . 2>.nconfig.tmp || exit 1
case $(GetOutput) in
'make uninstall')
sudo make uninstall
;;
'Purge previous installations')
sudo make purge
;;
'make clean')
make clean
;;
'make mrproper')
make mrproper
;;
'git clean -xdf')
git clean -xdf
;;
Quit)
return
;;
esac
done
}
BuildAndInstall() {
while : ; do
#dialog --checklist foo 30 30 20 foo foo1 foo2 bar bar1 bar2
dialog --menu "radare2 build" 0 0 0 \
"System build" . \
"Home build" . \
"iOS" . \
"Windows" . \
"Android ARM" . \
"Android MIPS" . \
"Android X86" . \
"Quit" . 2>.nconfig.tmp || exit 1
case $(GetOutput) in
Quit)
return
;;
"System build")
KEEP_PLUGINS_CFG=1 sys/install.sh
;;
"Home build")
KEEP_PLUGINS_CFG=1 sys/user.sh
;;
"iOS")
sys/ios-sdk.sh
;;
"OSX")
sys/osx-pkg.sh
;;
"Windows")
sys/mingw32.sh
;;
"Android ARM64")
sys/android-build.sh arm64
;;
"Android ARM")
sys/android-build.sh arm
;;
"Android MIPS")
sys/android-build.sh mips
;;
"Android X86")
sys/android-build.sh x86
;;
esac
done
}
ConfigurePlugins() {
#dialog --checklist foo 30 30 20 foo foo1 foo2 bar bar1 bar2
ARGS=""
dialog --menu "radare2 build" 0 0 0 ${ARGS}
}
SelectConfig() {
PLUGINS="`ls *.cfg | grep -v plugins.cfg`"
ARGS=""
for a in ${PLUGINS} ; do
ARGS="${ARGS} $a . on"
done
dialog --radiolist "Select plugins profile" 0 0 0 ${ARGS} 2> .nconfig.tmp
OPT=$(<.nconfig.tmp)
echo
echo "Selected ${OPT}"
if [ -n "${OPT}" -a -f "${OPT}" ]; then
cp -f ${OPT} plugins.cfg
./configure-plugins
fi
}
(
rm -f .nconfig.tmp
MainMenu
rm -f .nconfig.tmp
)
|