From 832bcf5ba5448f83e008a18e5d3b4f46ad045b4c Mon Sep 17 00:00:00 2001 From: Botspot <54716352+Botspot@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:23:17 -0500 Subject: [PATCH] Snap store: use core22, enable_module, avoid permanent menu symlink --- apps/Snap Store/install | 15 ++++++++++++--- apps/Snap Store/uninstall | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/Snap Store/install b/apps/Snap Store/install index a8064d277e..64889d57e0 100755 --- a/apps/Snap Store/install +++ b/apps/Snap Store/install @@ -15,9 +15,9 @@ fi sudo snap refresh sudo systemctl restart snapd.service || error "Unable to restart snapd.service" -sudo modprobe squashfs || exit 1 +enable_module squashfs || exit 1 -sudo snap install core18 || error "Snapd was unable to install core18" +sudo snap install core22 || error "Snapd was unable to install core22" sudo snap install core || error "Snapd was unable to install core" sudo snap install snapd || error "Snapd was unable to install snapd" @@ -27,5 +27,14 @@ echo "Output of 'snap version':" snap version sudo snap install snap-store || error "Unable to install snap store" sudo rm -rf /usr/share/applications/snap -ln -s /var/lib/snapd/desktop/applications /usr/share/applications/snap || sudo ln -s /var/lib/snapd/desktop/applications /usr/share/applications/snap || error "Failed to create symlink for Snap app shortcuts!" +#Pi-Apps tries to avoid unnecessary reboots at all cost. Snap places desktop launchers in /var/lib/snapd/desktop/applications, which is not searched by default. +#This path is added to $XDG_DATA_DIRS on the next reboot, but we don't want to wait for that! +#If there are files in /var/lib/snapd/desktop/applications, and XDG_DATA_DIRS is missing snap paths, then bind-mount to /usr/share/applications +if [[ "$XDG_DATA_DIRS" != */var/lib/snapd/desktop* ]] && [ ! -z "$(ls /var/lib/snapd/desktop/applications)" ] && [ -z "$(ls /usr/share/applications/snapd-temporary)" ];then + sudo mkdir -p /usr/share/applications/snapd-temporary + sudo mount --bind /var/lib/snapd/desktop/applications /usr/share/applications/snapd-temporary +elif [[ "$XDG_DATA_DIRS" == */var/lib/snapd/desktop* ]] ;then + sudo rm -rf /usr/share/applications/snapd-temporary +fi +#Additionally, PiOS Buster had a bug where XDG_DATA_DIRS was missing snap's entries due to PiOS mods. Pi-Apps fixes this with a runonce. diff --git a/apps/Snap Store/uninstall b/apps/Snap Store/uninstall index d12f34c595..3bb9daaa0e 100755 --- a/apps/Snap Store/uninstall +++ b/apps/Snap Store/uninstall @@ -1,5 +1,5 @@ #!/bin/bash -sudo rm -rf /var/snap/snap-store +sudo rm -rf /var/snap/snap-store /usr/share/applications/snapd-temporary if command -v snap >/dev/null ;then sudo snap remove snap-store || error "The snap command failed to uninstall snap-store\nPerhaps running this command would fix it?\nsudo apt install --reinstall snapd"