A Python port of the Invisible Internet Project (I2P)
at main 61 lines 1.8 kB view raw
1#!/usr/bin/env bash 2# Build .deb package for i2p-python. 3# Runs inside the Debian 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 a .deb 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} .deb ===" 15 16# Create staging root 17STAGING=/tmp/staging 18mkdir -p "${STAGING}/opt/i2p-python" 19mkdir -p "${STAGING}/usr/bin" 20mkdir -p "${STAGING}/etc/i2p-python" 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 config files 38cp packaging/linux/ufw-i2p "${STAGING}/etc/i2p-python/" 39 40# Build .deb with fpm from the staged directory 41fpm \ 42 -s dir \ 43 -t deb \ 44 -C "${STAGING}" \ 45 -n i2p-python \ 46 -v "${VERSION}" \ 47 --architecture amd64 \ 48 --description "I2P anonymous overlay network router — Python implementation" \ 49 --url "https://geti2p.net/" \ 50 --license MIT \ 51 --maintainer "bimo.studio" \ 52 --category net \ 53 --depends python3 \ 54 --deb-systemd packaging/linux/i2p-router.service \ 55 --after-install build/linux-deb/postinst.sh \ 56 --deb-no-default-config-files \ 57 -p "/out/i2p-python_${VERSION}_amd64.deb" \ 58 opt/ usr/bin/ etc/ var/ 59 60echo "=== .deb built ===" 61ls -lh /out/*.deb