From 9228c0fce1b0d447050f62a49f461802061434f9 Mon Sep 17 00:00:00 2001 From: Giovanni Fulco Date: Fri, 19 Jan 2024 17:57:37 +0100 Subject: [PATCH] [Feature] Add support for Squeezelite R2 #268 (#269) --- .github/workflows/docker-multi-arch.yml | 61 +++++++++++++------------ Dockerfile | 21 +++++---- README.md | 5 ++ build.sh | 42 +++++++++-------- install/install-dep.sh | 23 ++++++++-- install/installer.sh | 32 +++++++++---- install/remove-dep.sh | 7 +++ 7 files changed, 122 insertions(+), 69 deletions(-) create mode 100644 install/remove-dep.sh diff --git a/.github/workflows/docker-multi-arch.yml b/.github/workflows/docker-multi-arch.yml index fa39423..8a6d422 100644 --- a/.github/workflows/docker-multi-arch.yml +++ b/.github/workflows/docker-multi-arch.yml @@ -17,15 +17,15 @@ jobs: fail-fast: false matrix: base: [ stable ] - sourceforge: [ Y, N] - build_mode: [ full, pulse, alsa ] - #exclude: - # - base: stable - # sourceforge: Y - # build_mode: alsa - # - base: stable - # sourceforge: Y - # build_mode: pulse + build_mode: [ std, sf, r2 ] + binary_mode: [ full, pulse, alsa ] + exclude: + - base: stable + build_mode: r2 + binary_mode: full + - base: stable + build_mode: r2 + binary_mode: pulse steps: - name: Checkout @@ -46,7 +46,7 @@ jobs: echo "REF: ["$ref"]" build_platforms="linux/amd64,linux/arm64/v8,linux/arm/v7" - if [ ${{ matrix.sourceforge }} = "N" ]; then + if [[ ${{ matrix.build_mode }} = "std" ]] || [[ ${{ matrix.build_mode }} = "r2" ]]; then build_platforms="${build_platforms},linux/arm/v5" fi @@ -65,26 +65,29 @@ jobs: sl_versions[stable]=1.9.9 declare -A special_tags - special_tags[stable-N-full]="${image_name}:latest,${image_name}:stable" - special_tags[stable-N-alsa]="${image_name}:latest-alsa,${image_name}:stable-alsa" - special_tags[stable-N-pulse]="${image_name}:latest-pulse,${image_name}:stable-pulse" - special_tags[stable-Y-full]="${image_name}:sourceforge-latest,${image_name}:sourceforge-stable" - special_tags[stable-Y-alsa]="${image_name}:sourceforge-latest-alsa,${image_name}:sourceforge-stable-alsa" - special_tags[stable-Y-pulse]="${image_name}:sourceforge-latest-pulse,${image_name}:sourceforge-stable-pulse" + special_tags[stable-std-full]="${image_name}:latest,${image_name}:stable" + special_tags[stable-std-alsa]="${image_name}:latest-alsa,${image_name}:stable-alsa" + special_tags[stable-std-pulse]="${image_name}:latest-pulse,${image_name}:stable-pulse" + special_tags[stable-sf-full]="${image_name}:sourceforge-latest,${image_name}:sourceforge-stable" + special_tags[stable-sf-alsa]="${image_name}:sourceforge-latest-alsa,${image_name}:sourceforge-stable-alsa" + special_tags[stable-sf-pulse]="${image_name}:sourceforge-latest-pulse,${image_name}:sourceforge-stable-pulse" + special_tags[stable-r2-alsa]="${image_name}:r2-latest-alsa,${image_name}:r2-stable-alsa" declare -A distro_friendly_name_dict distro_friendly_name_dict[stable]=debian distro_friendly_name=${{ matrix.base }} - build_mode=${{ matrix.build_mode }} + binary_mode=${{ matrix.binary_mode }} lookup_distro_name=${distro_friendly_name_dict[${{ matrix.base }}]} if [ -n "${lookup_distro_name}" ]; then distro_friendly_name=$lookup_distro_name fi squeezelite_version_str="" - if [ ${{ matrix.sourceforge }} = "Y" ]; then + if [ ${{ matrix.build_mode }} = "sf" ]; then squeezelite_version_str="squeezelite-1.9.9-sourceforge" + elif [ ${{ matrix.build_mode }} = "r2" ]; then + squeezelite_version_str="squeezelite-1.8.4-r2" else select_squeezelite_version=unknown select_squeezelite_version=${sl_versions[${{ matrix.base }}]} @@ -112,11 +115,11 @@ jobs: echo "tag_name=[$tag_name]" if [[ "${tag_type}" == "release" || "${tag_type}" == "v" ]]; then echo "release tag" - tags="$image_name:${distro_friendly_name}-${build_mode}-${squeezelite_version_str}" - tags="$tags,$image_name:${distro_friendly_name}-${build_mode}-${squeezelite_version_str}-${tag_name}" - special_tag_lookup="${{ matrix.base }}-${{ matrix.sourceforge }}-${{ matrix.build_mode }}" + tags="$image_name:${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}" + tags="$tags,$image_name:${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}-${tag_name}" + special_tag_lookup="${{ matrix.base }}-${{ matrix.build_mode }}-${{ matrix.binary_mode }}" select_special_tags=${special_tags["${special_tag_lookup}"]} - building_now="${distro_friendly_name}-${build_mode}-${{ matrix.sourceforge }}" + building_now="${distro_friendly_name}-${binary_mode}-${{ matrix.build_mode }}" echo "Building now: ["$building_now"]" if [[ -n "${select_special_tags}" ]]; then echo "Found special tags for ["${building_now}"]=["${select_special_tags}"]" @@ -126,21 +129,21 @@ jobs: fi elif [[ "${tag_type}" == "feature" || "${tag_type}" == "f" ]]; then echo "feature tag" - tags="${image_name}:feature-${tag_name}-${distro_friendly_name}-${build_mode}-${squeezelite_version_str}" + tags="${image_name}:feature-${tag_name}-${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}" elif [[ "${tag_type}" = "daily" || "${tag_type}" = "d" ]]; then echo "daily build" - if [ ${{ matrix.sourceforge }} = "N" ]; then - tags="${tags},${image_name}:daily-${distro_friendly_name}-${build_mode}" + if [ ${{ matrix.build_mode }} = "N" ]; then + tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}" else - tags="${tags},${image_name}:daily-${distro_friendly_name}-${build_mode}-sourceforge" + tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}-sourceforge" fi - tags="${tags},${image_name}:daily-${distro_friendly_name}-${build_mode}-${squeezelite_version_str}" + tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}" fi fi echo "Building tags: ["${tags}"]" echo "RELEASE_TAGS=${tags}" >> $GITHUB_OUTPUT echo "BASE_IMAGE=${select_base_image}" >> $GITHUB_OUTPUT - echo "DOWNLOAD_FROM_SOURCEFORGE=N" >> $GITHUB_OUTPUT + echo "BUILD_MODE=${{ matrix.build_mode }}" >> $GITHUB_OUTPUT echo "BUILD_PLATFORMS=${build_platforms}" >> $GITHUB_OUTPUT - name: Set up QEMU @@ -164,8 +167,8 @@ jobs: context: . build-args: | BASE_IMAGE=${{ steps.prepare.outputs.BASE_IMAGE }} - DOWNLOAD_FROM_SOURCEFORGE=${{ matrix.sourceforge }} BUILD_MODE=${{ matrix.build_mode }} + BINARY_MODE=${{ matrix.binary_mode }} platforms: ${{ steps.prepare.outputs.BUILD_PLATFORMS }} push: true tags: ${{ steps.prepare.outputs.RELEASE_TAGS }} diff --git a/Dockerfile b/Dockerfile index 1274dfc..fee79e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} AS BASE -ARG DOWNLOAD_FROM_SOURCEFORGE ARG BUILD_MODE +ARG BINARY_MODE ARG FORCE_ARCH ARG USE_APT_PROXY @@ -18,25 +18,30 @@ RUN if [ "${USE_APT_PROXY}" = "Y" ]; then \ echo "Building without apt proxy"; \ fi +RUN mkdir -p /app/bin + # copy installer files RUN mkdir -p /app/install COPY install/install-dep.sh /app/install/ -RUN chmod u+x /app/install/install-dep.sh +COPY install/installer.sh /app/install/ +COPY install/remove-dep.sh /app/install/ -RUN /app/install/install-dep.sh -RUN rm /app/install/install-dep.sh +RUN chmod u+x /app/install/*.sh -COPY install/installer.sh /app/install/ -RUN chmod u+x /app/install/* +RUN /app/install/install-dep.sh WORKDIR /app/install -RUN mkdir -p /app/bin - # execute installation RUN /app/install/installer.sh +RUN /app/install/remove-dep.sh + +RUN rm /app/install/install-dep.sh +RUN rm /app/install/installer.sh +RUN rm /app/install/remove-dep.sh + # cleanup apt proxy config RUN if [ "${USE_APT_PROXY}" = "Y" ]; then \ rm /etc/apt/apt.conf.d/01-apt-proxy; \ diff --git a/README.md b/README.md index f82a259..e9c3c06 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,11 @@ Now also with multiplatform support thanks to [Der-Henning](https://github.com/D ## News +### Squeezelite R2 variant + +Since 2024-01-19 (see issue [#268](https://github.com/GioF71/squeezelite-docker/issues/268)) I am building separate builds for [Squeezelite R2](https://github.com/marcoc1712/squeezelite-R2), only in alsa mode. +This patched version allows server-side transcoding, also to DSD format, which some user might like to use. + ### Alsa and PulseAudio variants Since 2023-12-30 (see issue [#254](https://github.com/GioF71/squeezelite-docker/issues/254)) I am building separate builds for alsa and pulseaudio only. The [alsa sourceforge version](https://hub.docker.com/r/giof71/squeezelite/tags?page=1&name=debian-alsa-sourceforge) results in a particularily small image. Maybe the pulse version can be reduced in size, but I still need to perform a few tests in order to verify that I can remove some packages. diff --git a/build.sh b/build.sh index 8c9360d..e31637a 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ # error codes # 2 Invalid base image -# 3 Invalid download parameter +# 3 Invalid build_mode parameter # 4 Invalid proxy parameter declare -A base_images @@ -42,21 +42,21 @@ base_images[ubuntu:mantic]=ubuntu:mantic base_images[ubuntu:rolling]=ubuntu:rolling DEFAULT_BASE_IMAGE=stable -DEFAULT_SOURCEFORGE_DOWNLOAD=N +DEFAULT_BUILD_MODE=std DEFAULT_TAG=local DEFAULT_USE_PROXY=N -download=$DEFAULT_SOURCEFORGE_DOWNLOAD +build_mode=$DEFAULT_BUILD_MODE tag=$DEFAULT_TAG while getopts b:d:t:p:m:f: flag do case "${flag}" in b) base_image=${OPTARG};; - d) download=${OPTARG};; + d) build_mode=${OPTARG};; t) tag=${OPTARG};; p) proxy=${OPTARG};; - m) build_mode=${OPTARG};; + m) binary_mode=${OPTARG};; f) force_arch=${OPTARG};; esac done @@ -66,7 +66,7 @@ echo "Input: Download from SourceForge = [$sd]"; echo "Input: Force Architecture = [$force_arch]"; echo "Input: Image Tag = [$tag]"; echo "Input: Proxy = [$proxy]"; -echo "Input: Build mode = [$build_mode]"; +echo "Input: Binary mode = [$binary_mode]"; if [ -z "${base_image}" ]; then base_image=$DEFAULT_BASE_IMAGE @@ -78,16 +78,18 @@ if [ -z "${expanded_base_image}" ]; then exit 2 fi -if [ -z "${download}" ]; then - download="Y" +if [ -z "${build_mode}" ]; then + build_mode="Y" fi -if [[ "${download}" == "Y" || "${download}" == "y" ]]; then - download="Y" -elif [[ "${download}" == "N" || "${download}" == "n" ]]; then - download="N" +if [[ "${build_mode^^}" == "SF" ]]; then + build_mode="sf" +elif [[ "${build_mode^^}" == "STD" ]]; then + build_mode="std" +elif [[ "${build_mode^^}" == "R2" ]]; then + build_mode="r2" else - echo "invalid download parameter ["${download}"]" + echo "invalid build_mode parameter ["${build_mode}"]" exit 3 fi @@ -103,26 +105,26 @@ else exit 4 fi -if [[ -z "${build_mode}" ]]; then - build_mode=full +if [[ -z "${binary_mode}" ]]; then + binary_mode=full else - if [[ ! "${build_mode^^}" == "ALSA" ]] && [[ ! "${build_mode^^}" == "PULSE" ]] && [[ ! "${build_mode^^}" == "FULL" ]]; then - echo "invalid build_mode parameter ["${build_mode}"]" + if [[ ! "${binary_mode^^}" == "ALSA" ]] && [[ ! "${binary_mode^^}" == "PULSE" ]] && [[ ! "${binary_mode^^}" == "FULL" ]]; then + echo "invalid binary_mode parameter ["${binary_mode}"]" exit 4 fi fi echo "Build Argument: Base Image = ["$expanded_base_image"]" -echo "Build Argument: Download from SourceForge = ["$download"]" +echo "Build Argument: Download from SourceForge = ["$build_mode"]" echo "Build Argument: Force Architecture = [$force_arch]"; echo "Build Argument: Image Tag = ["$tag"]" -echo "Build Argument: Build Mode = ["$build_mode"]" +echo "Build Argument: Binary Mode = ["$binary_mode"]" echo "Build Argument: Proxy = ["$proxy"]" docker build . \ --build-arg BASE_IMAGE=${expanded_base_image} \ - --build-arg DOWNLOAD_FROM_SOURCEFORGE=${download} \ --build-arg BUILD_MODE=${build_mode} \ + --build-arg BINARY_MODE=${binary_mode} \ --build-arg FORCE_ARCH=${force_arch} \ --build-arg USE_APT_PROXY=${proxy} \ -t giof71/squeezelite:$tag \ diff --git a/install/install-dep.sh b/install/install-dep.sh index 0c54b82..364ace7 100644 --- a/install/install-dep.sh +++ b/install/install-dep.sh @@ -1,14 +1,14 @@ #!/bin/bash -if [[ "$DOWNLOAD_FROM_SOURCEFORGE" == "Y" ]]; then +if [[ "$BUILD_MODE" == "sf" ]]; then echo "Using sourceforge binaries, installing required dependencies - BEGIN" apt-get update - if [[ -z "${BUILD_MODE^^}" ]] || [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_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 "${BUILD_MODE^^}" ]] || [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_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 \ @@ -28,4 +28,19 @@ if [[ "$DOWNLOAD_FROM_SOURCEFORGE" == "Y" ]]; then echo "Support for PulseAudio installed." fi echo "Using sourceforge binaries, installing required dependencies - END" -fi +elif [[ "$BUILD_MODE" == "std" ]]; then + echo "Using standard packages, no additional dependencies required." +elif [[ "$BUILD_MODE" == "r2" ]]; then + echo "Preparing for Squeezelite R2 (compiling)" + apt-get update + apt-get install -y \ + git \ + build-essential \ + libasound2 \ + libasound2-dev \ + libflac-dev \ + libmad0-dev \ + libfaad-dev \ + libmpg123-dev \ + libvorbis-dev +fi \ No newline at end of file diff --git a/install/installer.sh b/install/installer.sh index 2430d51..246faa5 100644 --- a/install/installer.sh +++ b/install/installer.sh @@ -4,6 +4,7 @@ set -ex # Error codes # 1 Unsupported platform +# 2 Invalid argument ARCH=`uname -m` echo "ARCH=[${ARCH}] FORCE_ARCH=[${FORCE_ARCH}]" @@ -12,9 +13,9 @@ if [[ -n "${FORCE_ARCH}" ]]; then ARCH="${FORCE_ARCH}" fi +echo "install-script.sh: BINARY_MODE=[${BINARY_MODE}]" echo "install-script.sh: BUILD_MODE=[${BUILD_MODE}]" -echo "install-script.sh: DOWNLOAD_FROM_SOURCEFORGE=[${DOWNLOAD_FROM_SOURCEFORGE}]" -echo "install-script.sh: Architecture: ${ARCH}" +echo "install-script.sh: ARCH=[${ARCH}]" OUTPUT_FILE=/app/bin/squeezelite OUTPUT_FILE_PULSE=/app/bin/squeezelite-pulseaudio @@ -33,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-1.9.9.1428-aarch64.tar.gz/download" -if [[ "$DOWNLOAD_FROM_SOURCEFORGE" == "Y" ]]; then +if [[ "$BUILD_MODE" == "sf" ]]; then apt-get install wget -y #ARCH=`uname -m` mkdir /assets mkdir -p /assets/sourceforge - if [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_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 ..." @@ -52,7 +53,7 @@ if [[ "$DOWNLOAD_FROM_SOURCEFORGE" == "Y" ]]; then exit 1 fi fi - if [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_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 ..." @@ -69,15 +70,27 @@ if [[ "$DOWNLOAD_FROM_SOURCEFORGE" == "Y" ]]; then apt-get purge wget -y apt-get autoremove -y rm -Rf /assets -else - if [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_MODE^^}" == "ALSA" ]]; then +elif [[ "$BUILD_MODE" == "r2" ]]; then + echo "Building squeezelite r2 ..." + mkdir -p /app/r2-src + cd /app/r2-src + git clone https://github.com/marcoc1712/squeezelite-R2.git + cd squeezelite-R2 + mkdir Bin + make -f Makefile.debian + mv Bin/squeezelite-R2-deb /app/bin/squeezelite + 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 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 [[ "${BUILD_MODE^^}" == "FULL" ]] || [[ "${BUILD_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 @@ -85,4 +98,7 @@ else echo "Installed PULSE." fi apt-get remove squeezelite* -y +else + echo "Invalid BUILD_MODE=[$BUILD_MODE]" + exit 1 fi \ No newline at end of file diff --git a/install/remove-dep.sh b/install/remove-dep.sh new file mode 100644 index 0000000..1159e19 --- /dev/null +++ b/install/remove-dep.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ "$BUILD_MODE" == "r2" ]]; then + echo "Removing packages for Squeezelite R2" + apt-get remove -y git build-essential + apt-get autoremove -y +fi \ No newline at end of file