Skip to content

Commit

Permalink
Attempt to fix wpasupplicant and hostapd package builds (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshschmelzle authored Jan 31, 2025
1 parent 89f136b commit 64aabcb
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 45 deletions.
43 changes: 43 additions & 0 deletions debians/hostapd/hostapd.README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
hostapd for Debian
------------------

This package provides two methods for managing hostapd process(es); an
initscript and an ifupdown hook. Both methods require creation of a
hostapd daemon configuration file (/etc/hostapd/hostapd.conf) to
function correctly.

An example hostapd.conf may be used as a template but _must_ be edited
to suit your local configuration. An example is located at:
/usr/share/doc/hostapd/examples/hostapd.conf.gz

To use the example as a template:
# zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz > \
/etc/hostapd/hostapd.conf
# $EDITOR /etc/hostapd/hostapd.conf

If you're running systemd, you need to unmask the hostapd unit by running:

systemctl unmask hostapd

If you want to run multiple instances of hostapd with different
configurations, consider using a service template [email protected]
shipped with the package. E.g. for a hostapd configuration file named
/etc/hostapd/wifi.conf, the service name will be [email protected].

The previously supported configuration setting DAEMON_CONF in
/etc/default/hostapd is deprecated and its support will be removed.

To use the ifupdown method, the path to hostapd configuration file can
be specified in a network interfaces configuration stanza in
/etc/network/interfaces like so:

iface eth1 inet static
hostapd /etc/hostapd/hostapd.conf
...

The hostapd process will be started in the pre-up phase of ifup, and be
terminated in the post-down phase of ifdown.

Please note:
* If you want to use hostapd with a Prism2/2.5/3 card in WPA mode, you'll need
STA firmware version >= 1.7.0.
80 changes: 80 additions & 0 deletions debians/hostapd/hostapd.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh

### BEGIN INIT INFO
# Provides: hostapd
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $network
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Access point and authentication server for Wi-Fi and Ethernet
# Description: Access point and authentication server for Wi-Fi and Ethernet
# Userspace IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_SBIN=/usr/sbin/hostapd
DAEMON_DEFS=/etc/default/hostapd
DAEMON_CONF=/etc/hostapd/hostapd.conf
NAME=hostapd
DESC="advanced IEEE 802.11 management"
PIDFILE=/run/hostapd.pid

[ -x "$DAEMON_SBIN" ] || exit 0
[ -s "$DAEMON_DEFS" ] && . /etc/default/hostapd
[ -n "$DAEMON_CONF" ] || exit 0

DAEMON_OPTS="-B -P $PIDFILE $DAEMON_OPTS $DAEMON_CONF"

. /lib/lsb/init-functions

for conf in $DAEMON_CONF
do
if [ ! -r "$conf" ]
then
log_action_msg "hostapd config $conf not found, not starting hostapd."
exit 0
fi
done

case "$1" in
start)
if [ "$DAEMON_CONF" != /etc/hostapd/hostapd.conf ]
then
log_warning_msg "hostapd config not in /etc/hostapd/hostapd.conf -- please read /usr/share/doc/hostapd/NEWS.Debian.gz"
fi
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
log_end_msg "$?"
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --oknodo --quiet --exec "$DAEMON_SBIN" \
--pidfile "$PIDFILE"
log_end_msg "$?"
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
start-stop-daemon --stop --signal HUP --exec "$DAEMON_SBIN" \
--pidfile "$PIDFILE"
log_end_msg "$?"
;;
restart|force-reload)
$0 stop
sleep 8
$0 start
;;
status)
status_of_proc "$DAEMON_SBIN" "$NAME"
exit $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|reload|status}" >&2
exit 1
;;
esac

exit 0
9 changes: 9 additions & 0 deletions debians/hostapd/hostapd.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# We distribute the package under the terms of the BSD license due to the
# openssl issue, tell lintian to not complain:
hostapd binary: possible-gpl-code-linked-with-openssl

# no need for per-interface init scripts since hostapd has ifupdown integration
hostapd: package-supports-alternative-init-but-no-init.d-script lib/systemd/system/[email protected]

# we want to call systemctl and not anything else to mask a unit
hostapd: maintainer-script-calls-systemctl
16 changes: 16 additions & 0 deletions debians/hostapd/hostapd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Access point and authentication server for Wi-Fi and Ethernet
Documentation=man:hostapd(8)
After=network.target

[Service]
Type=forking
PIDFile=/run/hostapd.pid
Restart=on-failure
RestartSec=2
Environment=DAEMON_CONF=/etc/hostapd/hostapd.conf
EnvironmentFile=-/etc/default/hostapd
ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid $DAEMON_OPTS ${DAEMON_CONF}

[Install]
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions debians/hostapd/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Access point and authentication server for Wi-Fi and Ethernet (%I)
Documentation=man:hostapd(8)
After=network.target
BindsTo=sys-subsystem-net-devices-%i.device

[Service]
Type=forking
PIDFile=/run/hostapd.%i.pid
Restart=on-failure
RestartSec=2
EnvironmentFile=-/etc/default/hostapd
ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.%i.pid $DAEMON_OPTS /etc/hostapd/%i.conf

[Install]
WantedBy=multi-user.target sys-subsystem-net-devices-%i.device
74 changes: 69 additions & 5 deletions debians/hostapd/rules
Original file line number Diff line number Diff line change
@@ -1,12 +1,76 @@
#!/usr/bin/make -f

export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1

%:
dh $@ --with=autoreconf
# Pass hardening flags
DEB_CFLAGS_MAINT_APPEND = -MMD -Wall $(shell dpkg-buildflags --get CPPFLAGS)
DEB_CXXFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS)

include /usr/share/dpkg/default.mk

BINDIR = /sbin
V = 1

PKG_CONFIG ?= $(DEB_HOST_GNU_TYPE)-pkg-config
export BINDIR V PKG_CONFIG

HOSTAPD_DOT_CONFIG := debian/config/hostapd/$(DEB_HOST_ARCH_OS)

override_dh_auto_configure:
cd hostapd && $(MAKE)
# Configure hostapd using defconfig
cd hostapd && cp defconfig .config

override_dh_auto_build:
# Build hostapd
dh_auto_build --sourcedirectory=hostapd \
--buildsystem=makefile
dh_auto_clean --sourcedirectory=src --buildsystem=makefile

override_dh_auto_clean:
dh_auto_clean --sourcedirectory=hostapd \
--buildsystem=makefile

override_dh_auto_install:
cd hostapd && $(MAKE) install DESTDIR=$(CURDIR)/debian/hostapd
$(info Skip dh_auto_install ...)

execute_after_dh_install:
install -D hostapd/hostapd debian/hostapd/usr/sbin/hostapd
install -D hostapd/hostapd_cli debian/hostapd/usr/sbin/hostapd_cli

install --mode=755 -D debian/hostapd.init debian/hostapd/etc/init.d/hostapd

install --mode=644 -D debian/hostapd.service \
debian/hostapd/lib/systemd/system/hostapd.service
install --mode=644 -D debian/[email protected] \
debian/hostapd/lib/systemd/system/[email protected]

install --mode=644 -D README debian/hostapd/usr/share/doc/hostapd/README.gz
install --mode=644 -D debian/hostapd.README.Debian debian/hostapd/usr/share/doc/hostapd/README.Debian

install -d debian/hostapd/usr/share/doc/hostapd/examples
install --mode=644 hostapd/hostapd.conf \
debian/hostapd/usr/share/doc/hostapd/examples/
install --mode=644 hostapd/hostapd.accept \
debian/hostapd/usr/share/doc/hostapd/examples/
install --mode=644 hostapd/hostapd.deny \
debian/hostapd/usr/share/doc/hostapd/examples/
install --mode=644 hostapd/hostapd.eap_user \
debian/hostapd/usr/share/doc/hostapd/examples/
install --mode=644 hostapd/hostapd.radius_clients \
debian/hostapd/usr/share/doc/hostapd/examples/
install --mode=644 hostapd/hostapd.wpa_psk \
debian/hostapd/usr/share/doc/hostapd/examples/

install -d debian/hostapd/usr/share/lintian/overrides
install --mode=644 debian/hostapd.lintian-overrides \
debian/hostapd/usr/share/lintian/overrides/hostapd


override_dh_installchangelogs:
dh_installchangelogs --package=hostapd hostapd/ChangeLog
dh_installchangelogs --remaining-packages

%:
dh $@

36 changes: 0 additions & 36 deletions debians/wpasupplicant/changelog
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
wpasupplicant (2.11-6wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-6wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 02:21:04 +0000

wpasupplicant (2.11-5wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-5wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 01:17:56 +0000

wpasupplicant (2.11-4wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-4wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 01:09:28 +0000

wpasupplicant (2.11-3wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-3wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 01:07:29 +0000

wpasupplicant (2.11-2wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-2wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 00:59:22 +0000

wpasupplicant (2.11-1wlanpi1) bullseye; urgency=medium

* wpasupplicant version 2.11-1wlanpi1

-- Daniel Finimundi <[email protected]> Mon, 27 Jan 2025 00:57:18 +0000

wpasupplicant (2.11-0wlanpi0) unstable; urgency=medium

* Initial WLAN Pi package for wpa_supplicant
Expand Down
31 changes: 28 additions & 3 deletions debians/wpasupplicant/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@

export DH_VERBOSE = 1

%:
dh $@ --with=autoreconf
BINDIR = /sbin

override_dh_auto_configure:
cd wpa_supplicant && $(MAKE)


override_dh_auto_install:
cd wpa_supplicant && $(MAKE) install DESTDIR=$(CURDIR)/debian/wpasupplicant
$(info Skip dh_auto_install ...)

# override_dh_auto_install:
# cd wpa_supplicant && \
# $(MAKE) install DESTDIR=$(CURDIR)/debian/wpasupplicant BINDIR=/usr/bin SBINDIR=/sbin

execute_after_dh_install:
install -D wpa_supplicant/wpa_supplicant debian/wpasupplicant/sbin/wpa_supplicant
install -D wpa_supplicant/wpa_cli debian/wpasupplicant/sbin/wpa_cli
install -D wpa_supplicant/wpa_passphrase debian/wpasupplicant/usr/bin/wpa_passphrase

install --mode=644 -D wpa_supplicant/dbus/dbus-wpa_supplicant.conf \
debian/wpasupplicant/etc/dbus-1/system.d/wpa_supplicant.conf
install --mode=644 -D wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service \
debian/wpasupplicant/usr/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service

execute_before_dh_clean:
rm -rf debian/wpasupplicant-udeb

override_dh_installchangelogs:
dh_installchangelogs --package=wpasupplicant wpa_supplicant/ChangeLog
dh_installchangelogs --remaining-packages

%:
dh $@

4 changes: 3 additions & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ build_packages()
fi
package_version="${package_version}-${deb_version}wlanpi1"

if [ -n "$GITHUB_OUTPUT" ]; then
if [[ -n "${GITHUB_OUTPUT}" ]] && [[ -w "${GITHUB_OUTPUT}" ]]; then
echo "package-version=${package_version}" >> $GITHUB_OUTPUT
else
echo "GITHUB_OUTPUT is not set or not writable"
fi

log "Using version ${package_version} for ${package_name}"
Expand Down

0 comments on commit 64aabcb

Please sign in to comment.