tests/docker: tolerate chmod EPERM when unpacking hexagon toolchain
PATCH 1/1 tests/docker: tolerate chmod EPERM when unpacking hexagon toolchain
The debian-hexagon-cross image unpacks the codelinaro clang+llvm hexagon toolchain tarball into /opt. The archive contains symlinks (the .so/.a library aliases) and directories whose stored modes GNU tar restores via chmod()/lchmod(). Under docker, where the build runs as real root, those calls succeed. Under rootless podman the build runs in a user namespace on overlay storage, which rejects the chmod()/lchmod() calls with EPERM:
tar: .../libclang_rt.builtins.a: Cannot change mode to rwxrwxrwx: \
Operation not permitted
tar: .../x86_64-linux-gnu: Cannot change mode to rwxr-xr-x: \
Operation not permitted
tar: Exiting with failure status due to previous errorstar then exits non-zero and aborts the build. The mode metadata on these symlinks and directories is irrelevant for our use, and neither --no-same-permissions nor extracting as a non-root user stops GNU tar 1.35 from attempting the lchmod on the symlinks.
Download the tarball to a file and ignore tar errors during extraction with --no-same-owner and --no-same-permissions.
--- tests/docker/dockerfiles/debian-hexagon-cross.docker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/docker/dockerfiles/debian-hexagon-cross.docker +6 -1
@@ -49,7 +49,12 @@ ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin ENV TOOLCHAIN_URL=https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/${TOOLCHAIN_RELEASE}_/${TOOLCHAIN_BASENAME}.tar.zst ENV CCACHE_WRAPPERSDIR=/usr/libexec/ccache-wrappers -RUN curl -#SL "$TOOLCHAIN_URL" | tar --zstd -xC "$TOOLCHAIN_INSTALL" +# Ignore tar's chmod/lchmod EPERM on the toolchain symlinks and directories, +# which rootless podman's overlay storage rejects (harmless mode metadata). +RUN curl -#SLo /tmp/toolchain.tar.zst "$TOOLCHAIN_URL" && \ + { tar --zstd --no-same-owner --no-same-permissions \ + -xf /tmp/toolchain.tar.zst -C "$TOOLCHAIN_INSTALL" || true; } && \ + rm -f /tmp/toolchain.tar.zst ENV PATH=$PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin ENV MAKE=/usr/bin/make # As a final step configure the user (if env is defined)
Signature · 1 line
2.34.1
Quoted 1 line · On Thu, 18 Jun 2026 21:31:59 -0700 Brian Cain <[email protected]>…
...
Quoted 3 lines
Download the tarball to a file and ignore tar errors during extraction with --no-same-owner and --no-same-permissions.
tar's man page says --no-same-owner and --no-same-permissions are "default for ordinary users". Isn't that the case for rootless podman?
Quoted 10 lines
Signed-off-by Brian Cain <[email protected]>--- tests/docker/dockerfiles/debian-hexagon-cross.docker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0
tests/docker/dockerfiles/debian-hexagon-cross.docker ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin · line 57
Quoted 10 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +6
-1@@ -49,7 +49,12 @@ ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin ENV TOOLCHAIN_URL=https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/${TOOLCHAIN_RELEASE}_/${TOOLCHAIN_BASENAME}.tar.zst ENV CCACHE_WRAPPERSDIR=/usr/libexec/ccache-wrappers -RUN curl -#SL "$TOOLCHAIN_URL" | tar --zstd -xC "$TOOLCHAIN_INSTALL" +# Ignore tar's chmod/lchmod EPERM on the toolchain symlinks and directories, +# which rootless podman's overlay storage rejects (harmless mode metadata). +RUN curl -#SLo /tmp/toolchain.tar.zst "$TOOLCHAIN_URL" && \ + { tar --zstd --no-same-owner --no-same-permissions \ + -xf /tmp/toolchain.tar.zst -C "$TOOLCHAIN_INSTALL" || true; } && \ + rm -f /tmp/toolchain.tar.zst
Hmm, I think the "|| true" may mask some real failures. For example, if the URL is invalid, curl would still exit with no error code, but the output file would contain something like "errors" : [ { "status" : 404 } ]. Then, tar would fail to unpack that but || true would mask it.
Quoted 6 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0ENV PATH=$PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin ENV MAKE=/usr/bin/make # As a final step configure the user (if env is defined)Signature · 1 line
2.34.1
Quoted 24 lines · Matheus Tavares Bernardino
Quoted 1 line · On Thu, 18 Jun 2026 21:31:59 -0700 Brian Cain <[email protected]>…
...
Quoted 3 lines
Download the tarball to a file and ignore tar errors during extraction with --no-same-owner and --no-same-permissions.
tar's man page says --no-same-owner and --no-same-permissions are "default for ordinary users". Isn't that the case for rootless podman?
Quoted 13 lines
Signed-off-by Brian Cain <[email protected]>--- tests/docker/dockerfiles/debian-hexagon-cross.docker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0@@ -49,7 +49,12 @@ ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin ENV TOOLCHAIN_URL=https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/${TOOLCHAIN_RELEASE}_/${TOOLCHAIN_BASENAME}.tar.zst ENV CCACHE_WRAPPERSDIR=/usr/libexec/ccache-wrappers
Quoted 12 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin · line 57
Quoted 7 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +6
-1-RUN curl -#SL "$TOOLCHAIN_URL" | tar --zstd -xC "$TOOLCHAIN_INSTALL" +# Ignore tar's chmod/lchmod EPERM on the toolchain symlinks and directories, +# which rootless podman's overlay storage rejects (harmless mode metadata). +RUN curl -#SLo /tmp/toolchain.tar.zst "$TOOLCHAIN_URL" && \ + { tar --zstd --no-same-owner --no-same-permissions \ + -xf /tmp/toolchain.tar.zst -C "$TOOLCHAIN_INSTALL" || true; } && \ + rm -f /tmp/toolchain.tar.zstHmm, I think the "|| true" may mask some real failures. For example, if the URL is invalid, curl would still exit with no error code, but the output file would contain something like "errors" : [ { "status" : 404 } ]. Then, tar would fail to unpack that but || true would mask it.
Hmm - good point. I'll rethink it.
Quoted 6 lines
Quoted 6 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-1ENV PATH=$PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin ENV MAKE=/usr/bin/make # As a final step configure the user (if env is defined) --2.34.1
Quoted 10 lines · Matheus Tavares Bernardino
Quoted 1 line · On Thu, 18 Jun 2026 21:31:59 -0700 Brian Cain <[email protected]>…
...
Quoted 3 lines
Download the tarball to a file and ignore tar errors during extraction with --no-same-owner and --no-same-permissions.
tar's man page says --no-same-owner and --no-same-permissions are "default for ordinary users". Isn't that the case for rootless podman?
By default, you're still root in the container, even though id 0 is mapped to your original user in the kernel. So from tar point of view, it's not an ordinary user.
The side effect is that tar will try to apply the original user id, which gets mapped in the range configured by /set/subuid, which ends up being different from yours, and thus results in a
'Cannot change ownership: Operation not permitted'.
Quoted 32 lines
Quoted 10 lines
Signed-off-by Brian Cain <[email protected]>--- tests/docker/dockerfiles/debian-hexagon-cross.docker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0tests/docker/dockerfiles/debian-hexagon-cross.docker ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin · line 57
Quoted 10 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +6
-1@@ -49,7 +49,12 @@ ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin ENV TOOLCHAIN_URL=https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/${TOOLCHAIN_RELEASE}_/${TOOLCHAIN_BASENAME}.tar.zst ENV CCACHE_WRAPPERSDIR=/usr/libexec/ccache-wrappers -RUN curl -#SL "$TOOLCHAIN_URL" | tar --zstd -xC "$TOOLCHAIN_INSTALL" +# Ignore tar's chmod/lchmod EPERM on the toolchain symlinks and directories, +# which rootless podman's overlay storage rejects (harmless mode metadata). +RUN curl -#SLo /tmp/toolchain.tar.zst "$TOOLCHAIN_URL" && \ + { tar --zstd --no-same-owner --no-same-permissions \ + -xf /tmp/toolchain.tar.zst -C "$TOOLCHAIN_INSTALL" || true; } && \ + rm -f /tmp/toolchain.tar.zstHmm, I think the "|| true" may mask some real failures. For example, if the URL is invalid, curl would still exit with no error code, but the output file would contain something like "errors" : [ { "status" : 404 } ]. Then, tar would fail to unpack that but || true would mask it.
Quoted 6 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0ENV PATH=$PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin ENV MAKE=/usr/bin/make # As a final step configure the user (if env is defined)Signature · 1 line
2.34.1
Quoted 8 lines · Pierrick Bouvier
Quoted 7 lines · Matheus Tavares Bernardino
On Thu, 18 Jun 2026 21:31:59 -0700 Brian Cain <[email protected]> wrote:
...Quoted 2 lines
Download the tarball to a file and ignore tar errors during extraction with --no-same-owner and --no-same-permissions.
tar's man page says --no-same-owner and --no-same-permissions are "default for ordinary users". Isn't that the case for rootless podman?
Quoted 8 lines
By default, you're still root in the container, even though id 0 is mapped to your original user in the kernel. So from tar point of view, it's not an ordinary user.
The side effect is that tar will try to apply the original user id, which gets mapped in the range configured by /set/subuid, which ends up being different from yours, and thus results in a
'Cannot change ownership: Operation not permitted'.
Yeah - so apparently I can't seem to live without the || true. But Matheus recommended --fail for the curl, which makes a lot of sense to me regardless of the behavior of tar.
So, I'll send a v2 with that change.
Quoted 32 lines
Quoted 32 lines
Quoted 11 lines
Signed-off-by Brian Cain <[email protected]>--- tests/docker/dockerfiles/debian-hexagon-cross.docker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0tests/docker/dockerfiles/debian-hexagon-cross.docker ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin · line 57
Quoted 10 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +6
-1@@ -49,7 +49,12 @@ ENV TOOLCHAIN_BASENAME=clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-lin ENV TOOLCHAIN_URL=https://artifacts.codelinaro.org/artifactory/codelinaro-toolchain-for-hexagon/${TOOLCHAIN_RELEASE}_/${TOOLCHAIN_BASENAME}.tar.zst ENV CCACHE_WRAPPERSDIR=/usr/libexec/ccache-wrappers -RUN curl -#SL "$TOOLCHAIN_URL" | tar --zstd -xC "$TOOLCHAIN_INSTALL" +# Ignore tar's chmod/lchmod EPERM on the toolchain symlinks and directories, +# which rootless podman's overlay storage rejects (harmless mode metadata). +RUN curl -#SLo /tmp/toolchain.tar.zst "$TOOLCHAIN_URL" && \ + { tar --zstd --no-same-owner --no-same-permissions \ + -xf /tmp/toolchain.tar.zst -C "$TOOLCHAIN_INSTALL" || true; } && \ + rm -f /tmp/toolchain.tar.zstHmm, I think the "|| true" may mask some real failures. For example, if the URL is invalid, curl would still exit with no error code, but the output file would contain something like "errors" : [ { "status" : 404 } ]. Then, tar would fail to unpack that but || true would mask it.
Quoted 6 lines
tests/docker/dockerfiles/debian-hexagon-cross.docker +0
-0ENV PATH=$PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin ENV MAKE=/usr/bin/make # As a final step configure the user (if env is defined)Signature · 1 line
2.34.1