pdnsd.spec.in 9.1 KB

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