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