forked from MichaIng/DietPi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Squeezelite | Updated to latest version 1.9.9-1403, fixed install on Debian Bookworm and added support for the Opus audio codec format. Also the default command-line arguments have been enhanced to not enforce the audio format anymore, and they can now be easily adjusted via /etc/default/squeezelite. Many thanks to @scan80269 and @aposcic for doing this suggestions: MichaIng#4428, MichaIng#5791
- Loading branch information
Showing
6 changed files
with
300 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/bin/bash | ||
{ | ||
. /boot/dietpi/func/dietpi-globals | ||
|
||
# Build deps | ||
G_AG_CHECK_INSTALL_PREREQ make gcc libc6-dev libasound2-dev libflac-dev libmad0-dev libvorbis-dev libmpg123-dev libavformat-dev libsoxr-dev liblirc-dev libfaad-dev libssl-dev libopus-dev | ||
|
||
G_DIETPI-NOTIFY 2 'Downloading source code...' | ||
G_EXEC cd /tmp | ||
G_EXEC curl -sSfLO 'https://github.com/ralph-irving/squeezelite/archive/master.tar.gz' | ||
G_EXEC rm -Rf squeezelite-master | ||
G_EXEC tar xf master.tar.gz | ||
G_EXEC rm master.tar.gz | ||
G_DIETPI-NOTIFY 2 'Compiling binary...' | ||
G_EXEC cd squeezelite-master | ||
G_EXEC_OUTPUT=1 G_EXEC make CFLAGS='-g0 -O3' OPTS='-DDSD -DFFMPEG -DRESAMPLE -DVISEXPORT -DLINKALL -DIR -DUSE_SSL' | ||
G_EXEC strip --remove-section=.comment --remove-section=.note squeezelite | ||
|
||
G_DIETPI-NOTIFY 2 'Starting packaging...' | ||
|
||
# Dependencies based on distro version | ||
adeps=('libc6' 'libasound2' 'libflac8' 'libmad0' 'libvorbisfile3' 'libmpg123-0' 'libsoxr0' 'liblirc-client0' 'libfaad2' 'libopus0') | ||
case $G_DISTRO in | ||
[56]) adeps+=('libavformat58' 'libssl1.1');; | ||
7) adeps+=('libavformat59' 'libssl3');; | ||
*) G_DIETPI-NOTIFY 1 "Unsupported distro version: $G_DISTRO_NAME (ID=$G_DISTRO)"; exit 1;; | ||
esac | ||
|
||
# - Obtain DEB dependency versions | ||
DEPS_APT_VERSIONED= | ||
for i in "${adeps[@]}" | ||
do | ||
DEPS_APT_VERSIONED+=" $i (>= $(dpkg-query -Wf '${VERSION}' "$i"))," | ||
done | ||
DEPS_APT_VERSIONED=${DEPS_APT_VERSIONED%,} | ||
# shellcheck disable=SC2001 | ||
grep -q 'raspbian' /etc/os-release && DEPS_APT_VERSIONED=$(sed 's/+rp[it][0-9]\+)/)/g' <<< "$DEPS_APT_VERSIONED") || DEPS_APT_VERSIONED=$(sed 's/+b[0-9]\+)/)/g' <<< "$DEPS_APT_VERSIONED") | ||
|
||
# Package dir | ||
G_EXEC cd /tmp | ||
grep -q 'raspbian' /etc/os-release && DIR='squeezelite_armv6l' || DIR="squeezelite_$G_HW_ARCH_NAME" | ||
G_EXEC rm -Rf "$DIR" | ||
G_EXEC mkdir -p "$DIR/"{DEBIAN,lib/systemd/system,etc/default,usr/{bin,share/doc/squeezelite,share/man/man1}} | ||
# - Binary | ||
G_EXEC cp squeezelite-master/squeezelite "$DIR/usr/bin/" | ||
# - man page | ||
# shellcheck disable=SC2016 | ||
G_EXEC eval 'gzip -c squeezelite-master/doc/squeezelite.1 > $DIR/usr/share/man/man1/squeezelite.1.gz' | ||
# - Copyright | ||
G_EXEC cp squeezelite-master/LICENSE.txt "$DIR/usr/share/doc/squeezelite/copyright" | ||
# - Environment file | ||
cat << '_EOF_' > "$DIR/etc/default/squeezelite" | ||
# Squeezelite command-line arguments: https://ralph-irving.github.io/squeezelite.html | ||
ARGS='-W -C 5 -n DietPi-Squeezelite' | ||
_EOF_ | ||
# - systemd service | ||
cat << '_EOF_' > "$DIR/lib/systemd/system/squeezelite.service" | ||
[Unit] | ||
Description=Squeezelite (DietPi) | ||
Documentation=man:squeezelite(1) https://ralph-irving.github.io/squeezelite.html | ||
After=sound.target | ||
[Service] | ||
User=squeezelite | ||
EnvironmentFile=/etc/default/squeezelite | ||
ExecStart=/usr/bin/squeezelite $ARGS | ||
[Install] | ||
WantedBy=multi-user.target | ||
_EOF_ | ||
# - postinst | ||
cat << '_EOF_' > "$DIR/DEBIAN/postinst" | ||
#!/bin/sh | ||
if [ -d '/run/systemd/system' ] | ||
then | ||
if getent passwd squeezelite > /dev/null | ||
then | ||
echo 'Configuring Squeezelite service user ...' | ||
usermod -aG audio -d /run/squeezelite -s /usr/sbin/nologin squeezelite | ||
else | ||
echo 'Creating Squeezelite service user ...' | ||
useradd -rMU -G audio -d /run/squeezelite -s /usr/sbin/nologin squeezelite | ||
fi | ||
echo 'Configuring Squeezelite systemd service ...' | ||
systemctl unmask squeezelite | ||
systemctl enable --now squeezelite | ||
fi | ||
_EOF_ | ||
# - prerm | ||
cat << '_EOF_' > "$DIR/DEBIAN/prerm" | ||
#!/bin/sh | ||
if [ "$1" = 'remove' ] && [ -d '/run/systemd/system' ] && [ -f '/lib/systemd/system/squeezelite.service' ] | ||
then | ||
echo 'Deconfiguring Squeezelite systemd service ...' | ||
systemctl unmask squeezelite | ||
systemctl disable --now squeezelite | ||
fi | ||
_EOF_ | ||
# - postrm | ||
cat << '_EOF_' > "$DIR/DEBIAN/postrm" | ||
#!/bin/sh | ||
if [ "$1" = 'purge' ] | ||
then | ||
if [ -d '/etc/systemd/system/squeezelite.service.d' ] | ||
then | ||
echo 'Removing Squeezelite systemd service overrides ...' | ||
rm -Rv /etc/systemd/system/squeezelite.service.d | ||
fi | ||
if getent passwd squeezelite > /dev/null | ||
then | ||
echo 'Removing Squeezelite service user ...' | ||
userdel squeezelite | ||
fi | ||
if getent group squeezelite > /dev/null | ||
then | ||
echo 'Removing Squeezelite service group ...' | ||
groupdel squeezelite | ||
fi | ||
fi | ||
_EOF_ | ||
G_EXEC chmod +x "$DIR/DEBIAN/"{postinst,prerm,postrm} | ||
# - control | ||
cat << _EOF_ > "$DIR/DEBIAN/control" | ||
Package: squeezelite | ||
Version: $(mawk -F\" '/MAJOR_VERSION/{print $2;exit}' squeezelite-master/squeezelite.h).$(mawk -F\" '/MINOR_VERSION/{print $2;exit}' squeezelite-master/squeezelite.h)-$(mawk -F\" '/MICRO_VERSION/{print $2;exit}' squeezelite-master/squeezelite.h)-dietpi1 | ||
Architecture: $(dpkg --print-architecture) | ||
Maintainer: MichaIng <[email protected]> | ||
Date: $(date '+%a, %d %b %Y %T %z') | ||
Standards-Version: 4.6.1.0 | ||
Installed-Size: $(du -sk "$DIR" | mawk '{print $1}') | ||
Depends:$DEPS_APT_VERSIONED | ||
Conflicts: squeezelite-pa, squeezelite-pulseaudio | ||
Section: sound | ||
Priority: optional | ||
Homepage: https://github.com/ralph-irving/squeezelite | ||
Vcs-Git: https://github.com/ralph-irving/squeezelite.git | ||
Vcs-Browser: https://github.com/ralph-irving/squeezelite | ||
Description: lightweight headless Squeezebox emulator - ALSA version | ||
Squeezelite is a small headless Squeezebox emulator. It is aimed at | ||
supporting high quality audio including USB DAC based output at multiple | ||
sample rates. | ||
. | ||
It supports decoding PCM (WAV/AIFF), FLAC, MP3, Ogg, AAC, WMA and ALAC | ||
audio formats. It can also resample audio, which allows squeezelite to | ||
upsample the output to the highest sample rate supported by the output | ||
device. | ||
. | ||
This package is built with the resampling, ffmpeg and SSL options. | ||
It uses ALSA for audio output. | ||
_EOF_ | ||
G_CONFIG_INJECT 'Installed-Size: ' "Installed-Size: $(du -sk "$DIR" | mawk '{print $1}')" "$DIR/DEBIAN/control" | ||
# - Build | ||
G_EXEC rm -Rf "$DIR.deb" | ||
G_EXEC_OUTPUT=1 G_EXEC dpkg-deb -b "$DIR" | ||
G_EXEC rm -Rf "$DIR" | ||
|
||
exit 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/bin/bash | ||
# Created by MichaIng / [email protected] / dietpi.com | ||
{ | ||
########################################## | ||
# Load DietPi-Globals | ||
########################################## | ||
if [[ -f '/boot/dietpi/func/dietpi-globals' ]] | ||
then | ||
. /boot/dietpi/func/dietpi-globals | ||
else | ||
curl -sSf "https://raw.githubusercontent.com/${G_GITOWNER:=MichaIng}/DietPi/${G_GITBRANCH:=master}/dietpi/func/dietpi-globals" -o /tmp/dietpi-globals || exit 1 | ||
# shellcheck disable=SC1091 | ||
. /tmp/dietpi-globals | ||
G_EXEC_NOHALT=1 G_EXEC rm /tmp/dietpi-globals | ||
export G_GITOWNER G_GITBRANCH G_HW_ARCH_NAME=$(uname -m) | ||
fi | ||
case $G_HW_ARCH_NAME in | ||
'armv6l') export G_HW_ARCH=1;; | ||
'armv7l') export G_HW_ARCH=2;; | ||
'aarch64') export G_HW_ARCH=3;; | ||
'x86_64') export G_HW_ARCH=10;; | ||
*) G_DIETPI-NOTIFY 1 "Unsupported host system architecture \"$G_HW_ARCH_NAME\" detected, aborting..."; exit 1;; | ||
esac | ||
readonly G_PROGRAM_NAME='DietPi-squeezelite_container_setup' | ||
G_CHECK_ROOT_USER | ||
G_CHECK_ROOTFS_RW | ||
readonly FP_ORIGIN=$PWD # Store origin dir | ||
G_INIT | ||
G_EXEC cd "$FP_ORIGIN" # Process everything in origin dir instead of /tmp/$G_PROGRAM_NAME | ||
|
||
########################################## | ||
# Process inputs | ||
########################################## | ||
DISTRO= | ||
ARCH= | ||
while (( $# )) | ||
do | ||
case $1 in | ||
'-d') shift; DISTRO=$1;; | ||
'-a') shift; ARCH=$1;; | ||
*) G_DIETPI-NOTIFY 1 "Invalid input \"$1\", aborting..."; exit 1;; | ||
esac | ||
shift | ||
done | ||
distro= | ||
case $DISTRO in | ||
5) distro='buster';; | ||
6) distro='bullseye';; | ||
7) distro='bookworm';; | ||
*) G_DIETPI-NOTIFY 1 "Invalid distro \"$DISTRO\" passed, aborting..."; exit 1;; | ||
esac | ||
image= | ||
arch= | ||
case $ARCH in | ||
1) image="DietPi_Container-ARMv6-${distro^}" arch='armv6l';; | ||
2) image="DietPi_Container-ARMv7-${distro^}" arch='armv7l';; | ||
3) image="DietPi_Container-ARMv8-${distro^}" arch='aarch64';; | ||
10) image="DietPi_Container-x86_64-${distro^}" arch='x86_64';; | ||
*) G_DIETPI-NOTIFY 1 "Invalid architecture \"$ARCH\" passed, aborting..."; exit 1;; | ||
esac | ||
|
||
########################################## | ||
# Dependencies | ||
########################################## | ||
apackages=('7zip' 'parted' 'fdisk' 'systemd-container') | ||
(( $G_HW_ARCH == $ARCH || ( $G_HW_ARCH < 10 && $G_HW_ARCH > $ARCH ) )) || apackages+=('qemu-user-static' 'binfmt-support') | ||
G_AG_CHECK_INSTALL_PREREQ "${apackages[@]}" | ||
|
||
########################################## | ||
# Prepare container | ||
########################################## | ||
# Download | ||
G_EXEC curl -sSfO "https://dietpi.com/downloads/images/$image.7z" | ||
G_EXEC 7zz e "$image.7z" "$image.img" | ||
G_EXEC rm "$image.7z" | ||
G_EXEC truncate -s $((2*1024**3)) "$image.img" | ||
|
||
# Loop device | ||
FP_LOOP=$(losetup -f) | ||
G_EXEC losetup "$FP_LOOP" "$image.img" | ||
G_EXEC partprobe "$FP_LOOP" | ||
G_EXEC partx -u "$FP_LOOP" | ||
G_EXEC_OUTPUT=1 G_EXEC e2fsck -fp "${FP_LOOP}p1" | ||
G_EXEC_OUTPUT=1 G_EXEC eval "sfdisk -fN1 '$FP_LOOP' <<< ',+'" | ||
G_EXEC partprobe "$FP_LOOP" | ||
G_EXEC partx -u "$FP_LOOP" | ||
G_EXEC_OUTPUT=1 G_EXEC resize2fs "${FP_LOOP}p1" | ||
G_EXEC_OUTPUT=1 G_EXEC e2fsck -fp "${FP_LOOP}p1" | ||
G_EXEC mkdir rootfs | ||
G_EXEC mount "${FP_LOOP}p1" rootfs | ||
|
||
# Automated build | ||
cat << _EOF_ > rootfs/etc/rc.local || exit 1 | ||
#!/bin/dash | ||
infocmp "\$TERM" > /dev/null 2>&1 || TERM='dumb' | ||
if grep -q 'raspbian' /etc/os-release | ||
then | ||
sed -i '/^G_HW_ARCH=/c\G_HW_ARCH=1' /boot/dietpi/.hw_model | ||
sed -i '/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l' /boot/dietpi/.hw_model | ||
fi | ||
echo '[ INFO ] Running Squeezelite build script...' | ||
bash -c "\$(curl -sSf 'https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/software/squeezelite/build.bash')" | ||
mv -v '/tmp/squeezelite_$arch.deb' '/squeezelite_$arch.deb' | ||
poweroff | ||
_EOF_ | ||
G_EXEC chmod +x rootfs/etc/rc.local | ||
|
||
# Assure that build starts after DietPi-PostBoot | ||
[[ -d 'rootfs/etc/systemd/system/rc-local.service.d' ]] || G_EXEC mkdir rootfs/etc/systemd/system/rc-local.service.d | ||
G_EXEC eval 'echo -e '\''[Unit]\nAfter=dietpi-postboot.service'\'' > rootfs/etc/systemd/system/rc-local.service.d/dietpi.conf' | ||
|
||
########################################## | ||
# Boot container | ||
########################################## | ||
systemd-nspawn -bD rootfs --bind="$FP_LOOP"{,p1} --bind=/dev/disk | ||
[[ -f rootfs/squeezelite_$arch.deb ]] || exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters