LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File dhcp.spec of Package dhcp.219 (Project openSUSE:12.1:Update)

#
# spec file for package dhcp
#
# Copyright (c) 2012 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 http://bugs.opensuse.org/
#

# norootforbuild

%define isc_version   4.2.3-P2
%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
%endif
BuildRequires:  openldap2-devel
%endif
BuildRequires:  dos2unix
BuildRequires:  libtool
License:        BSD3c(or similar)
Group:          Productivity/Networking/Boot/Servers
AutoReqProv:    on
Version:        4.2.3.P2
Release:        0.<RELEASE0>
Summary:        Common Files Used by ISC DHCP Software
Url:            http://www.isc.org/software/dhcp
Source0:        dhcp-%{isc_version}.tar.bz2
#
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
#
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 thomas@suse.de 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.2-dhclient-send-hostname-rml.diff
## patch repo lives here: http://www.suse.de/~mt/git/dhcp-ldap.git/
Patch30:        dhcp-4.2.2-ldap-patch-mt01.diff.bz2
Patch40:        dhcp-4.1.1-P1-lpf-bind-msg-fix.diff
Patch44:        dhcp-4.2.2-xen-checksum.diff
Patch45:        dhcp-4.2.2-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.2-dhclient-option_param-a.diff
Patch49:        dhcp-4.2.2-dhclient-log-pid.diff
Patch50:        dhcp-4.2.2-dhclient-zero-length-options.patch
##
PreReq:         /bin/touch /sbin/chkconfig sysconfig
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

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

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

%package relay
License:        BSD3c(or similar)
Summary:        ISC DHCP Relay Agent
Group:          Productivity/Networking/Boot/Servers
Requires:       net-tools dhcp = %{version}
PreReq:         %insserv_prereq %fillup_prereq /bin/cat /bin/mkdir /bin/cp 
AutoReqProv:    on

%package devel
License:        BSD3c(or similar)
Summary:        Header Files and Libraries for dhcpctl API
Group:          Development/Libraries/C and C++
Requires:       dhcp = %{version}

%if %{with_doc_package}

%package doc
License:        BSD3c(or similar)
Summary:        Documentation
Group:          Productivity/Networking/Boot/Servers
%endif

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

Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>


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

Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>


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

Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>

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


Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>

%if %{with_doc_package}

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

Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>

%endif

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

Authors:
--------
    Internet Systems Consortium, Inc. <info@isc.org>


%prep
%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
%endif
%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/*

%build
# 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
popd
%if %suse_version >= 1210
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -W -Wall -Wno-unused"
%else
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -W -Wall -fno-strict-aliasing -Wno-unused"
%endif
%ifarch ppc ppc64 s390x
  # bugs 134590, 171532
  CFLAGS="$CFLAGS -fsigned-char"
%endif
%ifarch ia64 %sparc alpha s390x ppc64 x86_64
  CFLAGS="$CFLAGS -fPIE" 
%else
  CFLAGS="$CFLAGS -fpie" 
%endif
%if %suse_version >= 1210
LDFLAGS="-Wl,-z,relro,-z,now -pie"
%else
LDFLAGS="-pie"
%endif
FFLAGS="$CFLAGS"
CXXFLAGS="$CFLAGS"
export RPM_OPT_FLAGS LDFLAGS
export CFLAGS FFLAGS CXXFLAGS
#
%{?suse_update_config:%{suse_update_config -f}}
libtoolize --force
autoreconf
#
%configure \
	--enable-dhcpv6 \
	--enable-failover \
	--enable-paranoia \
	--enable-early-chroot \
%if %{with_ldap}
	--with-ldap \
	--with-ldapcrypto \
%if %{with_ldapcasa}
	--with-ldapcasa \
%endif
%endif
	--with-cli-pid-file=%{_localstatedir}/run/dhclient.pid \
	--with-cli-lease-file=%{_localstatedir}/lib/dhcp/dhclient.leases \
	--with-cli6-pid-file=%{_localstatedir}/run/dhclient6.pid \
	--with-cli6-lease-file=%{_localstatedir}/lib/dhcp6/dhclient.leases \
	--with-srv-pid-file=%{_localstatedir}/run/dhcpd.pid \
	--with-srv-lease-file=%{_localstatedir}/lib/dhcp/db/dhcpd.leases \
	--with-srv6-pid-file=%{_localstatedir}/run/dhcpd6.pid \
	--with-srv6-lease-file=%{_localstatedir}/lib/dhcp6/db/dhcpd6.leases
#
make %{?_smp_mflags}

%check
# 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

%install
export RPM_BUILD_ROOT
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
%endif
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                  \
                  $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd
ln -sf            %{_sysconfdir}/init.d/dhcpd               \
                  $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd
install    -m0755 $RPM_SOURCE_DIR/rc.dhcpd6                 \
                  $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcpd6
ln -sf            %{_sysconfdir}/init.d/dhcpd6              \
                  $RPM_BUILD_ROOT%{_sbindir}/rcdhcpd6
install    -m0755 $RPM_SOURCE_DIR/rc.dhcrelay               \
                  $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay
ln -sf            %{_sysconfdir}/init.d/dhcrelay            \
                  $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay
install    -m0755 $RPM_SOURCE_DIR/rc.dhcrelay6              \
                  $RPM_BUILD_ROOT%{_sysconfdir}/init.d/dhcrelay6
ln -sf            %{_sysconfdir}/init.d/dhcrelay6           \
                  $RPM_BUILD_ROOT%{_sbindir}/rcdhcrelay6
# sysconfig files
install    -m0644 $RPM_SOURCE_DIR/sysconfig.dhcpd           \
                  $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/
install    -m0644 $RPM_SOURCE_DIR/sysconfig.syslog-dhcpd    \
                  $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/
install    -m0644 $RPM_SOURCE_DIR/sysconfig.dhcrelay        \
                  $RPM_BUILD_ROOT%{_localstatedir}/adm/fillup-templates/
# another config files and scripts
%if %{with_ldap}
install    -m0644 contrib/ldap/dhcp.schema                       \
                  $RPM_BUILD_ROOT%{_sysconfdir}/openldap/schema
%endif
install    -m0644 $RPM_SOURCE_DIR/dhcpd.xml                 \
                  $RPM_SOURCE_DIR/dhcpd6.xml                \
                  $RPM_BUILD_ROOT/%{omc_svcdir}/
install    -m0644 $RPM_SOURCE_DIR/SuSEfirewall2.dhcp-server \
                  $RPM_BUILD_ROOT/%{susefw2dir}/dhcp-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 \
                  $RPM_BUILD_ROOT/etc/sysconfig/network/scripts/dhcpd-restart-hook
ln -sf            ../scripts/dhcpd-restart-hook \
                  $RPM_BUILD_ROOT/etc/sysconfig/network/if-up.d/60-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

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

%preun server
%stop_on_removal dhcpd
%stop_on_removal dhcpd6

%postun server
%restart_on_update dhcpd
%restart_on_update dhcpd6
%insserv_cleanup

%post relay
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
	DHCRELAY6_LOWER_INTERFACES_ARGS DHCRELAY6_LOWER_INTERFACES}
%{rename_sysconfig_variable -f etc/sysconfig/dhcrelay
	DHCRELAY6_UPPER_INTERFACES_ARGS DHCRELAY6_UPPER_INTERFACES}
%{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
%insserv_cleanup

%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

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

%files
%defattr(-,root,root)
%config %{susefw2dir}/dhcp-server
%{_bindir}/omshell
%doc %{_mandir}/man1/omshell.1.gz
%doc %{_mandir}/man5/dhcp-eval.5.gz
%doc %{_mandir}/man5/dhcp-options.5.gz

%files server
%defattr(-,root,root)
%{_sbindir}/dhcpd
%{_sbindir}/dhcpd6
%{_sbindir}/rcdhcpd
%{_sbindir}/rcdhcpd6
%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
%endif
%{omc_svcdir}/dhcpd.xml
%{omc_svcdir}/dhcpd6.xml
%{_sysconfdir}/sysconfig/network/scripts/dhcpd-restart-hook
%{_sysconfdir}/sysconfig/network/if-up.d/60-dhcpd-restart-hook
%{_localstatedir}/adm/fillup-templates/sysconfig.dhcpd
%{_localstatedir}/adm/fillup-templates/sysconfig.syslog-dhcpd
%if %{with_doc_package}

%files doc
%defattr(-,root,root)
%endif
%doc LICENSE README RELNOTES
%doc LIESMICH.* README.*
%doc DDNS-howto.txt doc/*
%doc contrib examples

%files client 
%defattr(-,root,root)
/sbin/dhclient
/sbin/dhclient6
/sbin/dhclient-script
%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 
%defattr(-,root,root)
%{_sbindir}/dhcrelay
%{_sbindir}/dhcrelay6
%{_sbindir}/rcdhcrelay
%{_sbindir}/rcdhcrelay6
%config %{_sysconfdir}/init.d/dhcrelay
%config %{_sysconfdir}/init.d/dhcrelay6
%doc %{_mandir}/man8/dhcrelay.8.gz
%{_localstatedir}/adm/fillup-templates/sysconfig.dhcrelay

%files devel
%defattr(-,root,root)
%_libdir/lib*
%{_prefix}/include/*
%doc %{_mandir}/man3/omapi.3.gz
%doc %{_mandir}/man3/dhcpctl.3.gz

%changelog