pdnsd-1.2.9a-r1.ebuild 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit systemd user
  5. DESCRIPTION="Proxy DNS server with permanent caching"
  6. HOMEPAGE="http://members.home.nl/p.a.rombouts/pdnsd/"
  7. SRC_URI="http://members.home.nl/p.a.rombouts/pdnsd/releases/${P}-par.tar.gz"
  8. LICENSE="GPL-3"
  9. SLOT="0"
  10. KEYWORDS="alpha amd64 arm ia64 ppc ~s390 sparc x86"
  11. IUSE="debug ipv6 isdn +urandom test"
  12. RDEPEND=""
  13. DEPEND="test? ( net-dns/bind-tools )"
  14. pkg_setup() {
  15. enewgroup pdnsd
  16. enewuser pdnsd -1 -1 /var/lib/pdnsd pdnsd
  17. }
  18. src_configure() {
  19. local myconf=""
  20. use debug && myconf="${myconf} --with-debug=3"
  21. use urandom && myconf="${myconf} --with-random-device=/dev/urandom"
  22. econf \
  23. --disable-dependency-tracking \
  24. --sysconfdir=/etc/pdnsd \
  25. --with-cachedir=/var/cache/pdnsd \
  26. --with-default-id=pdnsd \
  27. $(use_enable ipv6) $(use_enable ipv6 ipv6-startup) \
  28. $(use_enable isdn) \
  29. ${myconf}
  30. }
  31. src_install() {
  32. emake DESTDIR="${D}" install
  33. dodoc AUTHORS ChangeLog* NEWS README THANKS TODO README.par
  34. docinto contrib ; dodoc contrib/{README,dhcp2pdnsd,pdnsd_dhcp.pl}
  35. docinto html ; dohtml doc/html/*
  36. docinto txt ; dodoc doc/txt/*
  37. newdoc doc/pdnsd.conf pdnsd.conf.sample
  38. newinitd "${FILESDIR}/pdnsd.rc8" pdnsd
  39. newinitd "${FILESDIR}/pdnsd.online.2" pdnsd-online
  40. systemd_newtmpfilesd "${FILESDIR}/pdnsd.tmpfiles" pdnsd.conf
  41. systemd_dounit "${FILESDIR}/pdnsd.service"
  42. mkdir "${T}"/confd || die
  43. cat - > "${T}"/confd/pdnsd-online <<EOF
  44. # Make sure to change the rc_need variable to the service for the
  45. # interface that connects you to the dns servers.
  46. #
  47. # For instance if you use a PPP connection on ppp0 to connect, set
  48. # rc_need="net.ppp0"
  49. rc_need="net.lo"
  50. EOF
  51. # Don't try to do the smart thing and add the --help output here:
  52. # it will cause the file to be etc-updated if the help text
  53. # changes and fails when cross-compiling.
  54. cat - > "${T}"/confd/pdnsd <<EOF
  55. # Command line options, check pdnsd --help for a list of valid
  56. # parameters. Note that most of the options that can be given at
  57. # command-line are also available as configuration parameters in
  58. # /etc/pdnsd/pdnsd.conf
  59. PDNSDCONFIG=""
  60. EOF
  61. doconfd "${T}"/confd/*
  62. # gentoo resolvconf support
  63. exeinto /etc/resolvconf/update.d
  64. newexe "${FILESDIR}/pdnsd.resolvconf-r1" pdnsd
  65. }
  66. src_test() {
  67. fail_kill() {
  68. kill -9 $(<"${T}"/pid)
  69. die "$1"
  70. }
  71. mkdir "${T}/pdnsd" || die
  72. echo -n -e "pd12\0\0\0\0" > "${T}/pdnsd/pdnsd.cache"
  73. IPS=$(grep ^nameserver /etc/resolv.conf | sed -e 's/nameserver \(.*\)/\tip=\1;/g' | xargs)
  74. sed -e "s/\tip=/${IPS}/" -e "s:cache_dir=:cache_dir=${T}/pdnsd:" "${FILESDIR}/pdnsd.conf.test" \
  75. > "${T}/pdnsd.conf.test"
  76. src/pdnsd -c "${T}/pdnsd.conf.test" -g -s -d -p "${T}/pid" || die "couldn't start daemon"
  77. sleep 3
  78. find "${T}" -ls
  79. [ -s "${T}/pid" ] || die "empty or no pid file created"
  80. [ -S "${T}/pdnsd/pdnsd.status" ] || fail_kill "no socket created"
  81. src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" server all up || fail_kill "failed to start the daemon"
  82. src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" status || fail_kill "failed to communicate with the daemon"
  83. sleep 3
  84. dig @127.0.0.1 -p 33455 localhost > "${T}"/dig.output 2>&1
  85. cat "${T}"/dig.output || die
  86. fgrep -q "status: NOERROR" "${T}"/dig.output || fail_kill "www.gentoo.org lookup failed"
  87. kill $(<"${T}/pid") || fail_kill "failed to terminate daemon"
  88. }
  89. pkg_postinst() {
  90. elog
  91. elog "Add pdnsd to your default runlevel - rc-update add pdnsd default"
  92. elog ""
  93. elog "Add pdnsd-online to your online runlevel."
  94. elog "The online interface will be listed in /etc/conf.d/pdnsd-online"
  95. elog ""
  96. elog "Sample config file in /etc/pdnsd/pdnsd.conf.sample"
  97. # The tmpfiles.d configuration does not come into effect before the
  98. # next reboot so create the cachedir now.
  99. local cachedir="/var/cache/pdnsd"
  100. if [[ ! -d ${cachedir} ]] ; then
  101. mkdir ${cachedir} || eerror "Failed to create cache"
  102. fi
  103. chown pdnsd:pdnsd ${cachedir} \
  104. || eerror "Failed to set ownership for cachedir"
  105. chmod 0750 ${cachedir} \
  106. || eerror "Failed to set permissions for cachedir"
  107. }