From a41055d34467604e69e32820c32717b11bfdc2b4 Mon Sep 17 00:00:00 2001 From: Thor Galle Date: Fri, 4 Feb 2022 03:03:03 +0200 Subject: [PATCH 1/2] Proof-of-concept snap config with working FF native messssaging --- .gitignore | 4 +++- snap/hooks/configure | 18 +++++++++++++++ snap/snapcraft.yaml | 53 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 snap/hooks/configure create mode 100644 snap/snapcraft.yaml diff --git a/.gitignore b/.gitignore index 51207a6..30d67c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /bin /node_modules /pkg -/pub \ No newline at end of file +/pub +*.swp +*.snap diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100644 index 0000000..3ebdf84 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +# case "$1" in +# configure) + # Recursively create the system-wide manifest directories in case they don't exist. + mkdir -p /var/lib/snapd/hostfs/etc/opt/chrome/native-messaging-hosts + mkdir -p /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts + touch /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/touchy + + # Copy the manifest files. + cp $SNAP/usr/lib/readup/resources/app/content/linux/chrome/it.reallyread.mobile.browser_extension_app.json /var/lib/snapd/hostfs/etc/opt/chrome/native-messaging-hosts/ + cp $SNAP/usr/lib/readup/resources/app/content/linux/firefox/it.reallyread.mobile.browser_extension_app.json /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/ + #;; +#esac + +exit 0 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..5bc347e --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,53 @@ +name: readup +version: '1.0.6' +summary: A little description for the app. +description: The world's best reading app. +grade: stable +# confinement: classic +confinement: devmode +base: core18 + +parts: + readup: + plugin: dump + source: ./pkg/readup_1.0.6_amd64.deb + source-type: deb + stage-packages: + - libasound2 + - libnotify4 + - libnspr4 + - libnss3 + - libpcre3 + - libpulse0 + - libxss1 + - libxtst6 + override-pull: | + snapcraftctl pull + cd usr/lib/readup/resources/app/content/linux/ + sed -ri 's/\/usr\/lib\/readup\/resources\/app\/content\/linux\/BrowserExtensionApp/\/snap\/bin\/readup.browserextensionapp/' firefox/it.reallyread.mobile.browser_extension_app.json + sed -ri 's/\/usr\/lib\/readup\/resources\/app\/content\/linux\/BrowserExtensionApp/\/snap\/bin\/readup.browserextensionapp/' chrome/it.reallyread.mobile.browser_extension_app.json + chmod a+rx BrowserExtensionApp + +plugs: + native-messaging-integration: + interface: system-files + read: + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts + write: + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/touchy + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/it.reallyread.mobile.browser_extension_app.json + +hooks: + configure: + plugs: [native-messaging-integration] +apps: + readup: + extensions: [gnome-3-34] + command: "bin/desktop-launch $SNAP/usr/lib/readup/Readup" + desktop: usr/share/applications/readup.desktop + # Correct the TMPDIR path for Chromium Framework/Electron to ensure + # libappindicator has readable resources. + environment: + TMPDIR: $XDG_RUNTIME_DIR + browserextensionapp: + command: usr/lib/readup/resources/app/content/linux/BrowserExtensionApp From e22c19f971ca51679389a27889fa66e0e8b28e00 Mon Sep 17 00:00:00 2001 From: Thor Galle Date: Fri, 4 Feb 2022 14:40:21 +0200 Subject: [PATCH 2/2] Fix the desktop icon for snaps --- snap/snapcraft.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5bc347e..6d347dc 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -24,9 +24,15 @@ parts: override-pull: | snapcraftctl pull cd usr/lib/readup/resources/app/content/linux/ + # point the native messaging manifests to the readup.browserextension app exposed by this snap sed -ri 's/\/usr\/lib\/readup\/resources\/app\/content\/linux\/BrowserExtensionApp/\/snap\/bin\/readup.browserextensionapp/' firefox/it.reallyread.mobile.browser_extension_app.json sed -ri 's/\/usr\/lib\/readup\/resources\/app\/content\/linux\/BrowserExtensionApp/\/snap\/bin\/readup.browserextensionapp/' chrome/it.reallyread.mobile.browser_extension_app.json + # make the browser ext app world-readable and executable (required) chmod a+rx BrowserExtensionApp + # restore cwd + cd ../../../../../../.. + # fix the .desktop icon reference to be relative to the prime dir (https://forum.snapcraft.io/t/desktop-files-for-menu-integration/13115#heading--desktop-key) + sed -ri 's|Icon=readup|Icon=/usr/lib/readup/resources/app/content/images/icon.svg|g' usr/share/applications/readup.desktop plugs: native-messaging-integration: