diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /net-irc/znc |
reinit the tree, so we can have metadata
Diffstat (limited to 'net-irc/znc')
-rw-r--r-- | net-irc/znc/Manifest | 19 | ||||
-rw-r--r-- | net-irc/znc/files/README.gentoo | 22 | ||||
-rw-r--r-- | net-irc/znc/files/README.gentoo-r1 | 15 | ||||
-rw-r--r-- | net-irc/znc/files/znc-1.0-systemwideconfig.patch | 147 | ||||
-rw-r--r-- | net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch | 23 | ||||
-rw-r--r-- | net-irc/znc/files/znc-1.6.1-systemwideconfig.patch | 215 | ||||
-rw-r--r-- | net-irc/znc/files/znc.confd | 7 | ||||
-rw-r--r-- | net-irc/znc/files/znc.confd-r1 | 24 | ||||
-rw-r--r-- | net-irc/znc/files/znc.initd | 38 | ||||
-rw-r--r-- | net-irc/znc/files/znc.initd-r1 | 39 | ||||
-rw-r--r-- | net-irc/znc/files/znc.initd-r2 | 40 | ||||
-rw-r--r-- | net-irc/znc/metadata.xml | 20 | ||||
-rw-r--r-- | net-irc/znc/znc-1.6.3-r1.ebuild | 128 | ||||
-rw-r--r-- | net-irc/znc/znc-1.6.5.ebuild | 130 | ||||
-rw-r--r-- | net-irc/znc/znc-9999.ebuild | 164 |
15 files changed, 1031 insertions, 0 deletions
diff --git a/net-irc/znc/Manifest b/net-irc/znc/Manifest new file mode 100644 index 000000000000..6f4b18342eb7 --- /dev/null +++ b/net-irc/znc/Manifest @@ -0,0 +1,19 @@ +AUX README.gentoo 768 SHA256 25d0f479a4965198416422a8116685fe06c5890f0a337b5931f820082369352b SHA512 627d3a8291e228fbeb783e61f46fe82f45ebc2a3647962c9bda150651d9bcadef699b6318083fc2396e6acc988ddf0ae1c01694e618d099591fa0db0258879d6 WHIRLPOOL e4121b7199b9e1da0f138cb66b3ab932c01afa999cc908f86b3dbe360969db37645d86a5f8f00623f6d0f110e428d6608c4e7fbed08737eb14979f0bb8be7025 +AUX README.gentoo-r1 524 SHA256 bda95cf309c7bc431a8d8f33769d1b81ff6090b2bc4388367a6432574483e661 SHA512 522956f11a2579f163879e18aeea31b4f74a092e056cceed3526948f511c545d12a5411932cdb94b547f240522691a13fad89fe065d431c11922eeee232a09be WHIRLPOOL cf96e5691d923366e28d91d6c6db39c8a27f78dc06ecd70e929a59e40883c209c7187ab3b92d3fcf0e113798e64ddc3f2929b87f96b09458eb49749ffd7bc493 +AUX znc-1.0-systemwideconfig.patch 4252 SHA256 1ddd5e95b299ef3c2293ce89829bae290a5c8fdc8e260ff09ae7f22264b8fbc9 SHA512 4527317f8b45c77e329167cedd792eb7886b85eeb9cb0b39f7bb117edff9bdde406d3fc4aa81410a3b1f9f7957e8ac312cdd168469fdaefd234ddbbae279341e WHIRLPOOL 3556fef6a5a840657ed50e5e283d913ab441c73b3becdfd5e05661dd312cf9670677407734ec5ba8d4254a1e22a6d3274563ab8ff81b04b16fadc9c16029e933 +AUX znc-1.6.1-create-pidfile-per-default.patch 650 SHA256 93159ca75c7ce935e2ec584ba69339f1ee36cf2bdff94ade3d5f86b0262f3e25 SHA512 2e2342c8f87a58cd1703f19d3d76f58ac4c92a049de5b342dd46c2476a1344cbb9f85743fe387713a2465006f71f1379951d7f3770019f1867544b6705e0e8ec WHIRLPOOL 3cf437d127faefa652a2edb1def54422c4f2f12220bff8c89fa50f9693e174c5276e4f092ee8ebfb65ef8cdcecb3c4ddd05feb035cb162819429351cf96fee13 +AUX znc-1.6.1-systemwideconfig.patch 8079 SHA256 2d9b9de9ec22b2a12daea9837c5f68aa15e37a42dfcf2e1a5f053e54d4c0fc27 SHA512 295a08dd5ce43b217e816148e272b722dff1a956ccdb5e58b0d337b7929a2bdae4e017ec686e820f89e53b310dd86ea8668095134d9618e5552ec323b83e624d WHIRLPOOL 2aa82c90da795a1e7e66adf1187ffaca0aa44e5deb55e8019f3974b7170a17757b61f0091c65e4fd20699f121249cf69b33983c78f535b603b66cf6df3422365 +AUX znc.confd 123 SHA256 be3155e79e6ed13be88fbf9d99f6889b3ee8425837120c448c827b8302672063 SHA512 352f18d64cbfbd5970c859f2ae2290c0ddafcbd8f1bb5d74f33976bc8388f65a75f8a9a73a093fbac12f2d243d4bcf74380bbb3aaab8d68f7bf4eab7ce3bea46 WHIRLPOOL 24e8272f1d94ff39cb748c9c280761437e2f6527ffa26e4972d83c99cde62e2f70d0c99639f4a8aabb4464fd85ee4856eb8086d3196e12286e3989d8e19c544b +AUX znc.confd-r1 720 SHA256 69238e187b86c4c15d0751a28d6710e3b21fdd19627b28d5ee09009dc1d95b01 SHA512 3ab102f64ea0572350c8595fd3739874da591c43a3dbc3a740c72c53bd7418fded721d478d1fb92de0c0d18131313ba6679e842a135dfe239ea3f42821d8e468 WHIRLPOOL d949cdccf3a3f5263584b3371afb5c6804593ce4cc635a1e90278d8330e57fe138c1d7ce7014fc2b7cc542e95c2d993c569bff0ad4988e74ad995c6b7c559929 +AUX znc.initd 810 SHA256 b49aebd8864b0ba156e61ed67c8d505e875cbd1d9f0d1b330c4862db528c7e9b SHA512 909bf953cbb583754b516ddaada1f8f2362866e601a9fdc52ed563c0f0012776a0066e81b8bb6d72562557e6736b7d4f014eac7b700882ce43db9299594b5e32 WHIRLPOOL 159b7846247b698c040d7d552b2456a55e556f8e26ea65c0822cc97cafe46add299bd9887fa34de3ba3bdd43ad7989a53cf59c9812e3c50d69e3d1787bfbc0c8 +AUX znc.initd-r1 914 SHA256 ad19b0de6bd3616b6396b97eeddb4620d57de5aa5a399a3004bef78266140645 SHA512 01f44ab51f6fa29383b4a4bc6e5f19928ebac6b32f73fb96906113596a904324dd53ef9dbb895a8dd29028f3523e6f7285d2d5b2ee43058fc017f0b47ae788c1 WHIRLPOOL 5e9580aeaa79601b538ed527e5d8f959e7751dd9cd765a46f034981f2decd09b71ac0fcf335948a29a5d467da630fc9ebbd7e884d98c8d7cc5241a4edaacbe88 +AUX znc.initd-r2 952 SHA256 4a42672dd7a2ae45d18497d14d4b730d56f71d891b3d6176766cae47decf5ae6 SHA512 c3d676796aaa485dcaebee0fba58a8f86560cd192e0e2ccf06f58346c1368f58aa5be1c1e5160f8105e3dc5c684d3d1f82eff6a4d7b87c07f11450b72288727f WHIRLPOOL e3e68e4f20385c9548d40d454f14873074824557144f9df05d18f6cc265fbaa67e58e4db95b2443f270ddbdf7cd708b2802cc67ff2782be7ba75a1144f56d4e6 +DIST googletest-release-1.7.0.tar.gz 468653 SHA256 f73a6546fdf9fce9ff93a5015e0333a8af3062a152a9ad6bcb772c96687016cc SHA512 c623d5720c4ed574e95158529872815ecff478c03bdcee8b79c9b042a603533f93fe55f939bcfe2cd745ce340fd626ad6d9a95981596f1a4d05053d874cd1dfc WHIRLPOOL e59e6aede05fd882c64586de7d204ed97fd02ec0f53abeb3130dcd18940ecefb59a43592ac5bd14dd28a8825845bd11359f637e28671554852573a4a43f8cd9c +DIST znc-1.6.3.tar.gz 1464200 SHA256 631c46de76fe601a41ef7676bc974958e9a302b72b25fc92b4a603a25d89b827 SHA512 777279b6c973310b4e78a0472bd1e355c2adf3e4fbe9ebedde3dd4706e5c0b208d4330eb2318a8d9e0d7d7146bee0a4a428cbe5a3f230c8f6aa692a477e86e2b WHIRLPOOL 2a41e0ac90038a8cc8f289d4ffc0494d29eda75450f650b8870c076fb809eb9c5829720bb39eb43d38ee4ac7f9bea6000ad90fcdd8c0eea461bf04f88cc17b52 +DIST znc-1.6.5.tar.gz 1470681 SHA256 2f0225d49c53a01f8d94feea4619a6fe92857792bb3401a4eb1edd65f0342aca SHA512 d78603ac86d1fb92cdf591b1eb6d32fa19b0e39414bd69e1300c537051612ae590c43d3b8e4dd598cdff605bf3aa1d3d5d806edd428d15d50f733e1670f3e626 WHIRLPOOL b72585a2f11754bedb667ac078a617195aa718f9864e7e33b962d75387e7bc4c8c6c1465844f27b65a5af2d50cec7006ae325a43eb2ef930fc9c218bbaae60a1 +EBUILD znc-1.6.3-r1.ebuild 3385 SHA256 b2cb1fdddd4468a48fe56eb7cdabe1b68c5957cb29411670008c15c5dac1fe31 SHA512 e5e74f8903c17f83c7d1380a8e8abb94e62ded858c01b8ad47a464f4273688bb26f8f5a38e428e9c8e984492fa1b6cd7f6281de99c0690ea0d96fb3a1ddbc2da WHIRLPOOL f17fda6a7cc7791c7e29beb687e1996ff20aa855c7eb2ac2498b927439effa3f19d575907a99d14301918f6bc0d7bbb15e01c2ad5aae247ab6c6365c9afe838d +EBUILD znc-1.6.5.ebuild 3473 SHA256 edd357754ee7c9d0a334c5465c298b61f40f88939693fc4b9c9b974e0cb7b3d7 SHA512 5360728c9eed15ecf686128fc9553627615dbb8b5db1662a39fc0d7da4587cb4980b617de2660efa5b0bdfe7cdbcd7e0defccc7359c4f27b4be0dd82d8cf3672 WHIRLPOOL 91fe50ea134f12aafc9bf99fa723271e04e9cf04d5346cccef3218f95366026f8c5ddd225ec126fadefe4d2ccce684b5dea72343c8323381dec8832db4c0d0dd +EBUILD znc-9999.ebuild 4483 SHA256 883973c52afe750a50f029777b3577f4df717515b1eb683337d946962c249e07 SHA512 25f27e37e99f48ace063cf9bba92ebeb60562dd1e0782756320f7294b1773bc7235f22dc8ed0deb31be0f5e9c3012bfa65a61f2cf072400f52741d3bf7269a5e WHIRLPOOL 070045749cbbf423550fcf3bca139885b3535f3166dd35efc81970dcb4c218d80882cd368c50d24ccbd7642438a7b32cba276aee4176625916e69b866cf7c890 +MISC ChangeLog 7932 SHA256 7b50fa2f64eab48f0f5f1ff06cf9f0e01f16c6e38b7d10827e1b999efccd3aea SHA512 1bdd5791f9e33f96bfb8c4429f1a0ccf966f4807cd88076c1092df83966c59fb30aed20dd9586727078a414650b33270001150b3fa11901f72cb99529a2be27e WHIRLPOOL 3f575c7494e10eaf3ffa2805bc977ed1bbd85204014482dd85892edb2dca443109fa8d80a7bd8851bc2583cbc4bbcc555c5ed01b47b7a6ccb79ed274a67271a1 +MISC ChangeLog-2015 11832 SHA256 3417c88d6573e992d4429ca8a7d3c815d698cccb9438b744021414b06f4b87db SHA512 da72275af15996010fed8f466bb5f7f00b67e95f0c1469f9d03b809ef106aa92651057dad1174bff486a0b6c172f00900cd6bb97bca07bc516c54029bf705325 WHIRLPOOL 11940fb5a342df64a088b0d93d9ec98bab6eaf2e75df11394e09abd37ffeaef71034c1bd8e9aa436e3cfaeec052395ebb5642f6ca334f4ddc131894301b9d96e +MISC metadata.xml 757 SHA256 9d8b5e885040de4a150a9cc309d59a3d0214414bc572d0e71e8704e05b211dfc SHA512 fd055b958ea544d901a15bdf9f8af9ab437896f97d7fa76f84cb6eebfdf7b1de2e8f13d85757d8d4c7098fd6f2102b505084a8beb58156258aaa73367c479eaf WHIRLPOOL abd7357485ee057b08dbb9d607976525dc097c8b0df247c14005627d5fdbdddd0e0d4c9d4a826388668f9b9ba517875aa031abad92d8a1c14d4963484a9ec5e5 diff --git a/net-irc/znc/files/README.gentoo b/net-irc/znc/files/README.gentoo new file mode 100644 index 000000000000..5b222a24f589 --- /dev/null +++ b/net-irc/znc/files/README.gentoo @@ -0,0 +1,22 @@ +To run znc as a user, run 'znc --makeconf' to create a configuration file. + +If znc was compiled with the 'daemon' use flag, you may run + emerge --config znc +to configure it. + +To generate a new SSL certificate, run: + znc --system-wide-config-as znc --makepem -d /var/lib/znc +as root. + +If migrating from a user-based install, you can copy the existing +configuration files: + mkdir /var/lib/znc + mv /home/$USER/.znc/* /var/lib/znc + rm -rf /home/$USER/.znc + chown -R znc:znc /var/lib/znc +You may also adjust the location of the files and the user running znc +in /etc/conf.d/znc instead. + +To run as a daemon, please make sure that your configuration contains + PidFile = /run/znc/znc.pid +or that the PidFile value matches the one in /etc/conf.d/znc. diff --git a/net-irc/znc/files/README.gentoo-r1 b/net-irc/znc/files/README.gentoo-r1 new file mode 100644 index 000000000000..cbd565d3d964 --- /dev/null +++ b/net-irc/znc/files/README.gentoo-r1 @@ -0,0 +1,15 @@ +To run znc as a user, run 'znc --makeconf' to create a configuration file. + +To configure the system-wide daemon, you may run 'emerge --config znc'. + +If migrating from a user-based install, you can copy the existing +configuration files: + + # mkdir /var/lib/znc + # mv /home/$USER/.znc/* /var/lib/znc + # rm -rf /home/$USER/.znc + # chown -R znc:znc /var/lib/znc + +OpenRC user may also adjust the location of the files and the user running +znc in /etc/conf.d/znc instead. Systemd user may have to overwrite +existing unit file. diff --git a/net-irc/znc/files/znc-1.0-systemwideconfig.patch b/net-irc/znc/files/znc-1.0-systemwideconfig.patch new file mode 100644 index 000000000000..336163dd6a0c --- /dev/null +++ b/net-irc/znc/files/znc-1.0-systemwideconfig.patch @@ -0,0 +1,147 @@ +diff --git a/include/znc/znc.h b/include/znc/znc.h +index 03be646..f493c83 100644 +--- a/include/znc/znc.h ++++ b/include/znc/znc.h +@@ -169,6 +169,8 @@ public: + + static void DumpConfig(const CConfig* Config); + ++ void SetSystemWideConfig(bool systemWideConfig); ++ + private: + CFile* InitPidFile(); + bool DoRehash(CString& sError); +@@ -209,6 +211,7 @@ protected: + unsigned int m_uiConnectPaused; + TCacheMap<CString> m_sConnectThrottle; + bool m_bProtectWebSessions; ++ bool m_bSystemWideConfig; + }; + + #endif // !_ZNC_H +diff --git a/src/main.cpp b/src/main.cpp +index a1f3904..4950911 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -10,6 +10,9 @@ + #include <znc/FileUtils.h> + #include <sys/wait.h> + #include <signal.h> ++#include <sys/types.h> ++#include <pwd.h> ++#include <grp.h> + + 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' }, + { 0, 0, 0, 0 } + }; + +@@ -127,6 +131,8 @@ int main(int argc, char** argv) { + bool bMakeConf = false; + bool bMakePass = false; + bool bAllowRoot = false; ++ bool bSystemWideConfig = false; ++ CString sSystemWideConfigUser = "znc"; + bool bForeground = false; + #ifdef ALWAYS_RUN_IN_FOREGROUND + bForeground = true; +@@ -135,7 +141,7 @@ int main(int argc, char** argv) { + bool bMakePem = false; + #endif + +- 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) { + case 'c': + bMakeConf = true; + break; ++ case 'S': ++ bSystemWideConfig = true; ++ sSystemWideConfigUser = optarg; ++ break; + case 's': + bMakePass = true; + break; +@@ -187,8 +197,36 @@ int main(int argc, char** argv) { + return 1; + } + ++ if (bSystemWideConfig && getuid() == 0) { ++ struct passwd *pwd; ++ ++ pwd = getpwnam(sSystemWideConfigUser.c_str()); ++ if (pwd == NULL) { ++ CUtils::PrintError("Daemon user not found."); ++ return 1; ++ } ++ ++ if ((long) pwd->pw_uid == 0) { ++ CUtils::PrintError("Please define a daemon user other than root."); ++ return 1; ++ } ++ if (setgroups(0, NULL) != 0) { ++ CUtils::PrintError("setgroups: Unable to clear supplementary group IDs"); ++ return 1; ++ } ++ if (setgid((long) pwd->pw_gid) != 0) { ++ CUtils::PrintError("setgid: Unable to drop group privileges"); ++ return 1; ++ } ++ if (setuid((long) pwd->pw_uid) != 0) { ++ CUtils::PrintError("setuid: Unable to drop user privileges"); ++ return 1; ++ } ++ } ++ + CZNC* pZNC = &CZNC::Get(); + pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir); ++ pZNC->SetSystemWideConfig(bSystemWideConfig); + + #ifdef HAVE_LIBSSL + if (bMakePem) { +@@ -229,7 +267,7 @@ int main(int argc, char** argv) { + CUtils::PrintStatus(true, ""); + } + +- if (isRoot()) { ++ if (isRoot() && !bSystemWideConfig) { + CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid"); + 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 +--- a/src/znc.cpp ++++ b/src/znc.cpp +@@ -47,6 +47,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) { + CUtils::PrintMessage(""); + + File.UnLock(); +- return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true); ++ return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true); + } + + size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) { +@@ -1971,3 +1972,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) { + bool CZNC::WaitForChildLock() { + return m_pLockFile && m_pLockFile->ExLock(); + } ++ ++void CZNC::SetSystemWideConfig(bool systemWideConfig) { ++ m_bSystemWideConfig = systemWideConfig; ++} diff --git a/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch b/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch new file mode 100644 index 000000000000..8419e9344bf2 --- /dev/null +++ b/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch @@ -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 --git a/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch b/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch new file mode 100644 index 000000000000..d28fa30c219d --- /dev/null +++ b/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch @@ -0,0 +1,215 @@ +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 cf2326e..16394f9 100644 +--- a/include/znc/znc.h ++++ b/include/znc/znc.h +@@ -187,6 +187,8 @@ public: + + static void DumpConfig(const CConfig* Config); + ++ void SetSystemWideConfig(bool systemWideConfig); ++ + private: + CFile* InitPidFile(); + bool DoRehash(CString& sError); +@@ -231,6 +233,7 @@ protected: + unsigned int m_uiConnectPaused; + TCacheMap<CString> m_sConnectThrottle; + bool m_bProtectWebSessions; ++ bool m_bSystemWideConfig; + bool m_bHideVersion; + }; + +diff --git a/src/main.cpp b/src/main.cpp +index 09b2c9c..bd5cca6 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -16,6 +16,9 @@ + + #include <znc/znc.h> + #include <signal.h> ++#include <sys/types.h> ++#include <pwd.h> ++#include <grp.h> + + #if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD) + #include <znc/Threads.h> +@@ -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 } + }; + + 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; ++ bool bSystemWideConfig = false; ++ CString sSystemWideConfigUser = "znc"; + bool bForeground = false; + #ifdef ALWAYS_RUN_IN_FOREGROUND + bForeground = true; +@@ -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]); +@@ -219,6 +226,10 @@ int main(int argc, char** argv) { + case 'c': + bMakeConf = true; + break; ++ case 'S': ++ bSystemWideConfig = true; ++ sSystemWideConfigUser = optarg; ++ break; + case 's': + bMakePass = true; + break; +@@ -254,8 +265,36 @@ int main(int argc, char** argv) { + return 1; + } + ++ if (bSystemWideConfig && getuid() == 0) { ++ struct passwd *pwd; ++ ++ pwd = getpwnam(sSystemWideConfigUser.c_str()); ++ if (pwd == NULL) { ++ CUtils::PrintError("Daemon user not found."); ++ return 1; ++ } ++ ++ if ((long) pwd->pw_uid == 0) { ++ CUtils::PrintError("Please define a daemon user other than root."); ++ return 1; ++ } ++ if (setgroups(0, NULL) != 0) { ++ CUtils::PrintError("setgroups: Unable to clear supplementary group IDs"); ++ return 1; ++ } ++ if (setgid((long) pwd->pw_gid) != 0) { ++ CUtils::PrintError("setgid: Unable to drop group privileges"); ++ return 1; ++ } ++ if (setuid((long) pwd->pw_uid) != 0) { ++ CUtils::PrintError("setuid: Unable to drop user privileges"); ++ return 1; ++ } ++ } ++ + CZNC* pZNC = &CZNC::Get(); + pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir); ++ pZNC->SetSystemWideConfig(bSystemWideConfig); + + #ifdef HAVE_LIBSSL + if (bMakePem) { +@@ -304,7 +343,7 @@ int main(int argc, char** argv) { + CUtils::PrintStatus(true, ""); + } + +- if (isRoot()) { ++ if (isRoot() && !bSystemWideConfig) { + CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid"); + 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 78cda1a..b33e860 100644 +--- a/src/znc.cpp ++++ b/src/znc.cpp +@@ -55,6 +55,7 @@ CZNC::CZNC() { + m_sConnectThrottle.SetTTL(30000); + m_pLockFile = NULL; + m_bProtectWebSessions = true; ++ m_bSystemWideConfig = false; + m_bHideVersion = false; + m_uDisabledSSLProtocols = Csock::EDP_SSL; + m_sSSLProtocols = ""; +@@ -861,7 +862,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { + CUtils::PrintMessage(""); + + File.UnLock(); +- return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true); ++ return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true); + } + + void CZNC::BackupConfigOnce(const CString& sSuffix) { +@@ -1973,3 +1974,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) { + bool CZNC::WaitForChildLock() { + return m_pLockFile && m_pLockFile->ExLock(); + } ++ ++void CZNC::SetSystemWideConfig(bool systemWideConfig) { ++ m_bSystemWideConfig = systemWideConfig; ++} +-- +2.5.0 + diff --git a/net-irc/znc/files/znc.confd b/net-irc/znc/files/znc.confd new file mode 100644 index 000000000000..9681f8d792fb --- /dev/null +++ b/net-irc/znc/files/znc.confd @@ -0,0 +1,7 @@ +# /etc/conf.d/znc + +# Location of the znc configuration folder +ZNC_CONF="/var/lib/znc" + +# User to run znc as +ZNC_USER="znc" diff --git a/net-irc/znc/files/znc.confd-r1 b/net-irc/znc/files/znc.confd-r1 new file mode 100644 index 000000000000..b78e0534b33a --- /dev/null +++ b/net-irc/znc/files/znc.confd-r1 @@ -0,0 +1,24 @@ +# /etc/conf.d/znc + +# Location of the znc configuration folder +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 --git a/net-irc/znc/files/znc.initd b/net-irc/znc/files/znc.initd new file mode 100644 index 000000000000..16af8b64c687 --- /dev/null +++ b/net-irc/znc/files/znc.initd @@ -0,0 +1,38 @@ +#!/sbin/openrc-run +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="config" +extra_started_commands="reload save" + +depend() { + need net +} + +start() { + ebegin "Starting ZNC" + start-stop-daemon --start --user ${ZNC_USER} --name znc \ + --exec /usr/bin/znc -- -d ${ZNC_CONF} + eend $? +} + +stop() { + ebegin "Stopping ZNC" + start-stop-daemon --signal SIGINT --name znc \ + --exec /usr/bin/znc -- -d ${ZNC_CONF} + eend $? +} + +reload() { + ebegin "Reloading ZNC Configuration File from Disk" + start-stop-daemon --signal SIGHUP --name znc \ + --exec /usr/bin/znc -- -d ${ZNC_CONF} + eend $? +} + +save() { + ebegin "Saving ZNC Configuration File to Disk" + start-stop-daemon --signal SIGUSR1 --name znc \ + --exec /usr/bin/znc -- -d ${ZNC_CONF} + eend $? +} diff --git a/net-irc/znc/files/znc.initd-r1 b/net-irc/znc/files/znc.initd-r1 new file mode 100644 index 000000000000..dedb44b1362f --- /dev/null +++ b/net-irc/znc/files/znc.initd-r1 @@ -0,0 +1,39 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +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() { + use dns logger +} + +start_pre() { + checkpath -d -m 0770 -o ${user}:${group} "$(dirname ${pidfile})" +} + +stop_post() { + rm -f "${pidfile}" +} + +reload() { + ebegin "Reloading ZNC Configuration File from Disk" + start-stop-daemon --signal SIGHUP --pidfile "${pidfile}" + eend $? +} + +save() { + ebegin "Saving ZNC Configuration File to Disk" + start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}" + eend $? +} diff --git a/net-irc/znc/files/znc.initd-r2 b/net-irc/znc/files/znc.initd-r2 new file mode 100644 index 000000000000..72834a80da9b --- /dev/null +++ b/net-irc/znc/files/znc.initd-r2 @@ -0,0 +1,40 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="config" +extra_started_commands="reload save" +command="/usr/bin/znc" +command_args="--datadir \"${ZNC_DATADIR}\" --foreground" +command_background="yes" +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() { + use dns logger +} + +start_pre() { + checkpath -d -m 0770 -o ${user}:${group} "$(dirname ${pidfile})" +} + +stop_post() { + rm -f "${pidfile}" +} + +reload() { + ebegin "Reloading ZNC Configuration File from Disk" + start-stop-daemon --signal SIGHUP --pidfile "${pidfile}" + eend $? +} + +save() { + ebegin "Saving ZNC Configuration File to Disk" + start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}" + eend $? +} diff --git a/net-irc/znc/metadata.xml b/net-irc/znc/metadata.xml new file mode 100644 index 000000000000..51954559918c --- /dev/null +++ b/net-irc/znc/metadata.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>sautier.louis@gmail.com</email> + <name>Louis Sautier</name> + </maintainer> + <maintainer type="project"> + <email>proxy-maint@gentoo.org</email> + <name>Proxy Maintainers</name> + </maintainer> + <use> + <flag name="daemon">Allow znc to run as a system-wide service. Installs an init script and creates a znc user:group.</flag> + <flag name="zlib">Enable mod_deflate-like gzip support for znc's web interface using <pkg>sys-libs/zlib</pkg>.</flag> + </use> + <upstream> + <remote-id type="github">znc/znc</remote-id> + <bugs-to>https://github.com/znc/znc/issues</bugs-to> + </upstream> +</pkgmetadata> diff --git a/net-irc/znc/znc-1.6.3-r1.ebuild b/net-irc/znc/znc-1.6.3-r1.ebuild new file mode 100644 index 000000000000..80dcbf2099d1 --- /dev/null +++ b/net-irc/znc/znc-1.6.3-r1.ebuild @@ -0,0 +1,128 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python{3_4,3_5} ) +inherit eutils python-single-r1 readme.gentoo-r1 systemd user + +MY_PV=${PV/_/-} +GTEST_VER="1.7.0" +GTEST_URL="https://github.com/google/googletest/archive/release-${GTEST_VER}.tar.gz -> googletest-release-${GTEST_VER}.tar.gz" +DESCRIPTION="An advanced IRC Bouncer" + +SRC_URI=" + http://znc.in/releases/archive/${PN}-${MY_PV}.tar.gz + test? ( ${GTEST_URL} ) +" +KEYWORDS="amd64 arm x86" + +HOMEPAGE="http://znc.in" +LICENSE="Apache-2.0" +SLOT="0" +IUSE="daemon debug ipv6 libressl perl python ssl sasl tcl test" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +RDEPEND=" + dev-libs/icu:= + sys-libs/zlib + perl? ( >=dev-lang/perl-5.10:= ) + python? ( ${PYTHON_DEPS} ) + sasl? ( >=dev-libs/cyrus-sasl-2 ) + ssl? ( + !libressl? ( dev-libs/openssl:0= ) + libressl? ( dev-libs/libressl:0= ) + ) + tcl? ( dev-lang/tcl:0= ) +" +DEPEND=" + ${RDEPEND} + virtual/pkgconfig +" + +S=${WORKDIR}/${PN}-${MY_PV} + +PATCHES=( + "${FILESDIR}"/${PN}-1.6.1-systemwideconfig.patch + "${FILESDIR}"/${PN}-1.6.1-create-pidfile-per-default.patch +) + +pkg_setup() { + if use python; then + python-single-r1_pkg_setup + fi + if use daemon; then + enewgroup ${PN} + enewuser ${PN} -1 -1 /var/lib/${PN} ${PN} + # The home directory was previously set to /dev/null + # This caused a bug with the systemd unit + # https://bugs.gentoo.org/521916 + esethome ${PN} /var/lib/${PN} + fi +} + +src_configure() { + econf \ + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \ + $(use_enable debug) \ + $(use_enable ipv6) \ + $(use_enable perl) \ + $(use_enable python) \ + $(use_enable sasl cyrus) \ + $(use_enable ssl openssl) \ + $(use_enable tcl tcl) \ + $(use_with test gtest "${WORKDIR}/googletest-release-${GTEST_VER}") +} + +src_install() { + default + dodoc NOTICE + if use daemon; then + newinitd "${FILESDIR}"/znc.initd-r1 znc + newconfd "${FILESDIR}"/znc.confd-r1 znc + fi + DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo") + DISABLE_AUTOFORMATTING=1 + readme.gentoo_create_doc +} + +pkg_postinst() { + readme.gentoo_print_elog + if [[ -d "${EROOT%/}"/etc/znc ]]; then + 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 "or adjust /etc/conf.d/znc" + fi +} + +pkg_config() { + if use daemon; then + if [[ -e "${EROOT%/}/var/lib/znc" ]]; then + ewarn "${EROOT%/}/var/lib/znc 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." + else + einfo "Press any key to interactively create a new configuration file" + einfo "for znc." + einfo "To abort, press Control-C" + read + mkdir -p "${EROOT%/}/var/lib/znc" || die + chown -R ${PN}:${PN} "${EROOT%/}/var/lib/znc" || + die "Setting permissions failed" + "${EROOT%/}"/usr/bin/znc --system-wide-config-as ${PN} -c -r -d "${EROOT%/}/var/lib/znc" || + die "Config failed" + echo + einfo "To start znc, run '/etc/init.d/znc start'" + einfo "or add znc to a runlevel:" + einfo " rc-update add znc default" + fi + else + ewarn "To configure znc as a system-wide daemon you have to" + ewarn "enable the 'daemon' use flag." + fi +} diff --git a/net-irc/znc/znc-1.6.5.ebuild b/net-irc/znc/znc-1.6.5.ebuild new file mode 100644 index 000000000000..23d86965db2e --- /dev/null +++ b/net-irc/znc/znc-1.6.5.ebuild @@ -0,0 +1,130 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python3_{4,5,6} ) +inherit eutils python-single-r1 readme.gentoo-r1 systemd user + +MY_PV=${PV/_/-} +GTEST_VER="1.7.0" +GTEST_URL="https://github.com/google/googletest/archive/release-${GTEST_VER}.tar.gz -> googletest-release-${GTEST_VER}.tar.gz" +DESCRIPTION="An advanced IRC Bouncer" + +SRC_URI=" + http://znc.in/releases/archive/${PN}-${MY_PV}.tar.gz + test? ( ${GTEST_URL} ) +" +KEYWORDS="amd64 arm x86" + +HOMEPAGE="http://znc.in" +LICENSE="Apache-2.0" +SLOT="0" +IUSE="daemon debug +ipv6 +icu libressl perl python +ssl sasl tcl test +zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +RDEPEND=" + icu? ( dev-libs/icu:= ) + perl? ( >=dev-lang/perl-5.10:= ) + python? ( ${PYTHON_DEPS} ) + sasl? ( >=dev-libs/cyrus-sasl-2 ) + ssl? ( + !libressl? ( dev-libs/openssl:0= ) + libressl? ( dev-libs/libressl:0= ) + ) + tcl? ( dev-lang/tcl:0= ) + zlib? ( sys-libs/zlib ) +" +DEPEND=" + ${RDEPEND} + virtual/pkgconfig +" + +S=${WORKDIR}/${PN}-${MY_PV} + +PATCHES=( + "${FILESDIR}"/${PN}-1.6.1-systemwideconfig.patch + "${FILESDIR}"/${PN}-1.6.1-create-pidfile-per-default.patch +) + +pkg_setup() { + if use python; then + python-single-r1_pkg_setup + fi + if use daemon; then + enewgroup ${PN} + enewuser ${PN} -1 -1 /var/lib/${PN} ${PN} + # The home directory was previously set to /dev/null + # This caused a bug with the systemd unit + # https://bugs.gentoo.org/521916 + esethome ${PN} /var/lib/${PN} + fi +} + +src_configure() { + econf \ + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \ + $(use_enable debug) \ + $(use_enable icu charset) \ + $(use_enable ipv6) \ + $(use_enable perl) \ + $(use_enable python) \ + $(use_enable sasl cyrus) \ + $(use_enable ssl openssl) \ + $(use_enable tcl) \ + $(use_enable zlib) \ + $(use_with test gtest "${WORKDIR}/googletest-release-${GTEST_VER}") +} + +src_install() { + default + dodoc NOTICE + if use daemon; then + newinitd "${FILESDIR}"/znc.initd-r1 znc + newconfd "${FILESDIR}"/znc.confd-r1 znc + fi + DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo") || die + DISABLE_AUTOFORMATTING=1 + readme.gentoo_create_doc +} + +pkg_postinst() { + readme.gentoo_print_elog + if [[ -d "${EROOT%/}"/etc/znc ]]; then + 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 "or adjust /etc/conf.d/znc" + fi +} + +pkg_config() { + if use daemon; then + if [[ -e "${EROOT%/}/var/lib/znc" ]]; then + ewarn "${EROOT%/}/var/lib/znc 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." + else + einfo "Press any key to interactively create a new configuration file" + einfo "for znc." + einfo "To abort, press Control-C" + read + mkdir -p "${EROOT%/}/var/lib/znc" || die + chown -R ${PN}:${PN} "${EROOT%/}/var/lib/znc" || + die "Setting permissions failed" + "${EROOT%/}"/usr/bin/znc --system-wide-config-as ${PN} -c -r -d "${EROOT%/}/var/lib/znc" || + die "Config failed" + echo + einfo "To start znc, run '/etc/init.d/znc start'" + einfo "or add znc to a runlevel:" + einfo " rc-update add znc default" + fi + else + ewarn "To configure znc as a system-wide daemon you have to" + ewarn "enable the 'daemon' use flag." + fi +} diff --git a/net-irc/znc/znc-9999.ebuild b/net-irc/znc/znc-9999.ebuild new file mode 100644 index 000000000000..a0794296fcc8 --- /dev/null +++ b/net-irc/znc/znc-9999.ebuild @@ -0,0 +1,164 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python{3_4,3_5} ) +PLOCALES="ru" + +inherit cmake-utils l10n python-single-r1 readme.gentoo-r1 systemd user + +GTEST_VER="1.8.0" +GTEST_URL="https://github.com/google/googletest/archive/release-${GTEST_VER}.tar.gz -> gtest-${GTEST_VER}.tar.gz" +DESCRIPTION="An advanced IRC Bouncer" + +if [[ ${PV} == *9999* ]]; then + inherit git-r3 + EGIT_REPO_URI=${EGIT_REPO_URI:-"https://github.com/znc/znc.git"} + SRC_URI="" +else + SRC_URI=" + http://znc.in/releases/archive/${P}.tar.gz + test? ( ${GTEST_URL} ) + " + KEYWORDS="~amd64 ~arm ~x86" +fi + +HOMEPAGE="http://znc.in" +LICENSE="Apache-2.0" +SLOT="0" +IUSE="+ipv6 +icu libressl nls perl python +ssl sasl tcl test +zlib" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} icu )" + +RDEPEND=" + icu? ( dev-libs/icu:= ) + nls? ( dev-libs/boost:=[nls] ) + perl? ( >=dev-lang/perl-5.10:= ) + python? ( ${PYTHON_DEPS} ) + sasl? ( >=dev-libs/cyrus-sasl-2 ) + ssl? ( + !libressl? ( dev-libs/openssl:0= ) + libressl? ( dev-libs/libressl:0= ) + ) + tcl? ( dev-lang/tcl:0= ) + zlib? ( sys-libs/zlib ) +" +DEPEND=" + ${RDEPEND} + nls? ( sys-devel/gettext ) + virtual/pkgconfig + perl? ( >=dev-lang/swig-3.0.0 ) + python? ( >=dev-lang/swig-3.0.0 ) +" + +pkg_setup() { + if use python; then + python-single-r1_pkg_setup + fi + + enewgroup ${PN} + enewuser ${PN} -1 -1 /var/lib/${PN} ${PN} + # The home directory was previously set to /dev/null + # This caused a bug with the systemd unit + # https://bugs.gentoo.org/521916 + esethome ${PN} /var/lib/${PN} +} + +src_prepare() { + l10n_find_plocales_changes "${S}/src/po" "${PN}." '.po' + + remove_locale() { + # Some language/module pairs can be missing + rm -f src/po/${PN}.${1}.po modules/po/*.${1}.po || die + } + l10n_for_each_disabled_locale_do remove_locale + + # Let SWIG rebuild modperl/modpython to make user patching easier. + if [[ ${PV} != *9999* ]]; then + rm modules/modperl/generated.tar.gz || die + rm modules/modpython/generated.tar.gz || die + fi + + cmake-utils_src_prepare +} + +src_configure() { + local mycmakeargs=( + -DWANT_SYSTEMD=yes # Causes -DSYSTEMD_DIR to be used. + -DSYSTEMD_DIR="$(systemd_get_systemunitdir)" + -DWANT_ICU="$(usex icu)" + -DWANT_IPV6="$(usex ipv6)" + -DWANT_I18N="$(usex nls)" + -DWANT_PERL="$(usex perl)" + -DWANT_PYTHON="$(usex python)" + -DWANT_CYRUS="$(usex sasl)" + -DWANT_OPENSSL="$(usex ssl)" + -DWANT_TCL="$(usex tcl)" + -DWANT_ZLIB="$(usex zlib)" + ) + + if [[ ${PV} != *9999* ]] && use test; then + export GTEST_ROOT="${WORKDIR}/googletest-release-${GTEST_VER}/googletest" + export GMOCK_ROOT="${WORKDIR}/googletest-release-${GTEST_VER}/googlemock" + fi + + cmake-utils_src_configure +} + +src_test() { + pushd "${BUILD_DIR}" > /dev/null || die + ${CMAKE_MAKEFILE_GENERATOR} unittest || die "Unit test failed" + popd > /dev/null || die +} + +src_install() { + cmake-utils_src_install + + dodoc NOTICE + newinitd "${FILESDIR}"/znc.initd-r2 znc + newconfd "${FILESDIR}"/znc.confd-r1 znc + + DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r1") || die + DISABLE_AUTOFORMATTING=1 + readme.gentoo_create_doc +} + +pkg_postinst() { + if [[ -z "${REPLACING_VERSIONS}" ]]; then + # This is a new installation + readme.gentoo_print_elog + fi + + if [[ -d "${EROOT%/}"/etc/znc ]]; then + ewarn "${EROOT%/}/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 " ${EROOT%/}/var/lib/znc" + ewarn "please move ${EROOT%/}/etc/znc to ${EROOT%/}/var/lib/znc" + ewarn "or adjust your service configuration." + fi +} + +pkg_config() { + if [[ -e "${EROOT%/}/var/lib/znc" ]]; then + ewarn "${EROOT%/}/var/lib/znc 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." + else + einfo "Press any key to interactively create a new configuration file" + einfo "for znc." + einfo "To abort, press Control-C" + read + mkdir -p "${EROOT%/}/var/lib/znc" || die + chown -R ${PN}:${PN} "${EROOT%/}/var/lib/znc" || + die "Setting permissions failed" + start-stop-daemon --start --user ${PN}:${PN} --env ZNC_NO_LAUNCH_AFTER_MAKECONF=1 \ + "${EROOT%/}"/usr/bin/znc -- --makeconf --datadir "${EROOT%/}/var/lib/znc" || + die "Config failed" + einfo + einfo "Now you can start znc service using the init system of your choice." + einfo "Don't forget to enable znc service if you want to use znc on boot." + fi +} |