From 832b8e7b731b9f9a87600703e75f2ce72b941e96 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Wed, 5 Apr 2017 14:04:45 -0500 Subject: [PATCH] Enhance setup.sh (#207) * Install GDB before attempting to install Pwndbg * Bail if GDB is not found * Revert "Remove --target from setup.sh" This reverts commit 62b772a3d6aebabf097dc0ea755a705363097a1d. * Revert "Remove unused variables from setup.sh" This reverts commit 9042f5f76117600cef3acb854cb22b313eed4e15. * Remove unused variables from setup.sh * Ensure that pip is available via ensurepip * Upgrade pip itself * There is no ensurepip for Ubuntu installs * Fix typo, use correct Python --- setup.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 1553b73e0..e788f3d8f 100755 --- a/setup.sh +++ b/setup.sh @@ -3,13 +3,18 @@ set -ex if uname | grep -i Linux &>/dev/null; then sudo apt-get update || true - sudo apt-get -y install python-dev python3-dev python-pip python3-pip libglib2.0-dev libc6-dbg + sudo apt-get -y install gdb python-dev python3-dev python-pip python3-pip libglib2.0-dev libc6-dbg if uname -m | grep x86_64 > /dev/null; then sudo apt-get install libc6-dbg:i386 || true fi fi +if ! hash gdb; then + echo 'Could not find gdb in $PATH' + exit +fi + # Update all submodules git submodule update --init --recursive @@ -18,8 +23,20 @@ PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.pyth PYTHON=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)') PYTHON="${PYTHON}${PYVER}" +# Find the Python site-packages that we need to use so that +# GDB can find the files once we've installed them. +SITE_PACKAGES=$(gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])') + +# Make sure that pip is available +if ! ${PYTHON} -m pip -V; then + sudo ${PYTHON} -m ensurepip --upgrade +fi + +# Upgrade pip itself +sudo ${PYTHON} -m pip install --upgrade pip + # Install Python dependencies -sudo ${PYTHON} -m pip install -Ur requirements.txt +sudo ${PYTHON} -m pip install --target ${SITE_PACKAGES} -Ur requirements.txt # Install both Unicorn and Capstone for directory in capstone unicorn; do