Page 1 of 2

Build Domoticz from source on Raspberry and other Linux variants

Posted: Monday 21 December 2020 18:37
by megamarco83
if i will build an image with a raspberry pi (raspbian buster) this build i can share and will be compatible also with a PC that is running debian as OS ?
thanks!

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Monday 21 December 2020 19:30
by waaren
megamarco83 wrote: Monday 21 December 2020 18:37 if i will build an image with a raspberry pi (raspbian buster) this build i can share and will be compatible also with a PC that is running debian as OS ?
thanks!
I am not sure but probably not as they will have different CPU's. Easy enough to check :) ?

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Monday 21 December 2020 20:59
by megamarco83
waaren wrote: Monday 21 December 2020 19:30 Easy enough to check :) ?
yes it's difficult....of course for me :-) :-) :-)

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Wednesday 30 December 2020 23:00
by megamarco83
waaren wrote: Monday 21 December 2020 19:30
megamarco83 wrote: Monday 21 December 2020 18:37 if i will build an image with a raspberry pi (raspbian buster) this build i can share and will be compatible also with a PC that is running debian as OS ?
thanks!
I am not sure but probably not as they will have different CPU's. Easy enough to check :) ?
hi, i get a try to build from source in debian.
i succeed on all passage, but i have a doubt:
cd open-zwave-read-only
git pull
make # Make a note of the version information for the next steps
sudo make install
and it was:
Building OpenZWave Version 1.6-1570-ga9d57fcc - 1.6.1570

so i enter:

Code: Select all

marco@debian:~/open-zwave-read-only$ nano cpp/src/vers.cpp 
and this is the file:

Code: Select all

#include "Defs.h"
uint16_t ozw_vers_major = 1;
uint16_t ozw_vers_minor = 6;
uint16_t ozw_vers_revision = 1570;
char ozw_version_string[] = "1.6-1570-ga9d57fcc";
so i continue like explained:

Code: Select all

marco@debian:~/open-zwave-read-only$ rm libopenzwave.a
marco@debian:~/open-zwave-read-only$ make
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/build"
Building OpenZWave Version 1.6-1570-ga9d57fcc - 1.6.1570
Linking Static Library
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/build"
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/examples/MinOZW"
make[1]: Nessuna operazione da eseguire per "default".
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/examples/MinOZW"
marco@debian:~/open-zwave-read-only$ make install
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/build"
Makefile:249: Documentation not being built
Installing Shared Library
cp: impossibile creare il file regolare '//usr/local/lib64//libopenzwave.so.1.6': Permesso negato
make[1]: *** [Makefile:260: install] Error 1
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/build"
make: *** [Makefile:27: install] Error 2
why i receive this error?



but ok for me is not important the support for zwave so i proceed with the wiki...

finally steps are:

Code: Select all

cd dev-domoticz
git pull
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make
i complete without issue.
now i guess that i have to synchronize domoticz folder with domoticz-dev folder


so i create this .sh script:

Code: Select all

sudo nano update-domoticz-source.sh
and i paste this:

Code: Select all

source=~/dev-domoticz  # or the directory you use(d) for development
target=~/domoticz      # or another target directory

sudo mkdir -p $target/backups
sudo mkdir $target/plugins

# One of the next two rsync comamnds will copy your domoticz binary to the target location
sudo rsync -I $source/bin/domoticz $target/domoticz # will error if the binary is not in $source/bin
sudo rsync -I $source/domoticz $target/domoticz     # will error if the binary is not in $source

sudo rsync -rI $source/www/ $target/www
sudo rsync -rI $source/dzVents/ $target/dzVents
sudo rsync -rI $source/Config/ $target/Config
sudo rsync -rI $source/scripts/ $target/scripts

sudo rsync -I $source/History.txt $target
sudo rsync -I $source/License.txt $target
sudo rsync -I $source/server_cert.pem $target
(not need the #!/bin/bash at begin??)


then i stop domoticz and run the bash script:

Code: Select all

marco@debian:~$ sudo service domoticz stop
marco@debian:~$ ./update-domoticz-source.sh
mkdir: impossibile creare la directory "/home/marco/domoticz/plugins": File già esistente
rsync: link_stat "/home/marco/dev-domoticz/bin/domoticz" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
marco@debian:~$ sudo service domoticz start
why i got this error?
if i enter now in domoticz i see the last version committed: 12781
so it seams that all is working good....so why this two error: zwave and rsyn?

last question....next time that i want to compile i guess that i will have only to:
1) Build Support for OpenZWave 1.6+
2) Domoticz Source
3) Rsync script
is it correct?


the manual operation that you mention, that is the reason why the avaliable version for :
./updatebeta
is 12738
and last is 12781
it is this one:

Code: Select all

nano cpp/src/vers.cpp 
where we have to write the version downloaded with wget command?

thanks!!!
Marco

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Thursday 31 December 2020 0:12
by waaren
megamarco83 wrote: Wednesday 30 December 2020 23:00 hi, i get a try to build from source in debian.in the script
i succeed on all passage, but i have a doubt:

why i receive this error?
did you use sudo make install ?
so i create this .sh script:
(not need the #!/bin/bash at begin??)
No this will work in sh and in ash and in bash
why i got this error?
These errors can be ignored. Script will continue
if i enter now in domoticz i see the last version committed: 12781
Congrats !!

so it seams that all is working good....so why this rsync error?
Can be ignored. There are some extra actions in the script to ensure it will work for exceptions but these will generate error when the exceptions do not exist.
last question....next time that i want to compile i guess that i will have only to:
1) Build Support for OpenZWave 1.6+ -->>
Repeat the steps of the OpenZwave build without the clone part


2) Domoticz Source -->>
cd dev-domoticz
git pull
make

3) Rsync script -->>
Yes
the manual operation that you mention, that is the reason why the avaliable version for :
./updatebeta
is 12738
and last is 12781
Yes. Keep using your local compiled Beta versions until @gizmocuz fixed the build + upload process for Linux on the download server

Re: update beta not the last version

Posted: Thursday 31 December 2020 0:35
by megamarco83
waaren wrote: Thursday 31 December 2020 0:12 did you use sudo make install ?

no i do not use "sudo" as explained inside the wiki: (second wiki passage)
cd open-zwave-read-only
rm libopenzwave.a # this will force a new linking when doing a make. Ready in seconds
make
make install
i used "sudo" only here: (first wiki passage)
cd open-zwave-read-only
git pull
make # Make a note of the version information for the next steps
sudo make install
so, like in the wiki, first with sudo make install and second passage wihout "sudo" but only make install
but the error appear after remove "libopenzwave.a" and execution of "make"

please have a look here:

Code: Select all

marco@debian:~/open-zwave-read-only$ rm libopenzwave.a
marco@debian:~/open-zwave-read-only$ make
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/build"
Building OpenZWave Version 1.6-1570-ga9d57fcc - 1.6.1570
Linking Static Library
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/build"
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/examples/MinOZW"
make[1]: Nessuna operazione da eseguire per "default".
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/examples/MinOZW"
marco@debian:~/open-zwave-read-only$ make install
make[1]: ingresso nella directory "/home/marco/open-zwave-read-only/cpp/build"
Makefile:249: Documentation not being built
Installing Shared Library
cp: impossibile creare il file regolare '//usr/local/lib64//libopenzwave.so.1.6': Permesso negato
make[1]: *** [Makefile:260: install] Error 1
make[1]: uscita dalla directory "/home/marco/open-zwave-read-only/cpp/build"
make: *** [Makefile:27: install] Error 2
cp: impossibile creare il file regolare '//usr/local/lib64//libopenzwave.so.1.6': Permesso negato
means
cp: impossible create regular file '//usr/local/lib64//libopenzwave.so.1.6': Permission denied
:-)

if i enter now in domoticz i see the last version committed: 12781
waaren wrote: Thursday 31 December 2020 0:12Congrats !!
that's only happened because the wiki is very clear and very well written :) :-) :-)

waaren wrote: Thursday 31 December 2020 0:12
last question....next time that i want to compile i guess that i will have only to:
1) Build Support for OpenZWave 1.6+ -->>
Repeat the steps of the OpenZwave build without the clone part


2) Domoticz Source -->>
cd dev-domoticz
git pull
make

3) Rsync script -->>
Yes
if i do not need zwave support i can simply delete zwave folder, and start from step 2) Domoticz Source -->>
correct?

waaren wrote: Thursday 31 December 2020 0:12 Keep using your local compiled Beta versions until @gizmocuz fixed the build + upload process for Linux on the download server
after @gizmocuz will upload on download server i can perform:
./updatebeta
and i will have "official" release with support of zwave, correct?

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Thursday 31 December 2020 1:00
by waaren
megamarco83 wrote: Thursday 31 December 2020 0:35 no i do not use "sudo" as explained inside the wiki: (second wiki passage)
make install should always be done with root permissions so sudo make install
if i do not need zwave support i can simply delete zwave folder, and start from step 2) Domoticz Source -->>
correct?
Yes
after @gizmocuz will upload on download server i can perform:
./updatebeta
and i will have "official" release with support of zwave, correct?
Yes

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Thursday 31 December 2020 9:54
by megamarco83
waaren wrote: Thursday 31 December 2020 1:00
megamarco83 wrote: Thursday 31 December 2020 0:35 no i do not use "sudo" as explained inside the wiki: (second wiki passage)
make install should always be done with root permissions so sudo make install
mmm so maybe the wiki should be corrected in this point, here the wiki:
cd open-zwave-read-only
git pull
make # Make a note of the version information for the next steps
sudo make install

# Edit the version numbers and string in cpp/vers.cpp with information that you noted in the previous step.
# Below line use vi as editor but any editor will do
vi cpp/src/vers.cpp

rm libopenzwave.a # this will force a new linking when doing a make. Ready in seconds
make
make install
the last command should not:
make install
but
sudo make install

thanks for your help, i appreciate as always :-)
Marco

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Thursday 31 December 2020 11:04
by waaren
megamarco83 wrote: Thursday 31 December 2020 9:54
the last command should not:
make install
but
sudo make install
Thx for reporting. The wiki is updated accordingly.
Please continue to report if you still see room for improvement.

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Thursday 31 December 2020 13:12
by megamarco83
waaren wrote: Thursday 31 December 2020 11:04
Thx for reporting. The wiki is updated accordingly.
Please continue to report if you still see room for improvement.
i think that all the other commands works very good and all the wiki is very well explained!
just a comment maybe, adding the correction at command make install => sudo make install
and maybe explain better the passages with Rsync:

in detail after:

Code: Select all

sudo apt install rsync
could be added this command that is not present:

Code: Select all

sudo nano update-domoticz-source.sh
then paste this:

Code: Select all

source=~/dev-domoticz  # or the directory you use(d) for development
target=~/domoticz      # or another target directory

sudo mkdir -p $target/backups
sudo mkdir $target/plugins

# One of the next two rsync comamnds will copy your domoticz binary to the target location
sudo rsync -I $source/bin/domoticz $target/domoticz # will error if the binary is not in $source/bin
sudo rsync -I $source/domoticz $target/domoticz     # will error if the binary is not in $source

sudo rsync -rI $source/www/ $target/www
sudo rsync -rI $source/dzVents/ $target/dzVents
sudo rsync -rI $source/Config/ $target/Config
sudo rsync -rI $source/scripts/ $target/scripts

sudo rsync -I $source/History.txt $target
sudo rsync -I $source/License.txt $target
sudo rsync -I $source/server_cert.pem $target
then i stop domoticz and run the bash script, that it is not written inside wiki:

Code: Select all

sudo service domoticz stop
./update-domoticz-source.sh
sudo service domoticz start
these passages are not explained maybe we can add....


EDIT:
a bit of topic: i use windows system daily and on same PC i installed Debian. Inside debian i have domoticz test
Every time i have to switch off windows than run debian to see domoticz test, otherwise it is offline.
there is a way to workaround this?
visualize debian is possible? how?
or other solution?
thanks

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 14:09
by megamarco83
i try with:
sudo make install
when i compile zwave and this time i not get errors :)

question: is it possible to update domoticz not at latest commint but a specific commit?

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 17:17
by waaren
megamarco83 wrote: Saturday 02 January 2021 14:09 question: is it possible to update domoticz to a specific commit?
Yes but please check if your database version has not changed. You cannot downgrade domoticz and keep your current database if the database version changed between the older build and latest version you used.


Lookup and copy commit-id that you want to use and database versions on this Wiki page

cd <domoticz development dir>
sudo git checkout <commit-id>
make

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 20:50
by megamarco83
last question, i promise :)
i have 12781 and i see the latest 12811

so i have already the folder:
dev-domoticz
that was created for 12781

so i do:

Code: Select all

cd dev-domoticz
git pull
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make
and during commands i see :

Code: Select all

marco@debian:~/dev-domoticz$ cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
-- Submodule update
-- LUA library found at: /usr/lib/x86_64-linux-gnu/liblua5.3.a
-- Python3 includes found at: /usr/include/python3.7m
-- Building with I2C support
-- Building with SPI support
-- ###########################
-- Compiling Revision #12811
-- ###########################

so it seams that last version is compiled.
now i used rsync script to update domoticz

marco@debian:~$ ./update-domoticz-source.sh
marco@debian:~$

but after restart domoticz service i steel see 12781 and not 12811 ...why?

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 21:24
by waaren
megamarco83 wrote: Saturday 02 January 2021 20:50 i have 12781 and i see the latest 12811

so i do:

Code: Select all

cd dev-domoticz
git pull
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make
When compiing a later build you don not have to use the cmake step again. You only have to do a

Code: Select all

cd dev-domoticz
git pull
make
If that does give an error try with
sudo git pull and sudo make

What do you see when you do this?

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 21:33
by megamarco83
waaren wrote: Saturday 02 January 2021 21:24
When compiing a later build you don not have to use the cmake step again. You only have to do a

Code: Select all

cd dev-domoticz
git pull
make
If that does give an error try with
sudo git pull and sudo make

What do you see when you do this?

Code: Select all

marco@debian:~$ cd dev-domoticz
marco@debian:~/dev-domoticz$ git pull
Already up to date.

Code: Select all

marco@debian:~/dev-domoticz$ make
-- Found Git: /usr/bin/git (found version "2.20.1") 
-- domoticz has been modified locally: adding "-modified" to hash
[  0%] Built target revisiontag
[  1%] Built target minizip
[  3%] Built target jsoncpp_static
[ 16%] Built target libmosquitto_static
[ 16%] Built target SQLite3
[100%] Built target domoticz
i used without "sudo" and i not receive errors, so after that i do:

Code: Select all

marco@debian:~/dev-domoticz$ cd ..
marco@debian:~$ ./update-domoticz-source.sh
marco@debian:~$ 
but still on old version.... :(

could be that rsync not update the files from dev folder to domoticz folder?
because als when i wrongly used command "cmake" i see that compiled version was the latest one:
-- Compiling Revision #12811
but after using rsync i had again old version

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Saturday 02 January 2021 22:52
by waaren
megamarco83 wrote: Saturday 02 January 2021 21:33 but after using rsync i had again old version
Can you do a

cd dev-domoticz
ls -l domoticz
ls -l bin/domoticz

and copy the one with the latest date to your domoticz dir

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Sunday 03 January 2021 0:24
by megamarco83
waaren wrote: Saturday 02 January 2021 22:52
Can you do a

cd dev-domoticz
ls -l domoticz
ls -l bin/domoticz

and copy the one with the latest date to your domoticz dir

Code: Select all

marco@debian:~$ cd dev-domoticz
marco@debian:~/dev-domoticz$ ls -l domoticz
-rwxr-xr-x 1 marco marco 17483352 gen  2 15:14 domoticz
marco@debian:~/dev-domoticz$ ls -l bin/domoticz
-rwxr-xr-x 1 marco marco 17483352 gen  2 21:43 bin/domoticz
so it seams that the latest one is inside <dev dir domoticz>/bin/

and so i copy domoticz file from there:

Code: Select all

marco@debian:~/dev-domoticz$ sudo cp /home/marco/dev-domoticz/bin/domoticz /home/marco/domoticz/
i restart domoticz service and now it's update. :-)

but why rsyns do not succed on update file?
and why the first time that i used yes? (the rsync script it's the same, it don't recognize the new file?)
thanks for support!

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Monday 04 January 2021 21:19
by megamarco83
hi, last possible suggestion for the wiki.

i compiled successful on debian with a NUC.

now i try to do the same with raspberry pi3, but i find this issue:

Code: Select all

[ 18%] Building CXX object CMakeFiles/domoticz.dir/main/WebServer.cpp.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [CMakeFiles/domoticz.dir/build.make:516: CMakeFiles/domoticz.dir/main/WebServer.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:490: CMakeFiles/domoticz.dir/all] Error 2
make: *** [Makefile:169: all] Error 2
i think because of "memory" of raspberry, so i solved in this way:

Run these:

Code: Select all

   
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
sudo mkswap /swapfile
sudo chmod 600 /swapfile
sudo swapon /swapfile
don't know if i used too big swapfile, maybe less space should be enough...what do you think?
anyway in this condition i got success compiling.

But i also think that we need to make sure you then revert the swapon after compilation, with these:

Code: Select all

sudo swapoff /swapfile
sudo rm /swapfile
i'm wrong?

now that it is compiled for the first time on raspberry, the next git pull should update only the new commit and i guess that the compiling will be much faster and maybe will not be necessary anymore the swapfile, or I'm wrong?

thanks!

Build Domoticz from source on Raspberry and other Linux variants

Posted: Monday 04 January 2021 22:17
by waaren
megamarco83 wrote: Monday 04 January 2021 21:19 hi, last possible suggestion for the wiki.
The suggestion to have a swap file is already in the wiki including a link to "howto" and the remark that you do not need it to be set at boot time. If you want to remove the swap after a successful compilation and set it up again before the next compile is Ok but not necessary.
The compiling will be much faster if only some source files are changed but it is depending on which ones for the 1 Gb memory to be enough.
Compiling main/WebServer.cpp or main/mainworker.cpp are the "big memory spenders"

Re: Build Domoticz from source on Raspberry and other Linux variants

Posted: Tuesday 05 January 2021 0:06
by megamarco83
waaren wrote: Monday 04 January 2021 22:17
The suggestion to have a swap file is already in the wiki including a link to "howto" and the remark that you do not need it to be set at boot time..
ops....big shame on me, i not notice that :(