]> git.pld-linux.org Git - packages/domoticz.git/blob - domoticz.spec
up to 2024.4
[packages/domoticz.git] / domoticz.spec
1 Summary:        Open source Home Automation System
2 Name:           domoticz
3 Version:        2024.4
4 Release:        1
5 License:        GPLv3+ and ASL 2.0 and Boost and BSD and MIT
6 Group:          Base
7 URL:            http://www.domoticz.com
8 Source0:        https://github.com/domoticz/domoticz/archive/%{version}/%{name}-%{version}.tar.gz
9 # Source0-md5:  23f0aab1b388076394530d769defc710
10 Source1:        %{name}.service
11 Source2:        %{name}.conf
12 # Use system tinyxpath (https://github.com/domoticz/domoticz/pull/1759)
13 Patch0:         %{name}-tinyxpath.patch
14 # Fix python detection (https://github.com/domoticz/domoticz/pull/1749)
15 Patch1:         %{name}-python.patch
16 Patch2:         no-git.patch
17 Patch3:         %{name}-no_updates.patch
18 Patch4:         config.patch
19 BuildRequires:  boost-devel >= 1.66.0
20 BuildRequires:  cereal-devel
21 BuildRequires:  cmake >= 3.16.0
22 BuildRequires:  curl-devel
23 BuildRequires:  jsoncpp-devel
24 BuildRequires:  libmosquitto-devel
25 BuildRequires:  libopenzwave-devel >= 1.5.0
26 BuildRequires:  libstdc++-devel >= 6:4.9
27 BuildRequires:  libusb-compat-devel
28 BuildRequires:  linux-libc-headers
29 BuildRequires:  lua53-devel
30 BuildRequires:  minizip-devel
31 BuildRequires:  openssl-devel
32 BuildRequires:  pkgconfig
33 BuildRequires:  python3 >= 1:3.4
34 BuildRequires:  python3-devel >= 1:3.4
35 BuildRequires:  rpmbuild(macros) >= 1.644
36 BuildRequires:  sqlite3-devel
37 BuildRequires:  tinyxml-devel
38 BuildRequires:  tinyxpath-devel
39 BuildRequires:  zlib-devel
40 Requires(pre):  /usr/sbin/groupadd
41 Requires(pre):  /usr/sbin/useradd
42 Requires(post,preun,postun):    systemd-units >= 38
43 Requires:       fonts-TTF-Google-Droid
44 Requires:       fonts-TTF-OpenSans
45 Requires:       libopenzwave >= 1.5.0
46 Requires:       setup >= 2.10.1
47 Suggests:       python3-libs
48 Provides:       group(domoticz)
49 Provides:       user(domoticz)
50 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
51
52 %description
53 Domoticz is a Home Automation System that lets you monitor and
54 configure various devices like: Lights, Switches, various
55 sensors/meters like Temperature, Rain, Wind, UV, Electra, Gas, Water
56 and much more. Notifications/Alerts can be sent to any mobile device
57
58 %prep
59 %setup -q
60 %patch0 -p1
61 %patch1 -p1
62 %patch2 -p1
63 %patch3 -p1
64 %patch4 -p1
65
66 APPVERSION="%{version}"
67 echo "#define APPVERSION ${APPVERSION##*.}" > appversion.h
68 echo '#define APPHASH "%{snap}"' >> appversion.h
69 APPDATE=$(date --date="%{date}" "+%s")
70 echo "#define APPDATE ${APPDATE}" >> appversion.h
71
72 %{__rm} -r extern tinyxpath
73
74 %build
75 install -d build && cd build
76 export CXXFLAGS="%{rpmcxxflags} -DPYTHON_LIBDIR=\\\"%{_libdir}\\\""
77 %cmake \
78         -DUSE_BUILTIN_JSONCPP=NO \
79         -DUSE_BUILTIN_MINIZIP=NO \
80         -DUSE_BUILTIN_MQTT=NO \
81         -DUSE_BUILTIN_SQLITE=NO \
82         -DUSE_BUILTIN_TINYXPATH=NO \
83         -DUSE_LUA_STATIC=NO \
84         -DUSE_OPENSSL_STATIC=NO \
85         -DUSE_STATIC_BOOST=NO \
86         -DUSE_STATIC_LIBSTDCXX=NO \
87         -DUSE_STATIC_OPENZWAVE=NO \
88         -DFORCE_WITH_GPIO:BOOL=TRUE \
89         -DCMAKE_INSTALL_PREFIX=%{_datadir}/%{name} \
90         ..
91
92 %{__make}
93
94 %install
95 rm -rf $RPM_BUILD_ROOT
96
97 %{__make} -C build install \
98         DESTDIR=$RPM_BUILD_ROOT
99
100 install -d $RPM_BUILD_ROOT{%{_bindir},%{_sysconfdir}/{domoticz,sysconfig},%{systemdunitdir},%{_sharedstatedir}/%{name}}
101
102 # remove docs, we grab them in files below
103 %{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/*.txt
104
105 # move binary to standard directory
106 mv $RPM_BUILD_ROOT%{_datadir}/%{name}/%{name} $RPM_BUILD_ROOT%{_bindir}
107
108 sed -e 's#@DOMOTICZ_DIR@#%{_datadir}/%{name}#g' %{SOURCE1} > $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
109 sed -e 's#@DOMOTICZ_DIR@#%{_datadir}/%{name}#g' scripts/domoticz.conf > $RPM_BUILD_ROOT%{_sysconfdir}/domoticz/domoticz.conf
110 sed -e 's#@DOMOTICZ_CONF_DIR@#%{_sysconfdir}/%{name}#' %{SOURCE2} > $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
111
112 # Unbundle DroidSans.ttf
113 %{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element{al,-light,-dark}/fonts/{Droid,Open}Sans.ttf
114 ln -s %{_fontsdir}/TTF/DroidSans.ttf \
115         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/elemental/fonts
116 ln -s %{_fontsdir}/TTF/OpenSans-Regular.ttf \
117         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/elemental/fonts/OpenSans.ttf
118 ln -s %{_fontsdir}/TTF/DroidSans.ttf \
119         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-light/fonts
120 ln -s %{_fontsdir}/TTF/OpenSans-Regular.ttf \
121         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-light/fonts/OpenSans.ttf
122 ln -s %{_fontsdir}/TTF/DroidSans.ttf \
123         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-dark/fonts
124 ln -s %{_fontsdir}/TTF/OpenSans-Regular.ttf \
125         $RPM_BUILD_ROOT%{_datadir}/%{name}/www/styles/element-dark/fonts/OpenSans.ttf
126
127 # OpenZWave Control Panel temp file
128 ln -s %{_sharedstatedir}/%{name}/ozwcp.poll.XXXXXX.xml \
129         $RPM_BUILD_ROOT%{_datadir}/%{name}/ozwcp.poll.XXXXXX.xml
130
131 %clean
132 rm -rf $RPM_BUILD_ROOT
133
134 %pre
135 %groupadd -g 342 domoticz
136 %useradd -u 342 -r -d %{_datadir} -s /bin/false -c "Domoticz Home Automation Server" -G dialout,i2c -g domoticz domoticz
137
138 %post
139 %systemd_post %{name}.service
140
141 %preun
142 %systemd_preun %{name}.service
143
144 %postun
145 if [ "$1" = "0" ]; then
146         %userremove domoticz
147         %groupremove domoticz
148 fi
149 %systemd_reload
150
151 %triggerpostun -- domoticz < 2022.1
152 if [ -f /etc/sysconfig/domoticz.rpmnew ] && [ -f /etc/sysconfig/domoticz ] && ! grep -q '^DOMOTICZ_CONF=' /etc/sysconfig/domoticz; then
153         (
154         . /etc/sysconfig/domoticz
155         for c in WWW_PORT:http_port SSL_PORT:ssl_port SSLCERT:ssl_cert SSLPASS:ssl_pass SSLMETHOD:ssl_method SSLOPTIONS:ssl_options SSLDHPARAM:ssl_dhparam WWW_ROOT:http_root DBASE:dbase_file USERDATA:userdata_path LOG:log_file; do
156                 cn_before=${c%:*}
157                 cn_after=${c#*:}
158                 eval cn_value=\"\$$cn_before\"
159                 test -n "$cn_value" && sed -i -e "s|^[[:space:]#]*$cn_after=.*|$cn_after=$cn_value|" %{_sysconfdir}/%{name}/%{name}.conf
160         done
161         )
162         mv -f /etc/sysconfig/domoticz{,.rpmsave}
163         mv /etc/sysconfig/domoticz{.rpmnew,}
164 fi
165
166 %files
167 %defattr(644,root,root,755)
168 %doc License.txt README.md History.txt
169 %attr(755,root,root) %{_bindir}/%{name}
170 %dir %attr(750,domoticz,domoticz) %{_sysconfdir}/%{name}
171 %attr(640,domoticz,domoticz) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/%{name}.conf
172 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
173 %{_datadir}/%{name}
174 %dir %attr(750,domoticz,domoticz) %{_sharedstatedir}/%{name}
175 %{systemdunitdir}/%{name}.service
This page took 0.064869 seconds and 4 git commands to generate.