diff --git a/.gitignore b/.gitignore index e69de29..6d656f3 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/lldpd-0.9.7.tar.gz diff --git a/lldpd-fedora.service b/lldpd-fedora.service new file mode 100644 index 0000000..5ef083a --- /dev/null +++ b/lldpd-fedora.service @@ -0,0 +1,23 @@ +[Unit] +Description=LLDP daemon +Documentation=man:lldpd(8) +After=network.target + +[Service] +Type=notify +NotifyAccess=main +EnvironmentFile=-/etc/sysconfig/lldpd +ExecStart=/usr/sbin/lldpd $DAEMON_ARGS $LLDPD_OPTIONS +Restart=on-failure +PrivateTmp=yes +RestrictAddressFamilies=AF_INET AF_INET6 AF_PACKET AF_NETLINK AF_UNIX +ProtectHome=yes +ReadWritePaths=/var/run/lldpd +ProtectSystem=strict +ProtectKernelTunables=yes +ProtectControlGroups=yes +ProtectKernelModules=yes + +[Install] +WantedBy=multi-user.target + diff --git a/lldpd-tmpfiles b/lldpd-tmpfiles new file mode 100644 index 0000000..875f2a7 --- /dev/null +++ b/lldpd-tmpfiles @@ -0,0 +1,2 @@ +d /run/lldpd 0755 root root - +d /run/lldpd/chroot 0755 root root - diff --git a/lldpd.spec b/lldpd.spec new file mode 100644 index 0000000..d908169 --- /dev/null +++ b/lldpd.spec @@ -0,0 +1,146 @@ +# there are tests but they don't run in mock +# as they require the ability to create and act +# inside a network namespace +%bcond_with tests + +%global gh_owner vincentbernat + +Name: lldpd +Version: 0.9.7 +Release: 2%{?dist} +Summary: ISC-licensed implementation of LLDP + +License: ISC +URL: https://%{gh_owner}.github.io/%{name}/ +Source0: https://github.com/%{gh_owner}/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1: %{name}-fedora.service +Source2: %{name}-tmpfiles + +%if 0%{?with_tests} +#For tests +BuildRequires: python3-apipkg +BuildRequires: python3-execnet +BuildRequires: python3-py +BuildRequires: python3-pyroute2 +BuildRequires: python3-pytest +BuildRequires: python3-pytest-xdist +BuildRequires: python3-wheel +BuildRequires: python3-devel +%endif + +BuildRequires: libtool +BuildRequires: libevent-devel +BuildRequires: readline-devel +BuildRequires: check-devel +BuildRequires: net-snmp-devel +BuildRequires: libxml2-devel + +# For systemd stuff +BuildRequires: systemd +%{?systemd_requires} + +Requires(pre): shadow-utils + +%description +LLDP is an industry standard protocol designed to supplant proprietary +Link-Layer protocols such as EDP or CDP. The goal of LLDP is to provide +an inter-vendor compatible mechanism to deliver Link-Layer notifications +to adjacent network devices. + +%package devel +Requires: %{name}%{?_isa} = %{version}-%{release} +Summary: %{summary} + +%description devel +%{name} development libraries and headers + +%prep +%autosetup + + +%build +./autogen.sh +%configure --disable-static --with-snmp --disable-silent-rules \ + --with-systemdsystemunitdir=%{_unitdir} --with-sysusersdir=no \ + --with-privsep-user=%{name} --with-privsep-group=%{name} \ + --with-privsep-chroot=/run/%{name}/chroot \ + --with-lldpd-ctl-socket=/run/%{name}/%{name}.socket + +make %{?_smp_mflags} + + +%install +%make_install + +install -p -D -m644 redhat/%{name}.sysconfig %{buildroot}/etc/sysconfig/%{name} +install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service +install -p -D -m644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf +install -d -D -m 0755 %{buildroot}/run/%{name}/chroot +install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name} +# remove the docs from buildroot +rm -rf %{buildroot}/usr/share/doc/%{name} + + +# don't include completion conf yet +rm -f %{buildroot}/usr/share/bash-completion/completions/lldpcli +rm -f %{buildroot}/usr/share/zsh/vendor-completions/_lldpcli + +# remove static libtool archive +rm -f %{buildroot}%{_libdir}/liblldpctl.la + +%check +%if 0%{?with_tests} +cd tests/integration +%{__python3} -m pytest -n 5 -vv --boxed +%endif + +%pre +getent group %{name} >/dev/null || groupadd -r %{name} +getent passwd %{name} >/dev/null || \ + useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \ + -c "Used by the %{name} daemon" %{name} +exit 0 + +%post +/sbin/ldconfig +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +/sbin/ldconfig +%systemd_postun_with_restart %{name}.service + +%files +%doc NEWS README.md +%license LICENSE +%{_sbindir}/lldpcli +%{_sbindir}/lldpctl +%{_sbindir}/%{name} +%config %{_sysconfdir}/%{name}.d +%config(noreplace) %{_sysconfdir}/sysconfig/%{name} +%{_mandir}/man8/lldpcli.8* +%{_mandir}/man8/lldpctl.8* +%{_mandir}/man8/%{name}.8* +%{_libdir}/liblldpctl.so.4 +%{_libdir}/liblldpctl.so.4.8.0 +%dir /run/%{name} +%dir /run/%{name}/chroot +%{_unitdir}/%{name}.service +%{_tmpfilesdir}/%{name}.conf +%dir %attr(-,lldpd,lldpd) %{_sharedstatedir}/%{name} + +%files devel +%{_includedir}/lldp-const.h +%{_includedir}/lldpctl.h +%{_libdir}/liblldpctl.so +%{_libdir}/pkgconfig/lldpctl.pc + + +%changelog +* Wed Apr 05 2017 James Hogarth - 0.9.7-2 +- Tweaks to spec requested in review + +* Tue Apr 04 2017 James Hogarth - 0.9.7-1 +- Initial package diff --git a/sources b/sources index e69de29..e027035 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +SHA512 (lldpd-0.9.7.tar.gz) = ae115144b572bf2c9875bfb43fb18bb2ef5688533a511496b5be14f57fa0ef3949f5cfa384a106ff17bca943af9afa39fd977bc3bf49d230065334917cbcf6fc