From 65b2fce78765649c64e7b7e0efbc99214fae0805 Mon Sep 17 00:00:00 2001 From: Carlos Hernandez Date: Sun, 30 Aug 2020 17:13:41 +0000 Subject: [PATCH] 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 --- .travis.yml | 2 ++ ci/snap/install.sh | 1 + ci/snap/script.sh | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b920f70f45..34ff492bb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/ci/snap/install.sh b/ci/snap/install.sh index 23e0bc5eb8..0ceb6f0422 100755 --- a/ci/snap/install.sh +++ b/ci/snap/install.sh @@ -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 diff --git a/ci/snap/script.sh b/ci/snap/script.sh index 647cda4874..f0d45fea00 100755 --- a/ci/snap/script.sh +++ b/ci/snap/script.sh @@ -4,5 +4,5 @@ set -e set -o pipefail mkdir -p "$TRAVIS_BUILD_DIR/snaps-cache" -sudo snapcraft --use-lxd +sg lxd -c snapcraft