about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile19
-rwxr-xr-xnyx_mode/build_nyx_support.sh38
2 files changed, 26 insertions, 31 deletions
diff --git a/Dockerfile b/Dockerfile
index 21c229be..e9b1bc7e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,12 +10,13 @@ LABEL "about"="AFLplusplus docker image"
 ARG DEBIAN_FRONTEND=noninteractive
 
 ENV NO_ARCH_OPT 1
+ENV IS_DOCKER="1"
 
 RUN apt-get update && apt-get full-upgrade -y && \
     apt-get -y install --no-install-recommends \
     make cmake automake \
     meson ninja-build bison flex \
-    xz-utils libbz2-1.0 \
+    xz-utils bzip2 \
     git \
     python3 python3-dev python3-setuptools python-is-python3 \
     libtool libtool-bin \
@@ -43,16 +44,10 @@ RUN apt-get update && \
     libc++abi1-${LLVM_VERSION} libc++abi-${LLVM_VERSION}-dev libclang1-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev \
     libclang-common-${LLVM_VERSION}-dev libclang-cpp${LLVM_VERSION} libclang-cpp${LLVM_VERSION}-dev liblld-${LLVM_VERSION} \
     liblld-${LLVM_VERSION}-dev liblldb-${LLVM_VERSION} liblldb-${LLVM_VERSION}-dev libllvm${LLVM_VERSION} libomp-${LLVM_VERSION}-dev \
-    libomp5-${LLVM_VERSION} lld-${LLVM_VERSION} lldb-${LLVM_VERSION} llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev llvm-${LLVM_VERSION}-runtime llvm-${LLVM_VERSION}-tools && \
+    libomp5-${LLVM_VERSION} lld-${LLVM_VERSION} lldb-${LLVM_VERSION} llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev llvm-${LLVM_VERSION}-runtime llvm-${LLVM_VERSION}-tools \
+    $([ "$(dpkg --print-architecture)" = "amd64" ] && echo gcc-${GCC_VERSION}-multilib gcc-multilib) && \
     rm -rf /var/lib/apt/lists/*
-
-# arm64 doesn't have gcc-multilib, and it's only used for -m32 support on x86
-RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
-        apt-get update; \
-        apt-get -y install --no-install-recommends \
-        gcc-${GCC_VERSION}-multilib gcc-multilib; \
-        rm -rf /var/lib/apt/lists/*; \
-    fi
+    # arm64 doesn't have gcc-multilib, and it's only used for -m32 support on x86
 
 RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 0 && \
     update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 0
@@ -68,6 +63,9 @@ RUN git clone --depth=1 https://github.com/vanhauser-thc/afl-cov && \
 WORKDIR /AFLplusplus
 COPY . .
 
+# Until gcc v12.1 is released for ubuntu https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/1940029
+ENV NO_NYX 1
+
 RUN export CC=gcc-${GCC_VERSION} && export CXX=g++-${GCC_VERSION} && make clean && \
     make distrib && make install && make clean
 
@@ -75,4 +73,3 @@ RUN echo "set encoding=utf-8" > /root/.vimrc && \
     echo ". /etc/bash_completion" >> ~/.bashrc && \
     echo 'alias joe="joe --wordwrap --joe_state -nobackup"' >> ~/.bashrc && \
     echo "export PS1='"'[afl++ \h] \w$(__git_ps1) \$ '"'" >> ~/.bashrc
-ENV IS_DOCKER="1"
diff --git a/nyx_mode/build_nyx_support.sh b/nyx_mode/build_nyx_support.sh
index 83e0ae32..c4a480e6 100755
--- a/nyx_mode/build_nyx_support.sh
+++ b/nyx_mode/build_nyx_support.sh
@@ -1,4 +1,7 @@
 #!/bin/bash
+
+set -e
+
 echo "================================================="
 echo "           Nyx build script"
 echo "================================================="
@@ -6,14 +9,14 @@ echo
 
 echo "[*] Performing basic sanity checks..."
 
-if [ ! "`uname -s`" = "Linux" ]; then
+if [ ! "$(uname -s)" = "Linux" ]; then
 
   echo "[-] Error: Nyx mode is only available on Linux."
   exit 0
 
 fi
 
-if [ ! "`uname -m`" = "x86_64" ]; then
+if [ ! "$(uname -m)" = "x86_64" ]; then
 
   echo "[-] Error: Nyx mode is only available on x86_64 (yet)."
   exit 0
@@ -22,10 +25,10 @@ fi
 
 echo "[*] Making sure all Nyx is checked out"
 
-git status 1>/dev/null 2>/dev/null
-if [ $? -eq 0 ]; then
 
-  git submodule init || exit 1
+if git status 1>/dev/null 2>&1; then
+
+  git submodule init
   echo "[*] initializing QEMU-Nyx submodule"
   git submodule update ./QEMU-Nyx 2>/dev/null # ignore errors
   echo "[*] initializing packer submodule"
@@ -47,32 +50,27 @@ test -e QEMU-Nyx/.git || { echo "[-] QEMU-Nyx not checked out, please install gi
 
 echo "[*] checking packer init.cpio.gz ..."
 if [ ! -f "packer/linux_initramfs/init.cpio.gz" ]; then
-    cd packer/linux_initramfs/
-    sh pack.sh || exit 1
-    cd ../../
+    (cd packer/linux_initramfs/ && sh pack.sh)
 fi
 
 echo "[*] Checking libnyx ..."
 if [ ! -f "libnyx/libnyx/target/release/liblibnyx.a" ]; then
-    cd libnyx/libnyx
-    cargo build --release || exit 1
-    cd ../../
+    (cd libnyx/libnyx && cargo build --release)
 fi
 
 echo "[*] Checking QEMU-Nyx ..."
 if [ ! -f "QEMU-Nyx/x86_64-softmmu/qemu-system-x86_64" ]; then
-    cd QEMU-Nyx/
-    ./compile_qemu_nyx.sh static || exit 1
-    cd ..
+    
+    if ! [ "${IS_DOCKER}" = "" ]; then
+        echo "[-] Disabling GTK as we're building a container image."
+        sed -i 's/--enable-gtk//g' QEMU-Nyx/compile_qemu_nyx.sh
+    fi
+    (cd QEMU-Nyx && ./compile_qemu_nyx.sh static)
 fi
 
 echo "[*] Checking libnyx.so ..."
-if [ -f "libnyx/libnyx/target/release/liblibnyx.so" ]; then
-  cp -v libnyx/libnyx/target/release/liblibnyx.so ../libnyx.so || exit 1
-else
-  echo "[ ] libnyx.so not found..."
-  exit 1
-fi
+cp libnyx/libnyx/target/release/liblibnyx.so ../libnyx.so
+
 echo "[+] All done for nyx_mode, enjoy!"
 
 exit 0