~renatofilho/unity8-desktop-session/add-ubuntu-filemanger-app

« back to all changes in this revision

Viewing changes to scripts/unity8-snap-install

  • Committer: Bileto Bot
  • Author(s): Michael Terry
  • Date: 2016-11-23 15:46:51 UTC
  • mfrom: (112.1.7 idempotent)
  • Revision ID: ci-train-bot@canonical.com-20161123154651-equ8yefv6fkvbwll
Let unity8-snap-install handle already-installed versions of snaps.  And make it install several core app snaps.

Approved by: Stephen M. Webb

Show diffs side-by-side

added added

removed removed

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