Make ZIGPATH configurable and provide defaults (#1090)

* Make ZIGPATH configurable and provide defaults

Mostly fixes docker/docker-compose environment where building zig into
$pwd/.zig doesn't work well because it is later overwritten by mounting
the volume in /pwndbg.

With current approach during the docker build zig is put in /opt/zig
instead, and when you run it without docker it's possible to configure a
different path (with sane defaults)

* remove Makefile

* add ZIGPATH to tests.sh for CI

* move ZIGPATH setting before make in tests
pull/1093/head
Artur Czepiel 3 years ago committed by GitHub
parent 36ee7d238d
commit 4ee225b115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,8 @@ 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 && \
apt-get update && \

@ -5,6 +5,13 @@ echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# --------------------------------------"
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)
@ -46,8 +53,8 @@ install_apt() {
tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* "$(pwd)/.zig" 2>/dev/null >/dev/null || true
echo "Zig installed to $(pwd)/.zig"
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} 2>/dev/null >/dev/null || true
echo "Zig installed to ${ZIGPATH}"
fi
}

@ -1,9 +1,18 @@
#!/bin/bash
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"
cd ./tests/binaries || exit 1
make clean && make all || exit 2
cd ../../
# NOTE: We run tests under GDB sessions and because of some cleanup/tests dependencies problems
# we decided to run each test in a separate GDB session
TESTS_COLLECT_OUTPUT=$(gdb --silent --nx --nh --command gdbinit.py --command pytests_collect.py --eval-command quit)

@ -1,4 +1,4 @@
ZIGCC = $(shell pwd)/../../.zig/zig cc
ZIGCC = $(ZIGPATH)/zig cc
CC = gcc
DEBUG = 1

Loading…
Cancel
Save