Initial commit: snap using zen-bin
This commit is contained in:
13
snap/hooks/disconnect-plug-host-hunspell
Normal file
13
snap/hooks/disconnect-plug-host-hunspell
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Clean up old Firefox snap mount for host hunspell; we now use
|
||||
# the system-files interface for host hunspell dictionaries.
|
||||
|
||||
# TODO: Drop this (along with the host-hunspell mount-control
|
||||
# declaration in snapcraft.yaml) later in the future once a
|
||||
# reasonable amount of time has passed and nearly all users
|
||||
# have an updated version and were migrated to use system-files,
|
||||
# and just about no new Ubuntu installations start with a
|
||||
# Firefox snap that has the older mount-control interface.
|
||||
snapctl umount $SNAP_COMMON/host-hunspell || true
|
||||
rm -r $SNAP_COMMON/host-hunspell || true
|
1
snap/hooks/install
Normal file
1
snap/hooks/install
Normal file
@@ -0,0 +1 @@
|
||||
post-refresh
|
64
snap/hooks/post-refresh
Normal file
64
snap/hooks/post-refresh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2022 Canonical Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 3, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
host_hunspell=/var/lib/snapd/hostfs/usr/share/hunspell
|
||||
|
||||
if [ ! -d $host_hunspell ]; then
|
||||
echo "No host hunspell, skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DICPATH=$SNAP_COMMON/snap-hunspell
|
||||
|
||||
if [ -d $DICPATH ]; then
|
||||
# Clean up on each refresh to ensure we have an up-to-date list
|
||||
# of host dictionaries.
|
||||
find $DICPATH -type l -name "*.dic" -or -name "*.aff" | xargs rm
|
||||
else
|
||||
mkdir -p $DICPATH
|
||||
fi
|
||||
|
||||
# We deliberately don't directly use the host dictionary files.
|
||||
# Instead, we use their names to know which ones the user has
|
||||
# installed on their system, and we use the corresponding ones
|
||||
# we primed in '$SNAP/usr/share/hunspell' in our 'hunspell' part.
|
||||
#
|
||||
# - We don't set DICPATH=/var/lib/snapd/hostfs/usr/share/hunspell
|
||||
# to avoid potential incompatibility due to different hunspell
|
||||
# versions inside the snap and outside on the host. See:
|
||||
# https://github.com/snapcore/snapd/pull/11025
|
||||
#
|
||||
# - We don't set DICPATH="$SNAP/usr/share/hunspell" because that
|
||||
# would result in all available dictionaries we primed in our
|
||||
# 'hunspell' part being displayed in Firefox's interface,
|
||||
# presenting an overwhelming number of options to the user.
|
||||
# So instead we only use those that were installed on the host.
|
||||
# This way, the user could affect the dictionaries available to
|
||||
# Firefox snap similarly to how they could for non-snap Firefox.
|
||||
for dic in $(find $host_hunspell/ -name "*.dic"); do
|
||||
dic_file=$(basename $dic)
|
||||
aff_file="${dic_file%%.dic}.aff"
|
||||
# Some dic,aff files in hunspell are themselves symlinks to other files,
|
||||
# e.g. /usr/share/hunspell/fr_CH.dic -> fr.dic.
|
||||
# That extra level of indirection somehow breaks spell checking.
|
||||
# We therefore use readlink to link to the "real" file, not to a symlink.
|
||||
if [ -e "$SNAP/usr/share/hunspell/${dic_file}" ]; then
|
||||
ln -s "$(readlink -e $SNAP/usr/share/hunspell/${dic_file})" $DICPATH/${dic_file}
|
||||
fi
|
||||
if [ -e "$SNAP/usr/share/hunspell/${aff_file}" ]; then
|
||||
ln -s "$(readlink -e $SNAP/usr/share/hunspell/${aff_file})" $DICPATH/${aff_file}
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user