File domoticz.spec of Package domoticz
#Todo make dzVents logging visible again
#Todo the approot issue?
%global debug_package %{nil}
%define APPHASH 89d5c900d
%define APPVERSION 16812
# git rev-parse --short HEAD
# git rev-list HEAD --count + 2107
Name: domoticz
Version: 0
Release: 0
Summary: Open source Home Automation System
License: GPL-3.0-or-later and Apache-2.0 and BSL-1.0 and BSD-3-Clause and MIT
Group: Productivity/Networking/Web/Servers
URL: http://www.domoticz.com
Source0: %{name}-%{version}.tar.xz
Source1: %{name}.service
Patch0: %{name}-git.patch
Patch1: %{name}-%{version}.patch
BuildRequires: boost-devel > 1.85
BuildRequires: boost-devel < 1.87
BuildRequires: libboost_atomic-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_thread-devel
BuildRequires: cereal-devel
BuildRequires: uthash-devel
BuildRequires: mosquitto-devel
BuildRequires: libopenzwave-devel
BuildRequires: cmake >= 3.16
BuildRequires: curl-devel
BuildRequires: fontpackages-devel
BuildRequires: gcc-c++
BuildRequires: git
BuildRequires: pkgconfig
BuildRequires: fdupes
BuildRequires: libusb-devel
BuildRequires: lua-devel
BuildRequires: openssl-devel
BuildRequires: python3-devel
BuildRequires: sqlite-devel
BuildRequires: systemd-devel
BuildRequires: zlib-devel
BuildRequires: jsoncpp-devel
%if 0%{?suse_version}
BuildRequires: google-droid-fonts
Requires: google-droid-fonts
Requires: python3-devel
Requires(pre): shadow
%endif
%if 0%{?fedora}
BuildRequires: google-droid-sans-fonts
Requires: google-droid-sans-fonts
Requires(pre): shadow-utils
%endif
Requires(post): systemd
Requires(postun): systemd
Requires(preun): systemd
Recommends: system-python-libs >= 3.4
%global _python_bytecompile_extra 0
%description
Domoticz is a Home Automation System that lets you monitor and configure various
devices like: Lights, Switches, various sensors/meters like Temperature, Rain,
Wind, UV, Electra, Gas, Water and much more. Notifications/Alerts can be sent to
any mobile device
%prep
%setup -q
%patch -P0 -p1
%patch -P1 -p1
%build
DESTDIR=%{buildroot}
cat > appversion.h << EOL
#define APPVERSION %{APPVERSION}
#define APPHASH "%{APPHASH}"
#define APPDATE `date +%s`
EOL
cp -f appversion.h appversion.h.txt
mkdir build-obs
pushd build-obs
cmake .. \
-DUSE_STATIC_BOOST=OFF \
-DUSE_STATIC_OPENZWAVE=OFF \
-DUSE_BUILTIN_SQLITE=NO \
-DUSE_BUILTIN_MQTT=NO \
-DUSE_BUILTIN_JSONCPP=NO \
-DOPENSSL_SSL_LIBRARY=%{_libdir}/libssl.so -DOPENSSL_CRYPTO_LIBRARY=%{_libdir}/libcrypto.so \
-DCMAKE_INSTALL_PREFIX=%{_datadir}/%{name}
make %{?_smp_mflags}
popd
%install
pushd build-obs
make install DESTDIR=%{buildroot}
popd
#
# Cleanup
#
rm -f %{buildroot}%{_datadir}/%{name}/dzVents/runtime/tests/scandir/.f3.lua.swp
#
%fdupes -s %{buildroot}%{_datadir}/%{name}
# remove docs, we grab them in files below
rm -f %{buildroot}%{_datadir}/%{name}/*.txt
# move binary to standard directory
mkdir -p %{buildroot}%{_bindir}/
mv %{buildroot}%{_datadir}/%{name}/%{name} %{buildroot}%{_bindir}/
# install systemd service and config
#mkdir -p %{buildroot}%{_sysconfdir}/sysconfig/
mkdir -p %{buildroot}%{_unitdir}/
cp -p %{SOURCE1} %{buildroot}%{_unitdir}/
#cp -p %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
# create database/ssl cert directory
%if 0%{?suse_version}
mkdir -p %{buildroot}/var/lib/%{name}/
%endif
%if 0%{?fedora}
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}/
%endif
# Disable the app's self-update script
#chmod 644 %{buildroot}%{_datadir}/%{name}/updatedomo
# Move domoticz.conf file to standard location
mkdir -p %{buildroot}%{_sysconfdir}
mv %{buildroot}%{_datadir}/%{name}/scripts/%{name}.conf \
%{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# http_port=8080|http_port=8080|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# ssl_port=443|ssl_port=8443|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# ssl_cert=/opt/domoticz/server_cert.pem|ssl_cert=/var/lib/domoticz/domoticz.pem|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# http_root=/opt/domoticz/www|http_root=/usr/share/domoticz/www|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# dbase_file=/opt/domoticz/domoticz.db|dbase_file=/var/lib/domoticz/domoticz.db|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# userdata_path=/opt/domoticz|userdata_path=/usr/share/domoticz/|g' %{buildroot}%{_sysconfdir}/%{name}.conf
sed -i -e 's|# app_path=/opt/domoticz|app_path=/usr/share/domoticz/|g' %{buildroot}%{_sysconfdir}/%{name}.conf
# Byte compile the default plugin
%if 0%{?suse_version}
%py3_compile -O %{buildroot}%{_datadir}/%{name}/plugins/AwoxSMP
%endif
%if 0%{?fedora}
%py_byte_compile %{__python3} %{buildroot}%{_datadir}/%{name}/plugins/AwoxSMP
%endif
%if 0%{?suse_version}
mkdir -p %{buildroot}/var/log
touch %{buildroot}/var/log/domoticz.log
%endif
%if 0%{?fedora}
mkdir -p %{buildroot}%{_sharedstatedir}/log
touch %{buildroot}%{_sharedstatedir}/log/domoticz.log
%endif
mkdir -p %{buildroot}%{_datadir}/%{name}/Config
touch %{buildroot}%{_datadir}/%{name}/Config/OZW_Log.txt
%pre
getent group domoticz >/dev/null || groupadd -r domoticz
getent passwd domoticz >/dev/null || \
useradd -r -g domoticz -d %{_datadir}/%{name} -s /sbin/nologin \
-c "Domoticz Home Automation Server" domoticz
# For OpenZWave USB access (/dev/ttyACM#)
%if 0%{?suse_version} >= 1600
usermod -G domoticz,dialout domoticz
%else
usermod -G domoticz,dialout domoticz
%endif
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun_with_restart %{name}.service
%files
%license License.txt
%doc README.md History.txt
%{_bindir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}.conf
#config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_datadir}/%{name}/
%attr(0755,domoticz,domoticz) %{_datadir}/%{name}/plugins
%if 0%{?suse_version}
%attr(0755,domoticz,domoticz) /var/lib/%{name}/
%attr(-,domoticz,domoticz) /var/log/domoticz.log
%endif
%if 0%{?fedora}
%attr(0755,domoticz,domoticz) %{_sharedstatedir}/%{name}/
%attr(-,domoticz,domoticz) %{_sharedstatedir}/log/domoticz.log
%endif
%{_unitdir}/%{name}.service
%attr(-,domoticz,domoticz) %{_datadir}/%{name}/Config/OZW_Log.txt
%changelog