Mon, 17 Sep 2012 19:05:03 +0200
Import package vendor original spec for necessary manipulations.
1 ##
2 ## dhcpd.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package version
25 %define V_opkg 4.2.3
26 %define V_dist 4.2.3
28 # package information
29 Name: dhcpd
30 Summary: DHCP Daemon
31 URL: http://www.isc.org/products/DHCP/
32 Vendor: Internet Software Consortium
33 Packager: OpenPKG Foundation e.V.
34 Distribution: OpenPKG Community
35 Class: BASE
36 Group: DHCP
37 License: ISC/BSD
38 Version: %{V_opkg}
39 Release: 20111211
41 # package options
42 %option with_fsl yes
44 # list of sources
45 Source0: ftp://ftp.isc.org/isc/dhcp/dhcp-%{V_dist}/dhcp-%{V_dist}.tar.gz
46 Source1: dhcpd.conf
47 Source2: rc.dhcpd
48 Source3: fsl.dhcpd
49 Patch0: dhcpd.patch
51 # build information
52 BuildPreReq: OpenPKG, openpkg >= 20100101
53 PreReq: OpenPKG, openpkg >= 20100101
54 BuildPreReq: openssl
55 PreReq: openssl
56 %if "%{with_fsl}" == "yes"
57 BuildPreReq: fsl
58 PreReq: fsl
59 %endif
61 %description
62 This is the ISC DHCP daemon reference implementation.
64 %track
65 prog dhcpd = {
66 version = %{V_dist}
67 url = ftp://ftp.isc.org/isc/dhcp/
68 regex = dhcp-(\d+\.\d+\.\d+)
69 }
71 %prep
72 %setup -q -n dhcp-%{V_dist}
73 %patch -p0
75 %build
76 # configure program
77 %{l_shtool} subst \
78 -e 's;^[^#]*\(#define[^_]*_PATH_DHCPD_PID[^"]*\).*;\1 "%{l_prefix}/var/dhcpd/run/dhcpd.pid";' \
79 -e 's;^[^#]*\(#define[^_]*_PATH_DHCPD_DB[^"]*\).*;\1 "%{l_prefix}/var/dhcpd/db/dhcpd.leases";' \
80 -e 's;^[^#]*\(#define[^_]*_PATH_DHCPD_CONF[^"]*\).*;\1 "%{l_prefix}/etc/dhcpd/dhcpd.conf";' \
81 includes/site.h
82 CC="%{l_cc}" \
83 CFLAGS="%{l_cflags -O}" \
84 CPPFLAGS="%{l_cppflags} -DNOMINUM" \
85 LDFLAGS="%{l_ldflags} %{l_fsl_ldflags}" \
86 LIBS="%{l_fsl_libs}" \
87 ./configure \
88 --prefix=%{l_prefix} \
89 --mandir=%{l_prefix}/man \
90 --sysconfdir=%{l_prefix}/etc/dhcpd \
91 --localstatedir=%{l_prefix}/var/dhcpd \
92 --with-srv-lease-file=%{l_prefix}/var/dhcpd/db/dhcpd.leases \
93 --with-cli-lease-file=%{l_prefix}/var/dhcpd/db/dhclient.leases \
94 --with-srv-pid-file=%{l_prefix}/var/dhcpd/run/dhcpd.pid \
95 --with-cli-pid-file=%{l_prefix}/var/dhcpd/run/dhclient.pid \
96 --with-relay-pid-file=%{l_prefix}/var/dhcpd/run/dhrelay.pid \
97 --disable-dhcpv6
99 # build program
100 %{l_make} %{l_mflags}
102 %install
103 # install program
104 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
106 # install default configuration
107 %{l_shtool} install -c -m 644 \
108 %{SOURCE dhcpd.conf} \
109 $RPM_BUILD_ROOT%{l_prefix}/etc/dhcpd/dhcpd.conf
111 # post-adjust and strip down installation
112 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/dhclient-script
113 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/dhclient-script.8
114 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
115 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
117 # install run-command script
118 %{l_shtool} mkdir -f -p -m 755 \
119 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
120 %{l_shtool} install -c -m 755 %{l_value -s -a} \
121 %{SOURCE rc.dhcpd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
123 # install OSSP fsl configuration
124 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
125 %{l_shtool} install -c -m 644 %{l_value -s -a} \
126 %{SOURCE fsl.dhcpd} \
127 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
129 # create run-time directories
130 %{l_shtool} mkdir -f -p -m 755 \
131 $RPM_BUILD_ROOT%{l_prefix}/var/dhcpd/db \
132 $RPM_BUILD_ROOT%{l_prefix}/var/dhcpd/run \
133 $RPM_BUILD_ROOT%{l_prefix}/var/dhcpd/log
135 # determine installation files
136 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
137 %{l_files_std} \
138 '%config %{l_prefix}/etc/fsl/fsl.dhcpd' \
139 '%config %{l_prefix}/etc/dhcpd/*'
141 %files -f files
143 %clean
145 %post
146 if [ $1 -eq 1 ]; then
147 # display final hints on initial installation
148 ( echo "Before starting DHCP daemon, please set the configuration variable"
149 echo "\"dhcpd_if\" in $RPM_INSTALL_PREFIX/etc/rc.conf to the name of the"
150 echo "used network interface."
151 ) | %{l_rpmtool} msg -b -t notice
152 fi
154 # after upgrade, restart service
155 [ $1 -eq 2 ] || exit 0
156 eval `%{l_rc} dhcpd status 2>/dev/null`
157 [ ".$dhcpd_active" = .yes ] && %{l_rc} dhcpd restart
158 exit 0
160 %preun
161 # before erase, stop service and remove log files
162 [ $1 -eq 0 ] || exit 0
163 %{l_rc} dhcpd stop 2>/dev/null
164 rm -f $RPM_INSTALL_PREFIX/var/dhcpd/db/* >/dev/null 2>&1 || true
165 rm -f $RPM_INSTALL_PREFIX/var/dhcpd/run/* >/dev/null 2>&1 || true
166 exit 0