Commit 2f18960e authored by Olivier Tilloy's avatar Olivier Tilloy Committed by Commit Bot

Snap packaging updates, to match the latest changes in the chromium snap:

 - Use $SNAP_USER_COMMON to store profile directories,
   to avoid data loss when the snap is refreshed while running.
 - Add the bluez plug to enable Web Bluetooth.
 - Use 'snapctl is-connected password-manager-service' instead of D-Bus calls.

Change-Id: Iee24e689a9bbd678875d206fe00c7cbb28af38d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398521Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Olivier Tilloy <olivier.tilloy@canonical.com>
Cr-Commit-Position: refs/heads/master@{#810225}
parent 6a76f7b5
...@@ -5,12 +5,22 @@ ...@@ -5,12 +5,22 @@
REALHOME=$(getent passwd $(id -u) | cut -d ':' -f 6) REALHOME=$(getent passwd $(id -u) | cut -d ':' -f 6)
# Move an existing profile directory over to $SNAP_USER_COMMON, which is shared
# across revisions of the snap. This addresses profile corruption when the snap
# is refreshed while running, until a proper solution is implemented in snapd.
# Ref: https://launchpad.net/bugs/1616650
if [ ! -d "$SNAP_USER_COMMON/@@SNAPNAME@@" ]; then
if [ -d "$SNAP_USER_DATA/.config/@@SNAPNAME@@" ]; then
mv "$SNAP_USER_DATA/.config/@@SNAPNAME@@" "$SNAP_USER_COMMON/"
fi
fi
# When running the snap for the first time, try and locate an existing # When running the snap for the first time, try and locate an existing
# @@SNAPNAME@@ config in $HOME/.config/@@SNAPNAME@@, and import it if it was # @@SNAPNAME@@ config in $HOME/.config/@@SNAPNAME@@, and import it if it was
# created by an older version of @@SNAPNAME@@ (the profile data format is not # created by an older version of @@SNAPNAME@@ (the profile data format is not
# guaranteed to be forward-compatible). This requires the personal-files plug # guaranteed to be forward-compatible). This requires the personal-files plug
# to be connected. # to be connected.
if [ ! -d "$HOME/.config/@@SNAPNAME@@" ]; then if [ ! -d "$SNAP_USER_COMMON/@@SNAPNAME@@" ]; then
CHROME_CONFIG="$REALHOME/.config/@@SNAPNAME@@" CHROME_CONFIG="$REALHOME/.config/@@SNAPNAME@@"
if [ -d "$CHROME_CONFIG" ]; then if [ -d "$CHROME_CONFIG" ]; then
PREF_FILE="$CHROME_CONFIG/Default/Preferences" PREF_FILE="$CHROME_CONFIG/Default/Preferences"
...@@ -21,22 +31,23 @@ if [ ! -d "$HOME/.config/@@SNAPNAME@@" ]; then ...@@ -21,22 +31,23 @@ if [ ! -d "$HOME/.config/@@SNAPNAME@@" ]; then
OLD=$(printf "$VERSION\n$SNAP_VERSION" | sort -V | head -1) OLD=$(printf "$VERSION\n$SNAP_VERSION" | sort -V | head -1)
if [ "$OLD" = "$VERSION" ]; then if [ "$OLD" = "$VERSION" ]; then
SIZE=$(du -sb $CHROME_CONFIG | cut -f 1) SIZE=$(du -sb $CHROME_CONFIG | cut -f 1)
AVAILABLE_BLOCKS=$(stat -f -c %a $HOME) AVAILABLE_BLOCKS=$(stat -f -c %a $SNAP_USER_COMMON)
BLOCK_SIZE=$(stat -f -c %s $HOME) BLOCK_SIZE=$(stat -f -c %s $SNAP_USER_COMMON)
AVAILABLE_SIZE=$(($AVAILABLE_BLOCKS*$BLOCK_SIZE)) AVAILABLE_SIZE=$(($AVAILABLE_BLOCKS*$BLOCK_SIZE))
if [ $AVAILABLE_SIZE -gt $SIZE ]; then if [ $AVAILABLE_SIZE -gt $SIZE ]; then
printf "Importing existing @@SNAPNAME@@ profile from " printf "Importing existing @@SNAPNAME@@ profile from "
printf "$CHROME_CONFIG (version $VERSION)\n" printf "$CHROME_CONFIG (version $VERSION)\n"
TS1=$(date +%s.%3N) TS1=$(date +%s.%3N)
cp -R "$CHROME_CONFIG" "$HOME/.config/" cp -R "$CHROME_CONFIG" "$SNAP_USER_COMMON/"
TS2=$(date +%s.%3N) TS2=$(date +%s.%3N)
T=$(printf "$TS1 $TS2" | awk '{printf "%.3f",$2-$1}') T=$(printf "$TS1 $TS2" | awk '{printf "%.3f",$2-$1}')
printf "Import done in $T s\n" printf "Import done in $T s\n"
else else
printf "Not importing existing @@SNAPNAME@@ profile from " printf "Not importing existing @@SNAPNAME@@ profile from "
printf "$CHROME_CONFIG (version $VERSION) because there is not " printf "$CHROME_CONFIG (version $VERSION) because there is not "
printf "enough available space in $HOME (required: $SIZE bytes / " printf "enough available space in $SNAP_USER_COMMON "
printf "available: $AVAILABLE_SIZE bytes)\n" printf "(required: $SIZE bytes / available: $AVAILABLE_SIZE bytes)"
printf "\n"
fi fi
fi fi
fi fi
...@@ -50,22 +61,10 @@ fi ...@@ -50,22 +61,10 @@ fi
# the default password store for the current desktop environment. # the default password store for the current desktop environment.
# Ref: https://launchpad.net/bugs/1763829 # Ref: https://launchpad.net/bugs/1763829
PASSWORD_STORE=basic PASSWORD_STORE=basic
dbus-send --session --dest=org.freedesktop.secrets /org/freedesktop/secrets \ if snapctl is-connected password-manager-service; then
--print-reply org.freedesktop.DBus.Properties.GetAll \
string:'org.freedesktop.Secret.Service' >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
# An empty string means detect the store based on the current DE # An empty string means detect the store based on the current DE
# (os_crypt::SelectBackend()) # (os_crypt::SelectBackend())
PASSWORD_STORE= PASSWORD_STORE=
else
dbus-send --session --dest=org.kde.kwalletd5 /modules/kwalletd5 \
--print-reply org.freedesktop.DBus.Properties.GetAll \
string:'org.kde.KWallet' >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
# An empty string means detect the store based on the current DE
# (os_crypt::SelectBackend())
PASSWORD_STORE=
fi
fi fi
# Allow @@SNAPNAME@@ to look for the flash player plugin inside the snap's # Allow @@SNAPNAME@@ to look for the flash player plugin inside the snap's
......
...@@ -7,6 +7,8 @@ summary: @@SHORTDESC@@ ...@@ -7,6 +7,8 @@ summary: @@SHORTDESC@@
description: @@FULLDESC@@ description: @@FULLDESC@@
confinement: strict confinement: strict
base: core18 base: core18
assumes:
- snapd2.43 # for 'snapctl is-connected', used in chrome.launcher
apps: apps:
@@SNAPNAME@@: @@SNAPNAME@@:
...@@ -15,9 +17,11 @@ apps: ...@@ -15,9 +17,11 @@ apps:
environment: environment:
DISABLE_WAYLAND: 1 DISABLE_WAYLAND: 1
CHROME_DESKTOP: @@SNAPNAME@@.desktop CHROME_DESKTOP: @@SNAPNAME@@.desktop
CHROME_CONFIG_HOME: $SNAP_USER_COMMON
plugs: plugs:
- audio-playback - audio-playback
- audio-record - audio-record
- bluez # for Web Bluetooth (https://launchpad.net/bugs/1887201)
- camera - camera
- cups-control - cups-control
- desktop - desktop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment