Merge lp:~mterry/unity8-desktop-session/snap-install-idempotent into lp:unity8-desktop-session

Proposed by Michael Terry
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 119
Merged at revision: 113
Proposed branch: lp:~mterry/unity8-desktop-session/snap-install-idempotent
Merge into: lp:unity8-desktop-session
Diff against target: 61 lines (+50/-4)
1 file modified
scripts/unity8-snap-install (+50/-4)
To merge this branch: bzr merge lp:~mterry/unity8-desktop-session/snap-install-idempotent
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+311520@code.launchpad.net

Commit message

Let unity8-snap-install handle already-installed versions of snaps. And make it install several core app snaps.

Description of the change

Let unity8-snap-install handle already-installed versions of snaps. And make it install several core app snaps.

To post a comment you must log in.
114. By Michael Terry

Merely return instead of exit if the user doesn't want to replace a snap

115. By Michael Terry

use sh not bash

116. By Michael Terry

exit cleanly

117. By Michael Terry

Add filemanager and terminal

118. By Michael Terry

Add more apps

119. By Michael Terry

Drop webbrowser-app (we'll use built-in firefox for now; fix comments

Revision history for this message
Stephen M. Webb (bregma) wrote :

I'm OK with this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/unity8-snap-install'
2--- scripts/unity8-snap-install 2016-10-06 15:31:51 +0000
3+++ scripts/unity8-snap-install 2016-11-22 20:57:05 +0000
4@@ -1,7 +1,53 @@
5 #!/bin/sh
6+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
7
8-if [ -f ~/.snap/auth.json ] ; then
9- snap install --devmode --channel=edge unity8-session
10-else
11- sudo snap install --devmode --channel=edge unity8-session
12+sudo=
13+if ! [ -f ~/.snap/auth.json ]; then
14+ sudo=sudo
15 fi
16+
17+echo_cmd() {
18+ tput bold
19+ echo "$@"
20+ tput sgr0
21+ $@
22+}
23+
24+install_snap() {
25+ rev=$(snap list $1 2>/dev/null | grep "^$1 " | tr -s ' ' | cut -d' ' -f3)
26+
27+ # No version installed yet
28+ if [ -z "$rev" ]; then
29+ echo_cmd $sudo snap install $@
30+
31+ # Local version installed
32+ elif expr + "$rev" : 'x.*' >/dev/null; then
33+ while true; do
34+ read -p "Remove local snap of $1 in favor of store version? [Yn] " yn
35+ case ${yn:-y} in
36+ [Yy]* ) echo_cmd $sudo snap remove $1
37+ echo_cmd $sudo snap install $@
38+ break;;
39+ [Nn]* ) return;;
40+ * ) echo "Please answer yes or no.";;
41+ esac
42+ done
43+
44+ # Store version installed
45+ else
46+ # This refresh will usually fail due to no new version, but that's fine.
47+ echo_cmd $sudo snap refresh $@
48+ fi
49+}
50+
51+install_snap unity8-session --edge --devmode
52+install_snap address-book-app --edge --devmode
53+install_snap camera-app --edge --devmode
54+install_snap gallery-app --edge --devmode
55+install_snap ubuntu-calculator-app --edge
56+install_snap ubuntu-calendar-app --edge --devmode
57+install_snap ubuntu-clock-app --edge # has stable channel version
58+install_snap ubuntu-filemanager-app --edge --devmode
59+install_snap ubuntu-terminal-app --edge --devmode
60+
61+exit 0

Subscribers

People subscribed via source and target branches