]> git.ipfire.org Git - thirdparty/lldpd.git/blob - redhat/lldpd.spec
redhat: also ship lldpcli
[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 bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
6 %define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
7
8 # Conditional build options, disable with "--without xxx"
9 %bcond_without xml
10 %bcond_without cdp
11 %bcond_without edp
12 %bcond_without sonmp
13 %bcond_without fdp
14 %bcond_without lldpmed
15 %bcond_without dot1
16 %bcond_without dot3
17
18 # On RHEL < 5, disable SNMP, Net-SNMP installation seems broken. CentOS 5 too.
19 %if 0%{?rhel_version} > 0 && 0%{?rhel_version} < 600 || 0%{?centos_version} > 0 && 0%{?centos_version} < 600
20 %bcond_with snmp
21 %else
22 %bcond_without snmp
23 %endif
24
25 %define lldpd_user _lldpd
26 %define lldpd_group _lldpd
27 %define lldpd_chroot /var/run/lldpd
28
29 Summary: Implementation of IEEE 802.1ab (LLDP)
30 Name: lldpd
31 Version: 0.6.1
32 Release: 1%{?dist}
33 License: MIT
34 Group: System Environment/Daemons
35 URL: https://github.com/vincentbernat/lldpd/wiki
36 Source0: http://media.luffy.cx/files/lldpd/%{name}-%{version}.tar.gz
37 Source1: lldpd.init%{?suse_version:.suse}
38 Source2: lldpd.sysconfig
39
40 BuildRequires: pkgconfig
41 BuildRequires: libedit-devel
42 %if %{with snmp}
43 BuildRequires: net-snmp-devel
44 BuildRequires: openssl-devel
45 %{!?suse_version:BuildRequires: lm_sensors-devel}
46 %endif
47 %if %{with xml}
48 BuildRequires: libxml2-devel
49 %endif
50 %if 0%{?suse_version}
51 PreReq: %fillup_prereq %insserv_prereq pwdutils
52 %else
53 Requires(post): chkconfig
54 Requires(preun): chkconfig
55 Requires(preun): initscripts
56 Requires(postun): initscripts
57 %endif
58
59 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
60
61 %description
62 This implementation provides LLDP sending and reception, supports VLAN
63 and includes an SNMP subagent that can interface to an SNMP agent
64 through AgentX protocol.
65
66 LLDP is an industry standard protocol designed to supplant proprietary
67 Link-Layer protocols such as Extreme EDP (Extreme Discovery Protocol)
68 and CDP (Cisco Discovery Protocol). The goal of LLDP is to provide an
69 inter-vendor compatible mechanism to deliver Link-Layer notifications
70 to adjacent network devices.
71
72 This daemon is also able to deal with CDP, FDP, SONMP and EDP
73 protocol. It also handles LLDP-MED extension.
74
75 %package devel
76 Summary: Implementation of IEEE 802.1ab - Tools and header files for developers
77 Group: Development/Libraries
78 Requires: lldpd = %{version}-%{release}
79
80 %description devel
81 This package is required to develop alternate clients for lldpd.
82
83 %prep
84 %setup -q
85 %build
86 %configure \
87 %if %{with snmp}
88 --with-snmp \
89 %endif
90 %if %{with xml}
91 --with-xml \
92 %endif
93 %if %{with cdp}
94 --enable-cdp \
95 %else
96 --disable-cdp \
97 %endif
98 %if %{with edp}
99 --enable-edp \
100 %else
101 --disable-edp \
102 %endif
103 %if %{with sonmp}
104 --enable-sonmp \
105 %else
106 --disable-sonmp \
107 %endif
108 %if %{with fdp}
109 --enable-fdp \
110 %else
111 --disable-fdp \
112 %endif
113 %if %{with lldpmed}
114 --enable-lldpmed \
115 %else
116 --disable-lldpmed \
117 %endif
118 %if %{with dot1}
119 --enable-dot1 \
120 %else
121 --disable-dot1 \
122 %endif
123 %if %{with dot3}
124 --enable-dot3 \
125 %else
126 --disable-dot3 \
127 %endif
128 --with-privsep-user=%lldpd_user \
129 --with-privsep-group=%lldpd_group \
130 --with-privsep-chroot=%lldpd_chroot \
131 --prefix=/usr --localstatedir=%lldpd_chroot --sysconfdir=/etc --libdir=%{_libdir} \
132 --docdir=%{_docdir}/lldpd
133
134 [ -f /usr/include/net-snmp/agent/struct.h ] || touch src/struct.h
135 make %{?_smp_mflags}
136
137 %install
138 make install DESTDIR=$RPM_BUILD_ROOT
139 install -d -m770 $RPM_BUILD_ROOT/%lldpd_chroot
140 install -d $RPM_BUILD_ROOT/%{_initrddir}
141 install -m755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/lldpd
142 %if 0%{?suse_version}
143 mkdir -p ${RPM_BUILD_ROOT}/var/adm/fillup-templates
144 install -m700 %{SOURCE2} ${RPM_BUILD_ROOT}/var/adm/fillup-templates/sysconfig.lldpd
145 %else
146 install -d $RPM_BUILD_ROOT/etc/sysconfig
147 install -m644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/lldpd
148 %endif
149
150 %pre
151 # Create lldpd user/group
152 if getent group %lldpd_group >/dev/null 2>&1 ; then : ; else \
153 %{_sbindir}/groupadd -r %lldpd_group > /dev/null 2>&1 || exit 1 ; fi
154 if getent passwd %lldpd_user >/dev/null 2>&1 ; then : ; else \
155 %{_sbindir}/useradd -g %lldpd_group -M -r -s /bin/false \
156 -c "LLDP daemon" -d %lldpd_chroot %lldpd_user 2> /dev/null \
157 || exit 1 ; fi
158
159
160 %if 0%{?suse_version}
161 # Service management for SuSE
162
163 %post
164 %{fillup_and_insserv lldpd}
165 %postun
166 %restart_on_update lldpd
167 %insserv_cleanup
168 %preun
169 %stop_on_removal lldpd
170
171 %else
172 # Service management for Redhat/Centos
173
174 %post
175 /sbin/chkconfig --add lldpd
176 %postun
177 if [ "$1" -ge "1" ]; then
178 /sbin/service lldpd condrestart >/dev/null 2>&1 || :
179 fi
180 %preun
181 if [ "$1" = "0" ]; then
182 /sbin/service lldpd stop > /dev/null 2>&1
183 /sbin/chkconfig --del lldpd
184 fi
185
186 %endif
187
188 %clean
189 rm -rf $RPM_BUILD_ROOT
190
191 %files
192 %defattr(-,root,root,-)
193 %dir %{_docdir}/lldpd
194 %doc %{_docdir}/lldpd/NEWS
195 %doc %{_docdir}/lldpd/ChangeLog
196 %doc %{_docdir}/lldpd/README.md
197 %{_sbindir}/lldpd
198 %{_sbindir}/lldpctl
199 %{_sbindir}/lldpcli
200 %{_libdir}/liblldpctl.*
201 %doc %{_mandir}/man8/lldp*
202 %dir %attr(750,root,root) %lldpd_chroot
203 %config %attr(755,root,root) %{_initrddir}/lldpd
204 %if 0%{?suse_version}
205 %attr(644,root,root) /var/adm/fillup-templates/sysconfig.lldpd
206 %else
207 %config(noreplace) /etc/sysconfig/lldpd
208 %endif
209
210 %files devel
211 %defattr(-,root,root)
212 %{_libdir}/pkgconfig/lldpctl.pc
213 %{_includedir}/lldpctl.h
214 %{_includedir}/lldp-const.h
215
216 %changelog
217 * Wed Sep 27 2012 Vincent Bernat <bernat@luffy.cx> - 0.6.1-1
218 - New upstream version
219 - Do not require libevent, use embedded copy.
220 - Provide a -devel package.
221
222 * Fri Jun 11 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.1-1
223 - New upstream version
224 - Define bcond_without and with macros if not defined to be compatible
225 with RHEL
226 - Requires useradd and groupadd
227 - Adapt to make it work with SuSE
228 - Provide an init script targetted at SuSE
229 - Build require lm_sensors-devel on RHEL
230
231 * Fri Mar 12 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.0-1
232 - New upstream version
233 - Add XML support
234
235 * Tue May 19 2009 Vincent Bernat <bernat@luffy.cx> - 0.4.0-1
236 - Add variables
237 - Enable SNMP support
238 - Add _lldpd user creation
239 - Add initscript
240 - New upstream version
241
242 * Mon May 18 2009 Dean Hamstead <dean.hamstead@optusnet.com.au> - 0.3.3-1
243 - Initial attempt