~chromium-team/chromium-browser/focal-stable

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
set -e

skip_unusable_snapd() {
    if [ -e "/run/snapd.socket" ]; then
        # Snapd is present, run the upgrade
        return 1
    fi

    return 0
}

case "$1" in
    install|upgrade)
        . /usr/share/debconf/confmodule

        echo "=> Installing the chromium snap"

        # Warn about downtime
        if [ -e "/usr/lib/chromium-browser/chromium-browser" ]; then
            db_input high chromium-browser/snap-upgrade-warning || true
            db_go
        fi

        # Check store connectivity
        echo "==> Checking connectivity with the snap store"
        COUNT=0
        SKIP=false
        while :; do
            if skip_unusable_snapd; then
                echo "===> System doesn't have a working snapd, skipping"
                SKIP=true
                break
            fi

            snap info chromium >/dev/null 2>&1 && break

            db_fset chromium-browser/snap-no-connectivity seen false
            if ! db_input critical chromium-browser/snap-no-connectivity; then
                db_go

                if [ "${COUNT}" = "0" ]; then
                    echo "===> Unable to contact the store, trying every minute for the next 30 minutes"
                elif [ "${COUNT}" = "10" ]; then
                    echo "===> Still unable to contact the store, trying for another 20 minutes"
                elif [ "${COUNT}" = "20" ]; then
                    echo "===> Still unable to contact the store, trying for another 10 minutes"
                elif [ "${COUNT}" = "30" ]; then
                    echo "===> Still unable to contact the store, aborting"
                    exit 1
                fi

                sleep 1m
            else
                db_go
                db_get chromium-browser/snap-no-connectivity
                if [ "${RET}" = "Abort" ]; then
                    echo "===> Aborting at user request"
                    exit 1
                elif [ "${RET}" = "Skip" ]; then
                    echo "===> Skipping at user request"
                    SKIP=true
                    break
                fi

                if [ "${COUNT}" = "0" ]; then
                    echo "===> Unable to contact the store"
                fi
            fi

            COUNT=$((COUNT+1))
        done

        if ! ${SKIP}; then
            # Install the snap
            echo "==> Installing the chromium snap"
            snap install chromium
            echo "=> Snap installation complete"
        fi

        # Connect the password-manager-service interface for package upgrades only
        # See https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1836616
        if [ "$1" = "upgrade" ]; then
            echo "=> Connecting the password-manager-service interface (LP: #1836616)"
            # This step has been reported to fail under certain circumstances,
            # so handle the failure gracefully to proceed with the upgrade
            # See https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1838821
            snap connect chromium:password-manager-service || true
        fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0