diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2023-02-28 19:06:47 +0000 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2023-03-01 12:45:11 +0000 |
commit | 5b8bcf6b6cf7a254854e75def40883e2a8fea5dc (patch) | |
tree | 27762903713ba5ab30a085b9ad7f1636c85eba76 /tests/lcitool | |
parent | 60f999b7f2890c9e8ddcd404ce8c4b89b5dee0a2 (diff) |
tests/lcitool: append user setting stanza to dockerfiles
For the cross-compilation use-case it is important to add the host
user to the dockerfile so we can map them to the docker environment
when cross-building files.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230228190653.1602033-19-alex.bennee@linaro.org>
Diffstat (limited to 'tests/lcitool')
-rwxr-xr-x | tests/lcitool/refresh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index cc9e34ac87..c0d7ad5516 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -53,6 +53,15 @@ def generate(filename, cmd, trailer): content += trailer atomic_write(filename, content) +# Optional user setting, this will always be the last thing added +# so maximise the number of layers that are cached +add_user_mapping = [ + "# As a final step configure the user (if env is defined)", + "ARG USER", + "ARG UID", + "RUN if [ \"${USER}\" ]; then \\", + " id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi\n" +] def generate_dockerfile(host, target, cross=None, trailer=None): filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker") @@ -60,6 +69,12 @@ def generate_dockerfile(host, target, cross=None, trailer=None): if cross is not None: cmd.extend(["--cross", cross]) cmd.extend([target, "qemu"]) + + if trailer is not None: + trailer += "\n".join(add_user_mapping) + else: + trailer = "\n".join(add_user_mapping) + generate(filename, cmd, trailer) |