From 2f656eb3caaeb34abc0a451f7e6a6b0820996502 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 10 Oct 2019 15:59:12 +0200 Subject: [PATCH 1/4] Add hook for jabref integration --- snap/hooks/interface | 3 +++ snap/snapcraft.yaml | 28 +++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100755 snap/hooks/interface diff --git a/snap/hooks/interface b/snap/hooks/interface new file mode 100755 index 00000000000..1f5065210fa --- /dev/null +++ b/snap/hooks/interface @@ -0,0 +1,3 @@ +#!/bin/sh -e + +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/snapcraft.yaml b/snap/snapcraft.yaml index a60eadd2d4d..d6cb4ed3c5a 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,17 @@ license: MIT architectures: - build-on: amd64 +plugs: + jabfox-integration: + interface: system-files + write: + - /usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json + +hooks: + jabref-interface: + plugs: + - jabfox-integration + apps: jabref: command: bin/JabRef @@ -29,13 +38,18 @@ apps: - opengl - network-bind - removable-media + - jabfox-integration 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)" + # source: build/distribution/JabRef-portable_linux.tar.gz + # 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 + From 8e7a564b049841e1c9a68cb4985d8f2e6fc8e7e3 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 10 Oct 2019 16:28:15 +0200 Subject: [PATCH 2/4] update connect-plug hook --- snap/hooks/{interface => jabfox-interface} | 0 snap/snapcraft.yaml | 5 ++--- 2 files changed, 2 insertions(+), 3 deletions(-) rename snap/hooks/{interface => jabfox-interface} (100%) diff --git a/snap/hooks/interface b/snap/hooks/jabfox-interface similarity index 100% rename from snap/hooks/interface rename to snap/hooks/jabfox-interface diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d6cb4ed3c5a..272f24b47c2 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -16,10 +16,10 @@ plugs: jabfox-integration: interface: system-files write: - - /usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json hooks: - jabref-interface: + connect-plug-system-files: plugs: - jabfox-integration @@ -38,7 +38,6 @@ apps: - opengl - network-bind - removable-media - - jabfox-integration parts: jabref: From 4f645d199ba26d7489f9f01ae23fab46b8cecf8a Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Fri, 11 Oct 2019 00:42:09 +0200 Subject: [PATCH 3/4] Fix hook name and permission --- snap/hooks/connect-plug-jabfox-integration | 9 +++++++++ snap/hooks/jabfox-interface | 3 --- snap/snapcraft.yaml | 13 +++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) create mode 100755 snap/hooks/connect-plug-jabfox-integration delete mode 100755 snap/hooks/jabfox-interface diff --git a/snap/hooks/connect-plug-jabfox-integration b/snap/hooks/connect-plug-jabfox-integration new file mode 100755 index 00000000000..df5cde565f3 --- /dev/null +++ b/snap/hooks/connect-plug-jabfox-integration @@ -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/jabfox-interface b/snap/hooks/jabfox-interface deleted file mode 100755 index 1f5065210fa..00000000000 --- a/snap/hooks/jabfox-interface +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -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/snapcraft.yaml b/snap/snapcraft.yaml index 272f24b47c2..eb6d5f1fb36 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -15,13 +15,10 @@ architectures: plugs: jabfox-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/org.jabref.jabref.json - -hooks: - connect-plug-system-files: - plugs: - - jabfox-integration + - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json apps: jabref: @@ -42,9 +39,9 @@ apps: parts: jabref: plugin: dump - # source: build/distribution/JabRef-portable_linux.tar.gz + source: build/distribution/JabRef-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-portable_linux.tar.gz stage-packages: - x11-utils override-build: | From e6e8c52fff5b230f7645e9ee32f7ffd7b2d72ad0 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Fri, 11 Oct 2019 16:55:13 +0200 Subject: [PATCH 4/4] Add disconnect hook change plug name to browser-extension --- ...g-jabfox-integration => connect-plug-browser-extension} | 0 snap/hooks/disconnect-plug-browser-extension | 7 +++++++ snap/snapcraft.yaml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) rename snap/hooks/{connect-plug-jabfox-integration => connect-plug-browser-extension} (100%) create mode 100755 snap/hooks/disconnect-plug-browser-extension diff --git a/snap/hooks/connect-plug-jabfox-integration b/snap/hooks/connect-plug-browser-extension similarity index 100% rename from snap/hooks/connect-plug-jabfox-integration rename to snap/hooks/connect-plug-browser-extension 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 eb6d5f1fb36..abba7c87409 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -13,7 +13,7 @@ architectures: - build-on: amd64 plugs: - jabfox-integration: + browser-extension: interface: system-files read: - /var/lib/snapd/hostfs/usr/lib/mozilla/native-messaging-hosts