Skip to content

Commit

Permalink
[Feature] Add support for Squeezelite R2 #268 (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 committed Jan 19, 2024
1 parent 8e2548f commit 9228c0f
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 69 deletions.
61 changes: 32 additions & 29 deletions .github/workflows/docker-multi-arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}]}
Expand Down Expand Up @@ -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}"]"
Expand All @@ -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
Expand All @@ -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 }}
21 changes: 13 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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; \
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
42 changes: 22 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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 \
Expand Down
23 changes: 19 additions & 4 deletions install/install-dep.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
Loading

0 comments on commit 9228c0f

Please sign in to comment.