Skip to content

Commit 5273cf3

Browse files
committed
Fix several comments issue from itamaro
1 parent 6efd156 commit 5273cf3

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
``Tools/build/regen-configure.sh`` no longer leaves an ``autom4te.cache``
2-
directory owned by root in the source tree: the Autoconf container now runs as
3-
the invoking user, and the cache is removed when the script finishes.
1+
``Tools/build/regen-configure.sh`` no longer leaves
2+
root-owned files in the source tree.

‎Tools/build/regen-configure.sh‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,27 @@ if command -v selinuxenabled >/dev/null && selinuxenabled; then
2626
PATH_OPT=":Z"
2727
fi
2828

29+
# Run the container as the invoking user so that generated files are owned by
30+
# that user and not by root. Rootless runtimes already map root to the invoking
31+
# user, so a user mapping is only needed for rootful Docker.
32+
USER_OPT=""
33+
case "$RUNTIME" in
34+
podman)
35+
USER_OPT="--userns=keep-id"
36+
;;
37+
docker)
38+
if ! docker info --format '{{.SecurityOptions}}' | grep -q rootless; then
39+
USER_OPT="-u $(id -u):$(id -g)"
40+
fi
41+
;;
42+
esac
43+
2944
purge_autom4te_cache() {
45+
[ -d "$abs_srcdir/autom4te.cache" ] || return 0
3046
"$RUNTIME" run --rm -v "$abs_srcdir:$WORK_DIR$PATH_OPT" \
31-
--entrypoint sh "$IMAGE" -c "rm -rf $WORK_DIR/autom4te.cache"
47+
"$IMAGE" sh -c "rm -rf $WORK_DIR/autom4te.cache"
3248
}
3349

3450
purge_autom4te_cache
35-
trap purge_autom4te_cache EXIT
36-
"$RUNTIME" run --rm -u "$(id -u):$(id -g)" -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE"
51+
trap 'purge_autom4te_cache || true' EXIT
52+
"$RUNTIME" run --rm $USER_OPT -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE"

0 commit comments

Comments
 (0)