]> git.ipfire.org Git - thirdparty/pdns.git/blob - builder-support/specs/dnsdist.spec
Merge pull request #8087 from rgacogne/mplexer-test-debug
[thirdparty/pdns.git] / builder-support / specs / dnsdist.spec
1 Name: dnsdist
2 Version: %{getenv:BUILDER_RPM_VERSION}
3 Release: %{getenv:BUILDER_RPM_RELEASE}%{dist}
4 Summary: Powerful and scriptable DNS loadbalancer
5 License: GPLv2
6 Vendor: PowerDNS.COM BV
7 Group: System/DNS
8 Source: %{name}-%{getenv:BUILDER_VERSION}.tar.bz2
9 BuildRequires: readline-devel
10 BuildRequires: libedit-devel
11 BuildRequires: openssl-devel
12
13 %if 0%{?el6}
14 BuildRequires: boost148-devel
15 BuildRequires: lua-devel
16 BuildRequires: protobuf-compiler
17 BuildRequires: protobuf-devel
18 BuildRequires: re2-devel
19 %endif
20 %if 0%{?suse_version}
21 BuildRequires: boost-devel
22 BuildRequires: lua-devel
23 BuildRequires: systemd
24 BuildRequires: systemd-units
25 BuildRequires: systemd-devel
26 %endif
27 %if 0%{?rhel} >= 7
28 BuildRequires: boost-devel
29 BuildRequires: gnutls-devel
30 BuildRequires: libcap-devel
31 BuildRequires: libsodium-devel
32 %ifarch aarch64
33 BuildRequires: lua-devel
34 %define lua_implementation lua
35 %else
36 BuildRequires: luajit-devel
37 %define lua_implementation luajit
38 %endif
39 BuildRequires: net-snmp-devel
40 BuildRequires: protobuf-compiler
41 BuildRequires: protobuf-devel
42 BuildRequires: re2-devel
43 BuildRequires: systemd
44 BuildRequires: systemd-devel
45 BuildRequires: systemd-units
46 %endif
47
48 %if 0%{?el6}
49 Requires(pre): shadow-utils
50 %endif
51 %if 0%{?suse_version}
52 Requires(pre): shadow
53 %systemd_requires
54 %endif
55 %if 0%{?rhel} >= 7
56 Requires(pre): shadow-utils
57 BuildRequires: fstrm-devel
58 %systemd_requires
59 %endif
60
61 %description
62 dnsdist is a high-performance DNS loadbalancer that is scriptable in Lua.
63
64 %prep
65 %if 0%{?rhel} == 6
66 %setup -n %{name}-%{getenv:BUILDER_VERSION}
67 %else
68 %autosetup -p1 -n %{name}-%{getenv:BUILDER_VERSION}
69 %endif
70
71 # run as dnsdist user
72 sed -i '/^ExecStart/ s/dnsdist/dnsdist -u dnsdist -g dnsdist/' dnsdist.service.in
73
74 %build
75 %configure \
76 --enable-option-checking=fatal \
77 --sysconfdir=/etc/dnsdist \
78 --disable-static \
79 --disable-dependency-tracking \
80 --disable-silent-rules \
81 --enable-unit-tests \
82 --enable-dns-over-tls \
83 %if 0%{?el6}
84 --disable-dnscrypt \
85 --without-libsodium \
86 --with-re2 \
87 --with-net-snmp \
88 --with-protobuf \
89 --with-boost=/usr/include/boost148 LIBRARY_PATH=/usr/lib64/boost148
90 %endif
91 %if 0%{?suse_version}
92 --disable-dnscrypt \
93 --without-libsodium \
94 --without-re2 \
95 --enable-systemd --with-systemd=/lib/systemd/system \
96 --without-protobuf \
97 --without-net-snmp
98 %endif
99 %if 0%{?rhel} >= 7
100 --enable-dnstap \
101 --with-gnutls \
102 --with-protobuf \
103 --with-lua=%{lua_implementation} \
104 --with-libcap \
105 --with-libsodium \
106 --enable-dnscrypt \
107 --enable-dns-over-https \
108 --enable-systemd --with-systemd=/lib/systemd/system \
109 --with-re2 \
110 --with-net-snmp \
111 PKG_CONFIG_PATH=/opt/lib64/pkgconfig
112 %endif
113
114 %if 0%{?el6}
115 make %{?_smp_mflags} LIBRARY_PATH=/usr/lib64/boost148
116 %else
117 make %{?_smp_mflags}
118 %endif
119 mv dnsdistconf.lua dnsdist.conf.sample
120
121 %check
122 make %{?_smp_mflags} check || (cat test-suite.log && false)
123
124 %install
125 %make_install
126 install -d %{buildroot}/%{_sysconfdir}/dnsdist
127 %if 0%{?el6}
128 install -d -m 755 %{buildroot}/%{_sysconfdir}/init && install -m 644 contrib/dnsdist.upstart.conf %{buildroot}/%{_sysconfdir}/init/%{name}.conf
129 install -d -m 755 %{buildroot}/%{_sysconfdir}/default && install -m 644 contrib/dnsdist.default %{buildroot}/%{_sysconfdir}/default/%{name}
130 %else
131 # EL7 and SUSE
132 sed -i "s,/^\(ExecStart.*\)dnsdist\(.*\)\$,\1dnsdist -u dnsdist -g dnsdist\2," %{buildroot}/lib/systemd/system/dnsdist.service
133 sed -i "s,/^\(ExecStart.*\)dnsdist\(.*\)\$,\1dnsdist -u dnsdist -g dnsdist\2," %{buildroot}/lib/systemd/system/dnsdist@.service
134 %endif
135
136 %pre
137 getent group dnsdist >/dev/null || groupadd -r dnsdist
138 getent passwd dnsdist >/dev/null || \
139 useradd -r -g dnsdist -d / -s /sbin/nologin \
140 -c "dnsdist user" dnsdist
141 exit 0
142
143 %post
144 %if 0%{?el6}
145 if [ -x /sbin/initctl ]; then
146 /sbin/initctl reload-configuration
147 fi
148 %endif
149 %if 0%{?suse_version}
150 %service_add_post %{name}.service
151 %endif
152 %if 0%{?rhel} >= 7
153 %systemd_post %{name}.service
154 %endif
155
156 %preun
157 %if 0%{?el6}
158 if [ $1 -eq 0 ] ; then
159 # This is package removal, not upgrade
160 /sbin/stop %{name} >/dev/null 2>&1 || :
161 fi
162 %endif
163 %if 0%{?suse_version}
164 %service_del_preun %{name}.service
165 %endif
166 %if 0%{?rhel} >= 7
167 %systemd_preun %{name}.service
168 %endif
169
170 %postun
171 %if 0%{?el6}
172 if [ $1 -ge 1 ] ; then
173 # Package upgrade, not uninstall
174 if [ -x /sbin/initctl ] && /sbin/initctl status %{name} 2>/dev/null | grep -q 'running' ; then
175 /sbin/initctl restart %{name} > /dev/null 2>&1 || :
176 fi
177 fi
178 %endif
179 %if 0%{?suse_version}
180 %service_del_postun %{name}.service
181 %endif
182 %if 0%{?rhel} >= 7
183 %systemd_postun_with_restart %{name}.service
184 %endif
185
186 %files
187 %{!?_licensedir:%global license %%doc}
188 %doc dnsdist.conf.sample
189 %doc README.md
190 %{_bindir}/*
191 %{_mandir}/man1/*
192 %dir %{_sysconfdir}/dnsdist
193 %if 0%{?el6}
194 %{_sysconfdir}/init/%{name}.conf
195 %{_sysconfdir}/default/%{name}
196 %else
197 /lib/systemd/system/dnsdist*
198 %endif