Skip to content

Commit

Permalink
Introduce debian bookworm support
Browse files Browse the repository at this point in the history
  • Loading branch information
WhoAmI0501 committed Jul 19, 2023
1 parent 3e5bfd8 commit c114b38
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ piaware*.build
piaware*.buildinfo
piaware*.ddeb
package-*

# PyCharm stuff
.idea/
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node(label: 'raspberrypi') {
durabilityHint(hint: 'PERFORMANCE_OPTIMIZED')
])

def dists = ["bullseye", "buster", "stretch"]
def dists = ["bookworm", "bullseye", "buster", "stretch"]
def srcdir = "${WORKSPACE}/src"

stage('Checkout') {
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ package/debian/control:
* autoconf
* python3-dev
* python3-venv
* dh-systemd
* libz-dev
* python3-pip (only on debian for versions >= bookworm)
* libz-dev (also known as `zlib1g-dev`)
* cmake (only on debian for versions >= bookworm)

If you use pdebuild it will do this for you.

Expand Down
16 changes: 16 additions & 0 deletions bookworm/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.11), python3-venv, python3-pip, zlib1g-dev, openssl, libboost-system-dev, libboost-program-options-dev, libboost-regex-dev, libboost-filesystem-dev, cmake, patchelf
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 bookworm/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 bookworm/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 bookworm/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 bookworm/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 bookworm/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
104 changes: 104 additions & 0 deletions bookworm/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/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

override_dh_auto_clean: clean_tcllauncher clean_dump1090 clean_mlat-client clean_venv clean_piaware clean_dump978

override_dh_auto_configure: check_versions configure_tcllauncher

override_dh_auto_build: build_tcllauncher build_dump1090 setup_venv build_cxfreeze 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

setup_venv:
$(PYTHON3) -m venv $(VENV)

clean_venv:
rm -fr $(VENV)

build_cxfreeze:
cd zipp-3.16.2 && $(VENV)/bin/pip install --no-index --find-links ../archives/ .
cd importlib_metadata-6.8.0 && $(VENV)/bin/pip install --no-index --find-links ../archives/ .
cd cx_Freeze-6.15.4 && $(VENV)/bin/pip install --no-index --find-links ../archives/ .

build_mlat-client:
cd mlat-client && $(VENV)/bin/pip install --no-index --find-links ../archives/ .

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:
cd mlat-client && $(PYTHON3) setup.py clean -a

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
Loading

0 comments on commit c114b38

Please sign in to comment.