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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``Tools/build/regen-configure.sh`` no longer leaves
root-owned files in the source tree.
25 changes: 24 additions & 1 deletion Tools/build/regen-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,27 @@ if command -v selinuxenabled >/dev/null && selinuxenabled; then
PATH_OPT=":Z"
fi

"$RUNTIME" run --rm -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE"
# Run the container as the invoking user so that generated files are owned by
# that user and not by root. Rootless runtimes already map root to the invoking
# user, so a user mapping is only needed for rootful Docker.
USER_OPT=""
case "$RUNTIME" in
podman)
USER_OPT="--userns=keep-id"
;;
docker)
if ! docker info --format '{{.SecurityOptions}}' | grep -q rootless; then
USER_OPT="-u $(id -u):$(id -g)"
fi
;;
esac

purge_autom4te_cache() {
[ -d "$abs_srcdir/autom4te.cache" ] || return 0
"$RUNTIME" run --rm -v "$abs_srcdir:$WORK_DIR$PATH_OPT" \
"$IMAGE" sh -c "rm -rf $WORK_DIR/autom4te.cache"
}

purge_autom4te_cache
trap 'purge_autom4te_cache || true' EXIT
"$RUNTIME" run --rm $USER_OPT -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE"
Loading