From 21c6e5e680c1d0ff4d0e278c2dc89a4f86bbb68d Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 4 Mar 2020 15:19:56 +0100 Subject: [PATCH] snap: fix for native-messaging-host permissions (#6062) * snap: fix for native-messaging-host permissions add hook for chrome/chromium * snap: fix no newline * Add snap browser integration to changelog --- CHANGELOG.md | 1 + ...-plug-etc-chromium-native-messaging-jabref | 9 ++++ ...lug-etc-opt-chrome-native-messaging-jabref | 9 ++++ ...ug-hostfs-mozilla-native-messaging-jabref} | 2 +- ...-plug-etc-chromium-native-messaging-jabref | 7 +++ ...lug-etc-opt-chrome-native-messaging-jabref | 7 +++ ...ug-hostfs-mozilla-native-messaging-jabref} | 2 +- snap/snapcraft.yaml | 49 ++++++++++--------- 8 files changed, 60 insertions(+), 26 deletions(-) create mode 100755 snap/hooks/connect-plug-etc-chromium-native-messaging-jabref create mode 100755 snap/hooks/connect-plug-etc-opt-chrome-native-messaging-jabref rename snap/hooks/{connect-plug-browser-extension => connect-plug-hostfs-mozilla-native-messaging-jabref} (60%) create mode 100755 snap/hooks/disconnect-plug-etc-chromium-native-messaging-jabref create mode 100755 snap/hooks/disconnect-plug-etc-opt-chrome-native-messaging-jabref rename snap/hooks/{disconnect-plug-browser-extension => disconnect-plug-hostfs-mozilla-native-messaging-jabref} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0295db7c81..85855ba62a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Changed +- Added browser integration to the snap package for firefox/chromium browsers. [#6062](https://github.com/JabRef/jabref/pull/6062) - We reintroduced the possibility to extract references from plain text (using [GROBID](https://grobid.readthedocs.io/en/latest/)). [#5614](https://github.com/JabRef/jabref/pull/5614) - We changed the open office panel to show buttons in rows of three instead of going straight down to save space as the button expanded out to take up unnecessary horizontal space. [#5479](https://github.com/JabRef/jabref/issues/5479) - We cleaned up the group add/edit dialog. [#5826](https://github.com/JabRef/jabref/pull/5826) diff --git a/snap/hooks/connect-plug-etc-chromium-native-messaging-jabref b/snap/hooks/connect-plug-etc-chromium-native-messaging-jabref new file mode 100755 index 00000000000..2644fc7026a --- /dev/null +++ b/snap/hooks/connect-plug-etc-chromium-native-messaging-jabref @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ ! -d /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts ]; then + echo "Missing directory, create it manually then try again:" + echo "sudo mkdir -p /etc/chromium/native-messaging-hosts" + exit 1 +fi + +cp "$SNAP/lib/native-messaging-host/chromium/org.jabref.jabref.json" /etc/chromium/native-messaging-hosts/org.jabref.jabref.json diff --git a/snap/hooks/connect-plug-etc-opt-chrome-native-messaging-jabref b/snap/hooks/connect-plug-etc-opt-chrome-native-messaging-jabref new file mode 100755 index 00000000000..025087770a7 --- /dev/null +++ b/snap/hooks/connect-plug-etc-opt-chrome-native-messaging-jabref @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ ! -d /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts ]; then + echo "Missing directory, create it manually then try again:" + echo "sudo mkdir -p /etc/opt/chrome/native-messaging-hosts" + exit 1 +fi + +cp "$SNAP/lib/native-messaging-host/chromium/org.jabref.jabref.json" /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json diff --git a/snap/hooks/connect-plug-browser-extension b/snap/hooks/connect-plug-hostfs-mozilla-native-messaging-jabref similarity index 60% rename from snap/hooks/connect-plug-browser-extension rename to snap/hooks/connect-plug-hostfs-mozilla-native-messaging-jabref index df5cde565f3..ac597118d7c 100755 --- a/snap/hooks/connect-plug-browser-extension +++ b/snap/hooks/connect-plug-hostfs-mozilla-native-messaging-jabref @@ -6,4 +6,4 @@ if [ ! -d /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts ]; then exit 1 fi -cp $SNAP/lib/org.jabref.jabref.json /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json \ No newline at end of file +cp "$SNAP/lib/native-messaging-host/firefox/org.jabref.jabref.json" /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json diff --git a/snap/hooks/disconnect-plug-etc-chromium-native-messaging-jabref b/snap/hooks/disconnect-plug-etc-chromium-native-messaging-jabref new file mode 100755 index 00000000000..e68ad21ca73 --- /dev/null +++ b/snap/hooks/disconnect-plug-etc-chromium-native-messaging-jabref @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ! -f /etc/chromium/native-messaging-hosts/org.jabref.jabref.json ]; then + exit 0 +elif grep --quiet '"path": "/snap' /etc/chromium/native-messaging-hosts/org.jabref.jabref.json; then + rm /etc/chromium/native-messaging-hosts/org.jabref.jabref.json +fi diff --git a/snap/hooks/disconnect-plug-etc-opt-chrome-native-messaging-jabref b/snap/hooks/disconnect-plug-etc-opt-chrome-native-messaging-jabref new file mode 100755 index 00000000000..50eff0b9292 --- /dev/null +++ b/snap/hooks/disconnect-plug-etc-opt-chrome-native-messaging-jabref @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ! -f /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json ]; then + exit 0 +elif grep --quiet '"path": "/snap' /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json; then + rm /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json +fi diff --git a/snap/hooks/disconnect-plug-browser-extension b/snap/hooks/disconnect-plug-hostfs-mozilla-native-messaging-jabref similarity index 99% rename from snap/hooks/disconnect-plug-browser-extension rename to snap/hooks/disconnect-plug-hostfs-mozilla-native-messaging-jabref index 5af57cf27f9..280d1afc79d 100755 --- a/snap/hooks/disconnect-plug-browser-extension +++ b/snap/hooks/disconnect-plug-hostfs-mozilla-native-messaging-jabref @@ -4,4 +4,4 @@ if [ ! -f /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabre exit 0 elif grep --quiet '"path": "/snap' /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json; then rm /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json -fi \ No newline at end of file +fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index ccba913feba..3734858e789 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -12,6 +12,28 @@ license: MIT architectures: - build-on: amd64 +plugs: + desktop: + desktop-legacy: + wayland: + unity7: + home: + opengl: + network-bind: + removable-media: + hostfs-mozilla-native-messaging-jabref: + interface: system-files + write: + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json + etc-opt-chrome-native-messaging-jabref: + interface: system-files + write: + - /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json + etc-chromium-native-messaging-jabref: + interface: system-files + write: + - /etc/chromium/native-messaging-hosts/org.jabref.jabref.json + apps: jabref: command: bin/JabRef @@ -22,34 +44,13 @@ apps: environment: _JAVA_OPTIONS: "-Duser.home=$SNAP_USER_DATA" -plugs: - desktop: - desktop-legacy: - wayland: - unity7: - home: - opengl: - network-bind: - removable-media: - plugs: - hostfs-mozilla-native-messaging-jabref: - interface: system-files - write: - - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json - hostfs-chrome-native-messaging-jabref: - interface: system-files - write: - - /var/lib/snapd/hostfs/etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json - hostfs-chromium-native-messaging-jabref: - interface: system-files - write: - - /var/lib/snapd/hostfs/etc/chromium/native-messaging-hosts/org.jabref.jabref.json + parts: jabref: plugin: dump - source: build/distribution/JabRef-portable_linux.tar.gz + # source: build/distribution/JabRef-5.0-portable_linux.tar.gz # Use this source for debug purposes: - # source: https://builds.jabref.org/master/JabRef-portable_linux.tar.gz + source: https://builds.jabref.org/master/JabRef-5.0-portable_linux.tar.gz stage-packages: - x11-utils override-build: |