Skip to content

Commit

Permalink
Build debian package with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Fasano committed Dec 15, 2023
1 parent 98b9da2 commit 0eadd64
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build
venv
local
Dockerfile
panda/debian
.*sw*
.dockerignore
.github
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
1 change: 1 addition & 0 deletions panda/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
panda.deb
12 changes: 12 additions & 0 deletions panda/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: pandare
Version: 3.1.0
Architecture: all
BUILD_DEPENDS_LIST
DEPENDS_LIST
Maintainer: Andrew Fasano <[email protected]>
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.
52 changes: 52 additions & 0 deletions panda/debian/setup.sh
Original file line number Diff line number Diff line change
@@ -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 <OS> <version>"
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"

0 comments on commit 0eadd64

Please sign in to comment.