Fix auto-stop issue and add polkit rule (pkgrel=2)

- Add systemd drop-in override to fix StopWhenUnneeded auto-stop issue
- Add polkit rule for passwordless fcp-server management by audio group
- Improve post_install messages with troubleshooting guidance
- Add polkit to optdepends

This fixes the reliability issue where fcp-server would stop immediately
after being started by udev, preventing alsa-scarlett-gui from connecting.

Changes follow best practices:
- Drop-in override (non-invasive, survives upstream updates)
- Polkit rule follows PulseAudio/PipeWire precedent for audio group
- Comprehensive security review completed (see SECURITY_REVIEW.md)
This commit is contained in:
Sebastian Paul 2025-10-22 16:41:27 +02:00
parent f6628b601a
commit e44a239e2b
3 changed files with 51 additions and 2 deletions

View file

@ -1,7 +1,7 @@
pkgbase = fcp-support-git
pkgdesc = Focusrite Control Protocol user-space driver for Scarlett 4th Gen big models (16i16, 18i16, 18i20)
pkgver = r21.edae476
pkgrel = 1
pkgrel = 2
url = https://github.com/geoffreybennett/fcp-support
install = fcp-support-git.install
arch = x86_64
@ -19,6 +19,7 @@ pkgbase = fcp-support-git
depends = libcap
optdepends = alsa-scarlett-gui-git: GUI for controlling Focusrite interfaces
optdepends = scarlett4-firmware: Firmware files for Scarlett 4th Gen (required for first-time setup)
optdepends = polkit: Passwordless start/stop of fcp-server for audio group users (recommended)
provides = fcp-support
conflicts = fcp-support
source = git+https://github.com/geoffreybennett/fcp-support.git

View file

@ -3,7 +3,7 @@
pkgname=fcp-support-git
_pkgname=fcp-support
pkgver=r21.edae476
pkgrel=1
pkgrel=2
pkgdesc="Focusrite Control Protocol user-space driver for Scarlett 4th Gen big models (16i16, 18i16, 18i20)"
arch=('x86_64' 'i686')
url="https://github.com/geoffreybennett/fcp-support"
@ -25,6 +25,7 @@ makedepends=(
optdepends=(
'alsa-scarlett-gui-git: GUI for controlling Focusrite interfaces'
'scarlett4-firmware: Firmware files for Scarlett 4th Gen (required for first-time setup)'
'polkit: Passwordless start/stop of fcp-server for audio group users (recommended)'
)
provides=("$_pkgname")
conflicts=("$_pkgname")
@ -54,4 +55,40 @@ package() {
make install \
PREFIX=/usr \
DESTDIR="$pkgdir"
# Install systemd drop-in to fix StopWhenUnneeded issue
# The upstream service has StopWhenUnneeded=yes which causes systemd to stop
# the service immediately after udev starts it, breaking reliability
install -Dm644 /dev/stdin \
"$pkgdir/usr/lib/systemd/system/fcp-server@.service.d/arch.conf" <<'EOF'
# Arch Linux package override for fcp-server auto-stop issue
# See: https://github.com/geoffreybennett/fcp-support/issues
#
# The upstream service has StopWhenUnneeded=yes which conflicts with udev-based
# activation. This override keeps the service running while the device is connected.
[Unit]
# Keep service running while device is connected
StopWhenUnneeded=no
[Service]
# Always restart on crash
Restart=always
RestartSec=3
EOF
# Install polkit rule to allow audio group to manage fcp-server without password
# This enables alsa-scarlett-gui to auto-start the server seamlessly
install -Dm644 /dev/stdin \
"$pkgdir/usr/share/polkit-1/rules.d/50-fcp-server.rules" <<'EOF'
// Allow audio group members to start/stop fcp-server without authentication
// This enables seamless integration with alsa-scarlett-gui
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit").match(/^fcp-server@[0-9]+\.service$/) &&
subject.isInGroup("audio")) {
return polkit.Result.YES;
}
});
EOF
}

View file

@ -26,6 +26,11 @@ post_install() {
echo " sudo usermod -a -G audio \$USER"
echo " (then log out and back in)"
echo ""
echo "==> Package improvements in this version:"
echo " - Fixed auto-stop issue (service now stays running reliably)"
echo " - Added polkit rule (audio group can manage fcp-server without password)"
echo " - Better integration with alsa-scarlett-gui"
echo ""
echo "==> Install 'alsa-scarlett-gui-git' for a graphical interface:"
echo " yay -S alsa-scarlett-gui-git"
echo ""
@ -33,6 +38,12 @@ post_install() {
echo " Install scarlett4-firmware package and run:"
echo " fcp-tool --update-firmware"
echo ""
echo "==> Troubleshooting:"
echo " If service doesn't auto-start, manually start it:"
echo " systemctl start fcp-server@<card-number>"
echo " (find card number with: aplay -l)"
echo " View logs: journalctl -u 'fcp-server@*' -f"
echo ""
}
post_upgrade() {