Merge ~ack/ubuntu/+source/maas:snap-channel-2.7-default into ubuntu/+source/maas:ubuntu/focal-devel

Proposed by Alberto Donato
Status: Needs review
Proposed branch: ~ack/ubuntu/+source/maas:snap-channel-2.7-default
Merge into: ubuntu/+source/maas:ubuntu/focal-devel
Diff against target: 159 lines (+56/-29)
3 files modified
debian/changelog (+13/-0)
debian/maas.preinst (+42/-26)
debian/maas.templates (+1/-3)
Reviewer Review Type Date Requested Status
Julian Andres Klode (community) Approve
Review via email: mp+384013@code.launchpad.net

Commit message

Install snap from the 2.7/stable/ubuntu-$release channel by default.

- If currently installed maas is newer than 2.7, install from matching track.
- Rename maas/snap-track debconf var to maas/snap-channel (as the /ubuntu-$release is no longer appended)
- Fix wrong display of "MAAS not currently set up" message
- No-op when upgrading from a previous version of the transitional deb.

To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

I'd avoid renaming the template, as that just causes churn in the database I suppose.

The version logic to not do the migration also triggers if you removed the maas snap (but not purged) and then reinstalled - is that correct?

Revision history for this message
Alberto Donato (ack) wrote :

> I'd avoid renaming the template, as that just causes churn in the database I
> suppose.

Is that a big deal?
I renamed it as the new name is more correct, and the old option has unlikely been ever used since we were always appending the "/ubuntu-$release" branch, which only existed for 20.04.
I can revert to the old name if it's an issue.

>
> The version logic to not do the migration also triggers if you removed the
> maas snap (but not purged) and then reinstalled - is that correct?

If you previously had installed a 1:* release, the migration would have been performed. Removing and reinstalling the deb shouldn't do anything in that case too.

e344f4f... by Alberto Donato

fix debian/maas-track template

Revision history for this message
Julian Andres Klode (juliank) wrote :

Oh, I thought you did that, but you also still need an SRU bug https://wiki.ubuntu.com/StableReleaseUpdates#SRU_Bug_Template and set the target release to focal in changelog.

review: Needs Fixing
9d21b6a... by Alberto Donato

fix changelog release

84aff9b... by Alberto Donato

fix changelog

Revision history for this message
Julian Andres Klode (juliank) :
review: Approve

Unmerged commits

84aff9b... by Alberto Donato

fix changelog

9d21b6a... by Alberto Donato

fix changelog release

e344f4f... by Alberto Donato

fix debian/maas-track template

bceb82a... by Alberto Donato

no-op if upgrading from a transitional deb

f214ec7... by Alberto Donato

fix not setup notice

54d09cc... by Alberto Donato

always point to the release branch if a channel is not specified

4580b3e... by Alberto Donato

point at 2.7 branch by default, unless installed maas is newer

8d80ee7... by Alberto Donato

Import patches-unapplied version 1:0.6 to ubuntu/focal-proposed

Imported using git-ubuntu import.

Changelog parent: da0746bb20c11f985e4a2a2d0a96f87007976316

New changelog entries:
  * Fix snapd version check for default track support
  * Check if the snap is already installed, prompt the user in case it is

da0746b... by Alberto Donato

Import patches-unapplied version 1:0.5 to ubuntu/focal-proposed

Imported using git-ubuntu import.

Changelog parent: 4b7509341f2cf5e617b5ef5ac1d09b52dd164f4e

New changelog entries:
  * Fix all lintian warning/errors

4b75093... by Alberto Donato

Import patches-unapplied version 1:0.4 to ubuntu/focal-proposed

Imported using git-ubuntu import.

Upload parent: 14daa6d5fc4e98104718d3655ea489cf643f48f5

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 ca80f42..4809cde 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,16 @@
6+maas (1:0.7) focal; urgency=medium
7+
8+ * When a track is not specified, default to 2.7/stable. If MAAS deb
9+ version is higher than 2.7, pick the same track. LP: #1878769
10+ * Fix issue where "MAAS not currently set up" notice shows even when the
11+ snap is configured.
12+ * No-op when upgrading from a transitional deb, as migration already
13+ happened.
14+ * Rename "get_snap_mode" to "snap_mode".
15+ * Rename DEFAULT_SNAP_* variables to align with snap terminology.
16+
17+ -- Alberto Donato <alberto.donato@canonical.com> Wed, 06 May 2020 13:48:50 +0200
18+
19 maas (1:0.6) focal; urgency=medium
20
21 * Fix snapd version check for default track support
22diff --git a/debian/maas.preinst b/debian/maas.preinst
23index 2279230..a1ae4ea 100755
24--- a/debian/maas.preinst
25+++ b/debian/maas.preinst
26@@ -1,8 +1,7 @@
27 #!/bin/bash -e
28
29-DEFAULT_UBUNTU_RELEASE="20.04"
30-DEFAULT_SNAP_VERSION="2.7"
31-DEFAULT_SNAP_TRACK="stable"
32+DEFAULT_SNAP_TRACK="2.7"
33+DEFAULT_SNAP_RISK="stable"
34
35 SNAP_COMMON="/var/snap/maas/common"
36
37@@ -12,6 +11,20 @@ error_exit() {
38 exit 1
39 }
40
41+os_release() {
42+ # shellcheck disable=SC1091
43+ (. /etc/os-release && echo "$VERSION_ID")
44+}
45+
46+maas_version() {
47+ # only return major.minor version
48+ dpkg-query -W -f'${Version}\n' maas-common 2>/dev/null | cut -d. -f1,2
49+}
50+
51+is_version() {
52+ dpkg --compare-versions "$@"
53+}
54+
55 is_deb_installed() {
56 dpkg-query -W -f'${Status}\n' "$1" 2>/dev/null | grep -q ^install
57 }
58@@ -20,19 +33,13 @@ is_snap_installed() {
59 snap list "$1" >/dev/null 2>&1
60 }
61
62-get_snap_mode() {
63- local snap_mode
64- snap_mode=$(cat "$SNAP_COMMON/snap_mode" 2>/dev/null || true)
65- if [ -z "$snap_mode" ]; then
66- snap_mode="none"
67+snap_mode() {
68+ local mode
69+ mode=$(cat "$SNAP_COMMON/snap_mode" 2>/dev/null || true)
70+ if [ -z "$mode" ]; then
71+ mode="none"
72 fi
73- echo "$snap_mode"
74-}
75-
76-snapd_has_default_track_support() {
77- local version
78- version=$(snap version | awk '$1 == "snapd" { print $2; }')
79- dpkg --compare-versions "$version" ">=" "2.44"
80+ echo "$mode"
81 }
82
83 ensure_snap_not_installed() {
84@@ -94,18 +101,17 @@ install_snap() {
85 db_input medium maas/snap-track || true
86 db_go || true
87 db_get maas/snap-track
88- local track="$RET"
89- if [ -z "$track" ]; then
90- track="$DEFAULT_SNAP_TRACK"
91- snapd_has_default_track_support || track="$DEFAULT_SNAP_VERSION/$track"
92- fi
93-
94- local release="$DEFAULT_UBUNTU_RELEASE"
95- if [ -e "/etc/os-release" ]; then
96- release=$(. /etc/os-release && echo "$VERSION_ID")
97+ local channel="$RET"
98+ if [ -z "$channel" ]; then
99+ local track
100+ track="$(maas_version)"
101+ if [ -z "$track" ] || is_version "$track" "<<" "$DEFAULT_SNAP_TRACK"; then
102+ track="$DEFAULT_SNAP_TRACK"
103+ fi
104+ channel="$track/$DEFAULT_SNAP_RISK/ubuntu-$(os_release)"
105 fi
106
107- snap install maas --channel="${track}/ubuntu-${release}"
108+ snap install maas --channel="$channel"
109 }
110
111 migrate_to_snap() {
112@@ -121,7 +127,9 @@ preserve_db() {
113
114 notify_if_not_setup() {
115 # only show the notice if MAAS is not setup
116- [ "$(get_snap_mode)" != "none" ] || return 0
117+ if [ "$(snap_mode)" != "none" ]; then
118+ return 0
119+ fi
120 db_input high maas/snap-needs-setup || true
121 db_go || true
122 }
123@@ -134,12 +142,20 @@ case "$1" in
124 ;;
125 install|upgrade)
126 # only perform tasks in these cases
127+ old_version="$2"
128 ;;
129 *)
130 error_exit "preinst called with unknown argument: $1"
131 ;;
132 esac
133
134+if [[ "$old_version" = 1:* ]]; then
135+ # upgrading from a transitional snap, nothing to do as migration already
136+ # happened
137+ exit 0
138+fi
139+
140+# shellcheck disable=SC1091
141 . /usr/share/debconf/confmodule
142
143 ensure_snap_not_installed
144diff --git a/debian/maas.templates b/debian/maas.templates
145index f81df06..b260d66 100644
146--- a/debian/maas.templates
147+++ b/debian/maas.templates
148@@ -1,10 +1,8 @@
149 Template: maas/snap-track
150 Type: string
151-_Description: Track for the MAAS snap:
152+_Description: Channel for the MAAS snap:
153 This can be specified just as a track name (e.g. "2.7", "latest", ...) or include
154 a risk as well (e.g. "latest/candidate").
155- .
156- If not specified "stable" will be used.
157
158 Template: maas/snap-no-connectivity
159 Type: select

Subscribers

People subscribed via source and target branches