diff options
author | Sam James <sam@gentoo.org> | 2022-05-04 05:10:31 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-05-04 05:19:18 +0100 |
commit | 210c3f977cf72db1948716e4b7d85c7a5a984b5f (patch) | |
tree | e4a67c490a5493fe1e7424c21d449bf2f6965f48 | |
parent | dev-python/twisted: stable 22.4.0 for sparc, bug #837845 (diff) | |
download | gentoo-210c3f977cf72db1948716e4b7d85c7a5a984b5f.tar.gz gentoo-210c3f977cf72db1948716e4b7d85c7a5a984b5f.tar.bz2 gentoo-210c3f977cf72db1948716e4b7d85c7a5a984b5f.zip |
net-analyzer/darkstat: add error handling; EAPI 8; live template
- EAPI 8
- Add error handling for if chroot directory is empty (don't try to chown /;
thankfully no -R option was there)
- Use fowners instead of chown to notice missing user earlier (although shouldn't
happen)
- Use live ebuild template
Reported-by: Corvus
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | net-analyzer/darkstat/darkstat-3.0.719-r4.ebuild | 80 | ||||
-rw-r--r-- | net-analyzer/darkstat/darkstat-9999999.ebuild | 48 |
2 files changed, 107 insertions, 21 deletions
diff --git a/net-analyzer/darkstat/darkstat-3.0.719-r4.ebuild b/net-analyzer/darkstat/darkstat-3.0.719-r4.ebuild new file mode 100644 index 000000000000..1f62dd3d13c0 --- /dev/null +++ b/net-analyzer/darkstat/darkstat-3.0.719-r4.ebuild @@ -0,0 +1,80 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools + +DESCRIPTION="Network traffic analyzer with cute web interface" +HOMEPAGE="https://unix4lyfe.org/darkstat/" +if [[ ${PV} == *9999* ]] ; then + EGIT_REPO_URI="https://www.unix4lyfe.org/git/darkstat" + inherit git-r3 +else + SRC_URI="https://unix4lyfe.org/${PN}/${P}.tar.bz2" + KEYWORDS="~amd64 ~ppc ~x86" +fi + +LICENSE="GPL-2" +SLOT="0" + +DEPEND="acct-user/darkstat + dev-libs/libbsd + net-libs/libpcap + sys-libs/zlib" +RDEPEND="${DEPEND}" + +DARKSTAT_CHROOT_DIR=${DARKSTAT_CHROOT_DIR:-/var/lib/darkstat} + +DOCS=( AUTHORS ChangeLog README NEWS ) + +PATCHES=( + "${FILESDIR}"/${PN}-3.0.719-strncpy-off-by-one.patch +) + +src_prepare() { + default + + sed -i \ + -e '/-DNDEBUG/d' \ + -e 's|-flto||g' \ + configure.ac || die + + eautoreconf +} + +src_configure() { + econf --with-privdrop-user=darkstat +} + +src_install() { + default + + newinitd "${FILESDIR}"/darkstat-initd darkstat + newconfd "${FILESDIR}"/darkstat-confd darkstat + + sed -i -e "s:__CHROOT__:${DARKSTAT_CHROOT_DIR}:g" "${D}"/etc/conf.d/darkstat || die + sed -i -e "s:__CHROOT__:${DARKSTAT_CHROOT_DIR}:g" "${D}"/etc/init.d/darkstat || die + + keepdir "${DARKSTAT_CHROOT_DIR}" + fowners darkstat:0 "${DARKSTAT_CHROOT_DIR}" +} + +pkg_postinst() { + # Workaround bug #141619 + DARKSTAT_CHROOT_DIR=$( + sed -n 's/^#CHROOT=\(.*\)/\1/p' "${EROOT}"/etc/conf.d/darkstat + ) + + if [[ -n "${DARKSTAT_CHROOT_DIR}" ]] && [[ "${DARKSTAT_CHROOT_DIR}" != "${EROOT:-/}" ]] ; then + chown darkstat:0 "${EROOT}/${DARKSTAT_CHROOT_DIR#/}/" + fi + + elog "To start different darkstat instances which will listen on a different" + elog "interface, create within the ${EROOT}/etc/init.d directory a 'darkstat.if' symlink to" + elog "darkstat script where 'if' is the name of the interface." + elog "Also in the ${EROOT}/etc/conf.d directory, copy darkstat to darkstat.if" + elog "and edit it to change default values." + elog + elog "darkstat's default chroot directory is: ${EROOT}/${DARKSTAT_CHROOT_DIR#/}" +} diff --git a/net-analyzer/darkstat/darkstat-9999999.ebuild b/net-analyzer/darkstat/darkstat-9999999.ebuild index 4ca39eb748e3..1274c0c32950 100644 --- a/net-analyzer/darkstat/darkstat-9999999.ebuild +++ b/net-analyzer/darkstat/darkstat-9999999.ebuild @@ -1,32 +1,35 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=7 +EAPI=8 -inherit autotools git-r3 +inherit autotools DESCRIPTION="Network traffic analyzer with cute web interface" HOMEPAGE="https://unix4lyfe.org/darkstat/" -EGIT_REPO_URI="https://www.unix4lyfe.org/git/darkstat" +if [[ ${PV} == *9999* ]] ; then + EGIT_REPO_URI="https://www.unix4lyfe.org/git/darkstat" + inherit git-r3 +else + SRC_URI="https://unix4lyfe.org/${PN}/${P}.tar.bz2" + KEYWORDS="~amd64 ~ppc ~x86" +fi LICENSE="GPL-2" SLOT="0" -KEYWORDS="" -BDEPEND=" - app-editors/vim-core -" -DEPEND=" - acct-user/darkstat +# The live ebuild requires xxd to generate favicon.h. +BDEPEND="app-editors/vim-core" +DEPEND="acct-user/darkstat dev-libs/libbsd net-libs/libpcap - sys-libs/zlib -" -RDEPEND=" - ${DEPEND} -" + sys-libs/zlib" +RDEPEND="${DEPEND}" + DARKSTAT_CHROOT_DIR=${DARKSTAT_CHROOT_DIR:-/var/lib/darkstat} + DOCS=( AUTHORS ChangeLog README NEWS ) + PATCHES=( "${FILESDIR}"/${PN}-3.0.719-strncpy-off-by-one.patch ) @@ -56,21 +59,24 @@ src_install() { sed -i -e "s:__CHROOT__:${DARKSTAT_CHROOT_DIR}:g" "${D}"/etc/init.d/darkstat || die keepdir "${DARKSTAT_CHROOT_DIR}" - chown darkstat:0 "${D}${DARKSTAT_CHROOT_DIR}" + fowners darkstat:0 "${DARKSTAT_CHROOT_DIR}" } pkg_postinst() { # Workaround bug #141619 DARKSTAT_CHROOT_DIR=$( - sed -n 's/^#CHROOT=\(.*\)/\1/p' "${ROOT}"/etc/conf.d/darkstat + sed -n 's/^#CHROOT=\(.*\)/\1/p' "${EROOT}"/etc/conf.d/darkstat ) - chown darkstat:0 "${ROOT}${DARKSTAT_CHROOT_DIR}" + + if [[ -n "${DARKSTAT_CHROOT_DIR}" ]] && [[ "${DARKSTAT_CHROOT_DIR}" != "${EROOT:-/}" ]] ; then + chown darkstat:0 "${EROOT}/${DARKSTAT_CHROOT_DIR#/}/" + fi elog "To start different darkstat instances which will listen on a different" - elog "interfaces create in /etc/init.d directory the 'darkstat.if' symlink to" + elog "interface, create within the ${EROOT}/etc/init.d directory a 'darkstat.if' symlink to" elog "darkstat script where 'if' is the name of the interface." - elog "Also in /etc/conf.d directory copy darkstat to darkstat.if" + elog "Also in the ${EROOT}/etc/conf.d directory, copy darkstat to darkstat.if" elog "and edit it to change default values." elog - elog "darkstat's default chroot directory is: \"${ROOT}${DARKSTAT_CHROOT_DIR}\"" + elog "darkstat's default chroot directory is: ${EROOT}/${DARKSTAT_CHROOT_DIR#/}" } |