fix(chezmoi): Skip system packages tasks without sudo rights

mise bootstrap installs apt packages through sudo: for an account without
sudo (devenv sandbox agent), it failed and stopped chezmoi apply, thus the
image build. The bootstrap and the APT section of update are now skipped
unless the account is root, has passwordless sudo, or belongs to a sudo
group with a terminal to type the password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xavierandClaude Opus 5.5 committed 2026-11-11 21:37:42 +01:00
1 parent ee405c937a
commit e7d9189de4
3 files changed
+58 -23

No files matched your search

+17 -3
View File
@@ -8,6 +8,13 @@
set -euo pipefail
# Droits d'administration : root, sudo sans mot de passe, ou membre d'un
# groupe sudo avec un terminal pour saisir le mot de passe
can_sudo() {
(( EUID == 0 )) || sudo -n true 2>/dev/null \
|| { [ -t 0 ] && id -nG | grep -qwE 'sudo|admin|wheel'; }
}
export PATH="${HOME}/.local/bin:$PATH"
MISE_CONF_D="${HOME}/.config/mise/conf.d"
mkdir -p "$MISE_CONF_D"
@@ -54,9 +61,16 @@ MISE_TOOLBOX_EOF
{{- end }}
if command -v mise &>/dev/null; then
echo
echo "🚀 Mise bootstrap..."
mise bootstrap --yes
# Paquets système (apt) du bootstrap : droits sudo requis
# (sinon, par exemple compte sans sudo d'un bac à sable, on les ignore)
if can_sudo; then
echo
echo "🚀 Mise bootstrap..."
mise bootstrap --yes
else
echo
echo "⚠️ Pas de droits sudo : mise bootstrap ignoré (paquets système non installés)."
fi
echo
echo "⚡ Mise install..."