Initial implementation of the make menu

This commit is contained in:
pancake 2016-03-25 11:10:16 +01:00
parent cd6ef644bf
commit b6d5e6c9e3
5 changed files with 238 additions and 4 deletions

View file

@ -342,6 +342,9 @@ osx-sign-libs:
quality:
./sys/shellcheck.sh
menu nconfig:
./sys/menu.sh || true
include ${MKPLUGINS}
.PHONY: all clean distclean mrproper install symstall uninstall deinstall strip

View file

@ -47,7 +47,7 @@ R2PM_DESC() {
}
R2PM_List() {
cd "${R2PM_USRDIR}/pkg"
cd "${R2PM_USRDIR}/pkg" || exit 1
if [ -n "$1" ]; then
ls | grep -i "$1"
else
@ -56,7 +56,7 @@ R2PM_List() {
}
R2PM_Search() {
cd "${R2PM_DBDIR}"
cd "${R2PM_DBDIR}" || exit 1
if [ -n "$1" ]; then
grep R2PM_DESC * | sed -e "s,:R2PM_DESC, `printf ' \t'`," -e 's,",,g' | grep -i "$1"
else
@ -64,6 +64,16 @@ R2PM_Search() {
fi
}
R2PM_ListUninstalled() {
cd "${R2PM_DBDIR}" || exit 1
PKGS=$(grep R2PM_DESC * | sed -e "s,:R2PM_DESC, `printf ' \t'`," -e 's,",,g' |awk '{print $1}')
for a in ${PKGS} ; do
if [ ! -f "${R2PM_USRDIR}/pkg/$a" ]; then
echo $a
fi
done
}
R2PM_GIT() {
URL="$1"
DIR="`basename $1`"
@ -168,6 +178,9 @@ case "$1" in
-s|search)
R2PM_Search "$2"
;;
-lu)
R2PM_ListUninstalled "$2"
;;
-v|version)
echo "r2pm v0.1"
;;
@ -189,6 +202,7 @@ case "$1" in
echo " -i,install <pkgname> r2pm -i baleful"
echo " -u,uninstall <pkgname> r2pm -u baleful (-uu to force)"
echo " -l,list list installed pkgs"
echo " -lu list uninstalled packages"
echo " -t,test FX,XX,BR BID check in travis regressions"
echo " -s,search [<keyword>] search in database"
echo " -v,version show version"

View file

@ -27,7 +27,7 @@ void aes_expkey (const struct aes_state *st, ut32 expkey[2][st->rounds + 1][Nb])
int ROUND_KEY_COUNT = 4 * (1 + st->rounds);
ut32 tk[st->columns], tt;
st32 idx = 0, t = 0;
ut8 *key = st->key;
const ut8 *key = st->key;
st32 i, j, r;
for (i = 0; i <= st->rounds; i++)

View file

@ -82,7 +82,9 @@ if [ -d shlr/capstone/.git ]; then
( cd shlr/capstone ; git clean -xdf )
fi
[ "`uname`" = Linux ] && export LDFLAGS="-Wl,--as-needed ${LDFLAGS}"
rm -f plugins.cfg
if [ -z "${KEEP_PLUGINS_CFG}" ]; then
rm -f plugins.cfg
fi
unset DEPS
./configure ${CFGARG} --prefix=${PREFIX} || exit 1
${MAKE} -s -j${MAKE_JOBS} MAKE_JOBS=${MAKE_JOBS} || exit 1

215
sys/menu.sh Executable file
View file

@ -0,0 +1,215 @@
#!/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" > /dev/stderr
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")
Todo "Cherry-picking plugins is not yet done"
;;
"Cleanup")
Cleanup
;;
"Packages")
Packages
;;
"Load plugins profile")
SelectConfig
;;
esac
done
}
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 . on"
done
dialog --radiolist "Select packages to install" 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
}
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 ARM")
sys/android-arm.sh
;;
"Android MIPS")
sys/android-mips.sh
;;
"Android X86")
sys/android-x86.sh
;;
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
)