diff --git a/README.md b/README.md index 8bd936d..49571c9 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,18 @@ Ensure that your build machine has the build dependencies mentioned in package/debian/control. Something like this: ``` -# apt install build-essential git devscripts debhelper tcl8.6-dev autoconf \ - python3-dev python3-venv python3-setuptools libz-dev openssl \ +sudo apt install build-essential git devscripts debhelper tcl8.6-dev \ + autoconf python3-dev python3-venv python3-setuptools libz-dev openssl \ libboost-system-dev libboost-program-options-dev libboost-regex-dev \ libboost-filesystem-dev patchelf ``` +Additional packages are needed in order to build PiAware on Debian Trixie: + +``` +sudo apt install python3-build python3-pyasyncore python3-filelock +``` + If you use pdebuild it will do most of this for you. ## Caveat about tcl-tls @@ -63,19 +69,19 @@ Change to the package directory on your build machine and build with a debian package building tool of your choice: ``` - $ dpkg-buildpackage -b +dpkg-buildpackage -b --no-sign ``` or ``` - $ debuild +debuild ``` or ``` - $ pdebuild +pdebuild ``` etc. diff --git a/sensible-build.sh b/sensible-build.sh index 294f4dd..7c5808b 100755 --- a/sensible-build.sh +++ b/sensible-build.sh @@ -19,7 +19,7 @@ shallow_clone() { } usage() { - echo "syntax: $0 " >&2 + echo "syntax: $0 " >&2 exit 1 } @@ -53,6 +53,11 @@ case $dist in targetdist=bookworm extraversion="" ;; + trixie) + debdist=trixie + targetdist=trixie + extraversion="" + ;; xenial) # not tested debdist=stretch @@ -71,6 +76,12 @@ case $dist in targetdist=disco extraversion="~ubuntu1904+" ;; + noble) + # not tested + debdist=trixie + targetdist=noble + extraversion="~ubuntu2404+" + ;; *) echo "unknown build distribution $1" >&2 usage @@ -173,6 +184,12 @@ case $debdist in https://github.com/marcelotduarte/cx_Freeze/archive/refs/tags/6.15.9.tar.gz \ d32b309b355f2b377dae585a839e39e3251b3f9716f2b4983be92972c2863000 ;; + + trixie) + fetch_archive cx_freeze-7.2.0 \ + https://files.pythonhosted.org/packages/6e/23/6947cd90cfe87712099fbeab2061309ab1d2a95d54f3453cb6bb21b00034/cx_freeze-7.2.0.tar.gz \ + c57f7101b4d35132464b1ec88cb8948c3b7c5b4ece4bb354c16091589cb33583 + ;; esac # copy our control files diff --git a/trixie/control b/trixie/control new file mode 100644 index 0000000..66df92d --- /dev/null +++ b/trixie/control @@ -0,0 +1,16 @@ +Source: piaware +Section: embedded +Priority: extra +Maintainer: FlightAware Developers +Build-Depends: debhelper(>=10), tcl8.6-dev, autoconf, python3-dev(>=3.9), python3-venv, python3-setuptools (>=62.6), python3-wheel (>=0.38.4), python3-build, python3-pip, libz-dev, openssl, libboost-system-dev, libboost-program-options-dev, libboost-regex-dev, libboost-filesystem-dev, patchelf, python3-filelock, python3-pyasyncore +Standards-Version: 3.9.3 +Homepage: https://github.com/flightaware + +Package: piaware +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, net-tools, iproute2, tclx8.4, tcl8.6, tcllib, tcl-tls (>= 1.7.22-2+fa1), itcl3 +Suggests: dump1090-fa, dump978-fa +Conflicts: fa-mlat-client +Replaces: fa-mlat-client +Description: Open Aviation Data Exchange Protocol for ADS-B FlightFeeders + The client-side portion of fa_adept that sends aviation data via TCL sockets. diff --git a/trixie/piaware.docs b/trixie/piaware.docs new file mode 100644 index 0000000..9299e67 --- /dev/null +++ b/trixie/piaware.docs @@ -0,0 +1 @@ +piaware/MLAT-RESULTS-LICENSE.md diff --git a/trixie/piaware.install b/trixie/piaware.install new file mode 100644 index 0000000..c37c34e --- /dev/null +++ b/trixie/piaware.install @@ -0,0 +1,3 @@ +debian/rsyslog/piaware.conf etc/rsyslog.d/ +debian/upgrade-config.tcl usr/share/piaware/ +debian/piaware.conf etc/ diff --git a/trixie/piaware.logrotate b/trixie/piaware.logrotate new file mode 100644 index 0000000..0343881 --- /dev/null +++ b/trixie/piaware.logrotate @@ -0,0 +1,9 @@ +/var/log/piaware.log { + weekly + rotate 4 + missingok + notifempty + postrotate + invoke-rc.d rsyslog rotate >/dev/null 2>&1 || true + endscript +} diff --git a/trixie/piaware.postinst b/trixie/piaware.postinst new file mode 100644 index 0000000..4848be9 --- /dev/null +++ b/trixie/piaware.postinst @@ -0,0 +1,155 @@ +#!/bin/sh +# postinst script for piaware +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +NAME=piaware +RUNAS=piaware + +upgrade_piaware2_config() { + if [ ! -f /boot/piaware-config.txt -a -d /boot ] + then + # write an initial piaware-config.txt so it can be updated in a moment. + cat >/boot/piaware-config.txt <&2 <&2 + ;; + *) + # keep this + if [ -z "$new_mlat_config" ] + then + new_mlat_config="$part" + else + new_mlat_config="$new_mlat_config $part" + fi + ;; + esac + done + + if [ "$old_mlat_config" != "$new_mlat_config" ] + then + echo "Updating mlat results config to: $new_mlat_config" >&2 + piaware-config mlat-results-format "$new_mlat_config" + fi +} + +remove_user_and_password() { + for f in /boot/piaware-config.txt /etc/piaware.conf + do + if [ -e $f ] + then + sed -e 's@^\s*flightaware-user\s+@#flightaware-user @g' \ + -e 's@^\s*flightaware-password\s+.*$@#flightware-password [removed on upgrade]@g' <$f >$f.new + mv $f.new $f + fi + done +} + +case "$1" in + configure) + if ! getent passwd "$RUNAS" >/dev/null + then + useradd --system --home-dir /usr/share/$NAME --user-group "$RUNAS" + fi + + if [ ! -d /var/cache/piaware ] + then + mkdir -p /var/cache/piaware + chown $RUNAS:root /var/cache/piaware + chmod 0755 /var/cache/piaware + fi + + if test -n "$2" && dpkg --compare-versions "$2" lt "3.0" + then + # it's an upgrade from 2.x + # convert the old-format config files + upgrade_piaware2_config + + # put something in /tmp/piaware.out to alert the user + if [ -e /tmp/piaware.out ] + then + cat <>/tmp/piaware.out +=============================================================== + + PiAware 3 writes logging information to /var/log/piaware.log + Please see that file for future PiAware logging. + +=============================================================== +EOF + fi + fi + + if test -n "$2" && dpkg --compare-versions "$2" lt "3.5.1" + then + # it's an upgrade from pre-3.5.1 + # strip out mlat-forwarding configurations + update_mlat_config + fi + + if dpkg --compare-versions "$2" lt-nl "3.8.0" + then + # it's an upgrade from pre-3.8.0 + # strip out flightaware-user / flightaware-password + remove_user_and_password + fi + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/trixie/rsyslog/piaware.conf b/trixie/rsyslog/piaware.conf new file mode 100644 index 0000000..bb4f871 --- /dev/null +++ b/trixie/rsyslog/piaware.conf @@ -0,0 +1,2 @@ +if $programname == 'piaware' then /var/log/piaware.log +& stop diff --git a/trixie/rules b/trixie/rules new file mode 100644 index 0000000..1256522 --- /dev/null +++ b/trixie/rules @@ -0,0 +1,116 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +export DH_VERBOSE=1 + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +PYTHON3 := /usr/bin/$(shell py3versions -d) + +VENV=$(CURDIR)/debian/venv + +CHANGELOG_VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: //p') + +# ensure that setuptools doesn't try to retrieve anything off the network: +override http_proxy := http://127.0.0.1:9/ +override https_proxy := http://127.0.0.1:9/ +export http_proxy https_proxy + +# When building/installing wheels we need to ensure that the target +# platform is set to the correct platform for the Python we're running on; +# setuptools gets this wrong and looks at "uname -m" which might not match +# the running Python platform in 32-bit-userspace-on-64-bit-kernel cases +# (This is fixed in newer wheel releases but we don't have that, so..) + +ifeq (arm,$(DEB_HOST_GNU_CPU)) +PYTHON_HOST_PLATFORM=linux-armv7l +else ifeq (i686,$(DEB_HOST_GNU_CPU)) +PYTHON_HOST_PLATFORM=linux-i686 +else +PYTHON_HOST_PLATFORM=$(shell $(PYTHON3) -c "import sysconfig; print(sysconfig.get_platform())") +endif + +override_dh_auto_clean: clean_tcllauncher clean_dump1090 clean_mlat-client clean_piaware clean_dump978 + +override_dh_auto_configure: check_versions configure_tcllauncher + +override_dh_auto_build: build_tcllauncher build_dump1090 build_mlat-client build_dump978 + +override_dh_auto_install: install_tcllauncher install_dump1090 install_mlat-client install_piaware install_dump978 + +override_dh_strip: + # cxfreeze produces a launcher executable with a zipfile appended + # attempting to strip it will damage the zipfile + dh_strip -X debian/piaware/usr/lib/piaware/helpers/fa-mlat-client + +override_dh_installinit: + dh_installinit --no-stop-on-upgrade --no-restart-after-upgrade + +override_dh_systemd_enable: + dh_systemd_enable --name=piaware piaware.service + dh_systemd_enable --name=generate-pirehose-cert generate-pirehose-cert.service + +override_dh_systemd_start: + dh_systemd_start --no-stop-on-upgrade --no-restart-after-upgrade --name=piaware piaware.service + dh_systemd_start --name=generate-pirehose-cert generate-pirehose-cert.service + +check_versions: + debian/check_versions + +configure_tcllauncher: + cd tcllauncher && autoconf -f && ./configure --with-tcl=/usr/lib/tcl8.6 + +build_dump1090: + make -C dump1090 RTLSDR=no BLADERF=no DUMP1090_VERSION="piaware-$(CHANGELOG_VERSION)" faup1090 + +install_dump1090: + install -d $(CURDIR)/debian/piaware/usr/lib/piaware/helpers + install -t $(CURDIR)/debian/piaware/usr/lib/piaware/helpers dump1090/faup1090 + +build_dump978: + make -C dump978 faup978 VERSION=$(DEB_VERSION) + +install_dump978: + install -d $(CURDIR)/debian/piaware/usr/lib/piaware/helpers + install -t $(CURDIR)/debian/piaware/usr/lib/piaware/helpers dump978/faup978 + +build_mlat-client: + # setup venv for mlat-client build + $(PYTHON3) -m venv --system-site-packages --without-pip $(VENV) + # build cxfreeze for later packaging of mlat-client + $(VENV)/bin/python -m build --skip-dependency-check --no-isolation --wheel -C="--build-option=--plat-name" -C="--build-option=$(PYTHON_HOST_PLATFORM)" --outdir $(CURDIR)/wheels cx_freeze-7.2.0 + $(VENV)/bin/python -m pip install --no-index --no-deps --ignore-installed --require-virtualenv $(CURDIR)/wheels/cx_Freeze-7.2.0*.whl + # build mlat-client proper + $(VENV)/bin/python -m build --skip-dependency-check --no-isolation --wheel -C="--build-option=--plat-name" -C="--build-option=$(PYTHON_HOST_PLATFORM)" --outdir $(CURDIR)/wheels mlat-client + $(VENV)/bin/python -m pip install --no-index --no-deps --ignore-installed --require-virtualenv $(CURDIR)/wheels/MlatClient-*.whl + +install_mlat-client: + # newer cxfreeze deletes --target-dir (see cxfreeze issue #1300), so we have to freeze to a temporary directory and + # install from there + $(VENV)/bin/python $(VENV)/bin/cxfreeze --target-dir=$(CURDIR)/freeze-mlat-client $(VENV)/bin/fa-mlat-client + cp -a $(CURDIR)/freeze-mlat-client/* $(CURDIR)/debian/piaware/usr/lib/piaware/helpers/ + +clean_mlat-client: + rm -fr mlat-client/build mlat-client/dist + rm -fr cx_freeze-7.2.0/build cx_Freeze-7.2.0/dist + rm -fr $(VENV) $(CURDIR)/wheels + +install_piaware: + make -C piaware DESTDIR=$(CURDIR)/debian/piaware install INSTALL_SUDOERS=1 SYSTEMD= SYSVINIT= TCLLAUNCHER=$(CURDIR)/debian/piaware/usr/bin/tcllauncher + +configure_%: + dh_auto_configure -D $* + +build_%: + dh_auto_build -D $* + +install_%: + dh_auto_install -D $* + +clean_%: + dh_auto_clean -D $* + +%: + dh $@ --with=systemd