From e7de544bdf54d2080c8d92b7ac63aee9f83a6764 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 16 Apr 2020 16:32:24 +0200 Subject: [PATCH 01/23] Initial extention autoinstall for chrome/chromium in linux --- .../chromium/bifehkofibaamoeaopjglfkddgkijdlh.json | 3 +++ buildres/linux/postinst | 4 +++- buildres/linux/postrm | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json diff --git a/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json b/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json new file mode 100644 index 00000000000..661dc9abd3d --- /dev/null +++ b/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json @@ -0,0 +1,3 @@ +{ + "external_update_url": "http://myhost.com/mytestextension/updates.xml" +} diff --git a/buildres/linux/postinst b/buildres/linux/postinst index 1c3af73aa24..0cd6cb57710 100644 --- a/buildres/linux/postinst +++ b/buildres/linux/postinst @@ -22,7 +22,9 @@ case "$1" in install -D -m0755 /opt/jabref/lib/native-messaging-host/firefox/org.jabref.jabref.json /usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/chromium/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json - DESKTOP_COMMANDS_INSTALL + install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + DESKTOP_COMMANDS_INSTALL ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/buildres/linux/postrm b/buildres/linux/postrm index 0663ab759b4..c93bd112927 100644 --- a/buildres/linux/postrm +++ b/buildres/linux/postrm @@ -26,6 +26,8 @@ case "$1" in rm $NATIVE_MESSAGING_JSON fi done + rm /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + rm /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json ;; *) From 198819c013330ec923e16afcac14b442505e495e Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Tue, 28 Apr 2020 09:11:36 +0200 Subject: [PATCH 02/23] Add postinst/postrm chrome extension --- buildres/linux/postinst | 2 ++ buildres/linux/postrm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/buildres/linux/postinst b/buildres/linux/postinst index 0cd6cb57710..a83e52a46ca 100644 --- a/buildres/linux/postinst +++ b/buildres/linux/postinst @@ -19,9 +19,11 @@ set -e case "$1" in configure) + # Install the native-messaging host script for firefox/chrome/chromium install -D -m0755 /opt/jabref/lib/native-messaging-host/firefox/org.jabref.jabref.json /usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/chromium/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json + # Trigger an auto-install of the browser addon for chrome/chromium browsers install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json DESKTOP_COMMANDS_INSTALL diff --git a/buildres/linux/postrm b/buildres/linux/postrm index c93bd112927..740a023ade2 100644 --- a/buildres/linux/postrm +++ b/buildres/linux/postrm @@ -19,6 +19,7 @@ set -e case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + # Remove the native-messaging hosts script only if relative to the deb package for NATIVE_MESSAGING_JSON in "/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json"\ "/etc/chromium/native-messaging-hosts/org.jabref.jabref.json"\ "/etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json"; do @@ -26,6 +27,7 @@ case "$1" in rm $NATIVE_MESSAGING_JSON fi done + # Remove the auto-install triggers of the browser addon for chrom/chromium rm /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json rm /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json ;; From 4bbaba34d610884cc134cabc23ed4fd21c57b0b6 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 7 May 2020 19:50:34 +0200 Subject: [PATCH 03/23] Add json files to macos build --- .../chromium/bifehkofibaamoeaopjglfkddgkijdlh.json | 3 +++ .../chromium/org.jabref.jabref.json | 9 +++++++++ .../firefox/org.jabref.jabref.json | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json create mode 100644 buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json create mode 100644 buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json diff --git a/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json b/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json new file mode 100644 index 00000000000..661dc9abd3d --- /dev/null +++ b/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json @@ -0,0 +1,3 @@ +{ + "external_update_url": "http://myhost.com/mytestextension/updates.xml" +} diff --git a/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json b/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json new file mode 100644 index 00000000000..6283016eafe --- /dev/null +++ b/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json @@ -0,0 +1,9 @@ +{ + "name": "org.jabref.jabref", + "description": "JabRef", + "path": "/opt/jabref/lib/jabrefHost.py", + "type": "stdio", + "allowed_origins": [ + "chrome-extension://bifehkofibaamoeaopjglfkddgkijdlh/" + ] +} diff --git a/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json b/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json new file mode 100644 index 00000000000..1edebc9c576 --- /dev/null +++ b/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json @@ -0,0 +1,10 @@ +{ + "name": "org.jabref.jabref", + "description": "JabRef", + "path": "/opt/jabref/lib/jabrefHost.py", + "type": "stdio", + "allowed_extensions": [ + "browserextension@jabref.org", + "@jabfox" + ] +} From 384826a4db679acd85c818f4e53b5c162a88076f Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Fri, 8 May 2020 15:04:09 +0200 Subject: [PATCH 04/23] Add macos resource files and link in the pkg release --- build.gradle | 11 +++++++++++ buildres/mac/postinstall | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 buildres/mac/postinstall diff --git a/build.gradle b/build.gradle index 2d6959fd4c7..9476b77b340 100644 --- a/build.gradle +++ b/build.gradle @@ -720,6 +720,17 @@ if (OperatingSystem.current().isLinux()) { } } +if (OperatingSystem.current().isMacOsX()) { + tasks.jpackageImage.doLast { + copy { + from("${projectDir}/buildres/mac") { + include "native-messaging-host/**", "jabrefHost.py" + } + into "$buildDir/distribution/JabRef.app/Contents/Resources" + } + } +} + // Delete unnecessary folder in application image // TODO: Remove this workaround as soon as https://github.com/beryx/badass-jlink-plugin/issues/51 is fixed task deleteModsFolder(type: Delete) { diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall new file mode 100644 index 00000000000..d73105a8dc7 --- /dev/null +++ b/buildres/mac/postinstall @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +chown root:wheel "INSTALL_LOCATION" +chmod a+rX "INSTALL_LOCATION" +chmod +r "APP_LOCATION/"*.jar +# Trigger an auto-install of the browser addon for chrome/chromium browsers +install -D -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + +exit 0 \ No newline at end of file From 02878cc85f006cc02664ed203c110bf0f2c6807f Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Tue, 19 May 2020 21:31:54 +0200 Subject: [PATCH 05/23] Use chrome store url to install extension --- .../chromium/bifehkofibaamoeaopjglfkddgkijdlh.json | 2 +- .../chromium/bifehkofibaamoeaopjglfkddgkijdlh.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json b/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json index 661dc9abd3d..17f681d07f3 100644 --- a/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json +++ b/buildres/linux/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json @@ -1,3 +1,3 @@ { - "external_update_url": "http://myhost.com/mytestextension/updates.xml" + "external_update_url": "https://clients2.google.com/service/update2/crx" } diff --git a/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json b/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json index 661dc9abd3d..17f681d07f3 100644 --- a/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json +++ b/buildres/mac/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json @@ -1,3 +1,3 @@ { - "external_update_url": "http://myhost.com/mytestextension/updates.xml" + "external_update_url": "https://clients2.google.com/service/update2/crx" } From 386e2d991528fec294c7aa45c0d9a1d0720925fa Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 20 May 2020 09:24:29 +0200 Subject: [PATCH 06/23] set chromium auto-install to world readable --- buildres/linux/postinst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildres/linux/postinst b/buildres/linux/postinst index a83e52a46ca..96a816435ae 100644 --- a/buildres/linux/postinst +++ b/buildres/linux/postinst @@ -24,8 +24,8 @@ case "$1" in install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/chromium/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json # Trigger an auto-install of the browser addon for chrome/chromium browsers - install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json - install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json DESKTOP_COMMANDS_INSTALL ;; From fc0c8b6d7fd58af767bf685e4d251fc3f2f09b08 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 20 May 2020 09:34:14 +0200 Subject: [PATCH 07/23] Add permissions to macos autoinstall extension --- buildres/mac/postinstall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index d73105a8dc7..4e4f5049dc1 100644 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -4,6 +4,6 @@ chown root:wheel "INSTALL_LOCATION" chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers -install -D -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +install -D -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json -exit 0 \ No newline at end of file +exit 0 From ac8fd4fa22114963e9d899e34e13625088be2e23 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 20 May 2020 09:39:23 +0200 Subject: [PATCH 08/23] Add inst/rm for chromium extension on rpm --- buildres/linux/jabref.spec | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/buildres/linux/jabref.spec b/buildres/linux/jabref.spec index 71c9574c449..e877c424058 100644 --- a/buildres/linux/jabref.spec +++ b/buildres/linux/jabref.spec @@ -52,20 +52,28 @@ cp -r %{_sourcedir}APPLICATION_DIRECTORY/* %{buildroot}APPLICATION_DIRECTORY %(echo APPLICATION_DIRECTORY | sed -e "s|\(^/[^/]\{1,\}\).*$|\1|") %post +# Install the native-messaging host script for firefox/chrome/chromium install -D -m0755 /opt/jabref/lib/native-messaging-host/firefox/org.jabref.jabref.json /usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/chromium/native-messaging-hosts/org.jabref.jabref.json install -D -m0755 /opt/jabref/lib/native-messaging-host/chromium/org.jabref.jabref.json /etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json +# Trigger an auto-install of the browser addon for chrome/chromium browsers +install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json DESKTOP_COMMANDS_INSTALL %preun +# Remove the native-messaging hosts script only if relative to the deb package for NATIVE_MESSAGING_JSON in "/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json"\ - "/etc/chromium/native-messaging-hosts/org.jabref.jabref.json"\ - "/etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json"; do + "/etc/chromium/native-messaging-hosts/org.jabref.jabref.json"\ + "/etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json"; do if [ -e $NATIVE_MESSAGING_JSON ] && grep --quiet '"path": "/opt' $NATIVE_MESSAGING_JSON; then rm $NATIVE_MESSAGING_JSON fi done +# Remove the auto-install triggers of the browser addon for chrom/chromium +rm /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +rm /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json UTILITY_SCRIPTS DESKTOP_COMMANDS_UNINSTALL -%clean \ No newline at end of file +%clean From 53fda44996d0fd1fba5b290bb0f2138146de82fe Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 22 May 2020 12:51:54 +0200 Subject: [PATCH 09/23] Rename postinstall to postinstall.test --- buildres/mac/{postinstall => postinstall.test} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename buildres/mac/{postinstall => postinstall.test} (100%) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall.test similarity index 100% rename from buildres/mac/postinstall rename to buildres/mac/postinstall.test From 6025b72253214e9ee344aa9bf7c68fad3443187e Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Tue, 26 May 2020 13:32:23 +0200 Subject: [PATCH 10/23] try again with postinstall --- buildres/mac/{postinstall.test => postinstall} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename buildres/mac/{postinstall.test => postinstall} (100%) diff --git a/buildres/mac/postinstall.test b/buildres/mac/postinstall similarity index 100% rename from buildres/mac/postinstall.test rename to buildres/mac/postinstall From 15b8161d6b8e9bbc93871481584f890472a8b555 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 28 May 2020 18:22:33 +0200 Subject: [PATCH 11/23] Add exec permission to mac postinstall --- buildres/mac/postinstall | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 buildres/mac/postinstall diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall old mode 100644 new mode 100755 From 9f560b7c17c491e4be4bda369c76f0c5d25ea5b2 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 28 May 2020 18:33:55 +0200 Subject: [PATCH 12/23] Fix shell indentations --- buildres/linux/postinst | 2 +- buildres/linux/postrm | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/buildres/linux/postinst b/buildres/linux/postinst index 96a816435ae..a26e18b43cc 100644 --- a/buildres/linux/postinst +++ b/buildres/linux/postinst @@ -26,7 +26,7 @@ case "$1" in # Trigger an auto-install of the browser addon for chrome/chromium browsers install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json install -D -m0644 /opt/jabref/lib/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json - DESKTOP_COMMANDS_INSTALL + DESKTOP_COMMANDS_INSTALL ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/buildres/linux/postrm b/buildres/linux/postrm index 740a023ade2..5708fd243d9 100644 --- a/buildres/linux/postrm +++ b/buildres/linux/postrm @@ -19,17 +19,17 @@ set -e case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - # Remove the native-messaging hosts script only if relative to the deb package - for NATIVE_MESSAGING_JSON in "/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json"\ + # Remove the native-messaging hosts script only if relative to the deb package + for NATIVE_MESSAGING_JSON in "/usr/lib/mozilla/native-messaging-hosts/org.jabref.jabref.json"\ "/etc/chromium/native-messaging-hosts/org.jabref.jabref.json"\ "/etc/opt/chrome/native-messaging-hosts/org.jabref.jabref.json"; do - if [ -e $NATIVE_MESSAGING_JSON ] && grep --quiet '"path": "/opt' $NATIVE_MESSAGING_JSON; then - rm $NATIVE_MESSAGING_JSON - fi - done - # Remove the auto-install triggers of the browser addon for chrom/chromium - rm /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json - rm /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + if [ -e $NATIVE_MESSAGING_JSON ] && grep --quiet '"path": "/opt' $NATIVE_MESSAGING_JSON; then + rm $NATIVE_MESSAGING_JSON + fi + done + # Remove the auto-install triggers of the browser addon for chrom/chromium + rm /opt/google/chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json + rm /usr/share/google-chrome/extensions/bifehkofibaamoeaopjglfkddgkijdlh.json ;; *) From 1a546922787160ed447d3a6f63f068916e17e225 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 3 Jun 2020 09:09:04 +0200 Subject: [PATCH 13/23] Fix mac postinst to use -d option --- buildres/mac/postinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 4e4f5049dc1..5d24df360f5 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -4,6 +4,6 @@ chown root:wheel "INSTALL_LOCATION" chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers -install -D -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +install -d -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json exit 0 From e9c0d55e4af153104835a29c462c2d2f0cdffee2 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Mon, 15 Jun 2020 12:00:11 +0200 Subject: [PATCH 14/23] Add custom host file for macos Add hardcoded path Add failure error on mac/linux --- buildres/linux/jabrefHost.py | 13 +++-- buildres/mac/jabrefHost.py | 100 +++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 4 deletions(-) create mode 100755 buildres/mac/jabrefHost.py diff --git a/buildres/linux/jabrefHost.py b/buildres/linux/jabrefHost.py index 3c56a0a73e9..e1343e23207 100755 --- a/buildres/linux/jabrefHost.py +++ b/buildres/linux/jabrefHost.py @@ -5,12 +5,13 @@ # than text, mode. import json -import sys -import struct -import subprocess -import shlex import logging +import platform +import shlex import shutil +import struct +import subprocess +import sys from pathlib import Path # We assume that this python script is located in "jabref/lib" while the executable is "jabref/bin/JabRef" @@ -19,6 +20,10 @@ if not JABREF_PATH.exists(): JABREF_PATH = shutil.which("jabref") +if not JABREF_PATH.exists(): + logging.error("Could not determine JABREF_PATH") + sys.exit(-1) + logging_dir = Path.home() / ".mozilla/native-messaging-hosts/" if not logging_dir.exists(): logging_dir.mkdir(parents=True) diff --git a/buildres/mac/jabrefHost.py b/buildres/mac/jabrefHost.py new file mode 100755 index 00000000000..ea64ccdf77d --- /dev/null +++ b/buildres/mac/jabrefHost.py @@ -0,0 +1,100 @@ +#!/usr/bin/python3 -u + +# Note that running python with the `-u` flag is required on Windows, +# in order to ensure that stdin and stdout are opened in binary, rather +# than text, mode. + +import json +import logging +import platform +import shlex +import shutil +import struct +import subprocess +import sys +from pathlib import Path + +# We assume that this python script is located in "jabref/lib" while the executable is "jabref/bin/JabRef" +# Note that the `which` command does not work as intended on MacOs, so the path must be hardcoded. +script_dir = Path(__file__).resolve().parent.parent +JABREF_PATH = script_dir / "bin/JabRef" +if not JABREF_PATH.exists(): + JABREF_PATH = Path( "/Applications/JabRef.app/Contents/MacOS/JabRef") + +if not JABREF_PATH.exists(): + logging.error("Could not determine JABREF_PATH") + sys.exit(-1) + +logging_dir = Path.home() / ".mozilla/native-messaging-hosts/" +if not logging_dir.exists(): + logging_dir.mkdir(parents=True) +logging.basicConfig(filename=str(logging_dir / "jabref_browser_extension.log")) + +# Read a message from stdin and decode it. +def get_message(): + raw_length = sys.stdin.buffer.read(4) + if not raw_length: + logging.error("Raw_length null") + sys.exit(0) + message_length = struct.unpack("=I", raw_length)[0] + logging.info("Got length: {} bytes to be read".format(message_length)) + message = sys.stdin.buffer.read(message_length).decode("utf-8") + logging.info("Got message of {} chars".format(len(message))) + data = json.loads(message) + logging.info("Successfully retrieved JSON") + return data + + +# Encode a message for transmission, given its content. +def encode_message(message_content): + encoded_content = json.dumps(message_content).encode("utf-8") + encoded_length = struct.pack("=I", len(encoded_content)) + return { + "length": encoded_length, + "content": struct.pack(str(len(encoded_content)) + "s", encoded_content), + } + + +# Send an encoded message to stdout. +def send_message(message): + encoded_message = encode_message(message) + sys.stdout.buffer.write(encoded_message["length"]) + sys.stdout.buffer.write(encoded_message["content"]) + sys.stdout.buffer.flush() + + +def add_jabref_entry(data): + """Send string via cli as literal to preserve special characters""" + cmd = [str(JABREF_PATH), "--importBibtex", r"{}".format(data)] + logging.info("Try to execute command {}".format(cmd)) + try: + response = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as exc: + logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output)) + else: + logging.info("Called JabRef and got: {}".format(response)) + return response + + +logging.info("Starting JabRef backend") + +try: + message = get_message() +except Exception as e: + message = str(e) +logging.info(str(message)) + +if "status" in message and message["status"] == "validate": + cmd = [JABREF_PATH, "--version"] + try: + response = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as exc: + logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output)) + send_message({"message": "jarNotFound", "path": JABREF_PATH}) + else: + logging.info("Response: {}".format(response)) + send_message({"message": "jarFound"}) +else: + entry = message["text"] + output = add_jabref_entry(entry) + send_message({"message": "ok", "output": str(output)}) From 9f1bc8bc43df8bd34435aefdcf2bc7a24342b035 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Mon, 15 Jun 2020 12:01:07 +0200 Subject: [PATCH 15/23] Add path to macos native messaging host files --- .../mac/native-messaging-host/chromium/org.jabref.jabref.json | 2 +- .../mac/native-messaging-host/firefox/org.jabref.jabref.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json b/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json index 6283016eafe..84ce13113d7 100644 --- a/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json +++ b/buildres/mac/native-messaging-host/chromium/org.jabref.jabref.json @@ -1,7 +1,7 @@ { "name": "org.jabref.jabref", "description": "JabRef", - "path": "/opt/jabref/lib/jabrefHost.py", + "path": "/Applications/JabRef.app/Contents/Resources/jabrefHost.py", "type": "stdio", "allowed_origins": [ "chrome-extension://bifehkofibaamoeaopjglfkddgkijdlh/" diff --git a/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json b/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json index 1edebc9c576..df296d37c84 100644 --- a/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json +++ b/buildres/mac/native-messaging-host/firefox/org.jabref.jabref.json @@ -1,7 +1,7 @@ { "name": "org.jabref.jabref", "description": "JabRef", - "path": "/opt/jabref/lib/jabrefHost.py", + "path": "/Applications/JabRef.app/Contents/Resources/jabrefHost.py", "type": "stdio", "allowed_extensions": [ "browserextension@jabref.org", From 06f487c0ed5eaa273890389b1bd916cfb92d55d3 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 17 Jun 2020 10:14:40 +0200 Subject: [PATCH 16/23] Remove binary mode in python script --- buildres/mac/jabrefHost.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/buildres/mac/jabrefHost.py b/buildres/mac/jabrefHost.py index ea64ccdf77d..51727f9d81c 100755 --- a/buildres/mac/jabrefHost.py +++ b/buildres/mac/jabrefHost.py @@ -1,8 +1,4 @@ -#!/usr/bin/python3 -u - -# Note that running python with the `-u` flag is required on Windows, -# in order to ensure that stdin and stdout are opened in binary, rather -# than text, mode. +#!/usr/bin/python3 import json import logging From c7df1df349046cb52367a307d1590e47312d8277 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 17 Jun 2020 15:41:19 +0200 Subject: [PATCH 17/23] create the dir before copying file --- buildres/mac/postinstall | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 5d24df360f5..79a87841285 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -4,6 +4,7 @@ chown root:wheel "INSTALL_LOCATION" chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers -install -d -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +install -d /Library/Application\ Support/Google/Chrome/External\ Extensions/ +install -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json exit 0 From ba6ae485d441d53a17353619c19cb9f13ff06b16 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 17 Jun 2020 16:18:04 +0200 Subject: [PATCH 18/23] Add mac native-messaging json to postinst --- buildres/mac/postinstall | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 79a87841285..134918c059c 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -4,7 +4,15 @@ chown root:wheel "INSTALL_LOCATION" chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers +# First create the necessary path, then copy the autoinstall file. install -d /Library/Application\ Support/Google/Chrome/External\ Extensions/ install -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +# Install the native-messaging host script for firefox/chrome/chromium +install -d /Library/Application Support/Mozilla/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json +install -d /Library/Application Support/Chromium/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json +install -d /Library/Google/Chrome/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json exit 0 From a7eaf2d3c68d7cb81c76ef3b1ff984d65b5fe44a Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Mon, 27 Jul 2020 16:02:11 +0200 Subject: [PATCH 19/23] Try mkdir/cp to add files to macos pkg --- buildres/mac/postinstall | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 134918c059c..9be93ce74e9 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -5,14 +5,14 @@ chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers # First create the necessary path, then copy the autoinstall file. -install -d /Library/Application\ Support/Google/Chrome/External\ Extensions/ -install -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +mkdir /Library/Application Support/Google/Chrome/External Extensions/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json # Install the native-messaging host script for firefox/chrome/chromium -install -d /Library/Application Support/Mozilla/NativeMessagingHosts/ -install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json -install -d /Library/Application Support/Chromium/NativeMessagingHosts/ -install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json -install -d /Library/Google/Chrome/NativeMessagingHosts/ -install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json +mkdir /Library/Application Support/Mozilla/NativeMessagingHosts/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json +mkdir /Library/Application Support/Chromium/NativeMessagingHosts/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json +mkdir /Library/Google/Chrome/NativeMessagingHosts/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json exit 0 From 1b170499d333511b7c9a040791c1d90c0cec1bf4 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Tue, 28 Jul 2020 11:33:55 +0200 Subject: [PATCH 20/23] Fix path spaces --- buildres/mac/postinstall | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 9be93ce74e9..beea0b5b57c 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -5,13 +5,13 @@ chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers # First create the necessary path, then copy the autoinstall file. -mkdir /Library/Application Support/Google/Chrome/External Extensions/ +mkdir /Library/Application\ Support/Google/Chrome/External Extensions/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json # Install the native-messaging host script for firefox/chrome/chromium -mkdir /Library/Application Support/Mozilla/NativeMessagingHosts/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json -mkdir /Library/Application Support/Chromium/NativeMessagingHosts/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json +mkdir /Library/Application\ Support/Mozilla/NativeMessagingHosts/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application\ Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json +mkdir /Library/Application\ Support/Chromium/NativeMessagingHosts/ +cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application\ Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json mkdir /Library/Google/Chrome/NativeMessagingHosts/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json From ecec70517e2e362298bbda11b16fba351b33bdf8 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Tue, 28 Jul 2020 18:13:21 +0200 Subject: [PATCH 21/23] Add -p option to mkdir parents --- buildres/mac/postinstall | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index beea0b5b57c..be2d108ada5 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -5,14 +5,14 @@ chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers # First create the necessary path, then copy the autoinstall file. -mkdir /Library/Application\ Support/Google/Chrome/External Extensions/ +mkdir -p /Library/Application\ Support/Google/Chrome/External\ Extensions/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json # Install the native-messaging host script for firefox/chrome/chromium -mkdir /Library/Application\ Support/Mozilla/NativeMessagingHosts/ +mkdir -p /Library/Application\ Support/Mozilla/NativeMessagingHosts/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application\ Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json -mkdir /Library/Application\ Support/Chromium/NativeMessagingHosts/ +mkdir -p /Library/Application\ Support/Chromium/NativeMessagingHosts/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application\ Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json -mkdir /Library/Google/Chrome/NativeMessagingHosts/ +mkdir -p /Library/Google/Chrome/NativeMessagingHosts/ cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json exit 0 From 378008a68a14bcecd86581bdc21935338bec6212 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Tue, 4 Aug 2020 18:29:16 +0200 Subject: [PATCH 22/23] postinstall macos force /bin/sh --- buildres/mac/postinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index be2d108ada5..95f5a0644dd 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/sh chown root:wheel "INSTALL_LOCATION" chmod a+rX "INSTALL_LOCATION" From 42bef18a85e3c8aad9e07251dd6d3f3a241ec741 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Wed, 5 Aug 2020 08:31:15 +0200 Subject: [PATCH 23/23] revert to using install on macos --- buildres/mac/postinstall | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildres/mac/postinstall b/buildres/mac/postinstall index 95f5a0644dd..235feb0ca5e 100755 --- a/buildres/mac/postinstall +++ b/buildres/mac/postinstall @@ -5,14 +5,14 @@ chmod a+rX "INSTALL_LOCATION" chmod +r "APP_LOCATION/"*.jar # Trigger an auto-install of the browser addon for chrome/chromium browsers # First create the necessary path, then copy the autoinstall file. -mkdir -p /Library/Application\ Support/Google/Chrome/External\ Extensions/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json +install -d /Library/Application\ Support/Google/Chrome/External\ Extensions/ +install -m0644 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/bifehkofibaamoeaopjglfkddgkijdlh.json /Library/Application\ Support/Google/Chrome/External\ Extensions/bifehkofibaamoeaopjglfkddgkijdlh.json # Install the native-messaging host script for firefox/chrome/chromium -mkdir -p /Library/Application\ Support/Mozilla/NativeMessagingHosts/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application\ Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json -mkdir -p /Library/Application\ Support/Chromium/NativeMessagingHosts/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application\ Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json -mkdir -p /Library/Google/Chrome/NativeMessagingHosts/ -cp /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json +install -d /Library/Application\ Support/Mozilla/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/firefox/org.jabref.jabref.json /Library/Application\ Support/Mozilla/NativeMessagingHosts/org.jabref.jabref.json +install -d /Library/Application\ Support/Chromium/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Application\ Support/Chromium/NativeMessagingHosts/org.jabref.jabref.json +install -d /Library/Google/Chrome/NativeMessagingHosts/ +install -m0755 /Applications/JabRef.app/Contents/Resources/native-messaging-host/chromium/org.jabref.jabref.json /Library/Google/Chrome/NativeMessagingHosts/org.jabref.jabref.json exit 0