java-installer icon indicating copy to clipboard operation
java-installer copied to clipboard

Breaks other packages

Open neutron666 opened this issue 10 years ago • 9 comments

Hi,

I'm a packager of another synology app and your java installer, which you force to install while installing filebot 4.7, is breaking other packages. it is NOT checking if there is already a java version installed and overwrites existing "JAVA_HOME" variables, which is the part which is breaking my app in this case. I'm sure it also breaking a lot of other apps, because of this i'm asking you kindly to make a check and/or do not overwrite variables. Also people already having java 8 should be perfectly ok using filebot 4.7 with their installation, no need to have this as a dependency, i guess.

neutron666 avatar May 04 '16 19:05 neutron666

Well, wouldn't the new JAVA_HOME work perfectly fine as well? Why is it not working? Do you need a specific older version of Java?

The oracle-java dependencies have been added because of n00b users that fail to read the manual (which is everyone).

If somehow java-installer sets a new (but broken) JAVA_HOME (might happen on ppc and armv5?) that should be fixed, otherwise it's won't fix.

Dependencies are resolved by DSM. Sadly, optional / recommended dependencies are not supported. The only thing this installer could do, is not do anything on install, but that seems like a pretty stupid hack.

PS: so which packages specifically are broken?

rednoah avatar May 05 '16 05:05 rednoah

As i said, you are setting a JAVA_HOME in /etc/profile without checking if there's already a JAVA_HOME set. The result is there are two JAVA_HOME variables which mostly breaks any other App which already is using Java and was/is installed on the diskstation. It's 5 lines Bash to check and react on this, so I kindly ask to implement such a check. It's not only my App, there are plenty of it which might break. I already have a dozen of Users complaining.

neutron666 avatar May 05 '16 05:05 neutron666

Yeah, but what's to say my app doesn't break with your JAVA_HOME then? Why is your app not working with the latest Java 8 runtime? Java is extremely backwards compatible. I don't understand how your app could have any issues with the latest official Java runtime. If anything, it should work better.

  • Which app are you referring to? Is it open source so I can have a look?
  • Are there forum threads where these users are complaining that you could link here?

I understand your workaround, but it'd like to first understand the problem, before doing anything about it.

rednoah avatar May 05 '16 05:05 rednoah

Little misunderstanding. The app works perfectly well with java 8 or java 7, because of this i'm trying to find the path to the installed java binary, which now results in 2 paths, so the start-stop-status script doesn't work anymore.

At the moment i'm doing this:

JAVA_HOME=$(cat /etc/profile|awk '/JAVA_HOME=/ { print $1 }'|tail -c +11)

which results in a complete desaster.

I also could do

JAVA_HOME=$(cat /etc/profile|awk '/JAVA_HOME=/'|cut -d = -f 2|cut -d "#" -f 1)

which results into 2 lines of different paths for java, yours and the one already installed, which is a problem.

The package we are talking about is JDownloader 2 for the diskstation. You can grab the package with your synology package manager at https://spk.netzbaer.de

User's complaining can be found here (german):

http://www.synology-forum.de/showthread.html?68134-JDownloader-2-%28noarch%29-Paketzentrum/page137

If you have a more intelligent way to detect the java path, i'm open to suggestions.

neutron666 avatar May 05 '16 07:05 neutron666

Wouldn't it be easier to source /etc/profile and then check if JAVA_HOME is defined? http://superuser.com/a/46146/349721

Reading the /etc/profile shell script and trying to parse environment variables seem like a really horrible hack to me... it'll utterly fail on completely valid bash code like this: ABC=/home; JAVA_HOME=$ABC; CLASSPATH=$ABC

This is definitely an issue that should be fixed in your code. Actually, I don't even think you need that at all since /etc/profile is sourced by default, even when using DSM Scheduler or cron. But if you need to source it yourself for some reason, you should use source or . and not some crazy awk-on-shell-code construct.

rednoah avatar May 05 '16 10:05 rednoah

FYI: not cool, if you're not gonna verify hashes, the least you could do is use HTTPS (although that would be useless because of --no-check-certificate from a security point of view):

wget --no-check-certificate http://installer.jdownloader.org/JDownloader.jar

Please Read: https://en.wikipedia.org/wiki/Man-in-the-middle_attack

rednoah avatar May 05 '16 11:05 rednoah

Regardless of the fact that you think this is a horrible hack, sourcing works for the shell, but will fail in the DS package center, i already tried that. Whatever, i will try to work around that issue, let's see. Still, installing "another" java version and overwriting variables isn't correct either. The side effect, not talking about my package only, is that other apps maybe fail with your version and/or have other problems.

FYI: As i said, i'm only the packager, not the developer of JDownloader, there is no HTTPS source to download JDownloader.jar, not my fault, sorry.

neutron666 avatar May 06 '16 05:05 neutron666

Are you sure?

cat /var/packages/Node.js_v4/scripts/start-stop-status | head -n 3
#!/bin/sh
# Copyright (C) 2000-2015 Synology Inc. All rights reserved.
. `dirname $0`/common

'cause it sure looks like it's working just fine for Synology.

This package DOES NOT mess with /etc/profile, it merely APPENDS lines at the end, which is how it's done since the beginning of (Unix) time. Personally, I'd prefer the more modern /etc/profile.d approach of adding to the profile, but Synology doesn't support that right now.

This package uses known SHA-256 hashes to verify the integrity of files downloaded via HTTP. Depending on how often JDownloader.jar is updated, this may not be a convenient option for you.

rednoah avatar May 06 '16 07:05 rednoah

Doing this at the beginning of your start-stop-status script (called by DSM) works just fine:

source /etc/profile
printenv > /tmp/env.txt
SYNOPKG_DSM_LANGUAGE=def
HTTP_X_REQUESTED_WITH=XMLHttpRequest
ENABLE_X_ACCEL_REDIRECT=yes
HTTP_CONTENT_LENGTH=501
TERM=linux
SYNOPKG_DSM_ARCH=armada370
HTTP_USER_AGENT=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
HTTP_ORIGIN=http://10.0.1.5:5000
HTTP_HOST=10.0.1.5:5000
SERVER_PORT=5000
ANT_HOME=/usr/local/ant
LC_ALL=en_US.utf8
SCGI=1
DOCUMENT_ROOT=/usr/syno/synoman
SCRIPT_FILENAME=/usr/syno/synoman/webapi/entry.cgi
REQUEST_URI=/webapi/entry.cgi
SCRIPT_NAME=/webapi/entry.cgi
USERNAME=admin
PAGER=more
HTTP_CONNECTION=keep-alive
PATH_INFO=
REMOTE_PORT=51995
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
JOB=apparmor
PWD=/usr/syno/synoman/webapi
JAVA_HOME=/usr/local/java
APPARMOR_HAT_ARRAY=["DefaultHat"]
LANG=en_US.utf8
SYNO_WEBAPI_USERNAME=admin
SYNOPKG_PKGDEST=/volume1/@appstore/filebot-node
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,de;q=0.2,ja;q=0.2
SYNOPKG_PKGVER=0.2.0
HTTP_REFERER=http://10.0.1.5:5000/index.cgi
SYNOPKG_DSM_VERSION_MINOR=0
HTTP_DNT=1
HTTP_ACCEPT=*/*
REMOTE_ADDR=10.0.1.2
DOCUMENT_URI=/webapi/entry.cgi
HTTP_CONTENT_TYPE=application/x-www-form-urlencoded; charset=UTF-8
SERVER_NAME=10.0.1.5
SHLVL=1
TERMINFO=/usr/share/terminfo
CONTENT_LENGTH=501
SYNOPKG_DSM_VERSION_BUILD=7321
UPSTART_INSTANCE=
SYNOPKG_PKGNAME=filebot-node
SERVER_SOFTWARE=nginx/1.9.11
SOCKET=/run/synoscgi.sock
UPSTART_EVENTS=syno.network.ready started
QUERY_STRING=
GATEWAY_INTERFACE=CGI/1.1
PGDATA=/var/services/pgsql
SYNOPKG_DSM_VERSION_MAJOR=6
SYNOPKG_PKGDEST_VOL=/volume1
SERVER_PROTOCOL=HTTP/1.1
HTTP_ACCEPT_ENCODING=gzip, deflate
INSTANCE=
UPSTART_JOB=synoscgi
CONTENT_TYPE=application/x-www-form-urlencoded; charset=UTF-8
REQUEST_METHOD=POST
_=/bin/printenv

rednoah avatar May 06 '16 08:05 rednoah