Build squeezelite on the device on a 64-bit or trixie userland

The shipped squeezelite is a 32-bit ARM binary linked against libFLAC.so.12 (bookworm
on armhf). Elsewhere the role now builds upstream squeezelite at a pinned commit with
the same options as the old ARM build, installing the -dev packages instead of
soname-specific runtime libraries. `ansible_architecture` is the kernel's, so the
choice reads the userland's architecture from dpkg; override with
`pi_squeezelite_custom_build_from_source: true|false`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 23:14:18 +02:00
parent f6a169afaa
commit a6d4180b2b
4 changed files with 100 additions and 7 deletions

View File

@@ -3,3 +3,9 @@
Like `pi_squeezelite`, but uninstalls the distro package and deploys a Like `pi_squeezelite`, but uninstalls the distro package and deploys a
custom-compiled `squeezelite` build instead as a systemd service. See custom-compiled `squeezelite` build instead as a systemd service. See
`custom build/readme_build.md` for how that build is produced. `custom build/readme_build.md` for how that build is produced.
The shipped 32-bit binary only runs on an armhf userland with Debian 12 (bookworm) or
older. On a 64-bit userland or Debian 13 (trixie) the role builds the same upstream commit
on the device and installs it to `/opt/squeezelite` instead. That is picked
automatically from `dpkg --print-architecture` and the distribution version; override with
`pi_squeezelite_custom_build_from_source: true|false`.

View File

@@ -0,0 +1,34 @@
---
# The shipped files/squeezelite is a 32-bit ARM binary linked against libFLAC.so.12, which
# is what Debian bookworm on armhf provides. It cannot run on a 64-bit userland or on
# trixie (libflac14), so by default ("auto") the role uses it only on armhf + Debian <= 12
# and compiles pi_squeezelite_custom_version on the device everywhere else. Set true/false
# to force one or the other.
pi_squeezelite_custom_build_from_source: auto
pi_squeezelite_custom_repo: https://github.com/ralph-irving/squeezelite.git
# Upstream master when this was written (squeezelite 2.0, revision 1595). The commit the
# prebuilt binary came from (c89faf3 in the old build notes) does not exist upstream.
pi_squeezelite_custom_version: c7c4248ddd70e47dbfeba0bf4a8a7ec08d8a995c
# Runtime libraries the prebuilt binary links (bookworm package names).
pi_squeezelite_custom_runtime_packages:
- libmad0
- libmpg123-0
- libflac12
- libvorbisfile3
- libfaad2
# Headers (and, through them, the runtime libraries) for building. Installing the -dev
# packages is what makes this independent of soname bumps between Debian releases.
pi_squeezelite_custom_build_packages:
- build-essential
- git
- libasound2-dev
- libssl-dev
- libsoxr-dev
- libflac-dev
- libvorbis-dev
- libmad0-dev
- libfaad-dev
- libmpg123-dev

View File

@@ -0,0 +1,41 @@
---
- name: Check out squeezelite
ansible.builtin.git:
repo: "{{ pi_squeezelite_custom_repo }}"
dest: /opt/squeezelite-src
version: "{{ pi_squeezelite_custom_version }}"
force: true
register: pi_squeezelite_custom_checkout
- name: Check whether a built binary already exists
ansible.builtin.stat:
path: /opt/squeezelite
register: pi_squeezelite_custom_binary
- name: Write the makefile (upstream Makefile plus this build's options)
# Same options as the ARM build in "custom build/readme_build.md", minus the ARMv6
# -march/-mfpu/-mfloat-abi flags that make no sense for aarch64. No RPI (GPIO switching)
# option. -lasound is added explicitly, as before.
ansible.builtin.copy:
dest: /opt/squeezelite-src/mymakefile
mode: "0644"
content: |
OPTS = -DLINUX -DRESAMPLE -DDSD -DUSE_SSL -DLINKALL -I./include -I./include/opus -I./include/alac -I/usr/local/include
LDFLAGS = -L./lib -L/usr/local/lib -s -lasound
include Makefile
- name: Build squeezelite
ansible.builtin.shell:
cmd: make -f mymakefile clean && make -f mymakefile
chdir: /opt/squeezelite-src
when: pi_squeezelite_custom_checkout.changed or not pi_squeezelite_custom_binary.stat.exists
changed_when: true
- name: Install built squeezelite
ansible.builtin.copy:
src: /opt/squeezelite-src/squeezelite
dest: /opt/squeezelite
mode: "700"
remote_src: true
notify: Restart squeezelite

View File

@@ -3,15 +3,23 @@
ansible.builtin.apt: ansible.builtin.apt:
name: squeezelite name: squeezelite
state: absent state: absent
- name: Get the userland architecture
# `ansible_architecture` is the *kernel's*: a Pi on a 64-bit kernel with an armhf
# userland says aarch64. What decides whether a 32-bit binary runs is dpkg's.
ansible.builtin.command: dpkg --print-architecture
register: pi_squeezelite_custom_dpkg_arch
changed_when: false
check_mode: false # read-only
- name: Decide between the prebuilt binary and a build on the device
ansible.builtin.set_fact:
pi_squeezelite_custom_build: >-
{{ (pi_squeezelite_custom_build_from_source | string | lower == 'true')
or (pi_squeezelite_custom_build_from_source | string | lower == 'auto'
and (pi_squeezelite_custom_dpkg_arch.stdout | trim != 'armhf'
or ansible_facts.distribution_major_version | int >= 13)) }}
- name: Install dependencies - name: Install dependencies
ansible.builtin.apt: ansible.builtin.apt:
name: name: "{{ pi_squeezelite_custom_build_packages if pi_squeezelite_custom_build else pi_squeezelite_custom_runtime_packages }}"
- libmad0
- libmpg123-0
- libflac12
- libvorbisfile3
- libfaad2
# for building libssl-dev, libasound2-dev, libflac-dev, libvorbis-dev, libsoxr-dev, libfaad-dev, libmad0-dev, libmpg123-dev
state: present state: present
cache_valid_time: 7200 cache_valid_time: 7200
- name: Remove old config file if present - name: Remove old config file if present
@@ -24,6 +32,10 @@
dest: /opt/squeezelite dest: /opt/squeezelite
mode: "700" mode: "700"
notify: Restart squeezelite notify: Restart squeezelite
when: not pi_squeezelite_custom_build
- name: Build squeezelite from source (needed on a 64-bit userland, see README)
ansible.builtin.include_tasks: build.yml
when: pi_squeezelite_custom_build
- name: Install systemd service file - name: Install systemd service file
ansible.builtin.template: ansible.builtin.template:
src: squeezelite.service src: squeezelite.service