#!/usr/bin/env bash # Build .deb package for i2p-python. # Runs inside the Debian build container — never on bare metal. # # Strategy: install into a virtualenv under /opt/i2p-python, then package # the entire venv + config files as a .deb 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} .deb ===" # Create staging root STAGING=/tmp/staging mkdir -p "${STAGING}/opt/i2p-python" mkdir -p "${STAGING}/usr/bin" mkdir -p "${STAGING}/etc/i2p-python" 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 config files cp packaging/linux/ufw-i2p "${STAGING}/etc/i2p-python/" # Build .deb with fpm from the staged directory fpm \ -s dir \ -t deb \ -C "${STAGING}" \ -n i2p-python \ -v "${VERSION}" \ --architecture amd64 \ --description "I2P anonymous overlay network router — Python implementation" \ --url "https://geti2p.net/" \ --license MIT \ --maintainer "bimo.studio" \ --category net \ --depends python3 \ --deb-systemd packaging/linux/i2p-router.service \ --after-install build/linux-deb/postinst.sh \ --deb-no-default-config-files \ -p "/out/i2p-python_${VERSION}_amd64.deb" \ opt/ usr/bin/ etc/ var/ echo "=== .deb built ===" ls -lh /out/*.deb