snap: don't run snapcraft under sudo

Snapcraft 4.0 complains about running LXD builds under sudo.  So instead
add the CI user to the "lxd" group and use sg to switch to that
membership.

Resolves: #12712
This commit is contained in:
Carlos Hernandez 2020-08-30 17:13:41 +00:00
parent 9c65017c3b
commit 65b2fce787
No known key found for this signature in database
GPG Key ID: DF2BC08DD960FF47
3 changed files with 4 additions and 1 deletions

View File

@ -193,6 +193,7 @@ jobs:
- LANG: C.UTF-8
- SNAPCRAFT_ENABLE_SILENT_REPORT: y
- SNAPCRAFT_ENABLE_DEVELOPER_DEBUG: y
- SNAPCRAFT_BUILD_ENVIRONMENT: lxd
addons:
snaps:
- name: snapcraft
@ -221,6 +222,7 @@ jobs:
- LANG: C.UTF-8
- SNAPCRAFT_ENABLE_SILENT_REPORT: y
- SNAPCRAFT_ENABLE_DEVELOPER_DEBUG: y
- SNAPCRAFT_BUILD_ENVIRONMENT: lxd
fast_finish: true
before_install: ci/before_install.sh

View File

@ -4,6 +4,7 @@ set -e
set -o pipefail
sudo apt update
sudo usermod -aG lxd $USER
sudo /snap/bin/lxd.migrate -yes
sudo /snap/bin/lxd waitready
sudo /snap/bin/lxd init --auto

View File

@ -4,5 +4,5 @@ set -e
set -o pipefail
mkdir -p "$TRAVIS_BUILD_DIR/snaps-cache"
sudo snapcraft --use-lxd
sg lxd -c snapcraft