Skip to content

Commit

Permalink
net-irc/psybnc: EAPI7, improve ebuild
Browse files Browse the repository at this point in the history
Closes: https://bugs.gentoo.org/666720
Signed-off-by: Michael Mair-Keimberger <m.mairkeimberger@gmail.com>
  • Loading branch information
mm1ke committed Sep 21, 2018
1 parent 382f616 commit 714c100
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 21 deletions.
30 changes: 15 additions & 15 deletions net-irc/psybnc/files/compile.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -Naurp src/p_blowfish.c src/p_blowfish.c
--- src/p_blowfish.c 2007-02-26 12:16:53.000000000 +0000
+++ src/p_blowfish.c 2007-02-26 12:17:11.000000000 +0000
diff -Naurp a/src/p_blowfish.c b/src/p_blowfish.c
--- a/src/p_blowfish.c 2007-02-26 12:16:53.000000000 +0000
+++ b/src/p_blowfish.c 2007-02-26 12:17:11.000000000 +0000
@@ -31,7 +31,7 @@ static char rcsid[] = "@(#)# $Id$
#include <string.h>
#include <config.h>
Expand All @@ -10,9 +10,9 @@ diff -Naurp src/p_blowfish.c src/p_blowfish.c
char *lngtxt(int msgnum);

#define pcontext { strmncpy(ctxt,__FILE__,sizeof(ctxt));strmncpy(cfunc,__FUNCTION__,sizeof(cfunc)); cline=__LINE__; }
diff -Naurp src/p_global.h src/p_global.h
--- src/p_global.h 2007-02-26 12:16:53.000000000 +0000
+++ src/p_global.h 2007-02-26 12:17:11.000000000 +0000
diff -Naurp a/src/p_global.h b/src/p_global.h
--- a/src/p_global.h 2007-02-26 12:16:53.000000000 +0000
+++ b/src/p_global.h 2007-02-26 12:17:11.000000000 +0000
@@ -972,8 +972,8 @@ int checklogging(int usern);
#endif

Expand All @@ -33,9 +33,9 @@ diff -Naurp src/p_global.h src/p_global.h
int strmncasecmp(char *one, char *two);
int strmcmp(char *one, char *two);
int strmwildcmp(char *line, char *wildcard);
diff -Naurp src/p_memory.c src/p_memory.c
--- src/p_memory.c 2007-02-26 12:16:53.000000000 +0000
+++ src/p_memory.c 2007-02-26 12:17:11.000000000 +0000
diff -Naurp a/src/p_memory.c b/src/p_memory.c
--- a/src/p_memory.c 2007-02-26 12:16:53.000000000 +0000
+++ b/src/p_memory.c 2007-02-26 12:17:11.000000000 +0000
@@ -32,7 +32,7 @@ FILE *logm=NULL;

/* malloc-wrapper. No memory will log an error entry and kill the bouncer */
Expand All @@ -54,9 +54,9 @@ diff -Naurp src/p_memory.c src/p_memory.c
{
#ifdef LOGALLOC
if(logm==NULL)
diff -Naurp src/p_string.c src/p_string.c
--- src/p_string.c 2007-02-26 12:16:53.000000000 +0000
+++ src/p_string.c 2007-02-26 12:17:11.000000000 +0000
diff -Naurp a/src/p_string.c b/src/p_string.c
--- a/src/p_string.c 2007-02-26 12:16:53.000000000 +0000
+++ b/src/p_string.c 2007-02-26 12:17:11.000000000 +0000
@@ -51,7 +51,7 @@ char *lngtxt(unsigned int msgnum)

/* string copy with len and zero delimit */
Expand All @@ -66,9 +66,9 @@ diff -Naurp src/p_string.c src/p_string.c
{
char bf[strlen(source)+2];
char *pt;
diff -Naurp src/match.c src/match.c
--- src/match.c 2007-02-26 12:26:10.000000000 +0000
+++ src/match.c 2007-02-26 12:26:17.000000000 +0000
diff -Naurp a/src/match.c b/src/match.c
--- a/src/match.c 2007-02-26 12:26:10.000000000 +0000
+++ b/src/match.c 2007-02-26 12:26:17.000000000 +0000
@@ -36,6 +36,7 @@
/* Remove the next line to use this in IrcII */
#define EGGDROP
Expand Down
4 changes: 2 additions & 2 deletions net-irc/psybnc/files/psybnc-2.3.2.9-multinetwork.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- config.h.orig 2009-06-10 21:30:24.000000000 +0000
+++ config.h 2009-06-10 21:30:39.000000000 +0000
--- a/config.h.orig 2009-06-10 21:30:24.000000000 +0000
+++ b/config.h 2009-06-10 21:30:39.000000000 +0000
@@ -50,6 +50,10 @@

#define BLOCKDNS
Expand Down
4 changes: 2 additions & 2 deletions net-irc/psybnc/files/psybnc-2.3.2.9-oidentd.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- config.h.orig 2008-12-14 20:02:57.000000000 +0000
+++ config.h 2008-12-14 20:03:35.000000000 +0000
--- a/config.h 2008-12-14 20:02:57.000000000 +0000
+++ b/config.h 2008-12-14 20:03:35.000000000 +0000
@@ -14,6 +14,10 @@

#define TRANSLATE
Expand Down
4 changes: 2 additions & 2 deletions net-irc/psybnc/files/psybnc-2.3.2.9-scripting.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- config.h.orig 2009-01-03 17:30:41.000000000 +0000
+++ config.h 2009-01-03 17:31:27.000000000 +0000
--- a/config.h.orig 2009-01-03 17:30:41.000000000 +0000
+++ b/config.h 2009-01-03 17:31:27.000000000 +0000
@@ -26,6 +26,10 @@

#define TRAFFICLOG
Expand Down
159 changes: 159 additions & 0 deletions net-irc/psybnc/psybnc-2.3.2.9-r3.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit toolchain-funcs user

MY_PV="$(ver_rs 3 -)"
PSYBNC_HOME="/var/lib/psybnc"

DESCRIPTION="A multi-user and multi-server gateway to IRC networks"
HOMEPAGE="http://www.psybnc.at/index.html"
SRC_URI="http://www.psybnc.at/download/beta/psyBNC-${MY_PV}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~sparc ~x86 ~ppc"
IUSE="ipv6 ssl oidentd scripting multinetwork"

DEPEND="ssl? ( >=dev-libs/openssl-0.9.7d )
oidentd? ( >=net-misc/oidentd-2.0 )"
RDEPEND="${DEPEND}"
S="${WORKDIR}"/"${PN}"

pkg_setup() {
enewgroup psybnc
enewuser psybnc -1 -1 ${PSYBNC_HOME} psybnc
}

src_unpack() {
unpack ${A}
cd "${S}" || die

# Useless files
rm -f */INFO || die

# Pretend we already have a certificate, we generate it in pkg_config
touch key/psybnc.cert.pem || die

if [[ -f ${ROOT}/usr/share/psybnc/salt.h ]]; then
einfo "Using existing salt.h for password encryption"
cp "${ROOT}"/usr/share/psybnc/salt.h salt.h || die
fi
}

src_prepare() {
default
eapply "${FILESDIR}/compile.diff"
eapply "${FILESDIR}/ldflags-fix.patch"

# add oidentd
use oidentd && eapply "${FILESDIR}/${P}-oidentd.patch"

# add scripting support
use scripting && eapply "${FILESDIR}/${P}-scripting.patch"

# add multinetwork support
use multinetwork && eapply "${FILESDIR}/${P}-multinetwork.patch"

# Prevent stripping the binary
sed -i -e "/@strip/ d" tools/autoconf.c || die
}

src_compile() {
if use ipv6; then
rm -f tools/chkipv6.c || die
fi
if use ssl; then
rm -f tools/chkssl.c || die
fi

emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
}

src_install() {
dobin psybnc

insinto /usr/share/psybnc
doins -r help lang salt.h
fperms 0600 /usr/share/psybnc/salt.h

insinto /etc/psybnc
doins "${FILESDIR}"/psybnc.conf

keepdir "${PSYBNC_HOME}"/{log,motd,scripts}
dosym /usr/share/psybnc/lang "${PSYBNC_HOME}"/lang
dosym /usr/share/psybnc/help "${PSYBNC_HOME}"/help

fowners psybnc:psybnc "${PSYBNC_HOME}"/{,log,motd,scripts} /etc/psybnc/psybnc.conf
fperms 0750 "${PSYBNC_HOME}"/{,log,motd,scripts}
fperms 0640 /etc/psybnc/psybnc.conf

if use ssl; then
keepdir /etc/psybnc/ssl
dosym /etc/psybnc/ssl "${PSYBNC_HOME}"/key
else
# Drop SSL listener from psybnc.conf
sed -i -e "/^# Default SSL listener$/,+4 d" "${D}"/etc/psybnc/psybnc.conf || die
fi

if use oidentd; then
insinto /etc
doins "${FILESDIR}"/oidentd.conf.psybnc
fperms 640 /etc/oidentd.conf.psybnc
# install init-script with oidentd-support
newinitd "${FILESDIR}"/psybnc-oidentd.initd psybnc
else
# install init-script without oidentd-support
newinitd "${FILESDIR}"/psybnc.initd psybnc
fi

newconfd "${FILESDIR}"/psybnc.confd psybnc

dodoc CHANGES FAQ README SCRIPTING TODO
docinto example-script
dodoc scripts/example/DEFAULT.SCRIPT
}

pkg_config() {
if use ssl; then
if [[ -f ${ROOT}/etc/psybnc/ssl/psybnc.cert.pem || -f ${ROOT}/etc/psybnc/ssl/psybnc.key.pem ]]; then
ewarn "Existing /etc/psybnc/psybnc.cert.pem or /etc/psybnc/psybnc.key.pem found!"
ewarn "Remove /etc/psybnc/psybnc.*.pem and run emerge --config =${CATEGORY}/${PF} again."
return
fi

einfo "Generating certificate request..."
openssl req -new -out "${ROOT}"/etc/psybnc/ssl/psybnc.req.pem \
-keyout "${ROOT}"/etc/psybnc/ssl/psybnc.key.pem -nodes || die
einfo "Generating self-signed certificate..."
openssl req -x509 -days 365 -in "${ROOT}"/etc/psybnc/ssl/psybnc.req.pem \
-key "${ROOT}"/etc/psybnc/ssl/psybnc.key.pem \
-out "${ROOT}"/etc/psybnc/ssl/psybnc.cert.pem || die
einfo "Setting permissions on files..."
chown root:psybnc "${ROOT}"/etc/psybnc/ssl/psybnc.{cert,key,req}.pem || die
chmod 0640 "${ROOT}"/etc/psybnc/ssl/psybnc.{cert,key,req}.pem || die
fi
}

pkg_postinst() {
if use ssl; then
elog
elog "Please run \"emerge --config =${CATEGORY}/${PF}\" to create needed SSL certificates."
fi
if use oidentd; then
elog
elog "You have enabled oidentd-support. You will need to set"
elog "up your /etc/oident.conf file before running psybnc. An example"
elog "for psyBNC can be found under /etc/oidentd.conf.psybnc"
fi
elog
elog "You can connect to psyBNC on port 23998 with user gentoo and password gentoo."
elog "Please edit the psyBNC configuration at /etc/psybnc/psybnc.conf to change this."
elog
elog "To be able to reuse an existing psybnc.conf, you need to make sure that the"
elog "old salt.h is available at /usr/share/psybnc/salt.h when compiling a new"
elog "version of psyBNC. It is needed for password encryption and decryption."
elog
}

0 comments on commit 714c100

Please sign in to comment.