| 1 |
# Copyright 1999-2013 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/net-irc/unrealircd/unrealircd-3.2.10.ebuild,v 1.2 2013/01/27 07:31:25 binki Exp $
|
| 4 |
|
| 5 |
EAPI=4
|
| 6 |
|
| 7 |
inherit eutils ssl-cert versionator multilib user
|
| 8 |
|
| 9 |
MY_P=Unreal${PV/_/-}
|
| 10 |
|
| 11 |
DESCRIPTION="An advanced Internet Relay Chat daemon"
|
| 12 |
HOMEPAGE="http://www.unrealircd.com/"
|
| 13 |
SRC_URI="http://www.unrealircd.com/downloads/${MY_P}.tar.gz"
|
| 14 |
|
| 15 |
SLOT="0"
|
| 16 |
LICENSE="GPL-2"
|
| 17 |
KEYWORDS="~amd64 ~ppc ~x86 ~x86-fbsd ~amd64-linux"
|
| 18 |
IUSE="curl ipv6 +extban-stacking +operoverride operoverride-verify +prefixaq
|
| 19 |
showlistmodes shunnotices ssl topicisnuhost +usermod zlib"
|
| 20 |
|
| 21 |
RDEPEND="ssl? ( dev-libs/openssl )
|
| 22 |
zlib? ( sys-libs/zlib )
|
| 23 |
curl? ( net-misc/curl[ares] )
|
| 24 |
dev-libs/tre
|
| 25 |
>=net-dns/c-ares-1.7"
|
| 26 |
DEPEND="${RDEPEND}
|
| 27 |
>=sys-apps/sed-4
|
| 28 |
virtual/pkgconfig"
|
| 29 |
|
| 30 |
S=${WORKDIR}/Unreal$(get_version_component_range 1-3)
|
| 31 |
|
| 32 |
pkg_setup() {
|
| 33 |
enewuser unrealircd
|
| 34 |
}
|
| 35 |
|
| 36 |
src_prepare() {
|
| 37 |
# QA check against bundled pkgs
|
| 38 |
rm extras/*.gz || die
|
| 39 |
|
| 40 |
sed -i \
|
| 41 |
-e "s:ircd\.pid:${EPREFIX}/var/run/unrealircd/ircd.pid:" \
|
| 42 |
-e "s:ircd\.log:${EPREFIX}/var/log/unrealircd/ircd.log:" \
|
| 43 |
-e "s:debug\.log:${EPREFIX}/var/log/unrealircd/debug.log:" \
|
| 44 |
-e "s:ircd\.tune:${EPREFIX}/var/lib/unrealircd/ircd.tune:" \
|
| 45 |
include/config.h \
|
| 46 |
|| die "sed failed"
|
| 47 |
}
|
| 48 |
|
| 49 |
src_configure() {
|
| 50 |
econf \
|
| 51 |
--with-listen=5 \
|
| 52 |
--with-dpath="${EPREFIX}"/etc/unrealircd \
|
| 53 |
--with-spath="${EPREFIX}"/usr/bin/unrealircd \
|
| 54 |
--with-nick-history=2000 \
|
| 55 |
--with-sendq=3000000 \
|
| 56 |
--with-bufferpool=18 \
|
| 57 |
--with-permissions=0600 \
|
| 58 |
--with-fd-setsize=1024 \
|
| 59 |
--with-system-cares \
|
| 60 |
--with-system-tre \
|
| 61 |
--enable-dynamic-linking \
|
| 62 |
$(use_enable curl libcurl "${EPREFIX}"/usr) \
|
| 63 |
$(use_enable ipv6 inet6) \
|
| 64 |
$(use_enable prefixaq) \
|
| 65 |
$(use_enable ssl ssl "${EPREFIX}"/usr) \
|
| 66 |
$(use_enable zlib ziplinks "${EPREFIX}"/usr) \
|
| 67 |
$(use_with showlistmodes) \
|
| 68 |
$(use_with topicisnuhost) \
|
| 69 |
$(use_with shunnotices) \
|
| 70 |
$(use_with !operoverride no-operoverride) \
|
| 71 |
$(use_with operoverride-verify) \
|
| 72 |
$(use_with !usermod disableusermod) \
|
| 73 |
$(use_with !extban-stacking disable-extendedban-stacking)
|
| 74 |
}
|
| 75 |
|
| 76 |
src_install() {
|
| 77 |
keepdir /var/{lib,log}/unrealircd
|
| 78 |
|
| 79 |
newbin src/ircd unrealircd
|
| 80 |
|
| 81 |
exeinto /usr/$(get_libdir)/unrealircd/modules
|
| 82 |
doexe src/modules/*.so
|
| 83 |
|
| 84 |
dodir /etc/unrealircd
|
| 85 |
dosym /var/lib/unrealircd /etc/unrealircd/tmp
|
| 86 |
|
| 87 |
insinto /etc/unrealircd
|
| 88 |
doins {badwords.*,help,spamfilter,dccallow}.conf
|
| 89 |
newins doc/example.conf unrealircd.conf
|
| 90 |
|
| 91 |
insinto /etc/unrealircd/aliases
|
| 92 |
doins aliases/*.conf
|
| 93 |
|
| 94 |
local so_suffix=so
|
| 95 |
[[ ${CHOST} == -*mingw* ]] && so_suffix=dll
|
| 96 |
sed -i \
|
| 97 |
-e s:src/modules:"${EPREFIX}"/usr/$(get_libdir)/unrealircd/modules: \
|
| 98 |
-e '/loadmodule.*\.'${so_suffix}'/s;^//;;' \
|
| 99 |
-e s:ircd\\.log:"${EPREFIX}"/var/log/unrealircd/ircd.log: \
|
| 100 |
"${ED}"/etc/unrealircd/unrealircd.conf \
|
| 101 |
|| die
|
| 102 |
|
| 103 |
dodoc \
|
| 104 |
Changes Donation Unreal.nfo \
|
| 105 |
ircdcron/{ircd.cron,ircdchk} \
|
| 106 |
|| die "dodoc failed"
|
| 107 |
dohtml doc/*.html
|
| 108 |
|
| 109 |
newinitd "${FILESDIR}"/unrealircd.initd unrealircd
|
| 110 |
newconfd "${FILESDIR}"/unrealircd.confd-r1 unrealircd
|
| 111 |
|
| 112 |
# config should be read-only
|
| 113 |
fperms -R 0640 /etc/unrealircd{,/aliases}
|
| 114 |
fperms 0750 /etc/unrealircd{,/aliases}
|
| 115 |
# state is editable but not owned by unrealircd directly
|
| 116 |
fperms 0770 /var/{lib,log}/unrealircd
|
| 117 |
fowners -R root:unrealircd /{etc,var/{lib,log}}/unrealircd
|
| 118 |
}
|
| 119 |
|
| 120 |
pkg_preinst() {
|
| 121 |
# Must pre-create directories; otherwise their permissions are lost
|
| 122 |
# on installation.
|
| 123 |
|
| 124 |
# Usage: _unrealircd_dir_permissions <user> <group> <mode> <dir>[, <dir>…]
|
| 125 |
#
|
| 126 |
# Ensure that directories are created with the correct permissions
|
| 127 |
# before portage tries to merge them to the filesystem because,
|
| 128 |
# otherwise, those directories are installed world-readable.
|
| 129 |
#
|
| 130 |
# If this is a first-time install, create those directories with
|
| 131 |
# correct permissions before installing. Otherwise, update
|
| 132 |
# permissions—but only if we are replacing an unrealircd ebuild at
|
| 133 |
# least as old as net-irc/unrealircd-3.2.10. Portage handles normal
|
| 134 |
# file permissions correctly, so no need for recursive
|
| 135 |
# chmoding/chowning.
|
| 136 |
_unrealircd_dir_permissions() {
|
| 137 |
local user=${1} group=${2} mode=${3} dir v
|
| 138 |
shift 3
|
| 139 |
while dir=${1} && shift; do
|
| 140 |
if [[ ! -d "${EROOT}${dir}" ]]; then
|
| 141 |
ebegin "Creating ${EROOT}${dir} with correct permissions"
|
| 142 |
install -d -m "${mode}" -o "${user}" -g "${group}" "${EROOT}${dir}" || die
|
| 143 |
eend ${?}
|
| 144 |
elif ! [[ ${REPLACING_VERSIONS} ]] || for v in ${REPLACING_VERSIONS}; do
|
| 145 |
# If 3.2.10 ≤ ${REPLACING_VERSIONS}, then we update
|
| 146 |
# existing permissions.
|
| 147 |
version_is_at_least "${v}" 3.2.10 && break
|
| 148 |
done; then
|
| 149 |
ebegin "Correcting permissions of ${EROOT}${dir} left by ${CATEGORY}/${PN}-${v}"
|
| 150 |
chmod "${mode}" "${EROOT}${dir}" \
|
| 151 |
&& chown ${user}:${group} "${EROOT}${dir}" \
|
| 152 |
|| die "Unable to correct permissions of ${EROOT}${dir}"
|
| 153 |
eend ${?}
|
| 154 |
fi
|
| 155 |
done
|
| 156 |
}
|
| 157 |
|
| 158 |
# unrealircd only needs to be able to read files in /etc/unrealircd.
|
| 159 |
_unrealircd_dir_permissions root unrealircd 0750 etc/unrealircd{,/aliases}
|
| 160 |
|
| 161 |
# unrealircd needs to be able to create files in /var/lib/unrealircd
|
| 162 |
# and /var/log/unrealircd.
|
| 163 |
_unrealircd_dir_permissions root unrealircd 0770 var/{lib,log}/unrealircd
|
| 164 |
}
|
| 165 |
|
| 166 |
pkg_postinst() {
|
| 167 |
# Move docert call from scr_install() to install_cert in pkg_postinst for
|
| 168 |
# bug #201682
|
| 169 |
if use ssl ; then
|
| 170 |
if [[ ! -f "${EROOT}"/etc/unrealircd/server.cert.key ]]; then
|
| 171 |
install_cert /etc/unrealircd/server.cert
|
| 172 |
chown unrealircd "${EROOT}"/etc/unrealircd/server.cert.*
|
| 173 |
chmod 0640 "${EROOT}"/etc/unrealircd/server.cert.*
|
| 174 |
ln -snf server.cert.key "${EROOT}"/etc/unrealircd/server.key.pem
|
| 175 |
fi
|
| 176 |
fi
|
| 177 |
|
| 178 |
local unrealircd_conf="${EROOT}"/etc/unrealircd/unrealircd.conf
|
| 179 |
# Fix up the default cloak keys.
|
| 180 |
if grep -qe '"and another one";$' "${unrealircd_conf}" && grep -qe '"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";$' "${unrealircd_conf}"; then
|
| 181 |
ebegin "Generating cloak-keys"
|
| 182 |
local keys=(
|
| 183 |
$(unrealircd -k 2>&1 | tail -n 3)
|
| 184 |
)
|
| 185 |
[[ -n ${keys[0]} || -n ${keys[1]} || -n ${keys[2]} ]]
|
| 186 |
eend $?
|
| 187 |
|
| 188 |
ebegin "Substituting cloak-keys into ${unrealircd_conf}"
|
| 189 |
sed -i \
|
| 190 |
-e '/cloak-keys/ {
|
| 191 |
n
|
| 192 |
s/"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";/"'"${keys[0]}"'";/
|
| 193 |
n
|
| 194 |
s/"and another one";/"'"${keys[1]}"'";/
|
| 195 |
n
|
| 196 |
s/"and another one";/"'"${keys[2]}"'";/
|
| 197 |
}' \
|
| 198 |
"${unrealircd_conf}"
|
| 199 |
eend $?
|
| 200 |
fi
|
| 201 |
|
| 202 |
elog "UnrealIRCd will not run until you've set up /etc/unrealircd/unrealircd.conf"
|
| 203 |
elog
|
| 204 |
elog "You can find example cron scripts here:"
|
| 205 |
elog " /usr/share/doc/${PF}/ircd.cron.gz"
|
| 206 |
elog " /usr/share/doc/${PF}/ircdchk.gz"
|
| 207 |
elog
|
| 208 |
elog "You can also use /etc/init.d/unrealircd to start at boot"
|
| 209 |
}
|