Remove most Python2 references (#742)

* Remove most Python2 references

Still left some references to python2 for helper scripts since they
aren't tested (afaik) in CI

* Fix CI
This commit is contained in:
Eric Kilmer
2021-03-05 16:11:23 -05:00
committed by GitHub
parent 2ed00dc29e
commit e42f45ffff
7 changed files with 7 additions and 590 deletions
+2 -4
View File
@@ -65,7 +65,8 @@ jobs:
run: |
# --help return non-zero and fails...
mcsema-lift-${{ matrix.llvm }}.0 --version
mcsema-disass-2 --help
mcsema-disass --help
mcsema-lift-${{ matrix.llvm }}.0 --arch amd64 --os linux --cfg ./tests/test_suite_generator/generated/prebuilt_cfg/amd64/linux/cfg/hello_world --output hello_world.bc
mcsema-lift-${{ matrix.llvm }}.0 --arch x86 --os linux --cfg ./tests/test_suite_generator/generated/prebuilt_cfg/x86/linux/cfg/hello_world --output hello_world.bc
@@ -111,8 +112,5 @@ jobs:
run: |
# --help return non-zero and fails...
mcsema-lift-${{ matrix.llvm }}.0 --version
# TODO Might want to use virtualenv for this whole Python installation process
# Will need to be updated based on the Python2 version used during installation
PYTHONPATH=/usr/local/lib/python2.7/site-packages mcsema-disass-2 --help
# Will need to be updated based on the Python3 version used during installation
PYTHONPATH=/usr/local/lib/python3.9/site-packages mcsema-disass-3 --help
-31
View File
@@ -42,13 +42,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
option(MCSEMA_ENABLE_RUNTIME "Should runtimes for re-compilation of bitcode be produced?" ON)
find_package(Python2 QUIET)
if(Python2_FOUND)
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
else()
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
endif()
find_package(Python3 QUIET)
if(Python3_FOUND)
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
@@ -195,23 +188,6 @@ set(MCSEMA_PYTHON_SOURCES
tools/mcsema_disass/ida7/x86_util.py
)
if(MCSEMA_INSTALL_PYTHON2_LIBS)
add_custom_target(build_mcsema_disass_python2
DEPENDS ${MCSEMA_PYTHON_SOURCES})
add_custom_command(
TARGET build_mcsema_disass_python2 POST_BUILD
COMMAND which python2 && python2 setup.py build --force
COMMENT "Building McSema Python 2 mcsema-disass"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")
add_dependencies(${MCSEMA_LIFT}
build_mcsema_disass_python2)
add_dependencies(build_mcsema_disass_python2
protobuf_python_module_ida)
endif()
if(MCSEMA_INSTALL_PYTHON3_LIBS)
add_custom_target(build_mcsema_disass_python3
DEPENDS ${MCSEMA_PYTHON_SOURCES})
@@ -299,20 +275,13 @@ endif()
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
if(DEFINED WIN32)
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}.bat")
set(python_package_installer3 "${python_package_installer}.bat")
set(optional_interpreter "cmd.exe /C")
else()
set(python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}_py2.sh")
set(python_package_installer3 "${python_package_installer}_py3.sh")
endif()
if(MCSEMA_INSTALL_PYTHON2_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer2}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code2)\n if(NOT exit_code2 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 2 package\")\n endif()")
endif()
if(MCSEMA_INSTALL_PYTHON3_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer3}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code3)\n if(NOT exit_code3 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 3 package\")\n endif()")
-31
View File
@@ -37,13 +37,6 @@ set(MCSEMA_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
option(MCSEMA_ENABLE_RUNTIME "Should runtimes for re-compilation of bitcode be produced?" ON)
find_package(Python2 QUIET)
if(Python2_FOUND)
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries" ON)
else()
option(MCSEMA_INSTALL_PYTHON2_LIBS "Install Python 2 libraries")
endif()
find_package(Python3 QUIET)
if(Python3_FOUND)
option(MCSEMA_INSTALL_PYTHON3_LIBS "Install Python 3 libraries" ON)
@@ -179,23 +172,6 @@ set(MCSEMA_PYTHON_SOURCES
tools/mcsema_disass/ida7/x86_util.py
)
if(MCSEMA_INSTALL_PYTHON2_LIBS)
add_custom_target(build_mcsema_disass_python2
DEPENDS ${MCSEMA_PYTHON_SOURCES})
add_custom_command(
TARGET build_mcsema_disass_python2 POST_BUILD
COMMAND which python2 && python2 setup.py build --force
COMMENT "Building McSema Python 2 mcsema-disass"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools")
add_dependencies(${MCSEMA_LIFT}
build_mcsema_disass_python2)
add_dependencies(build_mcsema_disass_python2
protobuf_python_module_ida)
endif()
if(MCSEMA_INSTALL_PYTHON3_LIBS)
add_custom_target(build_mcsema_disass_python3
DEPENDS ${MCSEMA_PYTHON_SOURCES})
@@ -283,20 +259,13 @@ endif()
set(python_package_installer "${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_launcher")
if(DEFINED WIN32)
string(REPLACE "/" "\\" python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}.bat")
set(python_package_installer3 "${python_package_installer}.bat")
set(optional_interpreter "cmd.exe /C")
else()
set(python_package_install_path "${install_folder}")
set(python_package_installer2 "${python_package_installer}_py2.sh")
set(python_package_installer3 "${python_package_installer}_py3.sh")
endif()
if(MCSEMA_INSTALL_PYTHON2_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer2}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code2)\n if(NOT exit_code2 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 2 package\")\n endif()")
endif()
if(MCSEMA_INSTALL_PYTHON3_LIBS)
install(CODE
"execute_process(COMMAND ${optional_interpreter} \"${python_package_installer3}\" \"${python_package_install_path}\"\nWORKING_DIRECTORY \"${PROJECT_SOURCE_DIR}/tools\"\nRESULT_VARIABLE exit_code3)\n if(NOT exit_code3 EQUAL 0)\n message(FATAL_ERROR \"Failed to install the Python 3 package\")\n endif()")
+4 -4
View File
@@ -72,7 +72,7 @@ Why would anyone translate binaries *back* to bitcode?
| [CMake](https://cmake.org/) | 3.2+ |
| [Remill](https://github.com/lifting-bits/remill) | Latest |
| [Anvill](https://github.com/lifting-bits/anvill) | Latest |
| [Python](https://www.python.org/) | 2.7, 3.8 |
| [Python](https://www.python.org/) | 3.8 |
| [Python Package Index](https://pypi.python.org/pypi) | Latest |
| [python-protobuf](https://pypi.python.org/pypi/protobuf) | 3.2.0 |
| [python-clang](https://pypi.org/project/clang/) | 3.5.0 |
@@ -133,7 +133,7 @@ sudo apt-get install \
git \
curl \
cmake \
python2.7 python-pip python-virtualenv \
python3 python3-pip python3-virtualenv \
wget \
build-essential \
gcc-multilib g++-multilib \
@@ -266,7 +266,7 @@ In order to verify that McSema works correctly as built, head on over to [the do
2. Do **NOT** enable "Add to PATH"
**Python**
1. Get the latest Python 2.7 (X64) installer from the official download page: https://www.python.org/downloads/windows/
1. Get the latest Python 3 (X64) installer from the official download page: https://www.python.org/downloads/windows/
2. Enable "Add to PATH"
**CMake**
@@ -344,7 +344,7 @@ You should now have the following directories: C:\mcsema, C:\remill.
Make extra sure it only contains ASCII characters with no newlines! The following command should work fine under cmd:
```
echo|set /p="C:\mcsema\Lib\site-packages" > "C:\Python27\Lib\site-packages\mcsema.pth"
echo|set /p="C:\mcsema\Lib\site-packages" > "C:\Python3<version>\Lib\site-packages\mcsema.pth"
```
**Install the libmagic DLL**
+1 -1
View File
@@ -141,4 +141,4 @@ def main():
return ret
if __name__ == "__main__":
exit(main())
exit(main())
-434
View File
@@ -1,434 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2020 Trail of Bits, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
SOURCE_DIR="${SCRIPT_DIR}/../"
install_binja () {
# this file is the decrypted version and placed there by the
# before-install action in .travis.yml
local BINJA_TARGZ="${SCRIPT_DIR}/mcsema_binja.tar.gz"
local BINJA_INSTALL="${SOURCE_DIR}/binaryninja"
# make sure our PYTHONPATH is setup for binja
export PYTHONPATH=${BINJA_INSTALL}/python
python2.7 -c "import binaryninja" 2>/dev/null
if [ ! "$?" = "0" ]; then
if [ ! -e ${BINJA_INSTALL}/python/binaryninja/__init__.py ]; then
echo "Extracting Binary Ninja" && \
tar -xzf ${BINJA_TARGZ} -C ${SOURCE_DIR} && \
echo "Extracted to ${SOURCE_DIR}"
if [ ! "$?" = "0" ]; then
echo "FAILED: Binja extraction failed"
return 1
fi
else
echo "Found a copy of Binja, skipping install, using existing copy"
fi
if [ ! -e ${HOME}/.binaryninja/license.dat ]; then
echo "Could not find Binja license, checking for ~/.binaryninja"
if [ ! -e ${HOME}/.binaryninja ]; then
echo "~/.binaryninja does not exist, creating directory..."
mkdir ${HOME}/.binaryninja
fi
echo "Copying our CI Binja license to ${HOME}/.binaryninja/license.dat"
cp ${BINJA_INSTALL}/mcsema_binja_license.txt ${HOME}/.binaryninja/license.dat
else
echo "Found existing Binja license, ignoring..."
fi
# sanity check the install
python2.7 -c "import binaryninja" 2>/dev/null
if [ ! "$?" = "0" ]; then
echo "FAILED: still can't use Binary Ninja, aborting"
return 1
else
echo "BinaryNinja installed successfully"
fi
echo "Updating Binary Ninja to Dev Channel latest"
python2.7 ${SCRIPT_DIR}/update_binja.py
else
echo "Binja already exists; skipping..."
fi
return 0
}
main() {
if [ $# -ne 2 ] ; then
printf "Usage:\n\ttravis.sh <linux|osx> <initialize|build>\n"
return 1
fi
local platform_name="$1"
local operation_type="$2"
# This makes life simpler for github actions
if [[ "${platform_name}" == "macos-latest" ]] ; then
platform_name="osx"
elif [[ "${platform_name}" == "ubuntu-latest" ]] ; then
platform_name="linux"
fi
if [[ "${platform_name}" != "osx" && "${platform_name}" != "linux" ]] ; then
printf "Invalid platform: ${platform_name}\n"
return 1
fi
if [[ "${operation_type}" == "initialize" ]] ; then
"${platform_name}_initialize"
return $?
elif [[ "$operation_type" == "build" ]] ; then
"${platform_name}_build"
return $?
else
printf "Invalid operation\n"
return 1
fi
}
linux_initialize() {
printf "Initializing platform: linux\n"
printf " > Updating the system...\n"
sudo dpkg --add-architecture i386
sudo apt-get -qq update
if [ $? -ne 0 ] ; then
printf " x The package database could not be updated\n"
return 1
fi
printf " > Installing the required packages...\n"
sudo apt-get install -qqy python2.7 \
build-essential \
realpath \
python-setuptools \
git \
python2.7 \
wget \
libtinfo-dev \
gcc-multilib \
g++-multilib \
lsb-release \
liblzma-dev \
zlib1g-dev \
libprotobuf-dev \
protobuf-compiler \
ccache
sudo apt-get install -qqy libc6:i386 \
libstdc++6:i386 \
zlib1g-dev:i386 \
liblzma-dev:i386 \
libtinfo-dev:i386
# install clang and ccsyspath for ABI libraries generation
pip install clang ccsyspath
if [ $? -ne 0 ] ; then
printf " x Could not install the required dependencies\n"
return 1
fi
install_binja
if [ $? -ne 0 ] ; then
printf " x Could not install binary ninja"
return 1
fi
printf " > The system has been successfully initialized\n"
return 0
}
osx_initialize() {
printf "Initializing platform: osx\n"
printf " x This platform is not yet supported\n"
return 1
}
# Travis: do not delete the cxxcommon folder, because it is configured to be cached!
linux_build() {
local original_path="${PATH}"
local log_file=`mktemp`
# set up ada support for cmake
# Old supported versions: "35" "36" "37" "38" "39" "40"
llvm_version_list=( "50" "60" )
for llvm_version in "${llvm_version_list[@]}" ; do
printf "#\n"
printf "# Running CI tests for LLVM version ${llvm_version}...\n"
printf "#\n\n"
printf " > Cleaning up the environment variables...\n"
export PATH="${original_path}"
unset TRAILOFBITS_LIBRARIES
unset CC
unset CXX
printf " > Cleaning up the build folders...\n"
if [ -d "remill" ] ; then
sudo rm -rf remill > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to remove the existing remill folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
if [ -d "build" ] ; then
sudo rm -rf build > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to remove the existing build folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
if [ -d "libraries" ] ; then
sudo rm -rf libraries > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to remove the existing libraries folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
# create the cache folder for ccache
local cache_folder_name="ccache_llvm${llvm_version}"
printf " > Setting up ccache folder...\n"
if [ ! -d "${cache_folder_name}" ] ; then
mkdir "${cache_folder_name}" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to create the ccache folder: ${cache_folder_name}. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
export CCACHE_DIR="$(realpath ${cache_folder_name})"
printf " i ${CCACHE_DIR}\n"
linux_build_helper "${llvm_version}"
if [ $? -ne 0 ] ; then
printf " ! One or more tests have failed for LLVM ${llvm_version}\n"
return 1
fi
printf "\n\n"
done
return $?
}
osx_build() {
printf "Building for platform: osx\n"
printf " x This platform is not yet supported\n"
return 1
}
linux_build_helper() {
if [ $# -ne 1 ] ; then
printf "Usage:\n\tlinux_build_helper <llvm_version>\n\nllvm_version: 35, 40, ...\n"
return 1
fi
local llvm_version="$1"
local ubuntu_version=`cat /etc/issue | awk '{ print $2 }' | cut -d '.' -f 1-2 | tr -d '.'`
local log_file=`mktemp`
printf " > Cloning remill...\n"
git clone "https://github.com/lifting-bits/remill.git" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to clone the remill repository. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
cd remill
# we are supposed to put mcsema inside the remill folder
mkdir -p "remill/tools/mcsema" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to create the remill/tools/mcsema folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
printf " > Copying the mcsema folder...\n"
local file_list=( "cmake" "tools" "examples" "scripts" "tests" "docs" "mcsema" "generated" "CMakeLists.txt" "README.md" "CONTRIBUTING.md" ".gdbinit" "LICENSE" "ACKNOWLEDGEMENTS.md" ".gitignore" ".travis.yml" )
for file_name in "${file_list[@]}" ; do
cp -r "${file_name}" "remill/tools/mcsema" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to copy the mcsema files in remill/tools/mcsema. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
done
# acquire the cxx-common package
printf " > Acquiring the cxx-common package: LLVM${llvm_version}/Ubuntu ${ubuntu_version}\n"
if [ ! -d "cxxcommon" ] ; then
mkdir "cxxcommon" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to create the cxxcommon folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
local cxx_common_tarball_name="libraries-llvm${llvm_version}-ubuntu${ubuntu_version}-amd64.tar.gz"
if [ ! -f "${cxx_common_tarball_name}" ] ; then
( cd "cxxcommon" && wget "https://s3.amazonaws.com/cxx-common/${cxx_common_tarball_name}" ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to download the cxx-common package. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
fi
if [ ! -d "libraries" ] ; then
tar xzf "cxxcommon/${cxx_common_tarball_name}" > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x The archive appears to be corrupted. Error output follows:\n"
printf "===\n"
cat "${log_file}"
rm "cxxcommon/${cxx_common_tarball_name}"
rm -rf libraries
return 1
fi
fi
export TRAILOFBITS_LIBRARIES=`realpath libraries`
export PATH="${TRAILOFBITS_LIBRARIES}/llvm/bin:${TRAILOFBITS_LIBRARIES}/cmake/bin:${TRAILOFBITS_LIBRARIES}/protobuf/bin:${PATH}"
export CC="${TRAILOFBITS_LIBRARIES}/llvm/bin/clang"
export CXX="${TRAILOFBITS_LIBRARIES}/llvm/bin/clang++"
printf " > Generating the project...\n"
mkdir build > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to create the build folder. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
( cd build && cmake -DMCSEMA_DISABLED_ABI_LIBRARIES:STRING="" -DCMAKE_VERBOSE_MAKEFILE=True ../remill ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to generate the project. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
printf " > Building...\n"
if [ "${llvm_version:0:1}" != "4" ] ; then
printf " i Clang static analyzer not supported on this LLVM release\n"
#( cd build && make -j `nproc` ) > "${log_file}" 2>&1
else
printf " i Clang static analyzer enabled\n"
#( cd build && scan-build --show-description --status-bugs make -j `nproc` ) > "${log_file}" 2>&1
fi
if [ $? -ne 0 ] ; then
printf " x Failed to build the project. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
printf " > Installing...\n"
( cd build && sudo make install -j `nproc` ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to install the project. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
printf " > Build succeeded\n"
printf " > Building Integration Test Suite...\n"
pushd ./remill/tools/mcsema/tests/test_suite_generator
mkdir build
( cd build && cmake -DMCSEMA_PREBUILT_CFG_PATH=$(pwd)/../generated/prebuilt_cfg -DCMAKE_VERBOSE_MAKEFILE=True .. ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to generate test suite project. Error output follows:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
( cd build && make -j `nproc` ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to build test suite. Output below:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
( cd build && make install ) > "${log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to install test suite. Output below:\n"
printf "===\n"
cat "${log_file}"
return 1
fi
popd
printf "\n\n\nCalling the integration test suite...\n"
local test_log_file=`mktemp`
( cd ./remill/tools/mcsema/tests/test_suite_generator/test_suite && ./start.py ) > "${test_log_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed the integration test suite:\n"
printf "===\n"
cat "${test_log_file}"
return 1
fi
return 0
}
main $@
exit $?
-85
View File
@@ -1,85 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2020 Trail of Bits, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
main() {
if [ $# -ne 1 ] ; then
printf "Pass the install folder to the script!\n"
return 1
fi
local install_folder="$1"
printf "Looking for the Python interpreter\n"
which python2.7 > /dev/null 2>&1
if [ $? -eq 0 ] ; then
local python_interpreter="python2.7"
else
which python2 > /dev/null 2>&1
if [ $? -ne 0 ] ; then
which python > /dev/null 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to find a Python interpreter\n"
return 1
else
local python_interpreter="python"
fi
else
local python_interpreter="python2"
fi
fi
local python_version=`"${python_interpreter}" --version 2>&1 | awk '{ print $2 }' | cut -d '.' -f 1-2`
if [ "${python_version}" != "2.7" ]; then
printf " x Python 2.7 was not found\n"
return 1
fi
printf " i Python 2.7 found: ${python_interpreter}\n\n"
echo "Installing mcsema-disass"
export PYTHONPATH="${install_folder}/lib/python2.7/site-packages"
if [ ! -d "${PYTHONPATH}" ] ; then
mkdir -p "${PYTHONPATH}" > /dev/null 2>&1
if [ $? -ne 0 ] ; then
printf " x Failed to create the site-packages folder\n"
return 1
fi
fi
printf " i site-packages: ${PYTHONPATH}\n"
local temp_file=`mktemp`
"${python_interpreter}" setup.py install -f --prefix=${install_folder} > "${temp_file}" 2>&1
if [ $? -ne 0 ] ; then
printf " x Install failed\n\n"
printf "Output follows\n===\n"
cat "${temp_file}"
rm "${temp_file}"
return 1
else
printf " i Successfully installed\n"
rm "${temp_file}"
fi
return 0
}
main $@
exit $?