A Python port of the Invisible Internet Project (I2P)
1#!/usr/bin/env bash
2# Build .rpm package for i2p-python.
3# Runs inside the Fedora build container — never on bare metal.
4#
5# Strategy: install into a virtualenv under /opt/i2p-python, then package
6# the entire venv + config files as an .rpm using fpm -s dir.
7set -euo pipefail
8
9VERSION=$(python3 -c "
10import tomllib
11with open('pyproject.toml', 'rb') as f:
12 print(tomllib.load(f)['project']['version'])
13")
14echo "=== Building i2p-python ${VERSION} .rpm ==="
15
16# Create staging root
17STAGING=/tmp/staging
18mkdir -p "${STAGING}/opt/i2p-python"
19mkdir -p "${STAGING}/usr/bin"
20mkdir -p "${STAGING}/usr/lib/systemd/system"
21mkdir -p "${STAGING}/var/lib/i2p-python"
22
23# Install into isolated virtualenv at /opt/i2p-python
24python3 -m venv "${STAGING}/opt/i2p-python"
25"${STAGING}/opt/i2p-python/bin/pip" install --quiet .
26
27# Create wrapper scripts in /usr/bin
28for cmd in i2p-router i2p-sam i2p-tunnel; do
29 cat > "${STAGING}/usr/bin/${cmd}" << 'WRAPPER'
30#!/bin/sh
31exec /opt/i2p-python/bin/CMD "$@"
32WRAPPER
33 sed -i "s/CMD/${cmd}/" "${STAGING}/usr/bin/${cmd}"
34 chmod 755 "${STAGING}/usr/bin/${cmd}"
35done
36
37# Copy systemd unit
38cp packaging/linux/i2p-router.service "${STAGING}/usr/lib/systemd/system/"
39
40# Build .rpm with fpm from the staged directory
41fpm \
42 -s dir \
43 -t rpm \
44 -C "${STAGING}" \
45 -n i2p-python \
46 -v "${VERSION}" \
47 --architecture x86_64 \
48 --description "I2P anonymous overlay network router — Python implementation" \
49 --url "https://geti2p.net/" \
50 --license MIT \
51 --maintainer "bimo.studio" \
52 --category "Applications/Internet" \
53 --depends python3 \
54 -p "/out/i2p-python-${VERSION}-1.x86_64.rpm" \
55 opt/ usr/ var/
56
57echo "=== .rpm built ==="
58ls -lh /out/*.rpm