diff --git a/.dockerignore b/.dockerignore index aa1f2ae026d..0c91294c87b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ build venv local Dockerfile +panda/debian .*sw* .dockerignore .github diff --git a/Dockerfile b/Dockerfile index d666ddda12c..1770c79d8fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,6 +118,10 @@ RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \ ### Copy files for panda+pypanda from installer - Stage 5 FROM base as panda +# Include dependency lists for packager +COPY --from=base /tmp/base_dep.txt /tmp +COPY --from=base /tmp/build_dep.txt /tmp + # Copy panda + libcapstone.so* + libosi libraries COPY --from=cleanup /usr/local /usr/local COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/ @@ -134,4 +138,4 @@ ENV PANDA_PATH /usr/local/lib/python3.8/dist-packages/pandare/data RUN ldconfig && \ update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \ if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \ - if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi + if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi \ No newline at end of file diff --git a/panda/debian/.gitignore b/panda/debian/.gitignore new file mode 100644 index 00000000000..7bbf39a4c32 --- /dev/null +++ b/panda/debian/.gitignore @@ -0,0 +1 @@ +panda.deb diff --git a/panda/debian/control b/panda/debian/control new file mode 100644 index 00000000000..c5457a4457d --- /dev/null +++ b/panda/debian/control @@ -0,0 +1,12 @@ +Package: pandare +Version: 3.1.0 +Architecture: all +BUILD_DEPENDS_LIST +DEPENDS_LIST +Maintainer: Andrew Fasano +Description: dynamic analysis platform + Platform for Architecture Neutral Dynamic Analysis (PANDA) is a processor + emulator designed to support analyses of guest code. PANDA supports record- + and-replay based analyses as well as analyses on live systems. PANDA is forked + from the QEMU emulator. + Panda currently supports i386, x86_64, ARM, MIPS, and PPC. diff --git a/panda/debian/setup.sh b/panda/debian/setup.sh new file mode 100755 index 00000000000..810720bec3d --- /dev/null +++ b/panda/debian/setup.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -eu + +# Function to get the current Ubuntu version +get_ubuntu_version() { + lsb_release -i -s 2>/dev/null +} + +if [[ $# -eq 0 ]]; then + # No argument given, try building a package for current Ubuntu version + + # Check if we're running Ubuntu, exit otherwise + OS=$(get_ubuntu_version) +else + OS=$1 +fi + +if [[ $(get_ubuntu_version) != "Ubuntu" ]]; then + echo "ERROR: OS of $OS is not Ubuntu and unsupported" + exit 1 +fi + +if [[ $# -eq 1 ]]; then + echo "USAGE:" + echo " To build a package for current Ubuntu version:" + echo " $0" + echo " To build a package for a specific OS/version (only Ubuntu supported for now):" + echo " $0 " + exit 1 +fi + +if [[ $# -eq 2 ]]; then + version=$2 + +else + version=$(lsb_release -r | awk '{print $2}') +fi + +# Check if the given version is supported +if [[ ! -f "../dependencies/ubuntu_${version}_base.txt" ]]; then + echo "ERROR: Ubuntu ${version} is not supported, no dependencies file found" + exit 1 +fi + +# First build main panda container for the target ubuntu version +DOCKER_BUILDKIT=1 docker build --target panda -t panda --build-arg BASE_IMAGE="ubuntu:${version}" ../.. + +# Now build the packager container from that +docker build -t packager . + +# Copy deb file out of container to host +docker run --rm -v $(pwd):/out packager bash -c "cp /pandare.deb /out"