From e31834a6cd07b5113a501a74499ee7709f87b6ad Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 9 Jun 2020 14:46:11 -0700 Subject: [PATCH] Stop running snapcraft with sudo (#8063) * Do not use sudo when building the snap. * add user to lxd * Run with lxd group. --- snap/local/build_and_install.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/snap/local/build_and_install.sh b/snap/local/build_and_install.sh index 4c9754d3e..f103477f1 100755 --- a/snap/local/build_and_install.sh +++ b/snap/local/build_and_install.sh @@ -6,9 +6,15 @@ if [[ -z "$TRAVIS" ]]; then exit 1 fi +# Add the current user to the lxd group so they can run `snapcraft --use-lxd` +# without sudo since running the command without sudo is required by newer +# versions of snapcraft. +sudo usermod -aG lxd "$USER" sudo /snap/bin/lxd.migrate -yes sudo /snap/bin/lxd waitready sudo /snap/bin/lxd init --auto tools/strip_hashes.py letsencrypt-auto-source/pieces/dependency-requirements.txt > constraints.txt -sudo snapcraft --use-lxd +# Run snapcraft with the lxd group since it has not been added to the current +# shell. +sg lxd -c 'snapcraft --use-lxd' sudo snap install --dangerous --classic *.snap