1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7} )
8 inherit cmake-utils python-single-r1 readme.gentoo-r1 systemd user
11 GTEST_URL="https://github.com/google/googletest/archive/${GTEST_VER}.tar.gz -> gtest-${GTEST_VER}.tar.gz"
12 DESCRIPTION="An advanced IRC Bouncer"
14 if [[ ${PV} == *9999* ]]; then
16 EGIT_REPO_URI=${EGIT_REPO_URI:-"https://github.com/znc/znc.git"}
22 https://znc.in/releases/archive/${MY_P}.tar.gz
23 test? ( ${GTEST_URL} )
25 KEYWORDS="~amd64 ~arm ~x86"
29 HOMEPAGE="https://znc.in"
32 IUSE="+ipv6 +icu libressl nls perl python +ssl sasl tcl test +zlib"
33 RESTRICT="!test? ( test )"
35 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} icu )"
38 icu? ( dev-libs/icu:= )
39 nls? ( dev-libs/boost:=[nls] )
40 perl? ( >=dev-lang/perl-5.10:= )
41 python? ( ${PYTHON_DEPS} )
42 sasl? ( >=dev-libs/cyrus-sasl-2 )
44 !libressl? ( dev-libs/openssl:0= )
45 libressl? ( dev-libs/libressl:0= )
47 tcl? ( dev-lang/tcl:0= )
48 zlib? ( sys-libs/zlib:0= )
53 nls? ( sys-devel/gettext )
54 perl? ( >=dev-lang/swig-3.0.0 )
55 python? ( >=dev-lang/swig-3.0.0 )
56 test? ( dev-qt/qtnetwork:5 )
59 PATCHES=( "${FILESDIR}"/${PN}-1.7.1-inttest-dir.patch )
63 python-single-r1_pkg_setup
67 enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
68 # The home directory was previously set to /dev/null
69 # This caused a bug with the systemd unit
70 # https://bugs.gentoo.org/521916
71 esethome ${PN} /var/lib/${PN}
75 # Let SWIG rebuild modperl/modpython to make user patching easier.
76 if [[ ${PV} != *9999* ]]; then
77 rm modules/modperl/generated.tar.gz || die
78 rm modules/modpython/generated.tar.gz || die
81 sed -i -e "s|DZNC_BIN_DIR:path=|DZNC_BIN_DIR:path=${T}/inttest|" \
82 test/CMakeLists.txt || die
84 cmake-utils_src_prepare
89 -DWANT_SYSTEMD=yes # Causes -DSYSTEMD_DIR to be used.
90 -DSYSTEMD_DIR="$(systemd_get_systemunitdir)"
91 -DWANT_ICU="$(usex icu)"
92 -DWANT_IPV6="$(usex ipv6)"
93 -DWANT_I18N="$(usex nls)"
94 -DWANT_PERL="$(usex perl)"
95 -DWANT_PYTHON="$(usex python)"
96 -DWANT_CYRUS="$(usex sasl)"
97 -DWANT_OPENSSL="$(usex ssl)"
98 -DWANT_TCL="$(usex tcl)"
99 -DWANT_ZLIB="$(usex zlib)"
102 if [[ ${PV} != *9999* ]] && use test; then
103 export GTEST_ROOT="${WORKDIR}/googletest-release-${GTEST_VER}/googletest"
104 export GMOCK_ROOT="${WORKDIR}/googletest-release-${GTEST_VER}/googlemock"
107 cmake-utils_src_configure
111 cmake-utils_src_make unittest
112 if has network-sandbox ${FEATURES}; then
113 DESTDIR="${T}/inttest" cmake-utils_src_make install
116 filter="${filter}:ZNCTest.Modperl*"
118 if ! use python; then
119 filter="${filter}:ZNCTest.Modpython*"
121 # CMAKE_PREFIX_PATH and CXXFLAGS are needed for znc-buildmod
122 # invocations from inside the test
123 GTEST_FILTER="${filter}" ZNC_UNUSUAL_ROOT="${T}/inttest" \
124 CMAKE_PREFIX_PATH="${T}/inttest/usr/share/znc/cmake" \
125 CXXFLAGS="${CXXFLAGS} -isystem ${T}/inttest/usr/include" \
126 cmake-utils_src_make inttest
128 # TODO: don't require sandbox after
129 # https://github.com/znc/znc/pull/1363 is implemented
130 ewarn "FEATURES=-network-sandbox; skipping integration tests which"
131 ewarn "temporary open local ports."
136 cmake-utils_src_install
139 newinitd "${FILESDIR}"/znc.initd-r2 znc
140 newconfd "${FILESDIR}"/znc.confd-r1 znc
142 DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r1") || die
143 DISABLE_AUTOFORMATTING=1
144 readme.gentoo_create_doc
148 if [[ -z "${REPLACING_VERSIONS}" ]]; then
149 # This is a new installation
150 readme.gentoo_print_elog
153 if [[ -d "${EROOT}"/etc/znc ]]; then
154 ewarn "${EROOT}/etc/znc exists on your system."
155 ewarn "Due to the nature of the contents of that folder,"
156 ewarn "we have changed the default configuration to use"
157 ewarn " ${EROOT}/var/lib/znc"
158 ewarn "please move ${EROOT}/etc/znc to ${EROOT}/var/lib/znc"
159 ewarn "or adjust your service configuration."
164 if [[ -e "${EROOT}/var/lib/znc" ]]; then
165 ewarn "${EROOT}/var/lib/znc already exists, aborting to avoid damaging"
166 ewarn "any existing configuration. If you are sure you want"
167 ewarn "to generate a new configuration, remove the folder"
168 ewarn "and try again."
170 einfo "Press enter to interactively create a new configuration file for znc."
171 einfo "To abort, press Control-C"
173 mkdir -p "${EROOT}/var/lib/znc" || die
174 chown -R ${PN}:${PN} "${EROOT}/var/lib/znc" ||
175 die "Setting permissions failed"
176 start-stop-daemon --start --user ${PN}:${PN} --env ZNC_NO_LAUNCH_AFTER_MAKECONF=1 \
177 "${EROOT}"/usr/bin/znc -- --makeconf --datadir "${EROOT}/var/lib/znc" ||
180 einfo "You can now start the znc service using the init system of your choice."
181 einfo "Don't forget to enable it if you want to use znc at boot."