]> git.ipfire.org Git - thirdparty/lldpd.git/blob - redhat/lldpd.spec
redhat: use /sbin/nologin as a shell for lldpd
[thirdparty/lldpd.git] / redhat / lldpd.spec
1 # configure options
2
3 # Define with/without/bcond_without macros (needed for RHEL4)
4 %define with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
5 %define without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
6 %define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
7 %define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
8
9 # Conditional build options, disable with "--without xxx"
10 %bcond_without xml
11 %bcond_without cdp
12 %bcond_without edp
13 %bcond_without sonmp
14 %bcond_without fdp
15 %bcond_without lldpmed
16 %bcond_without dot1
17 %bcond_without dot3
18 %bcond_without custom
19 %bcond_with json
20
21 # On RHEL < 5, disable SNMP, Net-SNMP installation seems broken
22 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 500 || 0%{?centos_version} > 0 && 0%{?centos_version} < 500
23 %bcond_with snmp
24 %else
25 %bcond_without snmp
26 %endif
27
28 # On RHEL <= 6, compile with oldies
29 # For SuSE, SLE11 with a recent SP comes with 3.0. SLE12 comes with 3.12.
30 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 700 || 0%{?centos_version} > 0 && 0%{?centos_version} < 700
31 %bcond_without oldies
32 %else
33 %bcond_with oldies
34 %endif
35
36 # On RHEL < 7, disable systemd
37 # On SuSE < 12, disable systemd
38 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 700 || 0%{?centos_version} > 0 && 0%{?centos_version} < 700 || 0%{?suse_version} > 0 && 0%{?suse_version} < 1200
39 %bcond_with systemd
40 %else
41 %bcond_without systemd
42 %endif
43
44 # On RHEL < 7, use embedded libevent
45 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 700 || 0%{?centos_version} > 0 && 0%{?centos_version} < 700 || 0%{?suse_version} > 0 && 0%{?suse_version} < 1200
46 %bcond_with system_libevent
47 %else
48 %bcond_without system_libevent
49 %endif
50
51 # On RHEL < 6, use embedded libnl
52 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 600 || 0%{?centos_version} > 0 && 0%{?centos_version} < 600 || 0%{?suse_version} > 0 && 0%{?suse_version} < 1200
53 %bcond_with system_libnl
54 %else
55 %bcond_without system_libnl
56 %endif
57
58 %define lldpd_user _lldpd
59 %define lldpd_group _lldpd
60 %define lldpd_chroot /var/run/lldpd
61
62 Summary: Implementation of IEEE 802.1ab (LLDP)
63 Name: lldpd
64 Version: 0.8.0
65 Release: 1%{?dist}
66 License: MIT
67 Group: System/Management
68 URL: http://vincentbernat.github.com/lldpd/
69 Source0: http://media.luffy.cx/files/lldpd/%{name}-%{version}.tar.gz
70 Source1: lldpd.init%{?suse_version:.suse}
71 Source2: lldpd.sysconfig
72
73 BuildRequires: pkgconfig
74 %if %{with system_libevent}
75 BuildRequires: libevent-devel
76 %endif
77 %if %{with system_libnl}
78 BuildRequires: libnl3-devel
79 %endif
80 BuildRequires: readline-devel
81 %if %{with snmp}
82 BuildRequires: net-snmp-devel
83 BuildRequires: openssl-devel
84 %{!?suse_version:BuildRequires: lm_sensors-devel}
85 %endif
86 %if %{with xml}
87 BuildRequires: libxml2-devel
88 %endif
89 %if %{with json}
90 BuildRequires: json-c-devel
91 %endif
92 %if %{with systemd}
93 Requires(post): systemd
94 Requires(preun): systemd
95 Requires(postun): systemd
96 BuildRequires: systemd
97 BuildRequires: systemd-units
98 %endif
99 %if 0%{?suse_version}
100 PreReq: %fillup_prereq %insserv_prereq pwdutils
101 %else
102 Requires(pre): /usr/sbin/groupadd /usr/sbin/useradd
103 Requires(post): chkconfig
104 Requires(preun): chkconfig
105 Requires(preun): initscripts
106 Requires(postun): initscripts
107 %endif
108
109 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
110
111 %description
112 This implementation provides LLDP sending and reception, supports VLAN
113 and includes an SNMP subagent that can interface to an SNMP agent
114 through AgentX protocol.
115
116 LLDP is an industry standard protocol designed to supplant proprietary
117 Link-Layer protocols such as Extreme EDP (Extreme Discovery Protocol)
118 and CDP (Cisco Discovery Protocol). The goal of LLDP is to provide an
119 inter-vendor compatible mechanism to deliver Link-Layer notifications
120 to adjacent network devices.
121
122 This daemon is also able to deal with CDP, FDP, SONMP and EDP
123 protocol. It also handles LLDP-MED extension.
124
125 %package devel
126 Summary: Implementation of IEEE 802.1ab - Tools and header files for developers
127 Group: Development/Libraries/C
128 BuildRequires: pkgconfig
129 Requires: lldpd = %{version}-%{release}
130
131 %description devel
132 This package is required to develop alternate clients for lldpd.
133
134 LLDP is an industry standard protocol designed to supplant proprietary
135 Link-Layer protocols such as Extreme EDP (Extreme Discovery Protocol)
136 and CDP (Cisco Discovery Protocol). The goal of LLDP is to provide an
137 inter-vendor compatible mechanism to deliver Link-Layer notifications
138 to adjacent network devices.
139
140 %prep
141 %setup -q
142 %build
143 %configure \
144 %if %{with snmp}
145 --with-snmp \
146 %endif
147 %if %{with xml}
148 --with-xml \
149 %endif
150 %if %{with cdp}
151 --enable-cdp \
152 %else
153 --disable-cdp \
154 %endif
155 %if %{with edp}
156 --enable-edp \
157 %else
158 --disable-edp \
159 %endif
160 %if %{with sonmp}
161 --enable-sonmp \
162 %else
163 --disable-sonmp \
164 %endif
165 %if %{with fdp}
166 --enable-fdp \
167 %else
168 --disable-fdp \
169 %endif
170 %if %{with lldpmed}
171 --enable-lldpmed \
172 %else
173 --disable-lldpmed \
174 %endif
175 %if %{with dot1}
176 --enable-dot1 \
177 %else
178 --disable-dot1 \
179 %endif
180 %if %{with dot3}
181 --enable-dot3 \
182 %else
183 --disable-dot3 \
184 %endif
185 %if %{with custom}
186 --enable-custom \
187 %else
188 --disable-custom \
189 %endif
190 %if %{with oldies}
191 --enable-oldies \
192 %else
193 --disable-oldies \
194 %endif
195 --with-privsep-user=%lldpd_user \
196 --with-privsep-group=%lldpd_group \
197 --with-privsep-chroot=%lldpd_chroot \
198 %if %{without systemd}
199 --with-systemdsystemunitdir=no \
200 %endif
201 --with-sysusersdir=no \
202 --prefix=%{_usr} \
203 --localstatedir=%{_localstatedir} \
204 --sysconfdir=%{_sysconfdir} \
205 --libdir=%{_libdir} \
206 --docdir=%{_docdir}/lldpd
207
208 [ -f %{_includedir}/net-snmp/agent/struct.h ] || touch src/struct.h
209 make %{?_smp_mflags}
210
211 %install
212 make install DESTDIR=$RPM_BUILD_ROOT
213 %if %{without systemd}
214 install -d $RPM_BUILD_ROOT/%{_initrddir}
215 install -m755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/lldpd
216 %endif
217 %if 0%{?suse_version}
218 mkdir -p ${RPM_BUILD_ROOT}/var/adm/fillup-templates
219 install -m700 %{SOURCE2} ${RPM_BUILD_ROOT}/var/adm/fillup-templates/sysconfig.lldpd
220 %else
221 install -d $RPM_BUILD_ROOT/etc/sysconfig
222 install -m644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/lldpd
223 %endif
224
225 %pre
226 # Create lldpd user/group
227 if getent group %lldpd_group >/dev/null 2>&1 ; then : ; else \
228 %{_sbindir}/groupadd -r %lldpd_group > /dev/null 2>&1 || exit 1 ; fi
229 if getent passwd %lldpd_user >/dev/null 2>&1 ; then : ; else \
230 %{_sbindir}/useradd -g %lldpd_group -M -r -s /sbin/nologin \
231 -c "LLDP daemon" -d %lldpd_chroot %lldpd_user 2> /dev/null \
232 || exit 1 ; fi
233
234 %if 0%{?suse_version}
235 # Service management for SuSE
236
237 %post
238 /sbin/ldconfig
239 %{fillup_and_insserv lldpd}
240 %postun
241 /sbin/ldconfig
242 %restart_on_update lldpd
243 %insserv_cleanup
244 %preun
245 %stop_on_removal lldpd
246
247 %elseif %{without systemd}
248 # Service management for Redhat/CentOS without systemd
249
250 %post
251 /sbin/ldconfig
252 /sbin/chkconfig --add lldpd
253 %postun
254 /sbin/ldconfig
255 if [ "$1" -ge "1" ]; then
256 /sbin/service lldpd condrestart >/dev/null 2>&1 || :
257 fi
258 %preun
259 if [ "$1" = "0" ]; then
260 /sbin/service lldpd stop > /dev/null 2>&1
261 /sbin/chkconfig --del lldpd
262 fi
263
264 %else
265 # Service management for Redhat/CentOS with systemd
266
267 %post
268 /sbin/ldconfig
269 %systemd_post lldpd.service
270
271 %preun
272 %systemd_preun lldpd.service
273
274 %postun
275 %systemd_postun_with_restart lldpd.service
276 /sbin/ldconfig
277
278 %endif
279
280 %clean
281 rm -rf $RPM_BUILD_ROOT
282
283 %files
284 %defattr(-,root,root,-)
285 %dir %{_docdir}/lldpd
286 %doc %{_docdir}/lldpd/NEWS
287 %doc %{_docdir}/lldpd/ChangeLog
288 %doc %{_docdir}/lldpd/README.md
289 %doc %{_docdir}/lldpd/CONTRIBUTE.md
290 %{_sbindir}/lldpd
291 %{_sbindir}/lldpctl
292 %{_sbindir}/lldpcli
293 %{_libdir}/liblldpctl.so.*
294 %{_datadir}/zsh
295 %{_datadir}/bash-completion
296 %doc %{_mandir}/man8/lldp*
297 %config %{_sysconfdir}/lldpd.d
298 %if %{without systemd}
299 %config %attr(755,root,root) %{_initrddir}/lldpd
300 %else
301 %{_unitdir}/lldpd.service
302 %endif
303 %if 0%{?suse_version}
304 %attr(644,root,root) %{_var}/adm/fillup-templates/sysconfig.lldpd
305 %else
306 %config(noreplace) %{_sysconfdir}/sysconfig/lldpd
307 %endif
308
309 %files devel
310 %defattr(-,root,root)
311 %{_libdir}/liblldpctl.so
312 %{_libdir}/liblldpctl.a
313 %{_libdir}/liblldpctl.la
314 %{_libdir}/pkgconfig/lldpctl.pc
315 %{_includedir}/lldpctl.h
316 %{_includedir}/lldp-const.h
317
318 %changelog
319 * Sun Nov 22 2015 Vincent Bernat <bernat@luffy.cx> - 0.8.0-1
320 - New upstream version.
321 - Use system libnl3 when possible.
322 - Use system libevent when possible.
323
324 * Wed Sep 09 2015 Vincent Bernat <bernat@luffy.cx> - 0.7.17-1
325 - New upstream version.
326
327 * Fri Aug 07 2015 Vincent Bernat <bernat@luffy.cx> - 0.7.16-1
328 - New upstream version.
329
330 * Wed May 20 2015 Vincent Bernat <bernat@luffy.cx> - 0.7.15-1
331 - New upstream version.
332
333 * Sat Apr 04 2015 Vincent Bernat <bernat@luffy.cx> - 0.7.14-1
334 - New upstream version.
335
336 * Tue Dec 30 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.13-1
337 - New upstream version.
338
339 * Sat Nov 22 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.12-1
340 - New upstream version.
341 - Completion for bash and zsh.
342
343 * Wed Oct 08 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.11-1
344 - New upstream version.
345 - Completion for bash and zsh.
346
347 * Mon Jul 21 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.10-1
348 - New upstream version.
349
350 * Wed May 28 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.9-1
351 - New upstream version.
352
353 * Sun Apr 13 2014 Vincent Bernat <bernat@luffy.cx> - 0.7.8-1
354 - New upstream version.
355
356 * Sun Nov 10 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.7-1
357 - New upstream version.
358
359 * Fri Jul 12 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.6-1
360 - New upstream version.
361
362 * Sat Jun 22 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.5-1
363 - New upstream version.
364
365 * Sun May 12 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.3-1
366 - New upstream version.
367
368 * Fri Apr 19 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.2-1
369 - New upstream version.
370
371 * Sat Jan 12 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.1-1
372 - New upstream version.
373
374 * Sun Jan 06 2013 Vincent Bernat <bernat@luffy.cx> - 0.7.0-1
375 - New upstream version.
376 - Requires readline-devel.
377 - Ships lldpcli.
378
379 * Thu Sep 27 2012 Vincent Bernat <bernat@luffy.cx> - 0.6.1-1
380 - New upstream version
381 - Do not require libevent, use embedded copy.
382 - Provide a -devel package.
383
384 * Fri Jun 11 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.1-1
385 - New upstream version
386 - Define bcond_without and with macros if not defined to be compatible
387 with RHEL
388 - Requires useradd and groupadd
389 - Adapt to make it work with SuSE
390 - Provide an init script targetted at SuSE
391 - Build require lm_sensors-devel on RHEL
392
393 * Fri Mar 12 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.0-1
394 - New upstream version
395 - Add XML support
396
397 * Tue May 19 2009 Vincent Bernat <bernat@luffy.cx> - 0.4.0-1
398 - Add variables
399 - Enable SNMP support
400 - Add _lldpd user creation
401 - Add initscript
402 - New upstream version
403
404 * Mon May 18 2009 Dean Hamstead <dean.hamstead@optusnet.com.au> - 0.3.3-1
405 - Initial attempt