forked from shadowsocks/pdnsd
-
Notifications
You must be signed in to change notification settings - Fork 9
/
pdnsd.spec.in
244 lines (222 loc) · 9.11 KB
/
pdnsd.spec.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# rpmbuild spec file for pdnsd.
# with modifications by Paul Rombouts.
# Supported rpmbuild --define and --with options include:
#
# --with isdn Configure with --enable-isdn.
#
# --without poll Configure with --disable-poll
#
# --without nptl Configure with --with-thread-lib=linuxthreads.
#
# --with ipv6 Configure with --enable-ipv6.
#
# --without tcpqueries Configure with --disable-tcp-queries.
#
# --without debug Configure with --with-debug=0.
#
# --define "distro <distro>" Configure with --with-distribution=<distro>.
#
# --define "run_as_user <user>" Configure with --with-default-id=<user>.
# For RPMs the default <user> is "@def_id@".
#
# --define "run_as_uid <uid>" If the user defined by the previous option does not exist
# when the RPM is installed, the pre-install script will try
# to create a new user with numerical id <uid>.
#
# --define "cachedir <dir>" Configure with --with-cachedir=<dir>.
#
%{!?distro: %define distro @distribution@}
# The default run_as ID to use
%{!?run_as_user: %define run_as_user @def_id@}
# By default, if a new run_as_user is to be created, we let
# useradd choose the numerical uid, unless run_as_uid is defined.
#define run_as_uid 96
%{!?cachedir: %define cachedir @cachedir@}
%define conffile %{_sysconfdir}/pdnsd.conf
Summary: A caching dns proxy for small networks or dialin accounts
Name: @PACKAGE@
Version: @VERSION@
Release: @packagerelease@
License: GPLv3
Group: Daemons
Source: http://members.home.nl/p.a.rombouts/pdnsd/releases/%{name}-%{version}-%{release}.tar.gz
URL: http://members.home.nl/p.a.rombouts/pdnsd.html
Vendor: Paul A. Rombouts
Packager: Paul A. Rombouts <[email protected]>
Prefix: %{_prefix}
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
pdnsd is a proxy DNS daemon with permanent (disk-)cache and the ability
to serve local records. It is designed to detect network outages or hangups
and to prevent DNS-dependent applications like Netscape Navigator from hanging.
The original author of pdnsd is Thomas Moestl, but pdnsd is no longer maintained
by him. This is an extensively revised version by Paul A. Rombouts.
For a description of the changes see http://members.home.nl/p.a.rombouts/pdnsd.html
and the file README.par in %{_docdir}/%{name}-%{version}
%{!?distro:You can specify the target distribution when you build the source RPM. For instance, if you're building for a Red Hat system call rpmbuild with:}
%{!?distro: --define "distro RedHat"}
%{?distro:This package was built for a %{distro} distribution.}
%{!?_with_isdn:It's possible to rebuild the source RPM with isdn support using the rpmbuild option:}
%{!?_with_isdn: --with isdn}
%{?_with_isdn:This package was built with isdn support enabled.}
%{!?_with_ipv6:It's possible to rebuild the source RPM with ipv6 support using the rpmbuild option:}
%{!?_with_ipv6: --with ipv6}
%{?_with_ipv6:This package was built with ipv6 support.}
%{?_without_poll:This package was built with the select(2) function instead of poll(2).}
%prep
%setup
%build
CFLAGS="${CFLAGS:-$RPM_OPT_FLAGS -Wall}" ./configure \
--prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --mandir=%{_mandir} \
--with-cachedir="%{cachedir}" \
%{?distro:--with-distribution=%{distro}} --enable-specbuild \
--with-default-id=%{run_as_user} \
%{?_with_isdn:--enable-isdn} \
%{?_without_poll:--disable-poll} \
%{?_without_nptl:--with-thread-lib=linuxthreads} \
%{?_with_ipv6:--enable-ipv6} \
%{?_without_tcpqueries:--disable-tcp-queries} \
%{?_without_debug:--with-debug=0}
make
%install
%if "%{run_as_user}" != "nobody"
[ "$(id -un)" != root ] ||
id -u %{run_as_user} > /dev/null 2>&1 ||
/usr/sbin/useradd -c "Proxy DNS daemon" %{?run_as_uid:-u %{run_as_uid}} \
-s /sbin/nologin -r -d "%{cachedir}" %{run_as_user} || {
set +x
echo "Cannot create user \"%{run_as_user}\"%{?run_as_uid: with uid=%{run_as_uid}}"
echo "Please select another numerical uid and rebuild with --define \"run_as_uid uid\""
echo "or create a user named \"%{run_as_user}\" by hand and try again."
exit 1
}
%endif
rm -rf "$RPM_BUILD_ROOT"
make DESTDIR="$RPM_BUILD_ROOT" install
cp -f file-list.base file-list
find doc contrib -not -type d -not -iname '*makefile' -not -name '*.am' \
-not -name '*.in' -not -path 'doc/*.pl' |
sed -e 's/^/%doc --parents /' >> file-list
CURDIR=$PWD; cd "$RPM_BUILD_ROOT"
find . -not -type d '(' -not -name 'pdnsd.conf*' -or -name 'pdnsd.conf.[1-9]*' ')' \
-not -path '.%{_docdir}/*' -not -path './var/*' |
sed -e 's/^\.//
\:/man:{
/\.gz$/!s/$/.gz/
}' >> "$CURDIR/file-list"
%clean
rm -rf "$RPM_BUILD_ROOT"
#rm -rf %{_builddir}/%{name}-%{srcver}
%files -f file-list
%pre
# First stop any running pdnsd daemons
%if "%{distro}" == "SuSE"
/sbin/init.d/pdnsd stop >/dev/null 2>&1
%endif
%if "%{distro}" == "RedHat"
if [ -f /var/lock/subsys/pdnsd ]; then
if /sbin/pidof pdnsd > /dev/null; then
/sbin/service pdnsd stop >/dev/null 2>&1
if [ "$1" -ge 2 ]; then touch /var/lock/subsys/pdnsd; fi
else
rm -f /var/lock/subsys/pdnsd
fi
fi
%endif
%if "%{run_as_user}" != "nobody"
# Add the "pdnsd" user
id -u %{run_as_user} > /dev/null 2>&1 ||
/usr/sbin/useradd -c "Proxy DNS daemon" %{?run_as_uid:-u %{run_as_uid}} \
-s /sbin/nologin -r -d "%{cachedir}" %{run_as_user} || {
echo "Cannot create user \"%{run_as_user}\"%{?run_as_uid: with uid=%{run_as_uid}}"
echo "Please create a user named \"%{run_as_user}\" by hand and try again."
exit 1
}
[ "$(id -gn %{run_as_user})" = %{run_as_user} ] || {
echo "user \"%{run_as_user}\" does not have an corresponding group called \"%{run_as_user}\""
echo "Please change the initial group of user \"%{run_as_user}\" to \"%{run_as_user}\" and try again."
exit 1
}
if [ -f "%{conffile}" ] &&
grep -v -e '^[[:blank:]]*\(#\|\/\/\)' "%{conffile}" |
grep -q -e '\<run_as[[:blank:]]*=[[:blank:]]*"\?nobody"\?[[:blank:]]*;'
then
echo "An existing pdnsd configuration file %{conffile} has been detected, containing the run_as user ID \"nobody\""
echo "For security reasons it is recommended that pdnsd run as a seperate user \"%{run_as_user}\""
mv -f "%{conffile}" "%{conffile}.rpmsave" &&
echo "Your original %{conffile} has been saved as %{conffile}.rpmsave" &&
sed -e '/^[[:blank:]]*\(#\|\/\/\)/!s/\(\<run_as[[:blank:]]*=[[:blank:]]*\)"\?nobody"\?[[:blank:]]*;/\1"%{run_as_user}";/g' \
"%{conffile}.rpmsave" > "%{conffile}" &&
echo "In %{conffile} runs_as=\"nobody\" has been replaced by run_as=\"%{run_as_user}\""
fi
%endif
if [ -f "%{cachedir}/pdnsd.cache" ]; then
chown -c %{run_as_user}:%{run_as_user} "%{cachedir}/pdnsd.cache"
fi
%post
%if "%{distro}" == "SuSE"
if [ -w /etc/rc.config ]; then
grep "START_PDNSD" /etc/rc.config > /dev/null
if [ $? -ne 0 ] ; then
echo -e \
"\n\n#\n# Set to yes to start pdnsd at boot time\n#\nSTART_PDNSD=yes" \
>> /etc/rc.config
fi
fi
%endif
%if "%{distro}" == "RedHat"
if [ "$1" = 1 ]; then
/sbin/chkconfig --add pdnsd
fi
%endif
%preun
%if "%{distro}" == "RedHat"
if [ "$1" = 0 ]; then
/sbin/service pdnsd stop >/dev/null 2>&1
/sbin/chkconfig --del pdnsd
fi
%endif
%postun
%if "%{distro}" == "RedHat"
if [ "$1" -ge 1 ]; then
/sbin/service pdnsd condrestart >/dev/null 2>&1
fi
%endif
%changelog
* Tue Jan 31 2012 Paul A. Rombouts <[email protected]>
- Prevent makefiles and perl scripts from being installed
in the documentation directory.
* Sat Jan 28 2012 Paul A. Rombouts <[email protected]>
- Update the (Source) URLs.
* Sat Aug 4 2007 Paul Rombouts <[email protected]>
- License is now GPL version 3
* Fri Mar 24 2006 Paul Rombouts <[email protected]>
- Instead of using a fixed default value for run_as_uid,
I let useradd choose the uid if run_as_uid is undefined.
* Thu Dec 29 2005 Paul Rombouts <[email protected]>
- TCP-query support is now compiled in by default,
but can be disabled using "--without tcpqueries".
* Sun Jul 20 2003 Paul Rombouts <[email protected]>
- Changed default run_as ID from "nobody" to "pdnsd"
* Fri Jun 20 2003 Paul Rombouts <[email protected]>
- Added configuration option for NPTL.
* Sat Jun 07 2003 Paul Rombouts <[email protected]>
- Added automatic definition of distro using _vendor macro.
* Thu May 22 2003 Paul Rombouts <[email protected]>
- Ensured that modification times of acconfig.h and configure.in
are not changed by patching to avoid unwanted reconfigure during make phase.
* Tue May 20 2003 Paul Rombouts <[email protected]>
- Applied my customized patch file. See READ.par for details.
* Sun May 16 2001 Thomas Moestl <[email protected]>
- Make use of chkconfig for Red Hat (patch by Christian Engstler)
* Sun Mar 25 2001 Thomas Moestl <[email protected]>
- Merged SuSE fixes by Christian Engstler
* Fri Feb 09 2001 Thomas Moestl <[email protected]>
- Merged in a spec fix for mapage inclusion contributed by Sourav K.
Mandal
* Sun Nov 26 2000 Thomas Moestl <[email protected]>
- Added some patches contributed by Bernd Leibing
* Tue Aug 15 2000 Thomas Moestl <[email protected]>
- Added the distro for configure
* Tue Jul 11 2000 Sourav K. Mandal <[email protected]>
- autoconf/automake modifications