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		dietlibc
%bcond_with		minit
##


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

%{!?release_func:%global release_func() %1%{?dist}}

Summary:	DHCP relay agent
Name:		dhcp-forwarder
Version:	0.8
Release:	%release_func 1400
License:	GPLv3
Group:		System Environment/Daemons
URL:		http://www.tu-chemnitz.de/~ensc/dhcp-fwd
Source0:	http://www.tu-chemnitz.de/~ensc/dhcp-fwd/files/%name-%version.tar.bz2
Source1:	http://www.tu-chemnitz.de/~ensc/dhcp-fwd/files/%name-%version.tar.bz2.asc
Patch0:		reuseaddr.patch
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}

%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
BuildArch:		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
BuildArch:		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
BuildArch:		noarch


%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.



%prep
%setup -q
%patch0 -p1


%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
%__install -pD -m 0644 %SOURCE10 $RPM_BUILD_ROOT/etc/init/dhcp-forwarder.conf

%{!?with_minit:rm -rf $RPM_BUILD_ROOT%minitsvcdir}


%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 || :


%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


%files sysvinit
%defattr(-,root,root,-)
%config %_initrddir/*
%config(noreplace) %_sysconfdir/sysconfig/*


%files upstart
%defattr(-,root,root,-)
%config(noreplace) /etc/init/*


%if 0%{?with_minit:1}

%files minit
%defattr(-,root,root,-)
%dir %minitsvcdir
%minitsvcdir/run
%minitsvcdir/respawn
%config(noreplace) %minitsvcdir/params

%endif


%changelog
* Mon Jan  3 2011 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0.8-1400
- backported patch from 0.9 which allows to run dhcp-fwd and e.g. dnsmasq
  simultaneously on the same host

* 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.