commit:     b63d81cc7eee01fd502897d82767876ac52280fc
Author:     Filip Kobierski <fkobi <AT> pm <DOT> me>
AuthorDate: Tue May  6 15:42:16 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed May 21 21:47:57 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b63d81cc

net-vpn/i2pd: add 2.56.0-r1 with improved openrc files

Basically a rewrite at this point

Added:
- name
- reload command
- required_{dirs,files}
- command_args_background
- I2PD_LOGLEVEL
- default USER & GROUP
- confd file header
Fixed:
- pidfile usage
  - properly fix for #808845
  - part of #949988 (bad shutdown)
- not changing group
Changed:
- hardcode pidfile path to /run/i2pd/
- use command_progress instead of --progress
- use command_user instead of --user
- change `retry` timeouts to match upstream
- always run with --daemon --service --log=file
- rename OPTIONS to ARGS & add default value
- rename LOG to LOGFILE & add default value
- graceful command:
  - drop eval
  - use $retry
- style
  - group subcommands stuff at the bottom
  - indent stuff
  - unquote known atomic constants
  - use " instead of ' for strings
  - confd: move unprefixed rc_ulimit to the bottom
Removed:
- use netmount
- I2P_PID_DIR

Bug: https://bugs.gentoo.org/808845
Bug: https://bugs.gentoo.org/949988
Bug: https://bugs.gentoo.org/955416
Signed-off-by: Filip Kobierski <fkobi <AT> pm.me>
Part-of: https://github.com/gentoo/gentoo/pull/41968
Closes: https://github.com/gentoo/gentoo/pull/41968
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net-vpn/i2pd/files/i2pd-2.56.0.confd | 16 ++++++++
 net-vpn/i2pd/files/i2pd-2.56.0.initd | 53 +++++++++++++++++++++++++
 net-vpn/i2pd/i2pd-2.56.0-r1.ebuild   | 76 ++++++++++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+)

diff --git a/net-vpn/i2pd/files/i2pd-2.56.0.confd 
b/net-vpn/i2pd/files/i2pd-2.56.0.confd
new file mode 100644
index 000000000000..97cb169f9c45
--- /dev/null
+++ b/net-vpn/i2pd/files/i2pd-2.56.0.confd
@@ -0,0 +1,16 @@
+# /etc/conf.d/i2pd: config file for /etc/init.d/i2pd
+
+#I2PD_USER=i2pd
+#I2PD_GROUP=i2pd
+
+# Location of the i2pd log file
+#I2PD_LOGFILE=/var/log/i2pd.log
+
+# Minimal level of log messages (debug, info, warn, error, none)
+#I2PD_LOGLEVEL="warn"
+
+# Additional arguments passed to the daemon
+#I2PD_ARGS="--floodfill"
+
+# Max number of open files (for floodfill)
+rc_ulimit="-n 4096"

diff --git a/net-vpn/i2pd/files/i2pd-2.56.0.initd 
b/net-vpn/i2pd/files/i2pd-2.56.0.initd
new file mode 100644
index 000000000000..c58dcfcb575b
--- /dev/null
+++ b/net-vpn/i2pd/files/i2pd-2.56.0.initd
@@ -0,0 +1,53 @@
+#!/sbin/openrc-run
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+name="Invisible Internet Protocol daemon"
+description="C++ daemon for accessing the I2P network"
+
+command="/usr/bin/i2pd"
+pidfile="/run/i2pd/i2pd.pid"
+
+command_args_background="--daemon --pidfile=${pidfile}"
+command_progress=1
+command_user="${I2PD_USER:=i2pd}:${I2PD_GROUP:=i2pd}"
+retry="SIGTERM/30/SIGKILL/10"
+required_dirs="/var/lib/i2pd"
+required_files="/etc/i2pd/i2pd.conf"
+
+I2PD_LOGFILE="${I2PD_LOGFILE:=/var/log/i2pd.log}"
+
+command_args="--service --log=file \
+       --conf=/etc/i2pd/i2pd.conf \
+       --tunconf=/etc/i2pd/tunnels.conf \
+       --tunnelsdir=/etc/i2pd/tunnels.conf.d \
+       --loglevel='${I2PD_LOGLEVEL:=warn}'\
+       --logfile=${I2PD_LOGFILE} ${I2PD_ARGS} \
+"
+
+depend() {
+       use dns # for bootstrapping
+       use logger
+}
+
+start_pre() {
+       checkpath -o ${command_user} -d $(dirname ${pidfile})
+       checkpath -o ${command_user} -f ${I2PD_LOGFILE}
+}
+
+extra_started_commands="reload graceful"
+
+description_reload="Reload tunnels.conf configuration"
+reload() {
+       start-stop-daemon -s HUP -x ${command} -p ${pidfile}
+       eend $? "Reloaded tunnels configuration"
+}
+
+description_graceful="Graceful shutdown, takes 10 minutes"
+graceful() {
+       # on SIGINT, i2pd stops accepting tunnels and shuts down in 10 minutes
+       ebegin "Gracefully stopping i2pd, this takes 10 minutes"
+       mark_service_stopping
+       start-stop-daemon -K -x ${command} -p ${pidfile} -R 
"SIGINT/620/${retry}"
+       eend $? && mark_service_stopped
+}

diff --git a/net-vpn/i2pd/i2pd-2.56.0-r1.ebuild 
b/net-vpn/i2pd/i2pd-2.56.0-r1.ebuild
new file mode 100644
index 000000000000..0d05e22b9f24
--- /dev/null
+++ b/net-vpn/i2pd/i2pd-2.56.0-r1.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake systemd
+
+DESCRIPTION="A C++ daemon for accessing the I2P anonymous network"
+HOMEPAGE="https://github.com/PurpleI2P/i2pd";
+SRC_URI="https://github.com/PurpleI2P/${PN}/archive/${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~sparc ~x86"
+IUSE="+upnp"
+
+DEPEND="
+       dev-libs/boost:=
+       dev-libs/openssl:0=[-bindist(-)]
+       sys-libs/zlib
+       upnp? ( net-libs/miniupnpc:= )
+"
+RDEPEND="
+       acct-user/i2pd
+       acct-group/i2pd
+       ${DEPEND}
+"
+
+CMAKE_USE_DIR="${WORKDIR}/${P}/build"
+
+DOCS=( ../README.md ../contrib/i2pd.conf ../contrib/tunnels.conf )
+
+src_configure() {
+       local mycmakeargs=(
+               -DWITH_HARDENING=OFF # worsens or matches the non-hardened 
profiles
+               -DWITH_STATIC=OFF
+               -DWITH_UPNP=$(usex upnp ON OFF)
+               -DWITH_LIBRARY=ON
+               -DWITH_BINARY=ON
+       )
+       cmake_src_configure
+}
+
+src_install() {
+       cmake_src_install
+
+       # config
+       insinto /etc/i2pd
+       doins contrib/i2pd.conf
+       doins contrib/tunnels.conf
+
+       # working directory
+       insinto /var/lib/i2pd
+       doins -r contrib/certificates
+
+       # add /var/lib/i2pd/certificates to CONFIG_PROTECT
+       doenvd "${FILESDIR}/99i2pd"
+
+       # openrc and systemd daemon routines
+       newconfd "${FILESDIR}/i2pd-2.56.0.confd" i2pd
+       newinitd "${FILESDIR}/i2pd-2.56.0.initd" i2pd
+       systemd_newunit "${FILESDIR}/i2pd-2.38.0.service" i2pd.service
+
+       # logrotate
+       insinto /etc/logrotate.d
+       newins "${FILESDIR}/i2pd-2.38.0-r1.logrotate" i2pd
+}
+
+pkg_postinst() {
+       if [[ -f ${EROOT}/etc/i2pd/subscriptions.txt ]]; then
+               ewarn
+               ewarn "Configuration of the subscriptions has been moved from"
+               ewarn "subscriptions.txt to i2pd.conf. We recommend updating"
+               ewarn "i2pd.conf accordingly and deleting subscriptions.txt."
+       fi
+}

Reply via email to