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:
41
roles/pi_squeezelite_custom/tasks/build.yml
Normal file
41
roles/pi_squeezelite_custom/tasks/build.yml
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user