Skip to content

Added Dockerfile #20

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu:latest
MAINTAINER David Manouchehri

RUN useradd -m patchkit
WORKDIR /home/patchkit
ENV HOME /home/patchkit

RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git python-pip build-essential git cmake python-dev libglib2.0-dev && \
su - patchkit -c "git clone https://github.com/lunixbochs/patchkit.git" && \
su - patchkit -c "cd /home/patchkit/patchkit && HEADLESS=1 ./deps.sh" && \
cd /home/patchkit/patchkit && \
HEADLESS=1 build=/home/patchkit/patchkit/build ./install.sh && \
rm -rf /home/patchkit/patchkit/build

USER patchkit
ENV PATH /home/patchkit/patchkit:$PATH

CMD ["/bin/bash"]
37 changes: 12 additions & 25 deletions deps.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -u
#!/usr/bin/env bash

echo
echo "Take a look here if Unicorn fails to build:"
Expand All @@ -13,49 +13,36 @@ echo " brew install pkg-config glib cmake"
echo
echo "Using ./build as a tmp dir. ^C if that's a bad idea."
echo
echo -n "[press enter to continue]"
read
if [ ! "${HEADLESS}" ]; then
echo -n "[press enter to continue]"
read
fi
echo

cwd=$(pwd)
build="$cwd/build"
export build="${cwd}/build"

mkdir build &>/dev/null
set -e

echo "[*] Building Keystone"
cd "$build"
cd "${build}"
git clone https://github.com/keystone-engine/keystone.git
cd keystone && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="all" -G "Unix Makefiles" .. && make -j2
echo

echo "[*] Building Capstone"
cd "$build"
cd "${build}"
git clone https://github.com/aquynh/capstone.git
cd capstone && make -j2
echo

echo "[*] Building Unicorn"
cd "$build"
cd "${build}"
git clone https://github.com/unicorn-engine/unicorn.git
cd unicorn && ./make.sh

echo
echo "[*] Installing projects and Python bindings (using sudo)"
cd "$build/keystone/build" && sudo make install
cd "$build/keystone/bindings/python" && sudo make install

cd "$build/capstone" && sudo make install
cd "$build/capstone/bindings/python" && sudo make install

cd "$build/unicorn" && sudo ./make.sh install
cd "$build/unicorn/bindings/python" && sudo make install

which ldconfig &>/dev/null && sudo ldconfig

echo
echo "All done!"
echo
echo -n "Testing Python import: "
python -c "import capstone, keystone, unicorn; capstone.CS_ARCH_X86, unicorn.UC_ARCH_X86, keystone.KS_ARCH_X86; print 'works.'"
if [ ! "${HEADLESS}" ]; then
sudo ./install.sh
fi
20 changes: 20 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

echo
echo "[*] Installing projects and Python bindings (as root)"
cd "$build/keystone/build" && make install
cd "$build/keystone/bindings/python" && make install

cd "$build/capstone" && make install
cd "$build/capstone/bindings/python" && make install

cd "$build/unicorn" && ./make.sh install
cd "$build/unicorn/bindings/python" && make install

which ldconfig &>/dev/null && ldconfig

echo
echo "All done!"
echo
echo -n "Testing Python import: "
python -c "import capstone, keystone, unicorn; capstone.CS_ARCH_X86, unicorn.UC_ARCH_X86, keystone.KS_ARCH_X86; print 'works.'"