Merge ~ack/ubuntu/+source/maas:check-if-snap-configured into ubuntu/+source/maas:ubuntu/devel

Proposed by Alberto Donato
Status: Needs review
Proposed branch: ~ack/ubuntu/+source/maas:check-if-snap-configured
Merge into: ubuntu/+source/maas:ubuntu/devel
Diff against target: 240 lines (+94/-24)
4 files modified
debian/changelog (+7/-0)
debian/maas.preinst (+47/-20)
debian/maas.templates (+12/-2)
debian/po/templates.pot (+28/-2)
Reviewer Review Type Date Requested Status
Julian Andres Klode (community) Approve
Björn Tillenius (community) Approve
Review via email: mp+380426@code.launchpad.net

Commit message

Check (and prompt the user) if the snap is already set up

Also, fix snapd version comparison

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good to me, with a small comment inline.

review: Approve
095d0fe... by Alberto Donato

fix template description

ae33ac4... by Alberto Donato

update po files

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

Uploaded

Unmerged commits

ae33ac4... by Alberto Donato

update po files

095d0fe... by Alberto Donato

fix template description

fe0e857... by Alberto Donato

changelog

bb7a615... by Alberto Donato

fix snapd version comparison

61e673a... by Alberto Donato

Check (and prompt the user) if the snap is already set up

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

14daa6d... by Alberto Donato

fix typo/description

fc1d3e0... by Alberto Donato

fix package long description to match as transitional package

f66b3f9... by Alberto Donato

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

Imported using git-ubuntu import.

Changelog parent: e5187afe6941bd6f22749fbfb6d237c8f3519923

New changelog entries:
  * Set default snap version to 2.7 if default track support is not available in snapd

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 1d34be5..ca80f42 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+maas (1:0.6) focal; urgency=medium
7+
8+ * Fix snapd version check for default track support
9+ * Check if the snap is already installed, prompt the user in case it is
10+
11+ -- Alberto Donato <alberto.donato@canonical.com> Mon, 09 Mar 2020 15:11:54 +0100
12+
13 maas (1:0.5) focal; urgency=medium
14
15 * Fix all lintian warning/errors
16diff --git a/debian/maas.preinst b/debian/maas.preinst
17index 7f40bdc..2279230 100755
18--- a/debian/maas.preinst
19+++ b/debian/maas.preinst
20@@ -7,21 +7,47 @@ DEFAULT_SNAP_TRACK="stable"
21 SNAP_COMMON="/var/snap/maas/common"
22
23
24-is_installed() {
25- dpkg-query -W -f'${Status}\n' "$1" 2>/dev/null | grep -q ^install
26+error_exit() {
27+ echo "$@" >&2
28+ exit 1
29+}
30+
31+is_deb_installed() {
32+ dpkg-query -W -f'${Status}\n' "$1" 2>/dev/null | grep -q ^install
33+}
34+
35+is_snap_installed() {
36+ snap list "$1" >/dev/null 2>&1
37 }
38
39 get_snap_mode() {
40- cat "$SNAP_COMMON/snap_mode" 2>/dev/null || true
41+ local snap_mode
42+ snap_mode=$(cat "$SNAP_COMMON/snap_mode" 2>/dev/null || true)
43+ if [ -z "$snap_mode" ]; then
44+ snap_mode="none"
45+ fi
46+ echo "$snap_mode"
47 }
48
49 snapd_has_default_track_support() {
50 local version
51 version=$(snap version | awk '$1 == "snapd" { print $2; }')
52- local major="${version%%.*}"
53- local rest="${version#*.}"
54- local minor="${rest%%.*}"
55- [ "$major" -ge 2 ] && [ "$minor" -ge 44 ]
56+ dpkg --compare-versions "$version" ">=" "2.44"
57+}
58+
59+ensure_snap_not_installed() {
60+ if ! is_snap_installed maas; then
61+ return 0
62+ fi
63+
64+ db_input high maas/snap-reinstall || true
65+ db_go || true
66+ db_get maas/snap-reinstall
67+ if [ "$RET" = "false" ]; then
68+ db_fset maas/snap-reinstall seen false
69+ error_exit "The MAAS snap is already installed, aborting at user's request"
70+ fi
71+ snap remove maas
72 }
73
74 check_connectivity() {
75@@ -31,7 +57,7 @@ check_connectivity() {
76
77 db_fset maas/snap-no-connectivity seen false
78 if ! db_input critical maas/snap-no-connectivity; then
79- db_go
80+ db_go || true
81
82 case "$count" in
83 0)
84@@ -50,11 +76,10 @@ check_connectivity() {
85
86 sleep 1m
87 else
88- db_go
89+ db_go || true
90 db_get maas/snap-no-connectivity
91 if [ "$RET" = "Abort" ]; then
92- echo "Aborting at user request..."
93- exit 1
94+ error_exit "Aborting at user's request."
95 fi
96 if [ "$count" -eq 0 ]; then
97 echo "Unable to contact the store"
98@@ -67,7 +92,7 @@ check_connectivity() {
99
100 install_snap() {
101 db_input medium maas/snap-track || true
102- db_go
103+ db_go || true
104 db_get maas/snap-track
105 local track="$RET"
106 if [ -z "$track" ]; then
107@@ -81,24 +106,24 @@ install_snap() {
108 fi
109
110 snap install maas --channel="${track}/ubuntu-${release}"
111- snap stop maas # in case the snap was already installed
112 }
113
114 migrate_to_snap() {
115+ snap stop maas
116 /snap/maas/current/bin/maas-deb-migrate
117 snap start maas
118 }
119
120 preserve_db() {
121- is_installed maas-region-controller || return 0
122+ is_deb_installed maas-region-controller || return 0
123 apt-mark manual postgresql
124 }
125
126 notify_if_not_setup() {
127 # only show the notice if MAAS is not setup
128- [ -z "$(get_snap_mode)" ] || return 0
129+ [ "$(get_snap_mode)" != "none" ] || return 0
130 db_input high maas/snap-needs-setup || true
131- db_go
132+ db_go || true
133 }
134
135 ### main
136@@ -111,17 +136,19 @@ case "$1" in
137 # only perform tasks in these cases
138 ;;
139 *)
140- echo "preinst called with unknown argument: $1" >&2
141- exit 1
142+ error_exit "preinst called with unknown argument: $1"
143 ;;
144 esac
145
146 . /usr/share/debconf/confmodule
147
148+ensure_snap_not_installed
149 check_connectivity
150 install_snap
151-migrate_to_snap
152-preserve_db
153+if is_deb_installed maas-region-api || is_deb_installed maas-rack-controller; then
154+ migrate_to_snap
155+ preserve_db
156+fi
157 notify_if_not_setup
158
159 #DEBHELPER#
160diff --git a/debian/maas.templates b/debian/maas.templates
161index 9598b76..f81df06 100644
162--- a/debian/maas.templates
163+++ b/debian/maas.templates
164@@ -16,8 +16,8 @@ _Description: Unable to reach the snap store
165 .
166 You can manually check for connectivity by running "snap info maas"
167 .
168- Aborting will cause the upgrade to fail and will require it to be re-attempted
169- once snapd is functional on the system.
170+ Aborting will cause the installation to fail and will require it to be
171+ re-attempted once snapd is functional on the system.
172
173 Template: maas/snap-needs-setup
174 Type: note
175@@ -30,3 +30,13 @@ _Description: MAAS installed but not set up
176 .
177 This will interactively ask a set of questions. Non-interactive set up is
178 also available; run with --help to get a full list of available options.
179+
180+Template: maas/snap-reinstall
181+Type: boolean
182+_Description: MAAS snap already installed, reinstall it?
183+ The MAAS snap is already installed.
184+ .
185+ To migrate the current deb-based installation, the snap needs to be
186+ reinstalled. All data from the current snap installation will be removed.
187+ .
188+ Selecting "no" will abort the installation.
189diff --git a/debian/po/templates.pot b/debian/po/templates.pot
190index d5b3b09..f8e7823 100644
191--- a/debian/po/templates.pot
192+++ b/debian/po/templates.pot
193@@ -8,7 +8,7 @@ msgid ""
194 msgstr ""
195 "Project-Id-Version: maas\n"
196 "Report-Msgid-Bugs-To: maas@packages.debian.org\n"
197-"POT-Creation-Date: 2020-02-27 13:34+0000\n"
198+"POT-Creation-Date: 2020-03-10 12:43+0100\n"
199 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
200 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
201 "Language-Team: LANGUAGE <LL@li.org>\n"
202@@ -62,7 +62,7 @@ msgstr ""
203 #. Description
204 #: ../maas.templates:2001
205 msgid ""
206-"Aborting will cause the upgrade to fail and will require it to be re-"
207+"Aborting will cause the installation to fail and will require it to be re-"
208 "attempted once snapd is functional on the system."
209 msgstr ""
210
211@@ -97,3 +97,29 @@ msgid ""
212 "This will interactively ask a set of questions. Non-interactive set up is "
213 "also available; run with --help to get a full list of available options."
214 msgstr ""
215+
216+#. Type: boolean
217+#. Description
218+#: ../maas.templates:4001
219+msgid "MAAS snap already installed, reinstall it?"
220+msgstr ""
221+
222+#. Type: boolean
223+#. Description
224+#: ../maas.templates:4001
225+msgid "The MAAS snap is already installed."
226+msgstr ""
227+
228+#. Type: boolean
229+#. Description
230+#: ../maas.templates:4001
231+msgid ""
232+"To migrate the current deb-based installation, the snap needs to be "
233+"reinstalled. All data from the current snap installation will be removed."
234+msgstr ""
235+
236+#. Type: boolean
237+#. Description
238+#: ../maas.templates:4001
239+msgid "Selecting \"no\" will abort the installation."
240+msgstr ""

Subscribers

People subscribed via source and target branches