Skip to content

Commit

Permalink
277 feature add support for bluetooth (#290)
Browse files Browse the repository at this point in the history
* Allow installation of bluetooth libraries

* Correct markdown for new variable

* Support alsa-bt binary mode
  • Loading branch information
GioF71 committed Apr 4, 2024
1 parent 3e903e6 commit 963a4e4
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 21 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/docker-multi-arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ jobs:
matrix:
base: [ stable ]
build_mode: [ std, sf, r2 ]
binary_mode: [ full, pulse, alsa ]
binary_mode: [ full, pulse, alsa, alsa-bt ]
exclude:
- base: stable
build_mode: r2
binary_mode: full
- base: stable
build_mode: r2
binary_mode: pulse
- base: stable
build_mode: r2
binary_mode: alsa-bt
- base: stable
build_mode: sf
binary_mode: alsa-bt

steps:
- name: Checkout
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE} AS BASE
# BUILD_MODE: [ std, sf, r2, bt ]
ARG BUILD_MODE
# BINARY_MODE: [ "full", "pulse", "alsa", "alsa-bt" ]
ARG BINARY_MODE
ARG FORCE_ARCH
ARG USE_APT_PROXY
Expand Down Expand Up @@ -112,6 +114,8 @@ ENV AUDIO_GID ""
ENV SELECT_CUSTOM_BINARY_ALSA ""
ENV SELECT_CUSTOM_BINARY_PULSE ""

ENV INSTALL_BLUETOOTH_LIBRARIES ""

COPY app/bin/run-squeezelite.sh /app/bin/
COPY app/bin/run-squeezelite-alsa.sh /app/bin/
COPY app/bin/run-squeezelite-pulse.sh /app/bin/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ SQUEEZELITE_LOG_CATEGORY_DECODE|-d|Support for log level on category `decode`
SQUEEZELITE_LOG_CATEGORY_OUTPUT|-d|Support for log level on category `output`
SQUEEZELITE_LOG_CATEGORY_IR|-d|Support for log level on category `ir`
CONFIG_FILE_PREFIX||Prefix for files in volume `/config`
INSTALL_BLUETOOTH_LIBRARIES||Install bluetooth libraries if set to `yes`
STARTUP_DELAY_SEC||Delay before starting the application, defaults to `0`

It is possible to add and additional preset configuration file using the volume `/app/assets/additional-presets.conf`.
Expand Down
17 changes: 17 additions & 0 deletions app/bin/run-squeezelite-alsa.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# exit codes

# 5 root mode required

echo "=== BEGIN Available audio devices ==="
/app/bin/squeezelite -l
echo "=== END-- Available audio devices ==="
Expand Down Expand Up @@ -264,6 +268,19 @@ fi

echo "Resulting actual_user_mode: [$actual_user_mode]"

if [[ "${INSTALL_BLUETOOTH_LIBRARIES^^}" == "YES" || "${INSTALL_BLUETOOTH_LIBRARIES^^}" == "Y" ]]; then
echo "Bluetooth libraries installation requested."
if [ $current_user_id -ne 0 ]; then
echo "Installation of additional libraries is avaialable only when running as root."
exit 5
fi
# this will be executed on each startup
# maybe we can check if packages are already installed and
# avoid to install again
apt-get update
apt-get install -y bluetooth bluez-alsa-utils alsa-utils
fi

## User mode support
if [[ $actual_user_mode -eq 1 ]]; then
USE_USER_MODE="Y"
Expand Down
11 changes: 6 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ do
esac
done

echo "Input: base_image = [$base_image]";
echo "Input: Base Image = [$base_image]";
echo "Input: Build Mode = [$build_mode]";
echo "Input: Download from SourceForge = [$sd]";
echo "Input: Force Architecture = [$force_arch]";
echo "Input: Image Tag = [$tag]";
Expand All @@ -82,11 +83,11 @@ if [ -z "${build_mode}" ]; then
build_mode="std"
fi

if [[ "${build_mode^^}" == "SF" ]]; then
if [[ "${build_mode}" == "sf" ]]; then
build_mode="sf"
elif [[ "${build_mode^^}" == "STD" ]]; then
elif [[ "${build_mode}" == "std" ]]; then
build_mode="std"
elif [[ "${build_mode^^}" == "R2" ]]; then
elif [[ "${build_mode}" == "r2" ]]; then
build_mode="r2"
else
echo "invalid build_mode parameter ["${build_mode}"]"
Expand All @@ -108,7 +109,7 @@ fi
if [[ -z "${binary_mode}" ]]; then
binary_mode=full
else
if [[ ! "${binary_mode^^}" == "ALSA" ]] && [[ ! "${binary_mode^^}" == "PULSE" ]] && [[ ! "${binary_mode^^}" == "FULL" ]]; then
if [[ ! "${binary_mode}" == "alsa" ]] && [[ ! "${binary_mode}" == "pulse" ]] && [[ ! "${binary_mode}" == "full" ]] && [[ ! "${binary_mode}" == "alsa-bt" ]]; then
echo "invalid binary_mode parameter ["${binary_mode}"]"
exit 4
fi
Expand Down
1 change: 1 addition & 0 deletions doc/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Older build might be dropped in order to save space on docker-hub and incur in l

Date|Type|Description
:---|:---|:---
2024-04-02|Improvement|Add support for installing bluetooth libs (see [#277](https://github.com/GioF71/squeezelite-docker/issues/277))
2024-04-02|Maintenance|Remove 1.9.9 from sf tags (see [#288](https://github.com/GioF71/squeezelite-docker/issues/288))
2024-03-29|Update|Sourceforge binaries version bump (see [#286](https://github.com/GioF71/squeezelite-docker/issues/286))
2024-03-21|Update|Sourceforge binaries version bump (see [#284](https://github.com/GioF71/squeezelite-docker/issues/284))
Expand Down
45 changes: 39 additions & 6 deletions install/install-dep.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
#!/bin/bash

if [[ "$BUILD_MODE" == "sf" ]]; then
# exit codes
# 6 unsupported build type

invalid_combination=0

# Filter unnecessary builds
if [[ "${BINARY_MODE}" == "alsa-bt" ]]; then
# no sf and no r2 for this build mode
if [[ "${BUILD_MODE}" == "sf" ]] || [[ "${BUILD_MODE}" == "r2" ]]; then
invalid_combination=1
fi
fi

if [[ "${BUILD_MODE}" == "r2" ]]; then
# only alsa for r2 build mode
if [[ "${BINARY_MODE}" != "alsa" ]]; then
invalid_combination=1
fi
fi

if [ $invalid_combination -eq 1 ]; then
echo "Invalid combination BUILD_MODE=[${BUILD_MODE}] BINARY_MODE=[${BINARY_MODE}]"
exit 6
fi

if [[ "${BUILD_MODE}" == "sf" ]]; then
echo "Using sourceforge binaries, installing required dependencies - BEGIN"
apt-get update
if [[ -z "${BINARY_MODE^^}" ]] || [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "ALSA" ]]; then
if [[ -z "${BINARY_MODE}" ]] || [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "alsa" ]]; then
echo "Installing support for Alsa ..."
apt-get install --no-install-recommends -y libasound2
echo "Support for Alsa installed."
fi
if [[ -z "${BINARY_MODE^^}" ]] || [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "PULSE" ]]; then
if [[ -z "${BINARY_MODE}" ]] || [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "pulse" ]]; then
echo "Installing support for PulseAudio ..."
apt-get install --no-install-recommends -y \
libavcodec59 \
Expand All @@ -28,9 +53,17 @@ if [[ "$BUILD_MODE" == "sf" ]]; then
echo "Support for PulseAudio installed."
fi
echo "Using sourceforge binaries, installing required dependencies - END"
elif [[ "$BUILD_MODE" == "std" ]]; then
echo "Using standard packages, no additional dependencies required."
elif [[ "$BUILD_MODE" == "r2" ]]; then
elif [[ "${BUILD_MODE}" == "std" ]]; then
echo "Using standard packages."
if [[ "${BINARY_MODE}" == "alsa-bt" ]]; then
echo "Installing packages for bluetooth ..."
apt-get update
apt-get install -y bluetooth bluez-alsa-utils alsa-utils
echo "Finished installing packages for bluetooth ..."
else
echo "No additional packages to install."
fi
elif [[ "${BUILD_MODE}" == "r2" ]]; then
echo "Preparing for Squeezelite R2 (compiling)"
apt-get update
apt-get install -y \
Expand Down
16 changes: 8 additions & 8 deletions install/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ download_url_dict_pulse[$arch_amd64]="https://sourceforge.net/projects/lmsclient
download_url_dict_pulse[$arch_arm_v7]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1392-armhf.tar.gz/download"
download_url_dict_pulse[$arch_arm_v8]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-2.0.0.1465-aarch64.tar.gz/download"

if [[ "$BUILD_MODE" == "sf" ]]; then
if [[ "${BUILD_MODE}" == "sf" ]]; then
apt-get install wget -y
#ARCH=`uname -m`
mkdir /assets
mkdir -p /assets/sourceforge
if [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "ALSA" ]]; then
if [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "alsa" ]]; then
SL_URL=${download_url_dict_alsa["${ARCH}"]};
if [[ -n "${SL_URL}" ]]; then
echo "Found Alsa version for architecture ${ARCH}, downloading ..."
Expand All @@ -53,7 +53,7 @@ if [[ "$BUILD_MODE" == "sf" ]]; then
exit 1
fi
fi
if [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "PULSE" ]]; then
if [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "pulse" ]]; then
SL_URL_PULSE=${download_url_dict_pulse["${ARCH}"]};
if [[ -n "${SL_URL_PULSE}" ]]; then
echo "Found PulseAudio version for architecture ${ARCH}, downloading ..."
Expand All @@ -70,7 +70,7 @@ if [[ "$BUILD_MODE" == "sf" ]]; then
apt-get purge wget -y
apt-get autoremove -y
rm -Rf /assets
elif [[ "$BUILD_MODE" == "r2" ]]; then
elif [[ "${BUILD_MODE}" == "r2" ]]; then
echo "Building squeezelite r2 ..."
mkdir -p /app/r2-src
cd /app/r2-src
Expand All @@ -82,15 +82,15 @@ elif [[ "$BUILD_MODE" == "r2" ]]; then
chmod 755 /app/bin/squeezelite
cd /app
rm -Rf /app/r2-src
elif [[ "$BUILD_MODE" == "std" ]]; then
if [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "ALSA" ]]; then
elif [[ "${BUILD_MODE}" == "std" ]]; then
if [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "alsa" ]] || [[ "${BINARY_MODE}" == "alsa-bt" ]]; then
echo "Installing ALSA ..."
apt-get update
apt-get install squeezelite --no-install-recommends -y
cp /usr/bin/squeezelite /app/bin/squeezelite
echo "Installed ALSA."
fi
if [[ "${BINARY_MODE^^}" == "FULL" ]] || [[ "${BINARY_MODE^^}" == "PULSE" ]]; then
if [[ "${BINARY_MODE}" == "full" ]] || [[ "${BINARY_MODE}" == "pulse" ]]; then
echo "Installing Pulse ..."
apt-get update
apt-get install squeezelite-pulseaudio --no-install-recommends -y
Expand All @@ -99,6 +99,6 @@ elif [[ "$BUILD_MODE" == "std" ]]; then
fi
apt-get remove squeezelite* -y
else
echo "Invalid BUILD_MODE=[$BUILD_MODE]"
echo "Invalid BUILD_MODE=[${BUILD_MODE}]"
exit 1
fi
2 changes: 1 addition & 1 deletion install/remove-dep.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [[ "$BUILD_MODE" == "r2" ]]; then
if [[ "${BUILD_MODE}" == "r2" ]]; then
echo "Removing packages for Squeezelite R2"
apt-get remove -y git build-essential
apt-get autoremove -y
Expand Down

0 comments on commit 963a4e4

Please sign in to comment.