From 6cc6c45ecda6cae655f5c2c1fddde60b9d505d96 Mon Sep 17 00:00:00 2001 From: Peter Steenbergen Date: Fri, 10 Jan 2020 14:55:23 +0100 Subject: [PATCH 1/2] MycroftOS: Add spotifyd (Spotify connect) package. --- buildroot-external/Config.in | 1 + buildroot-external/configs/rpi3_defconfig | 1 + buildroot-external/package/spotifyd/Config.in | 6 + .../package/spotifyd/spotifyd.conf | 14 ++ .../package/spotifyd/spotifyd.mk | 45 +++++ .../package/spotifyd/spotifyd.service | 18 ++ ...d-rust-to-latest-versions-and-don-t-.patch | 181 ++++++++++++++++++ 7 files changed, 266 insertions(+) create mode 100644 buildroot-external/package/spotifyd/Config.in create mode 100644 buildroot-external/package/spotifyd/spotifyd.conf create mode 100644 buildroot-external/package/spotifyd/spotifyd.mk create mode 100644 buildroot-external/package/spotifyd/spotifyd.service create mode 100644 buildroot-patches/0031-Upgrade-cargo-and-rust-to-latest-versions-and-don-t-.patch diff --git a/buildroot-external/Config.in b/buildroot-external/Config.in index e7b4f4bc..ad8f2a0c 100644 --- a/buildroot-external/Config.in +++ b/buildroot-external/Config.in @@ -9,6 +9,7 @@ menu "Additional drivers, libraries and/or applications" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/alsa-plugins/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/fann/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/respeaker/Config.in" + source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/spotifyd/Config.in" endmenu menu "Additional external python modules" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-adapt-parser/Config.in" diff --git a/buildroot-external/configs/rpi3_defconfig b/buildroot-external/configs/rpi3_defconfig index e66ddfec..d8d76793 100644 --- a/buildroot-external/configs/rpi3_defconfig +++ b/buildroot-external/configs/rpi3_defconfig @@ -316,6 +316,7 @@ BR2_PACKAGE_WIFI_AP=y BR2_PACKAGE_ALSA_PLUGINS=y BR2_PACKAGE_FANN=y BR2_PACKAGE_RESPEAKER=y +BR2_PACKAGE_SPOTIFYD=y BR2_PACKAGE_PYTHON_ADAPT_PARSER=y BR2_PACKAGE_PYTHON_COLORZERO=y BR2_PACKAGE_PYTHON_COVERALLS=y diff --git a/buildroot-external/package/spotifyd/Config.in b/buildroot-external/package/spotifyd/Config.in new file mode 100644 index 00000000..b1f6397c --- /dev/null +++ b/buildroot-external/package/spotifyd/Config.in @@ -0,0 +1,6 @@ +config BR2_PACKAGE_SPOTIFYD + bool "spotifyd" + depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_CARGO + help + An open source Spotify client running as a UNIX daemon. diff --git a/buildroot-external/package/spotifyd/spotifyd.conf b/buildroot-external/package/spotifyd/spotifyd.conf new file mode 100644 index 00000000..704f24f4 --- /dev/null +++ b/buildroot-external/package/spotifyd/spotifyd.conf @@ -0,0 +1,14 @@ +[global] +# The port `spotifyd` uses to announce its service over the network. +zeroconf_port = 57621 + +# Cleartext username and password for remote Spotify access. +# Make sure the file is only accessible by spotifyd. +# username = USER +# password = PASS + +# alsa, pulseaudio or pipe +backend = pulseaudio + +# Name in Spotify Connect, cannot contain spaces: +device_name = MycroftOS-Spotify diff --git a/buildroot-external/package/spotifyd/spotifyd.mk b/buildroot-external/package/spotifyd/spotifyd.mk new file mode 100644 index 00000000..f87e5d57 --- /dev/null +++ b/buildroot-external/package/spotifyd/spotifyd.mk @@ -0,0 +1,45 @@ +################################################################################ +# +# spotifyd +# +################################################################################ + +SPOTIFYD_VERSION = v0.2.20 +SPOTIFYD_SITE = $(call github,Spotifyd,spotifyd,$(SPOTIFYD_VERSION)) +SPOTIFYD_LICENSE = GPL-3.0 +SPOTIFYD_LICENSE_FILES = LICENSE + +SPOTIFYD_DEPENDENCIES = host-cargo + +SPOTIFYD_CARGO_ENV = CARGO_HOME=$(HOST_DIR)/share/cargo \ + CC=$(HOST_DIR)/bin/arm-buildroot-linux-gnueabihf-gcc \ + HOST_CC=gcc \ + PKG_CONFIG_ALLOW_CROSS=1 \ + OPENSSL_LIB_DIR=$(HOST_DIR)/lib \ + OPENSSL_INCLUDE_DIR=$(HOST_DIR)/include +SPOTIFYD_BIN_DIR = target/$(RUSTC_TARGET_NAME)/release + +SPOTIFYD_CARGO_OPTS = --release \ + --no-default-features \ + --features=pulseaudio_backend \ + --target=$(RUSTC_TARGET_NAME) \ + --manifest-path=$(@D)/Cargo.toml + +define SPOTIFYD_BUILD_CMDS + $(TARGET_MAKE_ENV) $(SPOTIFYD_CARGO_ENV) rustc -V + $(TARGET_MAKE_ENV) $(SPOTIFYD_CARGO_ENV) cargo build $(SPOTIFYD_CARGO_OPTS) +endef + +define SPOTIFYD_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/$(SPOTIFYD_BIN_DIR)/spotifyd \ + $(TARGET_DIR)/usr/bin/spotifyd + $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/spotifyd/spotifyd.conf \ + $(TARGET_DIR)/etc/spotifyd.conf +endef + +define SPOTIFYD_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/spotifyd/spotifyd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/spotifyd.service +endef + +$(eval $(generic-package)) diff --git a/buildroot-external/package/spotifyd/spotifyd.service b/buildroot-external/package/spotifyd/spotifyd.service new file mode 100644 index 00000000..657276c9 --- /dev/null +++ b/buildroot-external/package/spotifyd/spotifyd.service @@ -0,0 +1,18 @@ +[Unit] +Description=A Spotify connect daemon +Documentation=https://github.com/Spotifyd/spotifyd +Wants=sound.target +After=sound.target +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +ExecStart=/usr/sbin/spotifyd --no-daemon +Restart=always +RestartSec=5 +StandardOutput=file:/var/log/spotifyd.log +StandardError=file:/var/log/spotifyd.error.log + +[Install] +WantedBy=multi-user.target diff --git a/buildroot-patches/0031-Upgrade-cargo-and-rust-to-latest-versions-and-don-t-.patch b/buildroot-patches/0031-Upgrade-cargo-and-rust-to-latest-versions-and-don-t-.patch new file mode 100644 index 00000000..a51f93e6 --- /dev/null +++ b/buildroot-patches/0031-Upgrade-cargo-and-rust-to-latest-versions-and-don-t-.patch @@ -0,0 +1,181 @@ +From 74f3635c586b39279f4a1c4f716cba607a160b06 Mon Sep 17 00:00:00 2001 +From: Peter Steenbergen +Date: Fri, 10 Jan 2020 14:49:05 +0100 +Subject: [PATCH 1/1] Upgrade cargo and rust to latest versions and don't + bother the offline build / vendor stuff + +--- + package/cargo-bin/cargo-bin.hash | 2 +- + package/cargo-bin/cargo-bin.mk | 2 +- + package/cargo/cargo.hash | 4 ++-- + package/cargo/cargo.mk | 34 +++----------------------------- + package/rust-bin/rust-bin.hash | 6 +++--- + package/rust-bin/rust-bin.mk | 2 +- + package/rust/rust.mk | 2 +- + 7 files changed, 12 insertions(+), 40 deletions(-) + +diff --git a/package/cargo-bin/cargo-bin.hash b/package/cargo-bin/cargo-bin.hash +index 0e9e9c5c61..1d5b600dab 100644 +--- a/package/cargo-bin/cargo-bin.hash ++++ b/package/cargo-bin/cargo-bin.hash +@@ -6,7 +6,7 @@ sha256 13acdb3c9f2505805ceed8a696f5f62ab8cd73e443cd43d6edd588aad88e1c32 cargo-0 + sha256 6628db22370f397676195555d768f0449a60f0a694bcac24611f4cd1cfc97cdc cargo-0.33.0-powerpc64le-unknown-linux-gnu.tar.xz + # From https://static.rust-lang.org/dist/cargo-0.33.0-x86_64-unknown-linux-gnu.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/cargo-0.33.0-x86_64-unknown-linux-gnu.tar.xz.asc +-sha256 c2c31db68c4dcb50ad856a19e6f11489a0d4df1212f31bd068dfbb73c5425761 cargo-0.33.0-x86_64-unknown-linux-gnu.tar.xz ++sha256 9b6ae643fa240c5ecbc1dc390f4020b6a683f25bac6f7437ebd4b9d32a8d0b6c cargo-0.41.0-x86_64-unknown-linux-gnu.tar.xz + # Locally generated + sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE + sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT +diff --git a/package/cargo-bin/cargo-bin.mk b/package/cargo-bin/cargo-bin.mk +index 3614f7a53d..87c528a200 100644 +--- a/package/cargo-bin/cargo-bin.mk ++++ b/package/cargo-bin/cargo-bin.mk +@@ -4,7 +4,7 @@ + # + ################################################################################ + +-CARGO_BIN_VERSION = 0.33.0 ++CARGO_BIN_VERSION = 0.41.0 + CARGO_BIN_SITE = https://static.rust-lang.org/dist + CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUSTC_HOST_NAME).tar.xz + CARGO_BIN_LICENSE = Apache-2.0 or MIT +diff --git a/package/cargo/cargo.hash b/package/cargo/cargo.hash +index baa2cfbc33..e16d727b61 100644 +--- a/package/cargo/cargo.hash ++++ b/package/cargo/cargo.hash +@@ -1,6 +1,6 @@ + # Locally generated +-sha256 1a4bae6910ca895157a1abe8225eb2b7e9b49ee1ee1e4e72fb81cb8e1446bff9 cargo-0.26.0.tar.gz +-sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz ++sha256 77b2e5b5207ed30dd6e6af934663f0c4553968dce575f95ca7e141444b6e9704 cargo-0.41.0.tar.gz ++sha256 531bd9147b15ea9c061e24038c2100c4beac8b023d2877db1bb5d85efeefe76e rust-installer-9f66c14c3f91a48a118c7817f434167b311c3515.tar.gz + sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE + sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT + sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880 LICENSE-THIRD-PARTY +diff --git a/package/cargo/cargo.mk b/package/cargo/cargo.mk +index a387281b4c..6541d26c44 100644 +--- a/package/cargo/cargo.mk ++++ b/package/cargo/cargo.mk +@@ -4,22 +4,16 @@ + # + ################################################################################ + +-CARGO_VERSION = 0.26.0 ++CARGO_VERSION = 0.41.0 + CARGO_SITE = $(call github,rust-lang,cargo,$(CARGO_VERSION)) + CARGO_LICENSE = Apache-2.0 or MIT + CARGO_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +-CARGO_DEPS_SHA512 = 6ed2a1644c9b18fc24ddad5350d41b6c36cd5b62de4cf0b748a57b589f4f0ac12f91461989158d58d0892bf6fc2c1626cf574e7e2b9da4b0e35f72dfd88f9048 +-CARGO_DEPS_SITE = https://src.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512) +-CARGO_DEPS_SOURCE = cargo-$(CARGO_VERSION)-vendor.tar.xz +- +-CARGO_INSTALLER_VERSION = 4f994850808a572e2cc8d43f968893c8e942e9bf ++CARGO_INSTALLER_VERSION = 9f66c14c3f91a48a118c7817f434167b311c3515 + CARGO_INSTALLER_SITE = $(call github,rust-lang,rust-installer,$(CARGO_INSTALLER_VERSION)) + CARGO_INSTALLER_SOURCE = rust-installer-$(CARGO_INSTALLER_VERSION).tar.gz + +-HOST_CARGO_EXTRA_DOWNLOADS = \ +- $(CARGO_DEPS_SITE)/$(CARGO_DEPS_SOURCE) \ +- $(CARGO_INSTALLER_SITE)/$(CARGO_INSTALLER_SOURCE) ++HOST_CARGO_EXTRA_DOWNLOADS = $(CARGO_INSTALLER_SITE)/$(CARGO_INSTALLER_SOURCE) + + HOST_CARGO_DEPENDENCIES = \ + $(BR2_CMAKE_HOST_DEPENDENCY) \ +@@ -34,15 +28,6 @@ HOST_CARGO_DEPENDENCIES = \ + HOST_CARGO_SNAP_BIN = $(HOST_CARGO_BIN_DIR)/cargo/bin/cargo + HOST_CARGO_HOME = $(HOST_DIR)/share/cargo + +-define HOST_CARGO_EXTRACT_DEPS +- @mkdir -p $(@D)/vendor +- $(call suitable-extractor,$(CARGO_DEPS_SOURCE)) \ +- $(HOST_CARGO_DL_DIR)/$(CARGO_DEPS_SOURCE) | \ +- $(TAR) --strip-components=1 -C $(@D)/vendor $(TAR_OPTIONS) - +-endef +- +-HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_DEPS +- + define HOST_CARGO_EXTRACT_INSTALLER + @mkdir -p $(@D)/src/rust-installer + $(call suitable-extractor,$(CARGO_INSTALLER_SOURCE)) \ +@@ -52,19 +37,6 @@ endef + + HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_INSTALLER + +-define HOST_CARGO_SETUP_DEPS +- mkdir -p $(@D)/.cargo +- ( \ +- echo "[source.crates-io]"; \ +- echo "registry = 'https://github.com/rust-lang/crates.io-index'"; \ +- echo "replace-with = 'vendored-sources'"; \ +- echo "[source.vendored-sources]"; \ +- echo "directory = '$(@D)/vendor'"; \ +- ) > $(@D)/.cargo/config +-endef +- +-HOST_CARGO_PRE_CONFIGURE_HOOKS += HOST_CARGO_SETUP_DEPS +- + HOST_CARGO_SNAP_OPTS = \ + --release \ + $(if $(VERBOSE),--verbose) +diff --git a/package/rust-bin/rust-bin.hash b/package/rust-bin/rust-bin.hash +index 96d81a347c..f148032cce 100644 +--- a/package/rust-bin/rust-bin.hash ++++ b/package/rust-bin/rust-bin.hash +@@ -3,7 +3,7 @@ + sha256 90b6414eddbce4a245cdcaea8353d3a637ef565d2bd119e25a6c2bf3e38cdf63 rustc-1.33.0-i686-unknown-linux-gnu.tar.xz + # From https://static.rust-lang.org/dist/rustc-1.33.0-x86_64-unknown-linux-gnu.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/rustc-1.33.0-x86_64-unknown-linux-gnu.tar.xz.asc +-sha256 57c5ced1a826d34f26e50adf041528dd0000f2a59e8be32d2359386843382ce1 rustc-1.33.0-x86_64-unknown-linux-gnu.tar.xz ++sha256 b1c00618b7a98156e88b14682508a503284f85748eab23de749a20dcc8847111 rustc-1.40.0-x86_64-unknown-linux-gnu.tar.xz + # From https://static.rust-lang.org/dist/rust-std-1.33.0-aarch64-unknown-linux-gnu.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/rust-std-1.33.0-aarch64-unknown-linux-gnu.tar.xz.asc + sha256 3e3449dada8306b3ff91f23c7803c7312a47e93af140f757b29b74f1e226a505 rust-std-1.33.0-aarch64-unknown-linux-gnu.tar.xz +@@ -12,7 +12,7 @@ sha256 3e3449dada8306b3ff91f23c7803c7312a47e93af140f757b29b74f1e226a505 rust-st + sha256 ddb372a43fb2ba9949e78643df43d6ae447b70cefd440ccdd6b9f6c2ff929ea7 rust-std-1.33.0-arm-unknown-linux-gnueabi.tar.xz + # From https://static.rust-lang.org/dist/rust-std-1.33.0-arm-unknown-linux-gnueabihf.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/rust-std-1.33.0-arm-unknown-linux-gnueabihf.tar.xz.asc +-sha256 1142d5064d8cbfab16ab71130e5a84804a1ebdfeb10173e6238adc0d757937b6 rust-std-1.33.0-arm-unknown-linux-gnueabihf.tar.xz ++sha256 f16b2cf9103127140f85d21c2753d85d45b90a9309967e3a788867fd7d95a6c1 rust-std-1.40.0-arm-unknown-linux-gnueabihf.tar.xz + # From https://static.rust-lang.org/dist/rust-std-1.33.0-armv7-unknown-linux-gnueabihf.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/rust-std-1.33.0-armv7-unknown-linux-gnueabihf.tar.xz.asc + sha256 8492b5c91a9ea7ee7e22881382c1b9ad8bb9a4147aff0dfee09940b34783e3d5 rust-std-1.33.0-armv7-unknown-linux-gnueabihf.tar.xz +@@ -42,7 +42,7 @@ sha256 4bc32bf4660a9fc5cd2af9e09f1bfb668b335442097fed6f3892b50950e97d3c rust-st + sha256 984d3ca2a47db04345a2bddd657761f66d209ef95a02097ad4bd549f45a0dc9f rust-std-1.33.0-powerpc64le-unknown-linux-gnu.tar.xz + # From https://static.rust-lang.org/dist/rust-std-1.33.0-x86_64-unknown-linux-gnu.tar.xz.sha256 + # Verified using https://static.rust-lang.org/dist/rust-std-1.33.0-x86_64-unknown-linux-gnu.tar.xz.asc +-sha256 6f20343ed73faf5fdfc423bec38a9bb1910a0a962af6f2dddd7184407543ed0e rust-std-1.33.0-x86_64-unknown-linux-gnu.tar.xz ++sha256 5a0b14a51f51b0194f70a2023749d9cb49c3b2e11f0d4c8232960b91fad336ac rust-std-1.40.0-x86_64-unknown-linux-gnu.tar.xz + # Locally generated + sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE + sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT +diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk +index a374215e20..8d2f3c9eca 100644 +--- a/package/rust-bin/rust-bin.mk ++++ b/package/rust-bin/rust-bin.mk +@@ -4,7 +4,7 @@ + # + ################################################################################ + +-RUST_BIN_VERSION = 1.33.0 ++RUST_BIN_VERSION = 1.40.0 + RUST_BIN_SITE = https://static.rust-lang.org/dist + RUST_BIN_LICENSE = Apache-2.0 or MIT + RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT +diff --git a/package/rust/rust.mk b/package/rust/rust.mk +index 5d14fc6682..74e5c50e59 100644 +--- a/package/rust/rust.mk ++++ b/package/rust/rust.mk +@@ -4,7 +4,7 @@ + # + ################################################################################ + +-RUST_VERSION = 1.33.0 ++RUST_VERSION = 1.40.0 + RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz + RUST_SITE = https://static.rust-lang.org/dist + RUST_LICENSE = Apache-2.0 or MIT +-- +2.24.0.rc1 + From 68488da04733f82625771754399a817f0f0c6a50 Mon Sep 17 00:00:00 2001 From: Peter Steenbergen Date: Fri, 10 Jan 2020 19:03:26 +0100 Subject: [PATCH 2/2] MycroftOS: Stupid mistake + make sure spotify starts after PulseAudio. --- buildroot-external/package/spotifyd/spotifyd.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildroot-external/package/spotifyd/spotifyd.service b/buildroot-external/package/spotifyd/spotifyd.service index 657276c9..699a295a 100644 --- a/buildroot-external/package/spotifyd/spotifyd.service +++ b/buildroot-external/package/spotifyd/spotifyd.service @@ -5,10 +5,11 @@ Wants=sound.target After=sound.target Wants=network-online.target After=network-online.target +After=pulseaudio.service [Service] Type=simple -ExecStart=/usr/sbin/spotifyd --no-daemon +ExecStart=/usr/bin/spotifyd --no-daemon Restart=always RestartSec=5 StandardOutput=file:/var/log/spotifyd.log