From d623a64a778ad405e965d6cea926c74f4a0cc137 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 12 Jun 2010 00:56:06 +0200 Subject: [PATCH] Fix .spec for SuSE. Packages can now be built on OpenSuSE and SLES. It has not been really tested. Notably, maybe the init script is totally inappropriate... --- redhat/lldpd.init | 18 +++++++-------- redhat/lldpd.spec | 50 ++++++++++++++++++++++++++++++++---------- redhat/lldpd.sysconfig | 10 +++++++-- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/redhat/lldpd.init b/redhat/lldpd.init index 67f521fc..dce386ed 100644 --- a/redhat/lldpd.init +++ b/redhat/lldpd.init @@ -9,13 +9,13 @@ ### BEGIN INIT INFO # Provides: lldpd -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network -# Should-Start: -# Should-Stop: -# Default-Start: -# Default-Stop: -# Short-Description: start and stop LLDP daemon +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Should-Start: $syslog $network $net-snmp +# Should-Stop: $syslog $network $net-snmp +# Default-Start: 2 3 5 +# Default-Stop: 0 1 6 +# Short-Description: LLDP daemon # Description: 802.1ab (LLDP) daemon ### END INIT INFO @@ -23,7 +23,7 @@ . /etc/init.d/functions -OPTIONS="" +LLDPD_OPTIONS="" if [ -e /etc/sysconfig/lldpd ]; then . /etc/sysconfig/lldpd fi @@ -52,7 +52,7 @@ start() { failure else build_chroot - daemon --pidfile=$pidfile $binary $OPTIONS + daemon --pidfile=$pidfile $binary $LLDPD_OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lldpd fi; diff --git a/redhat/lldpd.spec b/redhat/lldpd.spec index 0b86a549..9772ee26 100644 --- a/redhat/lldpd.spec +++ b/redhat/lldpd.spec @@ -26,7 +26,7 @@ %define lldpd_group _lldpd %define lldpd_chroot /var/run/lldpd -Summary: implementation of IEEE 802.1ab (LLDP) +Summary: Implementation of IEEE 802.1ab (LLDP) Name: lldpd Version: 0.5.1 Release: 1%{?dist} @@ -39,15 +39,14 @@ Source2: lldpd.sysconfig %if %{with snmp} BuildRequires: net-snmp-devel -Requires: net-snmp BuildRequires: openssl-devel -Requires: openssl %endif %if %{with xml} BuildRequires: libxml2-devel -Requires: libxml2 %endif -Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd +%if 0%{?suse_version} +PreReq: %fillup_prereq %insserv_prereq pwdutils +%endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -119,14 +118,19 @@ protocol. It also handles LLDP-MED extension. [ -f /usr/include/net-snmp/agent/struct.h ] || touch src/struct.h make %{?_smp_mflags} +%define _initdir %{?suse_version:/etc/init.d}%{!?suse_version:/etc/rc.d/init.d} %install -rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT install -d -m770 $RPM_BUILD_ROOT/%lldpd_chroot -install -d $RPM_BUILD_ROOT/etc/rc.d/init.d +install -d $RPM_BUILD_ROOT/%{_initdir} +install -m755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initdir}/lldpd +%if 0%{?suse_version} +mkdir -p ${RPM_BUILD_ROOT}/var/adm/fillup-templates +install -m700 %{SOURCE2} ${RPM_BUILD_ROOT}/var/adm/fillup-templates/sysconfig.lldpd +%else install -d $RPM_BUILD_ROOT/etc/sysconfig install -m644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/lldpd -install -m755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/lldpd +%endif %pre # Create lldpd user/group @@ -137,32 +141,53 @@ if getent passwd %lldpd_user >/dev/null 2>&1 ; then : ; else \ -c "LLDP daemon" -d %lldpd_chroot %lldpd_user 2> /dev/null \ || exit 1 ; fi + +%if 0%{?suse_version} +# Service management for SuSE + %post -/sbin/chkconfig --add lldpd +%{fillup_and_insserv lldpd} +%postun +%restart_on_update lldpd +%insserv_cleanup +%preun +%stop_on_removal lldpd +%else +# Service management for Redhat/Centos + +%post +/sbin/chkconfig --add lldpd %postun if [ "$1" -ge "1" ]; then - /etc/rc.d/init.d/lldpd condrestart >/dev/null 2>&1 + %{_initdir}/lldpd condrestart >/dev/null 2>&1 fi - %preun if [ "$1" = "0" ]; then /sbin/chkconfig --del lldpd fi +%endif + %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) +%dir %_docdir/lldpd %doc %_docdir/lldpd/CHANGELOG %doc %_docdir/lldpd/README %_sbindir/lldpd %_sbindir/lldpctl %doc %_mandir/man8/lldp* %dir %attr(750,root,root) %lldpd_chroot +%config %{_initdir}/lldpd +%attr(755,root,root) %{_initdir}/* +%if 0%{?suse_version} +%attr(644,root,root) /var/adm/fillup-templates/sysconfig.lldpd +%else %config(noreplace) /etc/sysconfig/lldpd -%attr(755,root,root) /etc/rc.d/init.d/* +%endif %changelog * Fri Jun 11 2010 Vincent Bernat - 0.5.1-1 @@ -171,6 +196,7 @@ rm -rf $RPM_BUILD_ROOT with RHEL - Disable SNMP by default on Fedora 13 and RHEL. - Requires useradd and groupadd. +- Adapt to make it work with SuSE * Fri Mar 12 2010 Vincent Bernat - 0.5.0-1 - New upstream version diff --git a/redhat/lldpd.sysconfig b/redhat/lldpd.sysconfig index 795e5f48..de2adcce 100644 --- a/redhat/lldpd.sysconfig +++ b/redhat/lldpd.sysconfig @@ -1,2 +1,8 @@ -# Uncomment to start SNMP subagent and enable CDP, SONMP and EDP protocol -#OPTIONS="-x -c -s -e" +## Path: Network/Discovery +## Description: lldpd configuration +## Type: string(-x,-c,-s,-e,-f) +## Default: "" +## ServiceRestart: lldpd +# Parameters for lldpd. See the manual page for the +# accepted parameters. +LLDPD_OPTIONS="" -- 2.39.5