Skip to content

Commit

Permalink
snap: fix for native-messaging-host permissions (#6062)
Browse files Browse the repository at this point in the history
* snap: fix for native-messaging-host permissions
add hook for chrome/chromium

* snap: fix no newline

* Add snap browser integration to changelog
  • Loading branch information
LyzardKing authored Mar 4, 2020
1 parent 8111707 commit 21c6e5e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions snap/hooks/connect-plug-etc-chromium-native-messaging-jabref
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
fi
49 changes: 25 additions & 24 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down

0 comments on commit 21c6e5e

Please sign in to comment.