HomeAssistant Core Cross Compile for Synology

Tags: #<Tag:0x00007f738781b210>

The SynoCommunity has released a current version of HomeAssistant Core for Synology. Yves Martin put together a framework that seems to allow any version of HomeAssistant to be compiled into a .spk file ready to install on a Synology SAN server. HomeAssistant Core makes sense for folks with Synology SAN Servers that are not capable of running Docker or who don’t wish to run Docker on a San Server.

The SynoCommunity does not put out updates to packages at the same frequency as the HomeAssistant developers. Currently the HomeAssistant 0.114.2 package is available. My goal was to find a way to create an installable .spkr file at any level I desire. Further I can pick what Python modules my system needs as compiled wheels.
FAQ-HomeAssistant

I did some testing with 0.114.4 and 0.115.0b8. HomeAssistant worked as a proof of concept. There certainly is no need to install every minor version if things are working well, but compiling will allow the user to pick their version of choice on the Synology.

I decided to use the Docker version of spksrc cross compilation framework to compile and package software for Synology NAS devices.

For more spksrc details see:
spksrc cross compilation framework
spksrc Developers-HOW-TO Wiki

First get the current source files:
git clone https://github.com/SynoCommunity/spksrc.git

Update Homeassistant version and wheel components:
vi spksrc/spk/homeassistant/src/requirements.txt
Update version to match version selected in requirements.txt:
vi spksrc/spk/homeassistant/Makefile

Linux Docker:

docker run -it --rm -v ~/spksrc:/spksrc -w /spksrc synocommunity/spksrc:latest /bin/bash 

make setup
cd spk/homeassistant
make arch-armadaxp

The make setup defaults to DSM 6.1 which is a reasonable minimum level. My DS414 is an armadxp architecture. Replace armadaxp with the model for your Synology: Synology Models You can also see the list of supported architectures listed in spksrc/toolchains

If everything was successful, the package will be in spksrc/packages
Install that package on your Synology from the Package Center Manual Install button.

2 Likes

Hi,

This is promising! I’m really looking forward for it to work, since my Synology NAS is Docker incompatible.
But… for now I’m stuck on running docker command posted by you and on spksrc GIT. The output I get is as follows:

[email protected]:~ $ docker run -it -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash
standard_init_linux.go:211: exec user process caused "exec format error"

As you can see I run it on RPi. Versions are as follows:

Raspbian: Version 10 (buster) - latest
Docker  
 Engine:  Version:          19.03.13
 containerd:  Version:          1.3.7
 runc:  Version:          1.0.0-rc10
 docker-init:  Version:          0.18.0

I’m quite new to docker, so I’d be more then welcome if you could point me in the right direction with this. Tried to look for solution on stackoverflow, etc. but with no success…

SPK I’m trying to make will be for DS216play (monaco) which fortunately is listed in Synology Models and spksrc/toolchains.

Sorry - spksrc won’t work on the Pi or any ARM machine.

A virtual machine based on an 64-bit version of Debian 10 stable OS is recommended. Non-x86 architectures are not supported.
https://hub.docker.com/r/synocommunity/spksrc

OS/ARCH linux/amd64
https://hub.docker.com/layers/synocommunity/spksrc/latest/images/sha256-c81e3a176a232593044e97bf890e77ad3a2832eba5016af62fce2a2f77e8ffff?context=explore

Oh ok… that explains why it wasn’t working.
I’ll try to run it on some other machine with Debian, hopefully with more luck :wink:

Updating the requirements.txt file for each new version of Home Assistant Core was not obvious to me. There may be some ‘trial and error’ to find all the python packages needed.

To update spksrc:
cd spksrc
git pull

Many packages are commented out in the requirements.txt file. I uncomment packages that I am using which include skybell and konnected for my hardware.

In the FAQ HomeAssistant, Yves Martin suggests checking error messages about packages that need to be upgraded in /var/packages/homeassistant/target/var/homeassistant.log He also has a process to submit packages to be included in the next release. As of today, proposed changes to HomeAssistant are: https://github.com/SynoCommunity/spksrc/pull/4149/files

The requirements.txt is built from several files found in the release:
https://github.com/home-assistant/core/blob/3880ac0b0daacf8b47c2bf94fb0231d9e2de1bda/requirements.txt
https://github.com/home-assistant/core/blob/3880ac0b0daacf8b47c2bf94fb0231d9e2de1bda/homeassistant/package_constraints.txt
https://github.com/home-assistant/core/blob/3880ac0b0daacf8b47c2bf94fb0231d9e2de1bda/requirements_all.txt

To see the changes by date select History on each page. If a requirement has been updated since the file was last edited, update the package level to meet the requirements of that core level.

Ok, some progress here. Docker up and running on almost-Debian. I say “almost” because it is running as a “Linux on Windows (WSL2)” with Docker attached to it.

But back to topic - I have problem with setting up toolchain. Tried for DSM-6.1, DSM-6.2, DMS-6.2.2 and the output for all of them is exactly the same.

DSM-6.1

[email protected]:/spksrc# make setup
Setting default toolchain version to DSM-6.1
[email protected]:/spksrc# cd spk/homeassistant/
[email protected]:/spksrc/spk/homeassistant# make arch-monaco
===>  Building package for arch monaco
make[1]: Entering directory '/spksrc/spk/homeassistant'
===>  Set up toolchain
===>    Downloading files for syno-monaco
inux%203.10.102/monaco-gcc493_glibc220_hard-GPL.txz
2020-09-24 14:52:50 URL:https://master.dl.sourceforge.net/project/dsgpl/Tool%20Chain/DSM%206.1%20Tool%20Chains/STMicroelectronics%20Monaco%20Linux%203.10.102/monaco-gcc493_glibc220_hard-GPL.txz [42375044/42375044] -> "monaco-gcc493_glibc220_hard-GPL.txz.part" [2]
===>    Verifying files for syno-monaco
===>      Checking sha1sum of file monaco-gcc493_glibc220_hard-GPL.txz
sha1sum: 'standard input': no properly formatted SHA1 checksum lines found
===>        Wrong sha1sum for file monaco-gcc493_glibc220_hard-GPL.txz
===>        Renamed as monaco-gcc493_glibc220_hard-GPL.txz.wrong
===>        Download cookie removed to trigger the download again
make[2]: *** [../../mk/spksrc.checksum.mk:42: checksum_target] Error 1
/spksrc/spk/homeassistant/work-monaco-6.1/tc_vars.mk:1: *** An error occured while setting up the toolchain, please check the messages above.  Stop.
make[1]: Leaving directory '/spksrc/spk/homeassistant'
make: [../../mk/spksrc.spk.mk:436: arch-monaco] Error 2 (ignored)

DSM-6.2

[email protected]:/spksrc# make setup
Setting default toolchain version to DSM-6.2
[email protected]:/spksrc# cd spk/homeassistant/
[email protected]:/spksrc/spk/homeassistant# make arch-monaco
===>  Building package for arch monaco
make[1]: Entering directory '/spksrc/spk/homeassistant'
===>  Set up toolchain
===>    Downloading files for syno-monaco
wget https://sourceforge.net/projects/dsgpl/files/Tool%20Chain/DSM%206.2%20Tool%20Chains/STMicroelectronics%20Monaco%20Linux%203.10.102/monaco-gcc493_glibc220_hard-GPL.txz
2020-09-24 15:15:15 URL:https://master.dl.sourceforge.net/project/dsgpl/Tool%20Chain/DSM%206.2%20Tool%20Chains/STMicroelectronics%20Monaco%20Linux%203.10.102/monaco-gcc493_glibc220_hard-GPL.txz [42219044/42219044] -> "monaco-gcc493_glibc220_hard-GPL.txz.part" [2]
===>    Verifying files for syno-monaco
===>      Checking sha1sum of file monaco-gcc493_glibc220_hard-GPL.txz
sha1sum: 'standard input': no properly formatted SHA1 checksum lines found
===>        Wrong sha1sum for file monaco-gcc493_glibc220_hard-GPL.txz
===>        Renamed as monaco-gcc493_glibc220_hard-GPL.txz.wrong
===>        Download cookie removed to trigger the download again
make[2]: *** [../../mk/spksrc.checksum.mk:42: checksum_target] Error 1
/spksrc/spk/homeassistant/work-monaco-6.2/tc_vars.mk:1: *** An error occured while setting up the toolchain, please check the messages above.  Stop.
make[1]: Leaving directory '/spksrc/spk/homeassistant'
make: [../../mk/spksrc.spk.mk:436: arch-monaco] Error 2 (ignored)

DMS-6.2.2

[email protected]:/spksrc# make setup
Setting default toolchain version to DSM-6.2.2
[email protected]:/spksrc# cd spk/homeassistant/
[email protected]:/spksrc/spk/homeassistant# make arch-monaco
===>  Building package for arch monaco
make[1]: Entering directory '/spksrc/spk/homeassistant'
===>  Set up toolchain
===>    Downloading files for syno-monaco
wget https://sourceforge.net/projects/dsgpl/files/Tool%20Chain/DSM%206.2.2%20Tool%20Chains/STMicroelectronics%20Monaco%20Linux%203.10.105/monaco-gcc493_glibc220_hard-GPL.txz
2020-09-24 15:32:12 URL:https://master.dl.sourceforge.net/project/dsgpl/Tool%20Chain/DSM%206.2.2%20Tool%20Chains/STMicroelectronics%20Monaco%20Linux%203.10.105/monaco-gcc493_glibc220_hard-GPL.txz [42227184/42227184] -> "monaco-gcc493_glibc220_hard-GPL.txz.part" [2]
===>    Verifying files for syno-monaco
===>      Checking sha1sum of file monaco-gcc493_glibc220_hard-GPL.txz
sha1sum: 'standard input': no properly formatted SHA1 checksum lines found
===>        Wrong sha1sum for file monaco-gcc493_glibc220_hard-GPL.txz
===>        Renamed as monaco-gcc493_glibc220_hard-GPL.txz.wrong
===>        Download cookie removed to trigger the download again
make[2]: *** [../../mk/spksrc.checksum.mk:42: checksum_target] Error 1
/spksrc/spk/homeassistant/work-monaco-6.2.2/tc_vars.mk:1: *** An error occured while setting up the toolchain, please check the messages above.  Stop.
make[1]: Leaving directory '/spksrc/spk/homeassistant'
make: [../../mk/spksrc.spk.mk:436: arch-monaco] Error 2 (ignored)

I’ll try to get proper installation of Debian working on some unused computer, but I’m not so sure “Linux on Windows” is the issue here.

The first post in this thread originally had documentation on using Windows WSL2 Docker. I removed any reference to Windows since I could not solve some problems.

The most important thing with Windows is to make sure every file is in Linux format. That’s probably the root of issues with spksrc on Windows. I suggest you delete spksrc directory and then git it again without crlf at the end of each line. Make sure you use an editor that does not add crlf. Windows notepad will leave files in Unix format. My favorite is notepad++.

First get the current source files:
git config --global core.autocrlf false #needed for Windows git
git clone https://github.com/SynoCommunity/spksrc.git

If you still have checksum errors, perhaps the spksrc needs an update. Compare the checksums of the downloaded file to the contents of /spksrc/toolchains/syno-monaco-6.1/digests

Notepad++ is my default code editor since beginning :wink: And first test - for DSM-6.1 from previous post was without any changes to files pulled from git.

For now, this probably worked

Docker/spksrc is working for almost an hour now - I’ll update this post when it’ll reach some kind of finish :wink:

#edit:
Finito… as expected with error:

checking build system type... i686-pc-linux-gnu
checking host system type... arm-unknown-linux-gnueabi
checking target system type... arm-unknown-linux-gnueabi
continue configure in default builddir "./arm-unknown-linux-gnueabi"
....exec /bin/bash .././configure "--srcdir=.." "--enable-builddir=arm-unknown-linux-gnueabi" "linux
gnueabi"
.././configure: line 2364: config.log: No such file or directory
.././configure: line 2374: config.log: No such file or directory
cat: standard output: No such file or directory
make[3]: *** [../../mk/spksrc.configure.mk:50: configure_target] Error 1
make[3]: Leaving directory '/spksrc/cross/libffi'
make[2]: *** [../../mk/spksrc.depend.mk:44: depend_target] Error 2
make[2]: Leaving directory '/spksrc/cross/python3'
make[1]: *** [../../mk/spksrc.depend.mk:44: depend_target] Error 2
make[1]: Leaving directory '/spksrc/spk/homeassistant'
make: [../../mk/spksrc.spk.mk:436: arch-monaco] Error 2 (ignored)

Ok, thank you for support and all usefull hints, but next attempt will be with fully setup Debian.

To be continued…