#!/usr/bin/env bash # Build .rpm package for i2p-python. # Runs inside the Fedora build container — never on bare metal. # # Strategy: install into a virtualenv under /opt/i2p-python, then package # the entire venv + config files as an .rpm using fpm -s dir. set -euo pipefail VERSION=$(python3 -c " import tomllib with open('pyproject.toml', 'rb') as f: print(tomllib.load(f)['project']['version']) ") echo "=== Building i2p-python ${VERSION} .rpm ===" # Create staging root STAGING=/tmp/staging mkdir -p "${STAGING}/opt/i2p-python" mkdir -p "${STAGING}/usr/bin" mkdir -p "${STAGING}/usr/lib/systemd/system" mkdir -p "${STAGING}/var/lib/i2p-python" # Install into isolated virtualenv at /opt/i2p-python python3 -m venv "${STAGING}/opt/i2p-python" "${STAGING}/opt/i2p-python/bin/pip" install --quiet . # Create wrapper scripts in /usr/bin for cmd in i2p-router i2p-sam i2p-tunnel; do cat > "${STAGING}/usr/bin/${cmd}" << 'WRAPPER' #!/bin/sh exec /opt/i2p-python/bin/CMD "$@" WRAPPER sed -i "s/CMD/${cmd}/" "${STAGING}/usr/bin/${cmd}" chmod 755 "${STAGING}/usr/bin/${cmd}" done # Copy systemd unit cp packaging/linux/i2p-router.service "${STAGING}/usr/lib/systemd/system/" # Build .rpm with fpm from the staged directory fpm \ -s dir \ -t rpm \ -C "${STAGING}" \ -n i2p-python \ -v "${VERSION}" \ --architecture x86_64 \ --description "I2P anonymous overlay network router — Python implementation" \ --url "https://geti2p.net/" \ --license MIT \ --maintainer "bimo.studio" \ --category "Applications/Internet" \ --depends python3 \ -p "/out/i2p-python-${VERSION}-1.x86_64.rpm" \ opt/ usr/ var/ echo "=== .rpm built ===" ls -lh /out/*.rpm