Blob Blame History Raw
## This package understands the following switches:
## --without dietlibc   ...   disable usage of dietlibc
## --without fedora     ...   disable fedora specific parts
## --with    minit      ...   disable creation of 'minit' subpackage


## Fedora Extras specific customization below...
%bcond_without		fedora
%bcond_without		noarch
%bcond_without		dietlibc
%bcond_with		minit
%bcond_with		sysv
%bcond_without		systemd
%bcond_without		upstart
##


%global	username	dhcp-fwd
%global homedir		%_var/lib/%username
%global minitdir	%_sysconfdir/minit
%global minitsvcdir	%minitdir/services/dhcp-fwd
%global service		dhcp-fwd

%{?with_noarch:%global noarch	BuildArch:	noarch}
%{!?_unitdir:%global _unitdir /lib/systemd/system}
%{!?release_func:%global release_func() %1%{?dist}}

Summary:	DHCP relay agent
Name:		dhcp-forwarder
Version:	0.9
Release:	%release_func 1501
License:	GPLv3
Group:		System Environment/Daemons
URL:		http://www.nongnu.org/dhcp-fwd/
Source0:	http://savannah.nongnu.org/download/dhcp-fwd/%name-%version.tar.xz
Source1:	http://savannah.nongnu.org/download/dhcp-fwd/%name-%version.tar.xz.asc
BuildRoot:	%_tmppath/%name-%version-%release-root
Requires:	init(%name)
BuildRequires:	which
BuildRequires:	fedora-usermgmt-devel
Provides:	user(%username) = 11
Provides:	group(%username) = 11
%{?FE_USERADD_REQ}

%{?with_dietlibc:BuildRequires:	dietlibc}

# Remove me after EOL of RHEL5
%package sysvinit
Summary:		SysV initscripts for dhcp-forwarder
Group:			System Environment/Base
Provides:		init(%name) = sysv
Requires:		%name = %version-%release
Requires(preun):	%name initscripts
Requires(postun):	%name initscripts
Requires(post):		/sbin/chkconfig
Requires(preun):	/sbin/chkconfig
Provides:		%name-sysv = %version-%release
Obsoletes:		%name-sysv < %version-%release
%{?noarch}

%package upstart
Summary:		upstart initscripts for dhcp-forwarder
Group:			System Environment/Base
Source10:		dhcp-forwarder.upstart
Provides:		init(%name) = upstart
Requires:		%name = %version-%release
Requires(pre):		/etc/init
Requires(post):		/usr/bin/killall
Requires(postun):	/sbin/initctl
%{?noarch}

%package minit
Summary:		minit initscripts for dhcp-forwarder
Group:			System Environment/Base
Provides:		init(%name) = minit
Requires:		%name = %version-%release
Requires(pre):		minit-setup
Requires(postun):	minit-setup
%{?noarch}

%package systemd
Summary:		Systemd initscripts for %name
Group:			System Environment/Daemons
Provides:		init(%name) = systemd
Source20:		%name.systemd.service
Requires(post):		/bin/systemctl
Requires(preun):	/bin/systemctl
Requires(postun):	/bin/systemctl
%{?noarch}

# Remove me after F17
%if 0%{!?with_sysv:1}
Provides:	%name-sysvinit = %version-%release
Obsoletes:	%name-sysvinit < %version-%release
%endif


%description
dhcp-fwd forwards DHCP messages between subnets with different sublayer
broadcast domains. It is similar to the DHCP relay agent dhcrelay of
ISC's DHCP, but has the following important features:

* Runs as non-root in a chroot-environment
* Uses AF_INET sockets which makes it possible to filter incoming
  messages with packetfilters
* The DHCP agent IDs can be defined freely
* Has a small memory footprint when using dietlibc


%description sysvinit
dhcp-fwd forwards DHCP messages between subnets with different sublayer
broadcast domains.

This package provides the scripts which can be used to start dhcp-forwarder
with the SysV initconcept.


%description upstart
dhcp-fwd forwards DHCP messages between subnets with different sublayer
broadcast domains.

This package provides the scripts which can be used to start dhcp-forwarder
with the upstart initconcept.


%description minit
dhcp-fwd forwards DHCP messages between subnets with different sublayer
broadcast domains.

This package provides the scripts which can be used to start dhcp-forwarder
with the minit initconcept.


%description systemd
dhcp-fwd forwards DHCP messages between subnets with different sublayer
broadcast domains.

This package provides the scripts which can be used to start dhcp-forwarder
with the systemd initconcept.



%prep
%setup -q


%build
%configure \
	--enable-release \
	--with-initrddir=%_initrddir \
	%{!?with_dietlibc:--disable}%{?with_dietlibc:--enable}-dietlibc
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install install-contrib
install -d -m 0700 $RPM_BUILD_ROOT%homedir $RPM_BUILD_ROOT%_var/run
install -D -p -m 0644 %SOURCE10 $RPM_BUILD_ROOT/etc/init/dhcp-forwarder.conf
install -D -p -m 0644 %SOURCE20 $RPM_BUILD_ROOT%_unitdir/%name.service

touch $RPM_BUILD_ROOT%_var/run/dhcp-fwd.pid

%{!?with_minit:   rm -rf $RPM_BUILD_ROOT%minitsvcdir}
%{!?with_systemd: rm -rf $RPM_BUILD_ROOT%_unitdir}
%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_var/run/dhcp-fwd.pid}
%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_initrddir}
%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_sysconfdir/sysconfig/dhcp-fwd}


%check
make check


%clean
rm -rf $RPM_BUILD_ROOT


%pre
%__fe_groupadd 11 -r %username &>/dev/null || :
%__fe_useradd  11 -r -s /sbin/nologin -M -c 'DHCP Forwarder user' \
                  -d %homedir -g %username %username &>/dev/null || :


%postun
%__fe_userdel  %username &>/dev/null || :
%__fe_groupdel %username &>/dev/null || :


%post sysvinit
/sbin/chkconfig --add %service

%preun sysvinit
if test "$1" = "0"; then
	%_initrddir/%service stop >/dev/null
	/sbin/chkconfig --del %service
fi

%postun sysvinit
test "$1" = "0" || %_initrddir/%service condrestart &>/dev/null


%post upstart
/usr/bin/killall -u %username dhcp-fwd 2>/dev/null || :

%preun upstart
test "$1" != "0" || /sbin/initctl -q stop dhcp-forwarder || :


%post systemd
test "$1" -ne 1 || /bin/systemctl daemon-reload >/dev/null 2>&1 || :

%preun systemd
test "$1" -ne 1 || /bin/systemctl disable %name.service > /dev/null 2>&1 || :
test "$1" -ne 1 || /bin/systemctl stop    %name.service > /dev/null 2>&1 || :

%postun systemd
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
test "$1" -eq 1 || /bin/systemctl try-restart %name.service >/dev/null 2>&1 || :


%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog NEWS README THANKS
%_mandir/*/*
%config(noreplace) %_sysconfdir/dhcp-fwd.conf
%_sbindir/*

## *DO NOT* add %defattr(-,dhcp-fwd,dhcp-fwd); the homedir is used for
## the chroot() only and there is no reason why the setuid()'ed daemon
## needs any kind of access there
%homedir


%if 0%{?with_minit:1}
%files minit
  %defattr(-,root,root,-)
  %dir %minitsvcdir
  %minitsvcdir/run
  %minitsvcdir/respawn
  %config(noreplace) %minitsvcdir/params
%endif

%if 0%{?with_systemd:1}
%files systemd
  %defattr(-,root,root,-)
  %_unitdir/%name.service
%endif

%if 0%{?with_sysv:1}
%files sysvinit
  %defattr(-,root,root,-)
  %config %_initrddir/*
  %config(noreplace) %_sysconfdir/sysconfig/*
  %ghost %_var/run/dhcp-fwd.pid
%endif

%if 0%{?with_upstart:1}
%files upstart
  %defattr(-,root,root,-)
  %config(noreplace) /etc/init/*
%endif


%changelog
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-1501
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Tue Dec 14 2010 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.9-1500
- updated to 0.9
- fixed source url and switched to .xz tarball
- added systemd initscripts and disabled generation of the old sysv ones
- minor specfile cleanups
- updated upstart script to wait for SIGSTOP

* Sun Dec  6 2009 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.8-1300
- updated -upstart to upstart 0.6.3

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Sun Mar  1 2009 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.8-4
- added upstart %%scriplets

* Sun Mar  1 2009 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.8-3
- added -upstart subpackage
- renamed -sysv subpackage to -sysvinit to make -upstart win the
  default dependency resolving

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Tue Dec 30 2008 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.8-1
- updated to 0.8
- license is now GPLv3, not GPLv2

* Wed Jul 16 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 0.7-15
- fix license tag

* Fri Feb 22 2008 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-14
- rebuilt with new dietlibc

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 0.7-13
- Autorebuild for GCC 4.3

* Thu Jan 18 2007 David Woodhouse <dwmw2@infradead.org> 0.7-12
- rebuilt with PPC support

* Thu Oct 05 2006 Christian Iseli <Christian.Iseli@licr.org> 0.7-11
 - rebuilt for unwind info generation, broken in gcc-4.1.1-21

* Mon Sep 18 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-10
- rebuilt

* Sun Jul  9 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-9
- rebuilt with dietlibc-0.30
- use new fedora-usermgmt code
- use %%bcond_* macros

* Mon Feb 20 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-8
- exclude PPC arch because dietlibc is not available there anymore

* Wed Jun  8 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-7
- do not build against dietlibc on non-i386 archs running FC3
- added sanity check for builds with mach
- buildrequire 'which'

* Thu May 19 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-4
- use %%dist instead of %%disttag

* Sun Mar  6 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.7-2
- fixed bigendian builds (backported from 0.8)
- s!%%define!%%global! to workaround bugs in rpm's macro-engine

* Thu Nov 11 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.7-0.fdr.1
- fedora'ized it

* Thu Aug 19 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.6.1-0
- added support for 'fedora-usermgmt' (enabled with '--with fedora' switch)

* Thu Jun 17 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.6.1-0
- conditionalized build of -minit subpackage

* Thu Aug  7 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0:0.5.1-0
- added minit support
- removed superfluous %%doc attribute of %%_mandir entries
- removed superfluous curlies
- use 'install-contrib' and cleaned up %%install section
- moved /etc/sysconfig/* file into -sysv subpackage; it is not used by
  -minit anymore
- minor cleanups

* Wed Jul 30 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0:0.5-0.fdr.1
- updated to version 0.5

* Tue May 27 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0:0.4-0.fdr.2
- create and remove group explicitely
- s/adduser/useradd/
- removed dependency on initscripts by calling the service-script in
  the %%post/%%preun scriptlets directly
- do not call '--install-contrib' anymore; it creates too much
  clutter to make sure that the initscripts will be installed into
  %%_initrddir but not in /etc/init.d. Instead of, install the
  scripts manually.

* Fri May  2 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0:0.4-0.fdr.1
- cleanups
- applied fedora.us naming scheme

* Wed Aug 28 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.3.1-1
- Added /etc/sysconfig/dhcp-fwd file

* Fri Jul 12 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.2.5-2
- Renamed username from dhcpfwd to dhcp-fwd
- Adjusted URL

* Fri Jul 12 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.2.5-1
- version 0.2.5
- Fixed some typos
- Added some PreReq's
- Enhanced %postun script

* Mon Jun 17 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.2-2
- Described purpose of the %%homedir and its handling

* Fri Jun 14 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.2-1
- Added manpage

* Thu Jun 13 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 0.1-0.3
- Added --without dietlibc option

* Sat Jun  1 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
- Initial build.