CI: Make user creation idempotent

adduser --system exits successfully if the user already exists, but
ordinary adduser doesn't.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/468
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2023-08-01 18:30:14 +01:00
parent b230cf03b0
commit 8d14293458

View file

@ -173,7 +173,9 @@ case "$ci_distro" in
if [ "$ci_in_docker" = yes ]; then
# Add the user that we will use to do the build inside the
# Docker container, and let them use sudo
adduser --disabled-password --gecos "" user
if ! getent passwd user > /dev/null; then
adduser --disabled-password --gecos "" user
fi
echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
chmod 0440 /etc/sudoers.d/nopasswd
fi