Support Arch Linux docker test (#1378)

* Specify dockerfile for ubuntu/debian

To add Dockerfile.arch later

* Support Arch Linux docker test

* Fix setup-dev supported distro

* Create set_zigpath function

* Download zig from upstream for archlinux

* Add hash as part of key for docker cache

as https://github.com/satackey/action-docker-layer-caching#inputs notes.
pull/1390/head
Xeonacid 3 years ago committed by GitHub
parent 995a1e959e
commit 1224cf75ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
images: [ubuntu18.04, ubuntu20.04, ubuntu22.04, debian10, debian11]
images: [ubuntu18.04, ubuntu20.04, ubuntu22.04, debian10, debian11, archlinux]
runs-on: ubuntu-latest
timeout-minutes: 30
@ -19,7 +19,7 @@ jobs:
continue-on-error: true
with:
path: ~/.cache/images
key: ${{ matrix.images }}-cache-images
key: ${{ matrix.images }}-cache-images-{hash}
- name: Docker Build ${{ matrix.images }}
run: docker-compose pull ${{ matrix.images }}

@ -1,4 +1,4 @@
# This dockerfile was created for development & testing purposes
# This dockerfile was created for development & testing purposes, for APT-based distro.
#
# Build as: docker build -t pwndbg .
#

@ -0,0 +1,46 @@
# This dockerfile was created for development & testing purposes, for Pacman-based distro.
#
# Build as: docker build -f Dockerfile.arch -t pwndbg .
#
# For testing use: docker run --rm -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined pwndbg bash
#
# For development, mount the directory so the host changes are reflected into container:
# docker run -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v `pwd`:/pwndbg pwndbg bash
#
ARG image=archlinux:latest
FROM $image
WORKDIR /pwndbg
ENV LANG en_US.utf8
ENV TZ=America/New_York
ENV ZIGPATH=/opt/zig
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
pacman -Syu --noconfirm && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
pacman -S --noconfirm vim && \
pacman -Scc --noconfirm
ADD ./setup.sh /pwndbg/
ADD ./requirements.txt /pwndbg/
ADD ./dev-requirements.txt /pwndbg/
# The `git submodule` is commented because it refreshes all the sub-modules in the project
# but at this time we only need the essentials for the set up. It will execute at the end.
RUN sed -i "s/^git submodule/#git submodule/" ./setup.sh && \
./setup.sh
# Comment these lines if you won't run the tests.
ADD ./setup-dev.sh /pwndbg/
RUN ./setup-dev.sh
RUN echo "source /pwndbg/gdbinit.py" >> ~/.gdbinit.py && \
echo "PYTHON_MINOR=$(python3 -c "import sys;print(sys.version_info.minor)")" >> /root/.bashrc && \
echo "PYTHON_PATH=\"/usr/local/lib/python3.${PYTHON_MINOR}/dist-packages/bin\"" >> /root/.bashrc && \
echo "export PATH=$PATH:$PYTHON_PATH" >> /root/.bashrc
ADD . /pwndbg/
RUN git submodule update --init --recursive

@ -14,6 +14,7 @@ services:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile
args:
image: ubuntu:18.04
@ -21,6 +22,7 @@ services:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile
args:
image: ubuntu:20.04
@ -28,6 +30,7 @@ services:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile
args:
image: ubuntu:22.04
@ -35,6 +38,7 @@ services:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile
args:
image: debian:10
@ -42,5 +46,14 @@ services:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile
args:
image: debian:11
archlinux:
<<: *base-spec
build:
context: .
dockerfile: Dockerfile.arch
args:
image: archlinux:latest

@ -2,7 +2,7 @@
echo "# --------------------------------------"
echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# Only works with Ubuntu / APT or Arch / Pacman."
echo "# --------------------------------------"
hook_script_path=".git/hooks/pre-push"
@ -37,13 +37,6 @@ if [ -t 1 ]; then
fi
fi
if [[ -z "$ZIGPATH" ]]; then
# If ZIGPATH is not set, set it to $pwd/.zig
# In Docker environment this should by default be set to /opt/zig
export ZIGPATH="$(pwd)/.zig"
fi
echo "ZIGPATH set to $ZIGPATH"
# If we are a root in a container and `sudo` doesn't exist
# lets overwrite it with a function that just executes things passed to sudo
# (yeah it won't work for sudo executed with flags)
@ -57,23 +50,16 @@ linux() {
uname | grep -i Linux &> /dev/null
}
install_apt() {
sudo apt-get update || true
sudo apt-get install -y \
nasm \
gcc \
libc6-dev \
curl \
build-essential \
gdb \
parallel
if [[ "$1" == "22.04" ]]; then
sudo apt install shfmt
set_zigpath() {
if [[ -z "$ZIGPATH" ]]; then
# If ZIGPATH is not set, set it
# In Docker environment this should by default be set to /opt/zig (APT) or /usr/bin (Pacman)
export ZIGPATH="$1"
fi
echo "ZIGPATH set to $ZIGPATH"
}
test -f /usr/bin/go || sudo apt-ge\t install -y golang
download_zig_binary() {
# Install zig to current directory
# We use zig to compile some test binaries as it is much easier than with gcc
@ -94,6 +80,61 @@ install_apt() {
echo "Zig installed to ${ZIGPATH}"
}
install_apt() {
set_zigpath "$(pwd)/.zig"
sudo apt-get update || true
sudo apt-get install -y \
nasm \
gcc \
libc6-dev \
curl \
build-essential \
gdb \
parallel
if [[ "$1" == "22.04" ]]; then
sudo apt install shfmt
fi
test -f /usr/bin/go || sudo apt-get install -y golang
download_zig_binary
}
install_pacman() {
set_zigpath "$(pwd)/.zig"
# add debug repo for glibc-debug
cat <<EOF | sudo tee -a /etc/pacman.conf
[core-debug]
Include = /etc/pacman.d/mirrorlist
[extra-debug]
Include = /etc/pacman.d/mirrorlist
[community-debug]
Include = /etc/pacman.d/mirrorlist
[multilib-debug]
Include = /etc/pacman.d/mirrorlist
EOF
sudo pacman -Syu --noconfirm || true
sudo pacman -S --noconfirm \
nasm \
gcc \
glibc-debug \
curl \
base-devel \
gdb \
parallel
test -f /usr/bin/go || sudo pacman -S --noconfirm go
download_zig_binary
}
if linux; then
distro=$(
. /etc/os-release
@ -108,12 +149,17 @@ if linux; then
)
install_apt $ubuntu_version
;;
"arch")
install_pacman
;;
*) # we can add more install command for each distros.
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'dnf' package managers."
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'pacman' package managers."
if hash apt; then
install_apt
elif hash pacman; then
install_pacman
else
echo "\"$distro\" is not supported and your distro don't have apt or dnf that we support currently."
echo "\"$distro\" is not supported and your distro don't have apt or pacman that we support currently."
exit
fi
;;

Loading…
Cancel
Save