Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setup on termux #367

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 69 additions & 2 deletions r2angr/angr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,78 @@ CWD=$(dirname $0)
OLD=$PWD
cd $CWD
if [ ! -d venv ]; then
python -m venv venv
if ! command -v termux-setup-storage; then
AbhiTheModder marked this conversation as resolved.
Show resolved Hide resolved
python3 -m venv venv
else
echo -e "\033[1;33mTermux environment detected. Installing necessary packages...\033[0m"
AbhiTheModder marked this conversation as resolved.
Show resolved Hide resolved

pkg update && pkg upgrade -y
pkg install -y cmake ninja clang python-numpy unicorn # uncorn Required for unicorn during angr installation
python3 -m venv --system-site-packages venv # For packages like numpy
fi
fi
. venv/bin/activate
if [ ! -x venv/bin/angr ]; then
pip install angr
if command -v termux-setup-storage; then
pip install setuptools
pip install unicorn==2.0.1.post1
AbhiTheModder marked this conversation as resolved.
Show resolved Hide resolved
# Because z3-solver from pip tries to force install custom cmake
# which breaks installation of z3-solver, check https://github.com/Z3Prover/z3/issues/7424
# Yes I know we could use solution(s) mentioned from this issue https://github.com/termux/termux-packages/issues/10065 but
# Because that's a bit lengthy and I don't want to (I'm lazy :P)
# And in that too we need to install cmake from source
# So I'm just going to install z3 from source :)
git clone https://github.com/Z3Prover/z3.git --depth 1
cd $CWD/z3
echo -e "\033[1;33m Starting z3 build, it may take a while...\033[0m"
python scripts/mk_make.py --python
cd build
make
make install
cd ../../

# Now we don't need z3 source anymore
if [ -d $CWD/z3 ]; then
rm -rf $CWD/z3
fi

# Create dist-info folder and METADATA file
DIST_INFO_PATH="$CWD/venv/lib/python3.12/site-packages/z3_solver-4.13.0.0.dist-info"
mkdir -p $DIST_INFO_PATH
touch $DIST_INFO_PATH/RECORD
echo "z3" >$DIST_INFO_PATH/top_level.txt
echo "z3_solver" >$DIST_INFO_PATH/WHEEL
echo "pip" >$DIST_INFO_PATH/INSTALLER

cat <<EOL >$DIST_INFO_PATH/METADATA
Metadata-Version: 2.1
Name: z3-solver
Version: 4.13.0.0
Summary: An efficient SMT solver library
Home-page: https://github.com/Z3Prover/z3
Author: The Z3 Theorem Prover Project
Maintainer: Audrey Dutcher and Nikolaj Bjorner
Maintainer-email: audrey@rhelmot.io
License: MIT License
Keywords: z3,smt,sat,prover,theorem
Requires-Dist: importlib-resources ; python_version < "3.9"

Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.

For documentation, please read http://z3prover.github.io/api/html/z3.html

In the event of technical difficulties related to configuration, compilation, or installation, please submit issues to https://github.com/z3prover/z3.git
EOL
# Re-Check if z3-solver is installed or not
if [ -z "$(pip show z3-solver)" ]; then
echo -e "\033[0;33mSeems like an error occured during installation!"
echo "Please try to install it manually"
echo -e "Without z3-solver, we can't install angr on Termux!\033[0m"
echo "You can find the venv folder in $HOME/.local/share/radare2/prefix/bin"
exit 1
fi
fi
pip install -v angr
pip install capstone==5.0.3
fi
cd $OLD
Expand Down