Skip to content

Commit

Permalink
[Maintenance] Simplify installer script #188 (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 authored Mar 17, 2023
1 parent b27acca commit 2e8521c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 64 deletions.
22 changes: 20 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,32 @@ RUN if [ "${USE_APT_PROXY}" = "Y" ]; then \
echo "Building without apt proxy"; \
fi

# update indexes
RUN apt-get update

# upgrade packages
RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y

# install pulseaudio
RUN apt-get install pulseaudio --no-install-recommends -y

# install alsa libraries
RUN apt-get install libasound2 --no-install-recommends -y

# copy installer files
RUN mkdir -p /app/bin
RUN mkdir -p /app/install
COPY install/installer.sh /app/install/
COPY install/install-script.sh /app/install/
RUN chmod u+x /app/install/*

WORKDIR /app/install

RUN /app/install/installer.sh $DOWNLOAD_FROM_SOURCEFORGE
# execute installation
RUN ./installer.sh $DOWNLOAD_FROM_SOURCEFORGE

# cleanup apt cache
RUN rm -rf /var/lib/apt/lists/*

# remove scripts
RUN rm -Rf /app/install
Expand All @@ -37,7 +55,7 @@ FROM scratch
COPY --from=BASE / /

LABEL maintainer="GioF71"
LABEL source="https://github.com/GioF71/upmpdcli-docker"
LABEL source="https://github.com/GioF71/squeezelite-docker"

RUN mkdir -p /app
RUN mkdir -p /app/bin
Expand Down
70 changes: 70 additions & 0 deletions install/install-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
set -ex

# Error codes
# 1 Unsupported platform

ARCH=`uname -m`
OUTPUT_FILE=/app/bin/squeezelite
OUTPUT_FILE_PULSE=/app/bin/squeezelite-pulseaudio
echo "Architecture: ${ARCH}"

arch_amd64=x86_64
arch_arm_v7=armv7l
arch_arm_v8=aarch64

declare -A download_url_dict_alsa
download_url_dict_alsa[$arch_amd64]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1421-x86_64.tar.gz/download"
download_url_dict_alsa[$arch_arm_v7]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1419-armhf.tar.gz/download"
download_url_dict_alsa[$arch_arm_v8]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1392-aarch64.tar.gz/download"

declare -A download_url_dict_pulse
download_url_dict_pulse[$arch_amd64]="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1421-x86_64.tar.gz/download"
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.1392-aarch64.tar.gz/download"

if [ "$DOWNLOADED_BIN" == "Y" ]; then
apt-get install wget -y
ARCH=`uname -m`
mkdir /assets
mkdir -p /assets/sourceforge
#URL_x86_64="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1421-x86_64.tar.gz/download"
#URL_aarch64="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1392-aarch64.tar.gz/download"
#URL_armv7l="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1419-armhf.tar.gz/download"
#URL_x86_64_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1421-x86_64.tar.gz/download"
#URL_aarch64_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1392-aarch64.tar.gz/download"
#URL_armv7l_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1392-armhf.tar.gz/download"
#echo $ARCH
SL_URL=${download_url_dict_alsa["${ARCH}"]};
if [[ -n "${SL_URL}" ]]; then
echo "Found Alsa version for architecture ${ARCH}, downloading ..."
wget $SL_URL -O /assets/sourceforge/squeezelite.tar.gz
mkdir /assets/sourceforge/expanded
tar xzvf /assets/sourceforge/squeezelite.tar.gz -C /assets/sourceforge/expanded
ls -la /assets/sourceforge/expanded/
mv /assets/sourceforge/expanded/squeezelite $OUTPUT_FILE
else
echo "NOT Found Alsa version for architecture ${ARCH}. This was mandatory, exiting"
exit 1
fi
SL_URL_PULSE=${download_url_dict_pulse["${ARCH}"]};
if [[ -n "${SL_URL_PULSE}" ]]; then
echo "Found PulseAudio version for architecture ${ARCH}, downloading ..."
wget $SL_URL_PULSE -O /assets/sourceforge/squeezelite-pulse.tar.gz
mkdir /assets/sourceforge/expanded-pulse
tar xzvf /assets/sourceforge/squeezelite-pulse.tar.gz -C /assets/sourceforge/expanded-pulse
ls -la /assets/sourceforge/expanded-pulse/
mv /assets/sourceforge/expanded-pulse/squeezelite $OUTPUT_FILE_PULSE
else
echo "NOT Found PulseAudio version for architecture ${ARCH}. This was mandatory, exiting"
fi
# cleanup
apt-get purge wget -y
apt-get autoremove -y
rm -Rf /assets
else
apt-get install squeezelite --no-install-recommends -y
cp /usr/bin/squeezelite /app/bin/squeezelite
apt-get install squeezelite-pulseaudio --no-install-recommends -y
cp /usr/bin/squeezelite-pulseaudio /app/bin/squeezelite-pulseaudio
apt-get remove squeezelite* -y
fi
63 changes: 1 addition & 62 deletions install/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,4 @@ echo ${1}
export DOWNLOADED_BIN=${1}
echo $DOWNLOADED_BIN

/bin/bash -c 'set -ex && \
ARCH=`uname -m` && \
OUTPUT_FILE=/usr/bin/squeezelite && \
echo $ARCH && \
if [ "$DOWNLOADED_BIN" == "Y" ]; then \
ARCH=`uname -m`; \
mkdir /assets; \
mkdir -p /assets/sourceforge; \
OUTPUT_FILE=/app/bin/squeezelite; \
OUTPUT_FILE_PULSE=/app/bin/squeezelite-pulseaudio; \
URL_x86_64="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1421-x86_64.tar.gz/download"; \
URL_aarch64="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1392-aarch64.tar.gz/download"; \
URL_armv7l="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1419-armhf.tar.gz/download"; \
URL_x86_64_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1421-x86_64.tar.gz/download"; \
URL_aarch64_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1392-aarch64.tar.gz/download"; \
URL_armv7l_PULSE="https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-pulse-1.9.9.1392-armhf.tar.gz/download"; \
echo $ARCH; \
SL_URL=""; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y; \
apt-get install wget -y; \
apt-get install libasound2 --no-install-recommends -y; \
apt-get install pulseaudio --no-install-recommends -y; \
if [ "$ARCH" == "armv7l" ]; then \
SL_URL=$URL_armv7l; \
SL_URL_PULSE=$URL_armv7l_PULSE; \
elif [ "$ARCH" == "x86_64" ]; then \
SL_URL=$URL_x86_64; \
SL_URL_PULSE=$URL_x86_64_PULSE; \
elif [ "$ARCH" == "aarch64" ]; then \
SL_URL=$URL_aarch64; \
SL_URL_PULSE=$URL_aarch64_PULSE; \
else \
echo "Unsupported platform ["$ARCH"]"; \
fi && \
echo "Downloading for architecture [$ARCH]"; \
wget $SL_URL -O /assets/sourceforge/squeezelite.tar.gz; \
mkdir /assets/sourceforge/expanded; \
tar xzvf /assets/sourceforge/squeezelite.tar.gz -C /assets/sourceforge/expanded; \
ls -la /assets/sourceforge/expanded/; \
mv /assets/sourceforge/expanded/squeezelite $OUTPUT_FILE; \
wget $SL_URL_PULSE -O /assets/sourceforge/squeezelite-pulse.tar.gz; \
mkdir /assets/sourceforge/expanded-pulse; \
tar xzvf /assets/sourceforge/squeezelite-pulse.tar.gz -C /assets/sourceforge/expanded-pulse; \
ls -la /assets/sourceforge/expanded-pulse/; \
mv /assets/sourceforge/expanded-pulse/squeezelite $OUTPUT_FILE_PULSE; \
apt-get purge wget -y; \
apt-get autoremove -y; \
rm -Rf \"/var/lib/apt/lists/*\"; \
rm -Rf /assets; \
else \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y; \
apt-get install squeezelite --no-install-recommends -y; \
cp /usr/bin/squeezelite /app/bin/squeezelite; \
apt-get install squeezelite-pulseaudio --no-install-recommends -y; \
cp /usr/bin/squeezelite-pulseaudio /app/bin/squeezelite-pulseaudio; \
apt-get install pulseaudio --no-install-recommends -y; \
apt-get remove squeezelite* -y; \
rm -rf \"/var/lib/apt/lists/*\"; \
fi'

/bin/bash install-script.sh

0 comments on commit 2e8521c

Please sign in to comment.