aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Wiehler <me@sephalon.net>2021-11-18 15:18:52 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-11-29 14:36:06 +0000
commitae18d35577c2e7e556be98bb4dc854317440a55a (patch)
treeb27030f5181e6228f08912fae321993d1a4f023b
parent8f3b15c4213fbdd6918d7ddd9ffa9fd4a623dc49 (diff)
tools/syz-env: add local build option
Useful for testing local Dockerfile changes that have not been pushed yet.
-rw-r--r--docs/contributing.md6
-rwxr-xr-xtools/syz-env13
2 files changed, 16 insertions, 3 deletions
diff --git a/docs/contributing.md b/docs/contributing.md
index 4d1278a1c..85ce77e6d 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -151,6 +151,12 @@ docker pull docker.pkg.github.com/google/syzkaller/env
docker tag docker.pkg.github.com/google/syzkaller/env gcr.io/syzkaller/env
```
+You can also build the container from the respective `Dockerfile` by setting the `SYZ_ENV_BUILD` environment variable, i.e.:
+```
+SYZ_ENV_BUILD=1 syz-env
+```
+This can be useful to test local changes that have not been pushed to the registry yet.
+
### Using [act](https://github.com/nektos/act)
.github/workflows has more tests compared to `syz-env make presubmit`. To have the same tests as the workflow, we can run these workflow jobs locally.
```
diff --git a/tools/syz-env b/tools/syz-env
index 30a1f8448..479f858ec 100755
--- a/tools/syz-env
+++ b/tools/syz-env
@@ -62,8 +62,15 @@ if [ ! "$(docker info -f "{{println .SecurityOptions}}" | grep rootless)" ]; the
DOCKERARGS+=" --user $(id -u ${USER}):$(id -g ${USER})"
fi
-# Update docker image
-docker pull -q gcr.io/syzkaller/${IMAGE}
+
+# Build or update docker image
+if [ ! -z "$SYZ_ENV_BUILD" ]; then
+ IMAGE_NAME="syz-$IMAGE"
+ docker build "$SCRIPT_DIR/docker/$IMAGE" --tag "$IMAGE_NAME" ${BUILDARGS[@]}
+else
+ IMAGE_NAME="gcr.io/syzkaller/$IMAGE"
+ docker pull -q "$IMAGE_NAME"
+fi
# Run everything as the host user, this is important for created/modified files.
docker run \
@@ -82,4 +89,4 @@ docker run \
--env GITHUB_PR_COMMITS \
--env CI \
${DOCKERARGS[@]} \
- gcr.io/syzkaller/${IMAGE} -c "$COMMAND"
+ "$IMAGE_NAME" -c "$COMMAND"