Merge ~sdeziel/ubuntu/+source/lxd-installer:25.04 into ubuntu/+source/lxd-installer:ubuntu/devel

Proposed by Simon Déziel
Status: Merged
Merged at revision: 9ffa5229b413fb7e15ec6bf9f6ad7b8457654be6
Proposed branch: ~sdeziel/ubuntu/+source/lxd-installer:25.04
Merge into: ubuntu/+source/lxd-installer:ubuntu/devel
Diff against target: 134 lines (+74/-11)
5 files modified
debian/changelog (+10/-0)
debian/tests/control (+1/-1)
debian/tests/no-install-on-source (+47/-0)
lxd-installer-service (+15/-9)
scripts/lxc (+1/-1)
Reviewer Review Type Date Requested Status
Julian Andres Klode (community) Approve
Pedro Antônio Barboza Ribeiro (community) Approve
Thomas Parrott (community) Approve
Lucas Kanashiro (community) Approve
Review via email: mp+475230@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomas Parrott (tomparrott) :
review: Approve
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote (last edit ):

It almost looks good to me, seem my inline comment.

review: Needs Fixing
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Thanks for the fix. +1

review: Approve
Revision history for this message
Simon Déziel (sdeziel) wrote :
Download full text (4.4 KiB)

While this couldn't be tested on 25.04 as there are not images available ATM, the ability to source the lxd-installer-service script without install the snap was tested on 24.10. Here are the results:

ubuntu@autopkg:~$ autopkgtest -U -s lxd-installer_9_source.changes -- lxd ubuntu-minimal-daily:24.10
autopkgtest [14:50:53]: starting date and time: 2024-11-04 14:50:53+0000
autopkgtest [14:50:53]: version 5.34ubuntu2
autopkgtest [14:50:53]: host autopkg; command line: /usr/bin/autopkgtest -U -s lxd-installer_9_source.changes -- lxd ubuntu-minimal-daily:24.10
autopkgtest [14:51:01]: testbed dpkg architecture: amd64
autopkgtest [14:51:02]: testbed apt version: 2.9.8
autopkgtest [14:51:02]: @@@@@@@@@@@@@@@@@@@@ test bed setup

...

autopkgtest [14:53:34]: test no-install-on-source: [-----------------------
Executing test on Ubuntu version 24.10
Check which lxd-installer version we have installed
+ . /etc/os-release
+ PRETTY_NAME=Ubuntu 24.10
+ NAME=Ubuntu
+ VERSION_ID=24.10
+ VERSION=24.10 (Oracular Oriole)
+ VERSION_CODENAME=oracular
+ ID=ubuntu
+ ID_LIKE=debian
+ HOME_URL=https://www.ubuntu.com/
+ SUPPORT_URL=https://help.ubuntu.com/
+ BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
+ PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
+ UBUNTU_CODENAME=oracular
+ LOGO=ubuntu-logo
+ echo Executing test on Ubuntu version 24.10
+ echo Check which lxd-installer version we have installed
+ dpkg -l
+ grep -wF lxd-installer
ii lxd-installer 9 all Wrapper to install lxd snap on demand
+ echo Make sure LXD's snap is not seeded in the current image
+ snap list lxd
Make sure LXD's snap is not seeded in the current image
Name Version Rev Tracking Publisher Notes
lxd 5.21.2-2f4ba6b 30131 5.21/stable/… canonical** -
+ echo Removing seeded LXD snap
+ snap remove --purge lxd
Removing seeded LXD snap
2024-11-04T14:53:36Z INFO Waiting for "snap.lxd.daemon.service" to stop.
lxd removed
+ echo Starting lxd-installer.socket now that LXD snap was removed
+ systemctl start lxd-installer.socket
Starting lxd-installer.socket now that LXD snap was removed
+ echo Report list of installed snaps:
+ snap list
Report list of installed snaps:
Name Version Rev Tracking Publisher Notes
core22 20241001 1663 latest/stable canonical** base
snapd 2.63 21759 latest/stable canonical** snapd
+ echo Source lxd-installer-service and check that no snap is installed
+ . /usr/share/lxd-installer/lxd-installer-service
Source lxd-installer-service and check that no snap is installed
+ set -eux
+ [ no-install-on-source = lxd-installer-service ]
+ echo Test lxd_channel function from imported script
Test lxd_channel function from imported script
+ lxd_channel
+ track=
+ [ -r /etc/os-release ]
+ . /etc/os-release
+ PRETTY_NAME=Ubuntu 24.10
+ NAME=Ubuntu
+ VERSION_ID=24.10
+ VERSION=24.10 (Oracular Oriole)
+ VERSION_CODENAME=oracular
+ ID=ubuntu
+ ID_LIKE=debian
+ HOME_URL=https://www.ubuntu.com/
+ SUPPORT_URL=https://help.ubuntu.com/
+ BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
+ PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and...

Read more...

Revision history for this message
Simon Déziel (sdeziel) wrote :

@ubuntu-sponsors, please consider keeping the git history if/when merging that change as this package's authoritative git repo is in Launchpad making it all the more important to keep the individual commits.

Thanks!

Revision history for this message
Thomas Parrott (tomparrott) :
review: Approve
Revision history for this message
Pedro Antônio Barboza Ribeiro (pedro-rib) :
review: Approve
Revision history for this message
Julian Andres Klode (juliank) wrote :

Uploaded with git-ubuntu handling, so this should be closed automatically and history preserved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index bdaddc8..727a444 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+lxd-installer (9) plucky; urgency=medium
7+
8+ * lxd-installer-service: use 5.21/stable for Ubuntu 25.04 too
9+ * lxd-installer-service: allow sourcing script without installing snap
10+ (LP: #2086304)
11+ * d/tests/no-install-on-source: new test
12+ * scripts/lxc: don't add extra line feed
13+
14+ -- Simon Deziel <simon.deziel@canonical.com> Mon, 04 Nov 2024 09:29:34 -0500
15+
16 lxd-installer (8) oracular; urgency=medium
17
18 * scripts/lxc: ask before proceeding if interactive (LP: #2073941, LP: #2080277)
19diff --git a/debian/tests/control b/debian/tests/control
20index 9969930..4ca28c0 100644
21--- a/debian/tests/control
22+++ b/debian/tests/control
23@@ -1,3 +1,3 @@
24-Tests: install-on-demand not-member-of-lxd-group
25+Tests: install-on-demand no-install-on-source not-member-of-lxd-group
26 Depends: @
27 Restrictions: allow-stderr isolation-container needs-root
28diff --git a/debian/tests/no-install-on-source b/debian/tests/no-install-on-source
29new file mode 100755
30index 0000000..1db982e
31--- /dev/null
32+++ b/debian/tests/no-install-on-source
33@@ -0,0 +1,47 @@
34+#!/bin/sh
35+
36+set -eux
37+
38+. /etc/os-release
39+echo "Executing test on ${NAME:-Unknown} version ${VERSION_ID:-n/a}"
40+
41+echo "Check which lxd-installer version we have installed"
42+dpkg -l | grep -wF lxd-installer
43+
44+echo "Make sure LXD's snap is not seeded in the current image"
45+if snap list lxd; then
46+ echo "Removing seeded LXD snap"
47+ snap remove --purge lxd
48+ echo "Starting lxd-installer.socket now that LXD snap was removed"
49+ systemctl start lxd-installer.socket
50+fi
51+
52+echo "Report list of installed snaps:"
53+snap list
54+
55+echo "Source lxd-installer-service and check that no snap is installed"
56+. /usr/share/lxd-installer/lxd-installer-service
57+
58+echo "Test lxd_channel function from imported script"
59+CHANNEL="$(lxd_channel)"
60+
61+echo "Check the returned channel is not empty"
62+if [ -z "${CHANNEL}" ]; then
63+ echo "lxd-installer could not obtain the LXD snap channel to use from lxd_channel function" >&2
64+ exit 1
65+fi
66+
67+echo "Check the returned channel is a stable one for Ubuntu ${VERSION_ID}"
68+if ! echo "${CHANNEL}" | grep -xE "[0-9]+\.[0-9]+/stable/ubuntu-${VERSION_ID}"; then
69+ echo "lxd-installer did not obtain a valid LXD snap channel to use from lxd_channel function" >&2
70+ exit 1
71+fi
72+
73+echo "Report list of installed snaps:"
74+snap list
75+
76+echo "Make sure LXD snap was not installed"
77+if snap list lxd; then
78+ echo "lxd-installer sourcing lxd-installer-service should not have installed LXD snap" >&2
79+ exit 1
80+fi
81diff --git a/lxd-installer-service b/lxd-installer-service
82index 45be5a8..083284d 100755
83--- a/lxd-installer-service
84+++ b/lxd-installer-service
85@@ -8,6 +8,8 @@ lxd_channel() {
86 # shellcheck disable=SC1091
87 [ -r /etc/os-release ] && . /etc/os-release
88 case "${VERSION_ID:-""}" in
89+ "25.04")
90+ track="5.21";;
91 "24.10")
92 track="5.21";;
93 "24.04")
94@@ -27,14 +29,18 @@ lxd_channel() {
95 fi
96 }
97
98-# Wait for snapd to be seeded
99-snap wait system seed.loaded || true
100+# Only do the snap installation when invoked with the lxd-installer-service name.
101+# This allows sourcing the script without triggering the snap installation.
102+if [ "${0##*/}" = "lxd-installer-service" ]; then
103+ # Wait for snapd to be seeded
104+ snap wait system seed.loaded || true
105
106-CHANNEL="$(lxd_channel)"
107-if [ -z "${CHANNEL}" ]; then
108- echo "Unable to determine the LXD LTS channel, aborting" >&2
109- exit 1
110-else
111- snap install lxd --channel="${CHANNEL}" 1>&2
112+ CHANNEL="$(lxd_channel)"
113+ if [ -z "${CHANNEL}" ]; then
114+ echo "Unable to determine the LXD LTS channel, aborting" >&2
115+ exit 1
116+ else
117+ snap install lxd --channel="${CHANNEL}" 1>&2
118+ fi
119+ echo 1
120 fi
121-echo 1
122diff --git a/scripts/lxc b/scripts/lxc
123index 2433aa8..38fca47 100644
124--- a/scripts/lxc
125+++ b/scripts/lxc
126@@ -4,7 +4,7 @@ if [ ! -f "${SNAP_BIN}" ]; then
127 # If there is a terminal connected to stdin and stdout, ask for confirmation before
128 # installing the needed snap(s) as it might take a while.
129 if [ -t 0 ] && [ -t 1 ]; then
130- echo "Would you like to install LXD snap now (Y/n)? " >&2
131+ echo -n "Would you like to install LXD snap now (Y/n)? " >&2
132 read -r answer
133 if [ "${answer:-y}" != "y" ] && [ "${answer:-y}" != "Y" ]; then
134 exit 1

Subscribers

People subscribed via source and target branches