Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build-in-container-inner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ mkdir -p "$BASEDIR"
# Fix ownership so builder can write to them.
sudo chown -R "$(id -u):$(id -g)" "$HOME/.cache" /output

# And hand ownership back to the host user on the way out.
if [ -n "$HOST_UID" ] && [ -n "$HOST_GID" ]; then
trap 'sudo chown -R "$HOST_UID:$HOST_GID" "$HOME/.cache" /output' EXIT
fi

# Prevent git "dubious ownership" errors
git config --global --add safe.directory '*'

Expand Down
8 changes: 8 additions & 0 deletions build-in-container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import hashlib
import json
import logging
import os
import subprocess
import sys
import urllib.request
Expand Down Expand Up @@ -387,6 +388,13 @@ def run_container(args, image_tag, source_dir, script_dir):
f"EXPLICIT_ROLE={args.role}",
"-e",
f"BUILD_NUMBER={args.build_number}",
# Who to give the writable mounts back to. The container builds as
# its own user, whose UID is not ours, so without this the packages
# and the cache come out owned by a stranger.
"-e",
f"HOST_UID={os.getuid()}",
"-e",
f"HOST_GID={os.getgid()}",
"-e",
f"JOB_BASE_NAME={cache_label}",
"-e",
Expand Down
Loading