Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian Trixie and Ubuntu Noble Numbat compatibility. #26

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 18 additions & 1 deletion sensible-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ shallow_clone() {
}

usage() {
echo "syntax: $0 <buster|bullseye|bookworm>" >&2
echo "syntax: $0 <buster|bullseye|bookworm|trixie>" >&2
exit 1
}

Expand Down Expand Up @@ -53,6 +53,11 @@ case $dist in
targetdist=bookworm
extraversion=""
;;
trixie)
debdist=trixie
targetdist=trixie
extraversion=""
;;
xenial)
# not tested
debdist=stretch
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions trixie/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: piaware
Section: embedded
Priority: extra
Maintainer: FlightAware Developers <[email protected]>
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.
1 change: 1 addition & 0 deletions trixie/piaware.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
piaware/MLAT-RESULTS-LICENSE.md
3 changes: 3 additions & 0 deletions trixie/piaware.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
debian/rsyslog/piaware.conf etc/rsyslog.d/
debian/upgrade-config.tcl usr/share/piaware/
debian/piaware.conf etc/
9 changes: 9 additions & 0 deletions trixie/piaware.logrotate
Original file line number Diff line number Diff line change
@@ -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
}
155 changes: 155 additions & 0 deletions trixie/piaware.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/bin/sh
# postinst script for piaware
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# 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 <<EOF || true
# This file was created automatically during an upgrade from PiAware $2
# Additional piaware configuration settings may be added below.

EOF
fi

if [ -f /root/.piaware -o -f /etc/piaware ]
then
# upgrade legacy config files
/usr/share/piaware/upgrade-config.tcl || echo >&2 <<EOF
Automatic config file upgrade failed. You may need to manually reconfigure
piaware using piaware-config or by editing /etc/piaware.conf or
/boot/piaware-config.txt. Your old config files are preserved as
/root/.piaware.old and /etc/piaware.old
EOF

[ -f /root/.piaware ] && mv /root/.piaware /root/.piaware.old
[ -f /etc/piaware ] && mv /etc/piaware /etc/piaware.old
fi
}

update_mlat_config() {
old_mlat_config=$(piaware-config -show mlat-results-format)
new_mlat_config=""

for part in $old_mlat_config
do
case "$part" in
*adsbexchange*|*167.114.60.74*)
# drop this
echo "Removed '$part' from mlat results config" >&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 <<EOF >>/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
2 changes: 2 additions & 0 deletions trixie/rsyslog/piaware.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if $programname == 'piaware' then /var/log/piaware.log
& stop
116 changes: 116 additions & 0 deletions trixie/rules
Original file line number Diff line number Diff line change
@@ -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