From a6d4180b2bd3275c6da0cc24fabb5a79614b5fce Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Fri, 2 Oct 2026 23:14:18 +0200 Subject: [PATCH] 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 --- roles/pi_squeezelite_custom/README.md | 6 +++ roles/pi_squeezelite_custom/defaults/main.yml | 34 +++++++++++++++ roles/pi_squeezelite_custom/tasks/build.yml | 41 +++++++++++++++++++ roles/pi_squeezelite_custom/tasks/main.yml | 26 ++++++++---- 4 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 roles/pi_squeezelite_custom/defaults/main.yml create mode 100644 roles/pi_squeezelite_custom/tasks/build.yml diff --git a/roles/pi_squeezelite_custom/README.md b/roles/pi_squeezelite_custom/README.md index 5595687..45add73 100644 --- a/roles/pi_squeezelite_custom/README.md +++ b/roles/pi_squeezelite_custom/README.md @@ -3,3 +3,9 @@ Like `pi_squeezelite`, but uninstalls the distro package and deploys a custom-compiled `squeezelite` build instead as a systemd service. See `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`. diff --git a/roles/pi_squeezelite_custom/defaults/main.yml b/roles/pi_squeezelite_custom/defaults/main.yml new file mode 100644 index 0000000..d26d494 --- /dev/null +++ b/roles/pi_squeezelite_custom/defaults/main.yml @@ -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 diff --git a/roles/pi_squeezelite_custom/tasks/build.yml b/roles/pi_squeezelite_custom/tasks/build.yml new file mode 100644 index 0000000..305dcc6 --- /dev/null +++ b/roles/pi_squeezelite_custom/tasks/build.yml @@ -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 diff --git a/roles/pi_squeezelite_custom/tasks/main.yml b/roles/pi_squeezelite_custom/tasks/main.yml index 843327b..884e593 100644 --- a/roles/pi_squeezelite_custom/tasks/main.yml +++ b/roles/pi_squeezelite_custom/tasks/main.yml @@ -3,15 +3,23 @@ ansible.builtin.apt: name: squeezelite 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 ansible.builtin.apt: - name: - - libmad0 - - libmpg123-0 - - libflac12 - - libvorbisfile3 - - libfaad2 - # for building libssl-dev, libasound2-dev, libflac-dev, libvorbis-dev, libsoxr-dev, libfaad-dev, libmad0-dev, libmpg123-dev + name: "{{ pi_squeezelite_custom_build_packages if pi_squeezelite_custom_build else pi_squeezelite_custom_runtime_packages }}" state: present cache_valid_time: 7200 - name: Remove old config file if present @@ -24,6 +32,10 @@ dest: /opt/squeezelite mode: "700" 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 ansible.builtin.template: src: squeezelite.service