termux / termux-root-packages

Termux packages that are only usable by root users.
Other
1.04k stars 295 forks source link

[WIP] open-zwave #176

Closed araczkowski closed 4 years ago

araczkowski commented 4 years ago

Hi, we were are able to compile open-zwave on Android device with this little change: OpenZWave/open-zwave#2178

The steps in Termux on device are:

pkg install clang git
ln -s /system/lib/libc.so /data/data/com.termux/files/usr/lib/libresolv.so
/*libresolv is needed to compile open-zwave*/
git clone https://github.com/sviete/open-zwave.git
cd open-zwave
LIBS+=-latomic make
PREFIX=$PREFIX make install

After this all is ready, we can plug the USB Zwave stick to USB, the device is visible on: /dev/ttyACM*

and we can use zwave, like below:

MinOZW /dev/ttyACM0
Starting MinOZW with OpenZWave Version 1.5.1
....

Unfortunately we are not able to add this as termux package, the full log is below:

./scripts/run-docker.sh ./build-package.sh -f -a arm termux-root-packages/packages/open-zwave/
Running container 'termux-package-builder' from image 'termux/package-builder'...
termux - building open-zwave for arch arm...
/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:82: Missing Either Git Binary, Not a Source Checkout or doesn't have a vers.cpp
make[1]: warning: -j8 forced in submake: resetting jobserver mode.
make[1]: Entering directory '/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build'
/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:82: Missing Either Git Binary, Not a Source Checkout or doesn't have a vers.cpp
Building OpenZWave Version  - 1.6.0
Building tinyxml/tinystr.cpp
Building tinyxml/tinyxmlerror.cpp
Building tinyxml/tinyxml.cpp
Building tinyxml/tinyxmlparser.cpp
Building aes/aeskey.c
g++: error: unrecognized command line option ‘-mfpu=neon’
g++: error: unrecognized command line option ‘-mfpu=neon’
Building aes/aescrypt.c
Building aes/aestab.c
g++: error: unrecognized command line option ‘-mfpu=neon’
g++: error: unrecognized command line option ‘-mfpu=neon’
g++: error: unrecognized command line option ‘-mfloat-abi=softfp’
g++: error: unrecognized command line option ‘-mfloat-abi=softfp’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mthumb’
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:187: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/tinystr.o] Error 1
make[1]: *** Waiting for unfinished jobs....
gcc: error: unrecognized command line option ‘-mfpu=neon’
gcc: error: unrecognized command line option ‘-mfpu=neon’
gcc: error: unrecognized command line option ‘-mfpu=neon’
g++: error: unrecognized command line option ‘-mfloat-abi=softfp’
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:187: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/tinyxmlerror.o] Error 1
g++: error: unrecognized command line option ‘-mfloat-abi=softfp’
g++: error: unrecognized command line option ‘-mthumb’
g++: error: unrecognized command line option ‘-mthumb’
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:187: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/tinyxml.o] Error 1
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:187: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/tinyxmlparser.o] Error 1
gcc: error: unrecognized command line option ‘-mfloat-abi=softfp’
gcc: error: unrecognized command line option ‘-mfloat-abi=softfp’
gcc: error: unrecognized command line option ‘-mfloat-abi=softfp’
gcc: error: unrecognized command line option ‘-mthumb’
gcc: error: unrecognized command line option ‘-mthumb’
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:198: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/aestab.o] Error 1
gcc: error: unrecognized command line option ‘-mthumb’
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:198: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/aeskey.o] Error 1
make[1]: *** [/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build/support.mk:198: /home/builder/termux-packages/.termux-build/open-zwave/src/.lib/aescrypt.o] Error 1
make[1]: Leaving directory '/home/builder/termux-packages/.termux-build/open-zwave/src/cpp/build'
make: *** [Makefile:23: all] Error 2

any idea how to fix this?

araczkowski commented 4 years ago

open-zwave marge the pull request, soon (after release), we should be able to switch the package to the official OpanZwave repo https://github.com/OpenZWave/open-zwave

Grimler91 commented 4 years ago

Hi, the PR you linked has been merged so is it okay to use the https://github.com/OpenZWave/open-zwave repo now?

araczkowski commented 4 years ago

Hi @Grimler91 yes it will be better to use the OpenZWave repo, but the fix was merged to the master branch, and it is not released yet. I don't know if it's possible to get the TERMUX_PKG_SRCURL directly from branch, instead of the release archive.

Grimler91 commented 4 years ago

We can use 1.6 and add your extra commit as a patch. I fixed some other build errors in https://github.com/termux/termux-root-packages/commit/a04077a696f7a73f7ddb20fe2682be183a2d7eec

araczkowski commented 4 years ago

I will watch and learn :) thanks for taking this

Grimler91 commented 4 years ago

We can use 1.6 and add your extra commit as a patch

They don't seem to make releases very often though so it might be easier to package the latest commit..

I see that it uses libusb also, so it should be possible to get it working without root if anyone is motivated enough to patch it (it needs something like this patch).

Could you test this deb: https://grimler.se/dists/testing/misc/binary-aarch64/open-zwave_1.6-git-0_aarch64.deb? (replace aarch64 by your arch if you are on another arch)

araczkowski commented 4 years ago

Could you test this deb

Unfortunately yesterday I left my z-wave stick in the office, I will grab it later to do the test - and I will let you know :)

I downloaded the arm version of the deb, from https://grimler.se/dists/testing/misc/binary-arm/open-zwave_1.6-git-0_arm.deb to my PC to quick look - it looks ok (similar to the version compiled on device).

But I noticed that the deb size is quite big: 130,8 MB, in my case (the compilation on device) the size was 11,6 MB

to check what is so big in this deb package I did:

mkdir tmp
dpkg-deb -R open-zwave_1.6-git-0_arm.deb tmp

cd temp/data/data/com.termux/files/usr/share
du -h

4,0K ./doc/open-zwave 352K ./doc/openzwave-1.6.0/images+css 3,3M ./doc/openzwave-1.6.0/api/html/search 157M ./doc/openzwave-1.6.0/api/html 157M ./doc/openzwave-1.6.0/api ...

as you can see the /data/data/com.termux/files/usr/share/doc/openzwave-1.6.0/api has 157M there is a lot of big images in this folder, I think that we should exclude this from the deb

araczkowski commented 4 years ago

Test on arm done - all works :+1:

1. Library

to install the binaries on fresh Termux

pkg install libusb curl
curl https://grimler.se/dists/testing/misc/binary-arm/open-zwave_1.6-git-0_arm.deb -o open-zwave.deb && dpkg -i open-zwave.deb  

MinOZW test

MinOZW /dev/ttyACM0

image

*green == ok ;)

2. Python package

to install the python-openzwave package on fresh Termux

pkg install pkg-config python

pip install cython==0.28.6 six pyserial 'PyDispatcher>=2.0.5'
pip install python-openzwave  --no-deps --install-option="--flavor=shared"

pyozw_check test

pyozw_check -i -d /dev/ttyACM0 --config_path /data/data/com.termux/files/usr/etc/openzwave

image

Now we can have zigbee (left usb stick) and zwave (right usb stick) on Android Thanks! @Grimler91 :1st_place_medal:

image

Grimler91 commented 4 years ago

@araczkowski awesome, thanks for testing, I'll add the package!

And thanks for spotting that the docs are very large.