File dhcp.spec of Package dhcp

# spec file for package dhcp
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define isc_version   4.2.5-P1
%define susefw2dir    %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
%define omc_prefix    /usr/share/omc
%define omc_svcdir    %{omc_prefix}/svcinfo.d
# always on
%define with_ldap         1
# on sles, but sles_version is gone
%define with_ldapcasa     0%{?sles_version} >= 10 || (%suse_version >= 1110 && %suse_version < 1140)
# doc package is new on 11.3
%define with_doc_package  %suse_version >= 1130

Name:           dhcp
%if %{with_ldap}
%if %{with_ldapcasa}
BuildRequires:  CASA-devel
BuildRequires:  openldap2-devel
BuildRequires:  dos2unix
BuildRequires:  libtool
Version:        4.2.5.P1
Release:        0.<RELEASE0>
Summary:        Common Files Used by ISC DHCP Software
License:        BSD-3-Clause
Group:          Productivity/Networking/Boot/Servers
Source0:        dhcp-%{isc_version}.tar.gz
Source1:        dhcp-%{isc_version}.tar.gz.asc
Source2:        %{name}.keyring
Source10:       rc.dhcpd
Source11:       rc.dhcpd6
Source12:       rc.dhcrelay
Source13:       rc.dhcrelay6
Source14:       sysconfig.dhcpd
Source15:       sysconfig.syslog-dhcpd
Source16:       sysconfig.dhcrelay
Source19:       if-up.d.dhcpd-restart-hook
Source20:       dhclient.conf
Source21:       dhclient6.conf
Source22:       dhcpd.conf
Source23:       dhcpd6.conf
Source24:       dhclient-script
Source30:       dhcpd.xml
Source31:       dhcpd6.xml
Source32:       SuSEfirewall2.dhcp-server
Source33:       SuSEfirewall2.dhcp6-server
Source40:       dhcp.LIESMICH
Source41:       dhcp.README
Source42:       dhcp.README.upgrade
Source43:       DDNS-howto.txt
Source44:       contrib.tar.gz
Source45:       examples.tar.gz
Patch10:        dhcp-4.1.1-default-paths.diff
# paranoia patch is included now, but not the
# additional patch by not ...
Patch11:        dhcp-4.1.1-paranoia.diff
Patch12:        dhcp-4.2.2-man-includes.diff
Patch13:        dhcp-4.1.1-tmpfile.diff
Patch15:        contrib-lease-path.diff
Patch20:        dhcp-4.1.1-dhclient-exec-filedes.diff
Patch21:        dhcp-4.2.5-dhclient-send-hostname-rml.patch
## my patch repo lives here:
Patch30:        dhcp-4.2.5-ldap-mt01.patch.bz2
Patch40:        dhcp-4.1.1-P1-lpf-bind-msg-fix.diff
Patch44:        dhcp-4.2.2-xen-checksum.diff
Patch45:        dhcp-4.2.4-dhclient-option-checks.bnc675052.diff
Patch46:        dhcp-4.2.2-close-on-exec.diff
Patch47:        dhcp-4.2.2-quiet-dhclient.bnc711420.diff
Patch48:        dhcp-4.2.3-P1-dhclient-log-pid.diff
Patch49:        dhcp-4.2.4-interface-discovery-using-getifaddrs.patch
Patch50:        dhcp-4.2.4-P2-do-not-die-on-sigpipe.patch
Patch60:        config-guess-sub-update.patch
PreReq:         /bin/touch /sbin/chkconfig sysconfig
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1220
BuildRequires:  gpg-offline

%package server
Summary:        ISC DHCP Server
Group:          Productivity/Networking/Boot/Servers
Requires:       dhcp = %{version}
Requires:       net-tools
PreReq:         %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp /usr/sbin/useradd

%package client
Summary:        ISC DHCP Client
Group:          Productivity/Networking/Boot/Clients
Requires:       /sbin/arping
Requires:       /usr/bin/host
Requires:       dhcp = %{version}
Requires:       net-tools
PreReq:         %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp /bin/grep

%package relay
Summary:        ISC DHCP Relay Agent
Group:          Productivity/Networking/Boot/Servers
Requires:       dhcp = %{version}
Requires:       net-tools
PreReq:         %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp 

%package devel
Summary:        Header Files and Libraries for dhcpctl API
Group:          Development/Libraries/C and C++
Requires:       dhcp = %{version}
Conflicts:      bind-devel

%if %{with_doc_package}

%package doc
Summary:        Documentation
Group:          Productivity/Networking/Boot/Servers

This package contains common programs used by both the ISC DHCP
server ("dhcp-server" package) and client ("dhcp-client") as the
omshell and common manual pages.

    Internet Systems Consortium, Inc. <>

%description server
This package contains the ISC DHCP server.

Please read the documentation in /usr/share/doc/packages/dhcp-server
regarding configuration of the DHCP server.

    Internet Systems Consortium, Inc. <>

%description client
This is an alternative DHCP client, the ISC DHCP client for Linux. Like
"dhcpcd" (the client that is installed by default), it can be used to
configure the network setup.  IP address, hostname, routing,
nameserver, netmask, and broadcast can be dynamically assigned while
booting the machine.

It is configurable via the configuration file /etc/dhclient.conf and
you can define your own 'hooks' to be used by the /sbin/dhclient-script
(which is called by the daemon).

    Internet Systems Consortium, Inc. <>

%description relay
This is the ISC DHCP relay agent. It can be used as a 'gateway' for
DHCP messages across physical network segments. This is necessary
because requests can be broadcast, and they will normally not be

    Internet Systems Consortium, Inc. <>

%if %{with_doc_package}

%description doc
This package contains additional documentation files provided with
the software. The manual pages are in the corresponding packages.

    Internet Systems Consortium, Inc. <>


%description devel
This package contains all of the libraries and headers for developing
with the Internet Software Consortium (ISC) dhcpctl API.

    Internet Systems Consortium, Inc. <>

%if 0%{?gpg_verify:1}
%gpg_verify %{S:1}
%setup -q -n %{name}-%{isc_version} -a 44 -a 45
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch15 -p0
%patch20 -p1
%patch21 -p1
%if %{with_ldap}
%patch30 -p1
%patch40 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
find . -type f -name \*.cat\* -exec rm -f {} \;
dos2unix contrib/ms2isc/*
# Remove GPL licensed files to make sure,
# they're not used to build (bnc#714004).
pushd bind
gunzip -c bind.tar.gz | tar xf -
rm -rf bind-*/contrib/dbus
patch -p0 -d bind-* < %{P:60}

%if %suse_version >= 1210
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -W -Wall -fno-strict-aliasing -Wno-unused"
%ifarch ppc ppc64 s390x
  # bugs 134590, 171532
  CFLAGS="$CFLAGS -fsigned-char"
%ifarch ia64 %sparc alpha s390x ppc64 x86_64
  CFLAGS="$CFLAGS -fpie" 
%if %suse_version >= 1210
LDFLAGS="-Wl,-z,relro,-z,now -pie"
%{?suse_update_config:%{suse_update_config -f}}
libtoolize --force
autoreconf -i
%configure \
	--enable-dhcpv6 \
	--enable-failover \
	--enable-paranoia \
	--enable-early-chroot \
%if %{with_ldap}
	--with-ldap \
	--with-ldapcrypto \
%if %{with_ldapcasa}
	--with-ldapcasa \
	--with-cli-pid-file=%{_localstatedir}/run/ \
	--with-cli-lease-file=%{_localstatedir}/lib/dhcp/dhclient.leases \
	--with-cli6-pid-file=%{_localstatedir}/run/ \
	--with-cli6-lease-file=%{_localstatedir}/lib/dhcp6/dhclient.leases \
	--with-srv-pid-file=%{_localstatedir}/run/ \
	--with-srv-lease-file=%{_localstatedir}/lib/dhcp/db/dhcpd.leases \
	--with-srv6-pid-file=%{_localstatedir}/run/ \
: building bind sources
make -C bind all
cat bind/configure.log
cat bind/build.log
cat bind/install.log
: building dhcp sources
make %{?_smp_mflags}

# with a minimal config, see if it runs
echo "ddns-update-style interim;" > testconf
./server/dhcpd -4 -t -cf testconf || exit 1
./server/dhcpd -6 -t -cf testconf || exit 1
# check syntax in our scripts
bash -n $RPM_SOURCE_DIR/rc.dhcpd
bash -n $RPM_SOURCE_DIR/rc.dhcpd6
bash -n $RPM_SOURCE_DIR/rc.dhcrelay
bash -n $RPM_SOURCE_DIR/rc.dhcrelay6
bash -n $RPM_SOURCE_DIR/dhclient-script

make install DESTDIR="$RPM_BUILD_ROOT"
# directories
install -d -m0755 $RPM_BUILD_ROOT/sbin
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/init.d
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/dhcpd{,6}.d
install -d -m0755 $RPM_BUILD_ROOT/%{susefw2dir}
install -d -m0755 $RPM_BUILD_ROOT/%{omc_svcdir}
%if %{with_ldap}
install -d -m0755 $RPM_BUILD_ROOT%{_sysconfdir}/openldap/schema
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/run
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates
# chroot jail
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/etc
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/dev
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/%_lib
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/var/run
install -d -m0755 $RPM_BUILD_ROOT%{_localstatedir}/lib/{dhcp,dhcp6}/db
# move the dhclient binary to /sbin
mv -f $RPM_BUILD_ROOT/usr/sbin/dhclient $RPM_BUILD_ROOT/sbin/
# provide a ...6 link, so we know it supports DHCPv6
ln -sf dhcpd      $RPM_BUILD_ROOT%{_sbindir}/dhcpd6
ln -sf dhcrelay   $RPM_BUILD_ROOT%{_sbindir}/dhcrelay6
ln -sf dhclient   $RPM_BUILD_ROOT/sbin/dhclient6
# install our adopted config examples and dhclient-script:
install    -m0644 $RPM_SOURCE_DIR/dhcpd.conf      $RPM_BUILD_ROOT%{_sysconfdir}/
install    -m0644 $RPM_SOURCE_DIR/dhcpd6.conf     $RPM_BUILD_ROOT%{_sysconfdir}/
install    -m0644 $RPM_SOURCE_DIR/dhclient.conf   $RPM_BUILD_ROOT%{_sysconfdir}/
install    -m0644 $RPM_SOURCE_DIR/dhclient6.conf  $RPM_BUILD_ROOT%{_sysconfdir}/
install    -m0750 $RPM_SOURCE_DIR/dhclient-script $RPM_BUILD_ROOT/sbin/
# init scripts
install    -m0755 $RPM_SOURCE_DIR/rc.dhcpd                  \
ln -sf            %{_sysconfdir}/init.d/dhcpd               \
install    -m0755 $RPM_SOURCE_DIR/rc.dhcpd6                 \
ln -sf            %{_sysconfdir}/init.d/dhcpd6              \
install    -m0755 $RPM_SOURCE_DIR/rc.dhcrelay               \
ln -sf            %{_sysconfdir}/init.d/dhcrelay            \
install    -m0755 $RPM_SOURCE_DIR/rc.dhcrelay6              \
ln -sf            %{_sysconfdir}/init.d/dhcrelay6           \
# sysconfig files
install    -m0644 $RPM_SOURCE_DIR/sysconfig.dhcpd           \
install    -m0644 $RPM_SOURCE_DIR/sysconfig.syslog-dhcpd    \
install    -m0644 $RPM_SOURCE_DIR/sysconfig.dhcrelay        \
# another config files and scripts
%if %{with_ldap}
install    -m0644 contrib/ldap/dhcp.schema                       \
install    -m0644 $RPM_SOURCE_DIR/dhcpd.xml                 \
                  $RPM_SOURCE_DIR/dhcpd6.xml                \
install    -m0644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp-server \
install    -m0644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp6-server \
install -d -m0755 $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d
install -d -m0755 $RPM_BUILD_ROOT/etc/sysconfig/network/scripts
install    -m0755 $RPM_SOURCE_DIR/if-up.d.dhcpd-restart-hook \
ln -sf            ../scripts/dhcpd-restart-hook \
# fix manual page permissions
find $RPM_BUILD_ROOT/%{_mandir} -type f | xargs chmod 644
# copy some documentation and examples from src dir
install    -m0644 $RPM_SOURCE_DIR/dhcp.LIESMICH       LIESMICH.SuSE
install    -m0644 $RPM_SOURCE_DIR/dhcp.README         README.SuSE
install    -m0644 $RPM_SOURCE_DIR/dhcp.README.upgrade README.upgrade
install    -m0644 $RPM_SOURCE_DIR/DDNS-howto.txt      .
cp                doc/examples/* ./examples/
rm -f             doc/{References.xml,Makefile*}
rm -f             contrib/dhcp.spec
rm -f             $RPM_BUILD_ROOT/etc/{dhcpd,dhclient}.conf.example
# install bind libs+includes needed for dhcp-devel
pushd bind
install -d -m0755 $RPM_BUILD_ROOT%_includedir/
for i in include/* ; do
	cp -r $i $RPM_BUILD_ROOT%_includedir/
install -d -m0755 $RPM_BUILD_ROOT%_libdir/
for l in lib/lib*.a ; do
	install -m0644 $l $RPM_BUILD_ROOT%_libdir/

%pre server
/usr/sbin/useradd -r -g nogroup -s /bin/false -c "DHCP server daemon" -d /var/lib/dhcp dhcpd 2> /dev/null ||:

%post server
%{fillup_and_insserv  -n dhcpd dhcpd dhcpd6}
%{fillup_only       -ans syslog dhcpd}
# update?
if [ ${FIRST_ARG:-0} -gt 1 ]; then
    if grep -q '^DHCPD_RUN_AS=.*nobody' etc/sysconfig/dhcpd; then
	tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX)
	sed 's|^DHCPD_RUN_AS=.*|DHCPD_RUN_AS="dhcpd"|' etc/sysconfig/dhcpd \
	  > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd
	rm -f $tmpfile
    if grep -q '^DHCPD_BINARY=.*dhcpd\..*' etc/sysconfig/dhcpd; then
	tmpfile=$(mktemp -q etc/sysconfig/dhcpd.XXXXXX)
	sed 's|^DHCPD_BINARY=.*|DHCPD_BINARY=""|' etc/sysconfig/dhcpd \
	  > $tmpfile && mv $tmpfile etc/sysconfig/dhcpd
	rm -f $tmpfile

%preun server
%stop_on_removal dhcpd
%stop_on_removal dhcpd6

%postun server
%restart_on_update dhcpd
%restart_on_update dhcpd6

%post relay
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
%{fillup_and_insserv  -n dhcrelay dhcrelay dhcrelay6}

%preun relay
%stop_on_removal dhcrelay
%stop_on_removal dhcrelay6

%postun relay
%restart_on_update dhcrelay
%restart_on_update dhcrelay6

%post client
test -e %{_localstatedir}/lib/dhcp/dhclient.leases   || \
  touch %{_localstatedir}/lib/dhcp/dhclient.leases
test -e %{_localstatedir}/lib/dhcp6/dhclient6.leases || \
  touch %{_localstatedir}/lib/dhcp6/dhclient6.leases

if ! test -f /.buildenv; then rm -rf $RPM_BUILD_ROOT; fi

%config %{susefw2dir}/dhcp-server
%config %{susefw2dir}/dhcp6-server
%doc %{_mandir}/man1/omshell.1.gz
%doc %{_mandir}/man5/dhcp-eval.5.gz
%doc %{_mandir}/man5/dhcp-options.5.gz

%files server
%config %{_sysconfdir}/init.d/dhcpd
%config %{_sysconfdir}/init.d/dhcpd6
%config(noreplace) %{_sysconfdir}/dhcpd.conf
%config(noreplace) %{_sysconfdir}/dhcpd6.conf
%attr(755,root,root) %dir %config(noreplace) %ghost %{_sysconfdir}/dhcpd.d/
%attr(755,root,root) %dir %config(noreplace) %ghost %{_sysconfdir}/dhcpd6.d/
%dir %{_localstatedir}/lib/dhcp
%dir %{_localstatedir}/lib/dhcp/etc
%dir %{_localstatedir}/lib/dhcp/dev
%dir %{_localstatedir}/lib/dhcp/%_lib
%dir %{_localstatedir}/lib/dhcp/var
%dir %{_localstatedir}/lib/dhcp/var/run
%attr(755,dhcpd,root) %dir %{_localstatedir}/lib/dhcp/db
%dir %{_localstatedir}/lib/dhcp6
%dir %{_localstatedir}/lib/dhcp6/etc
%dir %{_localstatedir}/lib/dhcp6/dev
%dir %{_localstatedir}/lib/dhcp6/%_lib
%dir %{_localstatedir}/lib/dhcp6/var
%dir %{_localstatedir}/lib/dhcp6/var/run
%attr(755,dhcpd,root) %dir %{_localstatedir}/lib/dhcp6/db
%doc %{_mandir}/man8/dhcpd.8.gz
%doc %{_mandir}/man5/dhcpd.conf.5.gz
%doc %{_mandir}/man5/dhcpd.leases.5.gz
%if %{with_ldap}
%dir %{_sysconfdir}/openldap
%dir %{_sysconfdir}/openldap/schema
%attr(0644, root, root) %config %{_sysconfdir}/openldap/schema/dhcp.schema
%if %{with_doc_package}

%files doc
%doc DDNS-howto.txt doc/*
%doc contrib examples

%files client 
%config(noreplace) %{_sysconfdir}/dhclient.conf
%config(noreplace) %{_sysconfdir}/dhclient6.conf
%doc %{_mandir}/man5/dhclient.conf.5.gz
%doc %{_mandir}/man5/dhclient.leases.5.gz
%doc %{_mandir}/man8/dhclient.8.gz
%doc %{_mandir}/man8/dhclient-script.8.gz
%dir %{_localstatedir}/lib/dhcp
%dir %{_localstatedir}/lib/dhcp6

%files relay 
%config %{_sysconfdir}/init.d/dhcrelay
%config %{_sysconfdir}/init.d/dhcrelay6
%doc %{_mandir}/man8/dhcrelay.8.gz

%files devel
%doc %{_mandir}/man3/omapi.3.gz
%doc %{_mandir}/man3/dhcpctl.3.gz

openSUSE Build Service is sponsored by