diff --git a/snap/hooks/connect-plug-browser-extension b/snap/hooks/connect-plug-browser-extension new file mode 100755 index 00000000000..df5cde565f3 --- /dev/null +++ b/snap/hooks/connect-plug-browser-extension @@ -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 /usr/lib/mozilla/native-messaging-hosts" + 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 diff --git a/snap/hooks/disconnect-plug-browser-extension b/snap/hooks/disconnect-plug-browser-extension new file mode 100755 index 00000000000..5af57cf27f9 --- /dev/null +++ b/snap/hooks/disconnect-plug-browser-extension @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ! -f /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json ]; then + 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 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index a60eadd2d4d..abba7c87409 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,7 +1,5 @@ name: jabref -# adopt-info: jabref -version: 'master' -version-script: cat build.gradle | grep "^version =" | cut -d'"' -f2 +adopt-info: jabref icon: snap/gui/jabref.png license: MIT summary: Bibliography manager @@ -14,6 +12,14 @@ license: MIT architectures: - build-on: amd64 +plugs: + browser-extension: + 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/org.jabref.jabref.json + apps: jabref: command: bin/JabRef @@ -34,8 +40,12 @@ parts: jabref: plugin: dump source: build/distribution/JabRef-portable_linux.tar.gz - # override-pull: | - # snapcraftctl pull - # snapcraftctl set-version "$(cat app/JabRef.cfg | grep "app.version=" | cut -d'=' -f2)" + # Use this source for debug purposes: + # source: https://builds.jabref.org/master/JabRef-portable_linux.tar.gz stage-packages: - x11-utils + override-build: | + snapcraftctl build + snapcraftctl set-version "$(cat $SNAPCRAFT_PART_INSTALL/lib/app/JabRef.cfg | grep "app.version=" | cut -d'=' -f2)" + sed -i 's|/opt/jabref/lib/jabrefHost.py|/snap/jabref/current/lib/jabrefHost.py|g' $SNAPCRAFT_PART_INSTALL/lib/org.jabref.jabref.json +