Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile against upstream librespot. #672

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ RUN mkdir /build \
&& echo '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' > /.cargo/config \
&& echo '[target.armv7-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config \
&& cargo install --jobs "$(nproc)" cargo-deb \
&& dpkg --add-architecture arm64 \
;

RUN dpkg --add-architecture arm64 \
&& dpkg --add-architecture armhf \
&& apt-get update \
&& apt-get -y upgrade \
Expand All @@ -31,11 +33,18 @@ RUN mkdir /build \
crossbuild-essential-armhf \
libasound2-dev:armhf \
libpulse-dev:armhf \
cmake \
clang-16 \
git \
bc \
dpkg-dev \
liblzma-dev \
pkg-config \
gettext-base \
&& rm -rf /var/lib/apt/lists/* \
&& git config --global --add safe.directory /mnt/raspotify
;

RUN cargo install --force --locked --root /usr bindgen-cli

RUN git config --global --add safe.directory /mnt/raspotify \
&& git config --global --add safe.directory /mnt/raspotify/librespot
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MIT License

Copyright (c) 2017-2023, David Cooper <david@dtcooper.com>
Copyright (c) 2021-2023, Jason Gray <jasonlevigray3@gmail.com>
Copyright (c) 2024, Kim Tore Jensen <kimtjen@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: all armhf arm64 amd64 clean distclean
.DEFAULT_GOAL := all

RASPOTIFY_AUTHOR?=Jason Gray <jasonlevigray3@gmail.com>
RASPOTIFY_AUTHOR?=Kim Tore Jensen <kimtjen@gmail.com>

armhf:
docker build -t raspotify .
Expand Down
31 changes: 16 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,8 @@ packages() {
cd /mnt/raspotify

if [ ! -d librespot ]; then
# Use a vendored version of librespot.
# https://github.com/librespot-org/librespot does not regularly or
# really ever update their dependencies on released versions.
# https://github.com/librespot-org/librespot/pull/1068
echo "Get https://github.com/JasonLG1979/librespot/tree/raspotify..."
git clone https://github.com/JasonLG1979/librespot
cd librespot
git checkout raspotify
cd /mnt/raspotify
echo "Get https://github.com/librespot-org/librespot/tree/dev..."
git clone --branch dev https://github.com/librespot-org/librespot
fi

DOC_DIR="raspotify/usr/share/doc/raspotify"
Expand All @@ -60,17 +53,25 @@ packages() {

cd librespot

# Get the git rev of librespot for .deb versioning
LIBRESPOT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo unknown)"
# We really should use the git rev of librespot for .deb versioning.
# The latest tag as of writing (0.4.2) is misleading because it doesn't reflect
# the fact we are using the dev branch (staged for 0.5.0).
#
# Hardcoding 0.5.0-dev in combination with the git hash suffix seems to be an
# acceptable solution as long as the raspotify version also is bumped every
# time we update against librespot.
#
#LIBRESPOT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo unknown)"
LIBRESPOT_VER=v0.5.0-dev
LIBRESPOT_HASH="$(git rev-parse HEAD | cut -c 1-7 2>/dev/null || echo unknown)"

echo "Build Librespot binary..."
cargo build --jobs "$(nproc)" --profile raspotify --target "$BUILD_TARGET" --no-default-features --features "alsa-backend pulseaudio-backend"
cargo build --jobs "$(nproc)" --profile release --target "$BUILD_TARGET" --no-default-features --features "alsa-backend pulseaudio-backend"

echo "Copy Librespot binary to package root..."
cd /mnt/raspotify

cp -v /build/"$BUILD_TARGET"/raspotify/librespot raspotify/usr/bin
cp -v /build/"$BUILD_TARGET"/release/librespot raspotify/usr/bin

# Compute final package version + filename for Debian control file
DEB_PKG_VER="${RASPOTIFY_GIT_VER}~librespot.${LIBRESPOT_VER}-${LIBRESPOT_HASH}"
Expand Down Expand Up @@ -181,8 +182,8 @@ case $ARCHITECTURE in
;;
esac

# Perm fixup. Not needed on macOS, but is on Linux
chown -R "$PERMFIX_UID:$PERMFIX_GID" /mnt/raspotify 2>/dev/null || true
# Fix broken permissions resulting from running the Docker container as root.
[ $(id -u) -eq 0 ] && chown -R "$PERMFIX_UID:$PERMFIX_GID" /mnt/raspotify 2>/dev/null

BUILD_TIME=$(duration_since "$START_BUILDS")

Expand Down