openhab / openhab-syno-spk

openHAB Synology SPK Install Package
Eclipse Public License 2.0
161 stars 42 forks source link

New generation packaging files #181

Closed thopiekar closed 2 years ago

thopiekar commented 3 years ago

TODOs:

Instructions as included in this PR itself: https://github.com/thopiekar/openhab-syno-spk/blob/master-new-generation-packaging-files/README.md

This change is Reviewable

thopiekar commented 3 years ago

Two points left in my to-do list. Regarding the icon, this is how it looks like now: image

thopiekar commented 3 years ago

I'm done but the documentation. Also, not manage to get all done I want, but finished up all possible. Packages for testing are available her: https://dl.thopiekar.eu/openhab/

ekkards commented 3 years ago

tried openHAB-3.0.0-syno-noarch-0.0.1.spk on my

Not sure, whether you intended this version for this test, and I did not find anything about in the updated documentation, so here are my 2 observations:

  1. Version number checks: I had previously installed openHAB spk from the released 3.0.0-SNAPSHOT (which did not work for me). Upon install with the 0.0.1 package I got the message "Current package version is 3.0.0.000-SNAPSHOT. You cannot downgrade it to the older version 2.5.10.000". Note that I was attempting to install 3.0.0.

  2. DSM version: Removed the previously installed OpenHAB package and tried the install again. The install exited with message "This package requires DSM version 7.0-40000 or onward". Yes, I have DSM 6, but I was expecting that the new package would solve the issues with the older package. Does the new version replace the older version, or is it only for DSM 7?

Not sure, whether this helps, but this is the best I can do...

thopiekar commented 3 years ago

@sventippelt: Saw your reaction on my post. Can you give some feedback? Did you try the installation?

@ekkards: That's correct. The new packaging files are not compatible with the old ones. I had to rewrite the scripts to make it compatible with the latest conventions set by Synology. That is basically the prohibition of using any "root" rights. In my point of view something that is overdue in the 21th century. Just imagine a typo somewhere in a "rm" command and all files are gone. No RAID will save your life. For the system it is the clear instruction to wipe everything.

The work here as nothing to do with the SPK files (old packaging) you can find in the "tags" section of the project page. And yes, the SPK files I offer on my URL for testing are made for DSM 7 only until I find a brave tester for DSM 6.x. I followed Synology's latest developer manual and there are some sections in the document marked as "new". However, they don't explicitly state since (eg. the start-stop mechanism of services) if newly introduced - DSM 7 only? DSM 6, too? That's why I can't be sure about how it will work on DSM 6.x and therefore don't give support for it.

If you or someone else is interested in testing and providing log files, so I can verify, I'll enable compatibility for DSM 6 series, too.

Hope that answers your and the others questions on this PR.

IF YOU INSTALL OPENHAB USING THE SPKs HERE, PLEASE LEAVE FEEDBACK - GOOD OR BAD. THANKS!

sventippelt commented 3 years ago

@thopiekar Hi, yes tried it on my 218+ with the new synology 7 beta, but didn't worked. Just didn't had a look at the errors and just wanted to wait until the rtm from synology. If you want some logs, just contact me.

Gemikro1 commented 3 years ago

@thopiekar Hi, i tried openHAB-3.0.0-syno-noarch-0.0.1.spk on my DS418 (RTD1296, DSM 6.2.3).

OpenJDK 11.0.9.1_1 was installed already and i confirmed it to run correctly with openHAB-2.5.2.000-syno-noarch-0.001.spk.

After deinstalling 2.5.2 i modified the INFO file in your package to be able to install on DSM 6.2.3 and started the install. The package content was transfered to the /var/packages/openHAB folder and seems to be Ok but installation was ended with the error "Please re-install the package because something went wrong".

The openhab user also seems to have been created successfully. I can start openHAB with the start.sh script and then log into the web interface. This seems to be a minor problem in the installer script but I could not locate a log file to investigate anywhere.

Logfile content:

2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin preinst + exit 0 2021/02/19 17:50:15 install openHAB 3.0.0.000 End preinst ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/rm -rf /volume1/@appstore/openHAB 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/rm -rf /volume1/@appstore/openHAB ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mv -f /volume1/@tmp/pkginstall/package /volume1/@appstore/openHAB 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mv -f /volume1/@tmp/pkginstall/package /volume1/@appstore/openHAB ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/rm -rf /var/packages/openHAB 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/rm -rf /var/packages/openHAB ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mkdir -p /var/packages/openHAB 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mkdir -p /var/packages/openHAB ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mv -f /volume1/@tmp/pkginstall/INFO /var/packages/openHAB/INFO 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mv -f /volume1/@tmp/pkginstall/INFO /var/packages/openHAB/INFO ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/rm -rf /var/packages/openHAB/scripts 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/rm -rf /var/packages/openHAB/scripts ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mv -f /volume1/@tmp/pkginstall/scripts /var/packages/openHAB/scripts 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mv -f /volume1/@tmp/pkginstall/scripts /var/packages/openHAB/scripts ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/rm -rf /var/packages/openHAB/WIZARD_UIFILES 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/rm -rf /var/packages/openHAB/WIZARD_UIFILES ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mv -f /volume1/@tmp/pkginstall/WIZARD_UIFILES /var/packages/openHAB/WIZARD_UIFILES 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mv -f /volume1/@tmp/pkginstall/WIZARD_UIFILES /var/packages/openHAB/WIZARD_UIFILES ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/rm -rf /var/packages/openHAB/conf 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/rm -rf /var/packages/openHAB/conf ret=[0] 2021/02/19 17:50:15 install openHAB 3.0.0.000 Begin /bin/mv -f /volume1/@tmp/pkginstall/conf /var/packages/openHAB/conf 2021/02/19 17:50:15 install openHAB 3.0.0.000 End /bin/mv -f /volume1/@tmp/pkginstall/conf /var/packages/openHAB/conf >ret=[0] 2021/02/19 17:50:20 install openHAB 3.0.0.000 Begin postinst ++ dirname /var/packages/openHAB/scripts/postinst + source /var/packages/openHAB/scripts/common-vars.sh ++ SHARE_OPENHAB=/var/packages/openHAB/shares/openHAB ++ SHARE_OPENHAB_BACKUP=/var/packages/openHAB/shares/openHAB/backup ++ PKGDEST_OPENHAB=/volume1/@appstore/openHAB/openHAB ++ SYNOPKG_PKGDEST_OPENHAB_ENV=/volume1/@appstore/openHAB/openHAB.env + echo 'OPENHAB_HTTP_ADDRESS="0.0.0.0"' + echo 'OPENHAB_HTTP_PORT="8180"' + echo 'OPENHAB_HTTPS_PORT="8443"' + echo 'ORG_APACHE_KARAF_STARTREMOTESHELL="true"' + echo 'ORG_APACHE_KARAF_SHELL_SSHHOST="0.0.0.0"' + echo 'ORG_APACHE_KARAF_SHELL_SSHPORT="8101"' + echo 'EXTRA_JAVA_OPTS=""' /var/packages/openHAB/scripts/postinst: line 23: SYNOPKG_PKGVAR: unbound variable 2021/02/19 17:50:20 install openHAB 3.0.0.000 End postinst ret=[1] 2021/02/19 17:50:20 install openHAB 3.0.0.000 Begin /bin/rm -rf /volume1/@tmp/pkginstall 2021/02/19 17:50:20 install openHAB 3.0.0.000 End /bin/rm -rf /volume1/@tmp/pkginstall ret=[0] 2021/02/19 17:51:29 upgrade openHAB 3.0.0.000 Begin preupgrade ++ dirname /volume1/@tmp/pkginstall/scripts/preupgrade + source /volume1/@tmp/pkginstall/scripts/common-vars.sh ++ SHARE_OPENHAB=/var/packages/openHAB/shares/openHAB ++ SHARE_OPENHAB_BACKUP=/var/packages/openHAB/shares/openHAB/backup ++ PKGDEST_OPENHAB=/volume1/@appstore/openHAB/openHAB ++ SYNOPKG_PKGDEST_OPENHAB_ENV=/volume1/@appstore/openHAB/openHAB.env /volume1/@tmp/pkginstall/scripts/preupgrade: line 15: SYNOPKG_PKGVAR: unbound variable 2021/02/19 17:51:29 upgrade openHAB 3.0.0.000 End preupgrade ret=[1] 2021/02/19 17:51:29 upgrade openHAB 3.0.0.000 Begin /bin/rm -rf /volume1/@tmp/pkginstall 2021/02/19 17:51:29 upgrade openHAB 3.0.0.000 End /bin/rm -rf /volume1/@tmp/pkginstall ret=[0]

Gemikro1 commented 3 years ago

@thopiekar I had some time to look at the install and start-stop-status scripts. There seems to be an issue with the common-vars.sh script. In my case openHAB was installed in /volume1/@appstore/openHAB/openHAB/ and not /volume1/@appstore/openHAB/ due to the line

other shortcuts
PKGDEST_OPENHAB=${SYNOPKG_PKGDEST}/openHAB

Was this done on purpose ?

thopiekar commented 3 years ago

Yes, I want to keep everything separated. So within the first openHAB directory (which is the main folder of the synology app) your have the second openHAB directory which has the exact content of the official distribution.

thopiekar commented 3 years ago

Regarding your DSM 6 experiments: what is the exact version string you've used? πŸ™‚

Will investigate later into your log. Looks like a variable is misspelled or I've missed to include the common script there.

Thank you the the review πŸ‘

Gemikro1 commented 3 years ago

@thopiekar I modified the INFO file to this:

package="openHAB"
version="3.0.0.000"
maintainer="openHAB.org"
maintainer_url="http://openhab.org/"
distributor="cniweb, tim, dieter, dominic, schoppax"
description="The open Home Automation Bus (openHAB) project aims at providing a universal integration platform for all things around home automation. During the installation you can choose a shared folder for configuration, addons and userdata."
arch="noarch"
firmware="4.0-0001"
dsmuidir="ui"
dsmappname="SYNO.SDS.OH2.Instance"
adminurl="/start/index"
adminport="8080"
helpurl="https://community.openhab.org/"
package_icon="PACKAGE_ICON.PNG"
package_icon_120="PACKAGE_ICON_120.PNG"
startable="yes

The installer seems to pretty much get everything installed. As i mentioned, openHAB starts perfectly from the command line. I could not start the daemon via the DSM though, all tests were done either as root or user. The openHAB daemon user has been created successfully.

I have not installed Zulu as recommended but openJDK 11 which seems to have a small problem with TLS. Currently i am using some Tasmota devices compiled with TLS and Server Fingerprinting, connecting to the Mosquitto broker running on the Synology which works quite well.

There is an issue though with openHAB: after a restart i have to delete the fingerprints from the settings an connect again to the Mosquitto broker. If i do not delete the fingerprints i receive a Java Error:

java.security.NoSuchAlgorithmException: Algorithm is missing

which maby is due to something missing in the TLS implementation of openJDK.

Gemikro1 commented 3 years ago

The problem with the postinst, postuninst, preupgrade and postupgrade scripts is the usage of SYNOPKG_PKGVAR which seems not to exist in the DSM6 install process. To make them DSM6 compatible would require a test if SYNOPKG_PKGVAR is defined at the begin of the scripts and if not set it to a DSM6 compatible directory.

Gemikro1 commented 3 years ago

Another problem ist in the karaf-service.sh: JAVA_HOME="${SYNOPKG_PKGDEST}/OpenJDK_$(uname -m)" does not always point to one of the provided Java Versions, as the architecture in my case is aarch64. I also had Java11 already installed in a different location so the script should check if JAVA_HOME is already set.

thopiekar commented 3 years ago

Ok, so it is not absolutely bug-free for DSM6 as I expected. I've added the missing Java runtime for aarch64. The updated SPKs can be found by the same link above.

But for the DSM6 problems, I definitely need a DSM6 installation or a VM. I remember that there was a possibility to run a DSM of choice in the VM Manager of a DSM. As far as I heard Synology removed this feature, isn't it?

thopiekar commented 3 years ago

Oh, and looks like you are right: image

I'm wondering how to make a compatibility layer here between both DSMs :thinking:

Gemikro1 commented 3 years ago

I would check if SYNOPKG_PKGVAR is set and if not just set it to the desired value. I now can start and stop openHAB from the Package Manager. The changes i made where the following:

I updated the openHAB core to 3.01 (seems to run better) and changed the owner of all content to openHAB:openHAB. Previously these were owned by root so openHAB could not write any log files and correctly start Karaf service. I had to delete the lock file in the /var/packages/openHAB folder which enables package manager to accept the package as installed. Then the manager could start and stop openHAB without any problems. Also the log files and pid files are written correctly.

Gemikro1 commented 3 years ago

If you have a test version ready i can try it on my two systems, one DS418 and one DS414j, they have different architecture (rtd1296 and comcerto2k). The issue with DSM in a VM is that not all Synology versions have support for VM: https://www.synology.com/en-us/dsm/packages/Virtualization, neither of mine does support it.

Unfortunately I also could not yet get rid of the java algorithm error by using Zulu11 instead of openJDK11.

thopiekar commented 3 years ago

I'm going to take a look into this. I agree there must be an elegant way to work around this missing variable.

thopiekar commented 3 years ago

I think one thing to take a look at is to make the scripts independent of SYNOPKG_PKGVAR. At least this the only showstopper to make it backwards compatible with DSM6 series.

cniweb commented 3 years ago

No idea, unfortunately I don't have a DSM 7 (both of my disk stations are too old)...

Toover commented 3 years ago

What's next? Why wouldn't that be merged?

cbandera commented 3 years ago

No idea, unfortunately I don't have a DSM 7 (both of my disk stations are too old)...

I have installed it on my DS218+ running DSM7.0 and the installation worked fine as far as I can tell πŸ‘

cniweb commented 2 years ago

What's next? Why wouldn't that be merged?

This branch has conflicts that must be resolved

thopiekar commented 2 years ago

Wanted to rebase the branch and resolve the conflicts. Somehow managed to the the PR closed this way and can't reopen it anymore. Continuing here: #196