diff -rupN old/net-irc/znc/files/znc-1.0-systemwideconfig.patch new/net-irc/znc/files/znc-1.0-systemwideconfig.patch --- old/net-irc/znc/files/znc-1.0-systemwideconfig.patch 2012-11-21 19:11:31.000000000 +0100 +++ new/net-irc/znc/files/znc-1.0-systemwideconfig.patch 2015-08-04 21:25:24.000000000 +0200 @@ -1,8 +1,24 @@ +Add system-wide daemon support. + +This patch adds system-wide daemon support to ZNC so that you can run +one ZNC instance system-wide using the new "--system-wide-config-as" +option. + +Patch is based on @mrueg version from 2012. + +X-Gentoo-Bug: 438430 +X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=438430 +--- + include/znc/znc.h | 3 ++ + src/main.cpp | 83 ++++++++++++++++++++++++++++++++++++++++--------------- + src/znc.cpp | 7 ++++- + 3 files changed, 70 insertions(+), 23 deletions(-) + diff --git a/include/znc/znc.h b/include/znc/znc.h -index 03be646..f493c83 100644 +index cf2326e..16394f9 100644 --- a/include/znc/znc.h +++ b/include/znc/znc.h -@@ -169,6 +169,8 @@ public: +@@ -187,6 +187,8 @@ public: static void DumpConfig(const CConfig* Config); @@ -11,37 +27,86 @@ index 03be646..f493c83 100644 private: CFile* InitPidFile(); bool DoRehash(CString& sError); -@@ -209,6 +211,7 @@ protected: +@@ -231,6 +233,7 @@ protected: unsigned int m_uiConnectPaused; TCacheMap m_sConnectThrottle; bool m_bProtectWebSessions; + bool m_bSystemWideConfig; + bool m_bHideVersion; }; - #endif // !_ZNC_H diff --git a/src/main.cpp b/src/main.cpp -index a1f3904..4950911 100644 +index 09b2c9c..bd5cca6 100644 --- a/src/main.cpp +++ b/src/main.cpp -@@ -10,6 +10,9 @@ - #include - #include +@@ -16,6 +16,9 @@ + + #include #include +#include +#include +#include - using std::cout; - using std::endl; -@@ -46,6 +49,7 @@ static const struct option g_LongOpts[] = { - { "makepass", no_argument, 0, 's' }, - { "makepem", no_argument, 0, 'p' }, - { "datadir", required_argument, 0, 'd' }, -+ { "system-wide-config-as", required_argument, 0, 'S' }, + #if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD) + #include +@@ -99,34 +102,36 @@ static inline int getopt_long(int argc, char * const argv[], const char *optstri + #endif + + static const struct option g_LongOpts[] = { +- { "help", no_argument, 0, 'h' }, +- { "version", no_argument, 0, 'v' }, +- { "debug", no_argument, 0, 'D' }, +- { "foreground", no_argument, 0, 'f' }, +- { "no-color", no_argument, 0, 'n' }, +- { "allow-root", no_argument, 0, 'r' }, +- { "makeconf", no_argument, 0, 'c' }, +- { "makepass", no_argument, 0, 's' }, +- { "makepem", no_argument, 0, 'p' }, +- { "datadir", required_argument, 0, 'd' }, ++ { "help", no_argument, 0, 'h' }, ++ { "version", no_argument, 0, 'v' }, ++ { "debug", no_argument, 0, 'D' }, ++ { "foreground", no_argument, 0, 'f' }, ++ { "no-color", no_argument, 0, 'n' }, ++ { "allow-root", no_argument, 0, 'r' }, ++ { "makeconf", no_argument, 0, 'c' }, ++ { "makepass", no_argument, 0, 's' }, ++ { "makepem", no_argument, 0, 'p' }, ++ { "datadir", required_argument, 0, 'd' }, ++ { "system-wide-config-as", required_argument, 0, 'S' }, { 0, 0, 0, 0 } }; -@@ -127,6 +131,8 @@ int main(int argc, char** argv) { + static void GenerateHelp(const char *appname) { + CUtils::PrintMessage("USAGE: " + CString(appname) + " [options]"); + CUtils::PrintMessage("Options are:"); +- CUtils::PrintMessage("\t-h, --help List available command line options (this page)"); +- CUtils::PrintMessage("\t-v, --version Output version information and exit"); +- CUtils::PrintMessage("\t-f, --foreground Don't fork into the background"); +- CUtils::PrintMessage("\t-D, --debug Output debugging information (Implies -f)"); +- CUtils::PrintMessage("\t-n, --no-color Don't use escape sequences in the output"); +- CUtils::PrintMessage("\t-r, --allow-root Don't complain if ZNC is run as root"); +- CUtils::PrintMessage("\t-c, --makeconf Interactively create a new config"); +- CUtils::PrintMessage("\t-s, --makepass Generates a password for use in config"); ++ CUtils::PrintMessage("\t-h, --help List available command line options (this page)"); ++ CUtils::PrintMessage("\t-v, --version Output version information and exit"); ++ CUtils::PrintMessage("\t-f, --foreground Don't fork into the background"); ++ CUtils::PrintMessage("\t-D, --debug Output debugging information (Implies -f)"); ++ CUtils::PrintMessage("\t-n, --no-color Don't use escape sequences in the output"); ++ CUtils::PrintMessage("\t-r, --allow-root Don't complain if ZNC is run as root"); ++ CUtils::PrintMessage("\t-c, --makeconf Interactively create a new config"); ++ CUtils::PrintMessage("\t-s, --makepass Generates a password for use in config"); + #ifdef HAVE_LIBSSL +- CUtils::PrintMessage("\t-p, --makepem Generates a pemfile for use with SSL"); ++ CUtils::PrintMessage("\t-p, --makepem Generates a pemfile for use with SSL"); + #endif /* HAVE_LIBSSL */ +- CUtils::PrintMessage("\t-d, --datadir Set a different ZNC repository (default is ~/.znc)"); ++ CUtils::PrintMessage("\t-d, --datadir Set a different ZNC repository (default is ~/.znc)"); ++ CUtils::PrintMessage("\t-S, --system-wide-config-as Create a system-wide ZNC daemon configuration"); + } + + static void die(int sig) { +@@ -192,6 +197,8 @@ int main(int argc, char** argv) { bool bMakeConf = false; bool bMakePass = false; bool bAllowRoot = false; @@ -50,16 +115,16 @@ index a1f3904..4950911 100644 bool bForeground = false; #ifdef ALWAYS_RUN_IN_FOREGROUND bForeground = true; -@@ -135,7 +141,7 @@ int main(int argc, char** argv) { - bool bMakePem = false; +@@ -201,7 +208,7 @@ int main(int argc, char** argv) { #endif + CZNC::CreateInstance(); - while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) { + while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) { switch (iArg) { case 'h': GenerateHelp(argv[0]); -@@ -153,6 +159,10 @@ int main(int argc, char** argv) { +@@ -219,6 +226,10 @@ int main(int argc, char** argv) { case 'c': bMakeConf = true; break; @@ -70,7 +135,7 @@ index a1f3904..4950911 100644 case 's': bMakePass = true; break; -@@ -187,8 +197,36 @@ int main(int argc, char** argv) { +@@ -254,8 +265,36 @@ int main(int argc, char** argv) { return 1; } @@ -107,7 +172,7 @@ index a1f3904..4950911 100644 #ifdef HAVE_LIBSSL if (bMakePem) { -@@ -229,7 +267,7 @@ int main(int argc, char** argv) { +@@ -304,7 +343,7 @@ int main(int argc, char** argv) { CUtils::PrintStatus(true, ""); } @@ -117,18 +182,18 @@ index a1f3904..4950911 100644 CUtils::PrintError("reasons for this and it can, in theory, cause great damage!"); if (!bAllowRoot) { diff --git a/src/znc.cpp b/src/znc.cpp -index 9469790..297b021 100644 +index 78cda1a..b33e860 100644 --- a/src/znc.cpp +++ b/src/znc.cpp -@@ -47,6 +47,7 @@ CZNC::CZNC() { +@@ -55,6 +55,7 @@ CZNC::CZNC() { m_sConnectThrottle.SetTTL(30000); m_pLockFile = NULL; m_bProtectWebSessions = true; + m_bSystemWideConfig = false; - } - - CZNC::~CZNC() { -@@ -952,7 +953,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { + m_bHideVersion = false; + m_uDisabledSSLProtocols = Csock::EDP_SSL; + m_sSSLProtocols = ""; +@@ -861,7 +862,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { CUtils::PrintMessage(""); File.UnLock(); @@ -136,8 +201,8 @@ index 9469790..297b021 100644 + return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true); } - size_t CZNC::FilterUncommonModules(set& ssModules) { -@@ -1971,3 +1972,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) { + void CZNC::BackupConfigOnce(const CString& sSuffix) { +@@ -1973,3 +1974,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) { bool CZNC::WaitForChildLock() { return m_pLockFile && m_pLockFile->ExLock(); } @@ -145,3 +210,6 @@ index 9469790..297b021 100644 +void CZNC::SetSystemWideConfig(bool systemWideConfig) { + m_bSystemWideConfig = systemWideConfig; +} +-- +2.5.0 + diff -rupN old/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch new/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch --- old/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch 1970-01-01 01:00:00.000000000 +0100 +++ new/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch 2015-08-04 21:45:12.000000000 +0200 @@ -0,0 +1,23 @@ +Add PidFile option to new configurations per default + +Our runscript requires that ZNC creates a pidfile. This patch will add +the PidFile directive to ZNC's default configuration. +--- + src/znc.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/znc.cpp b/src/znc.cpp +index b33e860..4a02568 100644 +--- a/src/znc.cpp ++++ b/src/znc.cpp +@@ -575,6 +575,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { + VCString vsLines; + + vsLines.push_back(MakeConfigHeader()); ++ vsLines.push_back("PidFile = /run/znc/znc.pid"); + vsLines.push_back("Version = " + CString(VERSION_STR)); + + m_sConfigFile = ExpandConfigPath(sConfigFile); +-- +2.5.0 + diff -rupN old/net-irc/znc/files/znc.confd new/net-irc/znc/files/znc.confd --- old/net-irc/znc/files/znc.confd 2013-01-22 19:56:25.000000000 +0100 +++ new/net-irc/znc/files/znc.confd 2015-08-04 20:47:16.000000000 +0200 @@ -1,7 +1,24 @@ # /etc/conf.d/znc # Location of the znc configuration folder -ZNC_CONF="/var/lib/znc" +ZNC_DATADIR="/var/lib/znc" # User to run znc as ZNC_USER="znc" + +# Group to run znc as +ZNC_GROUP="znc" + +# PID file +ZNC_PIDFILE="/run/znc/znc.pid" + +# You can use this configuration option to pass additional options to the +# start-stop-daemon, see start-stop-daemon(8) for more details. +# Per default we wait 1000ms after we have started the service to ensure +# that the daemon is really up and running. +ZNC_SSDARGS="--wait 1000" + +# The termination timeout (start-stop-daemon parameter "retry") ensures +# that the service will be terminated within a given time (30 + 5 seconds +# per default) when you are stopping the service. +ZNC_TERMTIMEOUT="TERM/30/KILL/5" diff -rupN old/net-irc/znc/files/znc.initd new/net-irc/znc/files/znc.initd --- old/net-irc/znc/files/znc.initd 2012-11-21 19:11:31.000000000 +0100 +++ new/net-irc/znc/files/znc.initd 2015-08-04 22:34:54.446663454 +0200 @@ -5,35 +5,36 @@ extra_commands="config" extra_started_commands="reload save" +command="/usr/bin/znc" +command_args="--datadir ${ZNC_DATADIR}" +pidfile="${ZNC_PIDFILE:-/run/znc/znc.pid}" +user=${ZNC_USER:-znc} +group=${ZNC_GROUP:-znc} +start_stop_daemon_args="--chdir \"${ZNC_DATADIR}\" --user ${user} --group ${group} ${ZNC_SSDARGS}" +retry="${ZNC_TERMTIMEOUT}" + +required_dirs="${ZNC_DATADIR}" depend() { - need net + use dns logger } -start() { - ebegin "Starting ZNC" - start-stop-daemon --start --user ${ZNC_USER} --name znc \ - --exec /usr/bin/znc -- -d ${ZNC_CONF} - eend $? +start_pre() { + checkpath -d -m 0770 -o ${user}:${group} $(dirname ${pidfile}) } -stop() { - ebegin "Stopping ZNC" - start-stop-daemon --signal SIGINT --name znc \ - --exec /usr/bin/znc -- -d ${ZNC_CONF} - eend $? +stop_post() { + rm -f ${pidfile} } reload() { ebegin "Reloading ZNC Configuration File from Disk" - start-stop-daemon --signal SIGHUP --name znc \ - --exec /usr/bin/znc -- -d ${ZNC_CONF} + start-stop-daemon --signal SIGHUP --pidfile ${pidfile} eend $? } save() { ebegin "Saving ZNC Configuration File to Disk" - start-stop-daemon --signal SIGUSR1 --name znc \ - --exec /usr/bin/znc -- -d ${ZNC_CONF} + start-stop-daemon --signal SIGUSR1 --pidfile ${pidfile} eend $? } diff -rupN old/net-irc/znc/znc-1.4-r1.ebuild new/net-irc/znc/znc-1.4-r1.ebuild --- old/net-irc/znc/znc-1.4-r1.ebuild 2015-07-10 21:01:15.000000000 +0200 +++ new/net-irc/znc/znc-1.4-r1.ebuild 2015-08-04 22:34:11.886892047 +0200 @@ -8,22 +8,25 @@ PYTHON_COMPAT=( python{3_3,3_4} ) inherit base python-single-r1 systemd user MY_PV=${PV/_/-} +GTEST_VER="1.7.0" +GTEST_URL="https://googletest.googlecode.com/files/gtest-${GTEST_VER}.zip" DESCRIPTION="An advanced IRC Bouncer" -if [[ ${PV} == *9999* ]]; then - inherit git-2 - EGIT_REPO_URI=${EGIT_REPO_URI:-"git://github.com/znc/znc.git"} - SRC_URI="" +if [[ ${PV} == "9999" ]]; then + inherit git-r3 + EGIT_REPO_URI="git://github.com/znc/znc.git" + SRC_URI="test? ( ${GTEST_URL} )" KEYWORDS="" else - SRC_URI="http://znc.in/releases/${PN}-${MY_PV}.tar.gz" - KEYWORDS="amd64 ~arm ~x86" + SRC_URI="http://znc.in/releases/${PN}-${MY_PV}.tar.gz + test? ( ${GTEST_URL} )" + KEYWORDS="~amd64 ~x86" fi HOMEPAGE="http://znc.in" LICENSE="GPL-2" SLOT="0" -IUSE="daemon debug ipv6 perl python ssl sasl tcl" +IUSE="daemon debug ipv6 perl python ssl sasl tcl test" REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" @@ -48,10 +51,11 @@ DEPEND=" S=${WORKDIR}/${PN}-${MY_PV} PATCHES=( - "${FILESDIR}/${PN}-1.0-systemwideconfig.patch" + "${FILESDIR}"/${PN}-1.6.1-systemwideconfig.patch + "${FILESDIR}"/${PN}-1.6.1-create-pidfile-per-default.patch ) -CONFDIR="/var/lib/znc" +ZNC_DATADIR="${ZNC_DATADIR:-"/var/lib/znc"}" pkg_setup() { if use python; then @@ -63,6 +67,20 @@ pkg_setup() { fi } +src_unpack() { + if [[ ${PV} == "9999" ]] ; then + git-r3_src_unpack + else + default + fi + + if use test; then + cd "${S}"/test || die "Failed to chdir into '${S}/test'" + unpack $(basename ${GTEST_URL}) + mv gtest-${GTEST_VER} gtest || die "Failed to rename '${S}/test/gtest-${GTEST_VER}' dir" + fi +} + src_prepare() { if [[ ${PV} == *9999* ]]; then ./autogen.sh @@ -80,11 +98,12 @@ src_configure() { $(use python && echo "--enable-python=python3") \ $(use_enable sasl cyrus) \ $(use_enable ssl openssl) \ - $(use_enable tcl tcl) + $(use_enable tcl tcl) \ + $(use_with test gtest "${S}/test/gtest") } src_install() { - emake install DESTDIR="${D}" + emake install DESTDIR="${D%/}" dodoc NOTICE README.md if use daemon; then newinitd "${FILESDIR}"/znc.initd znc @@ -102,53 +121,64 @@ pkg_postinst() { elog elog "An init-script was installed in /etc/init.d" elog "A config file was installed in /etc/conf.d" - if [[ ! -d "${EROOT}${CONFDIR}" ]]; then + if [[ ! -d "${EROOT}${ZNC_DATADIR}" ]]; then elog elog "Run 'emerge --config znc' to configure ZNC" elog "as a system-wide daemon." elog elog "To generate a new SSL certificate, run:" - elog " znc --system-wide-config-as znc --makepem -d ${CONFDIR}" + elog " znc --system-wide-config-as znc --makepem -d ${ZNC_DATADIR}" elog "as root" elog elog "If migrating from a user-based install" elog "you can use your existing config files:" - elog " mkdir ${CONFDIR}" - elog " mv /home/\$USER/.znc/* ${CONFDIR}" + elog " mkdir ${ZNC_DATADIR}" + elog " mv /home/\$USER/.znc/* ${ZNC_DATADIR}" elog " rm -rf /home/\$USER/.znc" - elog " chown -R znc:znc ${CONFDIR}" + elog " chown -R znc:znc ${ZNC_DATADIR}" elog elog "If you already have znc set up and want take advantage of the" elog "init script but skip of all the above, you can also edit" elog " /etc/conf.d/znc" elog "and adjust the variables to your current znc user and config" elog "location." + elog + elog "Please make sure that your existing configuration contains" + elog " PidFile = /run/znc/znc.pid" + elog "or that PidFile value matches the one in /etc/conf.d/znc" if [[ -d "${EROOT}"/etc/znc ]]; then elog ewarn "/etc/znc exists on your system." ewarn "Due to the nature of the contents of that folder," ewarn "we have changed the default configuration to use" - ewarn " /var/lib/znc" - ewarn "please move /etc/znc to /var/lib/znc" + ewarn " ${ZNC_DATADIR}" + ewarn "please move /etc/znc to ${ZNC_DATADIR}" ewarn "or adjust /etc/conf.d/znc" fi else - elog "Existing config detected in ${CONFDIR}" - elog "You're good to go :)" + elog "Existing config detected in ${ZNC_DATADIR}" + if ! systemd_is_booted; then + elog + elog "Please make sure that your existing configuration contains" + elog " PidFile = /run/znc/znc.pid" + elog "or that PidFile value matches the one in /etc/conf.d/znc" + else + elog "You're good to go :)" + fi fi elog fi } pkg_config() { - if use daemon && ! [[ -d "${EROOT}${CONFDIR}" ]]; then + if use daemon && ! [[ -d "${EROOT}${ZNC_DATADIR}" ]]; then einfo "Press ENTER to interactively create a new configuration file for znc." einfo "To abort, press Control-C" read - mkdir -p "${EROOT}${CONFDIR}" || die - chown -R ${PN}:${PN} "${EROOT}${CONFDIR}" || + mkdir -p "${EROOT}${ZNC_DATADIR}" || die + chown -R ${PN}:${PN} "${EROOT}${ZNC_DATADIR}" || die "Setting permissions failed" - "${EROOT}"/usr/bin/znc --system-wide-config-as znc -c -r -d "${EROOT}${CONFDIR}" || + "${EROOT}"/usr/bin/znc --system-wide-config-as znc -c -r -d "${EROOT}${ZNC_DATADIR}" || die "Config failed" echo einfo "To start znc, run '/etc/init.d/znc start'" @@ -156,7 +186,7 @@ pkg_config() { einfo " rc-update add znc default" else if use daemon; then - ewarn "${CONFDIR} already exists, aborting to avoid damaging" + ewarn "${ZNC_DATADIR} already exists, aborting to avoid damaging" ewarn "any existing configuration. If you are sure you want" ewarn "to generate a new configuration, remove the folder" ewarn "and try again."