From 236f128117b215238dac53f715683225077ad52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 25 Oct 2014 21:48:57 +0200 Subject: [PATCH] shairplay: add new package. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- multimedia/shairplay/Makefile | 56 +++++++++++++++++++ multimedia/shairplay/files/shairplay.config | 9 +++ multimedia/shairplay/files/shairplay.init | 47 ++++++++++++++++ .../shairplay/patches/001-key_file_dir.patch | 11 ++++ .../patches/002-libavahi-compat-dnssd.patch | 11 ++++ .../patches/003-fix_big-endian.patch | 24 ++++++++ 6 files changed, 158 insertions(+) create mode 100644 multimedia/shairplay/Makefile create mode 100644 multimedia/shairplay/files/shairplay.config create mode 100644 multimedia/shairplay/files/shairplay.init create mode 100644 multimedia/shairplay/patches/001-key_file_dir.patch create mode 100644 multimedia/shairplay/patches/002-libavahi-compat-dnssd.patch create mode 100644 multimedia/shairplay/patches/003-fix_big-endian.patch diff --git a/multimedia/shairplay/Makefile b/multimedia/shairplay/Makefile new file mode 100644 index 000000000..9653c925b --- /dev/null +++ b/multimedia/shairplay/Makefile @@ -0,0 +1,56 @@ +# +# Copyright (C) 2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=shairplay +PKG_VERSION:=2014-10-25 +PKG_RELEASE:=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=git://github.com/juhovh/shairplay.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=64d59e3087f829006d091fa0d114efb50972a2bf +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz +PKG_MAINTAINER:=Álvaro Fernández Rojas + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +PKG_FIXUP:=libtool + +define Package/shairplay + SECTION:=multimedia + CATEGORY:=Multimedia + DEPENDS:=+avahi-daemon +libao +libavahi-compat-libdnssd +libltdl +libpthread + TITLE:=Shairplay +endef + +define Build/Configure + (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH); \ + ./autogen.sh;) + $(call Build/Configure/Default) +endef + +define Package/shairplay/description + Free portable AirPlay server implementation similar to ShairPort. +endef + +define Package/shairplay/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/shairplay $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/usr/share/shairplay + $(INSTALL_DATA) $(PKG_BUILD_DIR)/airport.key $(1)/usr/share/shairplay/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) files/shairplay.init $(1)/etc/init.d/shairplay + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) files/shairplay.config $(1)/etc/config/shairplay +endef + +$(eval $(call BuildPackage,shairplay)) diff --git a/multimedia/shairplay/files/shairplay.config b/multimedia/shairplay/files/shairplay.config new file mode 100644 index 000000000..6c4435cbd --- /dev/null +++ b/multimedia/shairplay/files/shairplay.config @@ -0,0 +1,9 @@ +config shairplay main + option disabled '1' + option apname 'AirPlay' + option port '5000' + option password '' + option hwaddr '' + option ao_driver 'oss' + option ao_devicename '' + option ao_deviceid '' diff --git a/multimedia/shairplay/files/shairplay.init b/multimedia/shairplay/files/shairplay.init new file mode 100644 index 000000000..2fcafe772 --- /dev/null +++ b/multimedia/shairplay/files/shairplay.init @@ -0,0 +1,47 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 OpenWrt.org + +START=90 +USE_PROCD=1 + +append_arg() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param command $opt="${val:-$def}" +} + +start_instance() { + local cfg="$1" + + config_get_bool disabled "$cfg" 'disabled' '0' + [ "$disabled" = 1 ] && return 1 + + procd_open_instance + + procd_set_param command /usr/bin/shairplay + + append_arg "$cfg" apname "--apname" "AirPlay" + append_arg "$cfg" port "--server_port" + append_arg "$cfg" password "--password" + append_arg "$cfg" hwaddr "--hwaddr" + + append_arg "$cfg" ao_driver "--ao_driver" + append_arg "$cfg" ao_devicename "--ao_devicename" + append_arg "$cfg" ao_deviceid "--ao_deviceid" + + procd_close_instance +} + +service_triggers() { + procd_add_reload_trigger "shairplay" +} + +start_service() { + config_load shairplay + config_foreach start_instance shairplay +} diff --git a/multimedia/shairplay/patches/001-key_file_dir.patch b/multimedia/shairplay/patches/001-key_file_dir.patch new file mode 100644 index 000000000..3c5e3a595 --- /dev/null +++ b/multimedia/shairplay/patches/001-key_file_dir.patch @@ -0,0 +1,11 @@ +--- a/src/shairplay.c ++++ b/src/shairplay.c +@@ -346,7 +346,7 @@ main(int argc, char *argv[]) + raop_cbs.audio_destroy = audio_destroy; + raop_cbs.audio_set_volume = audio_set_volume; + +- raop = raop_init_from_keyfile(10, &raop_cbs, "airport.key", NULL); ++ raop = raop_init_from_keyfile(10, &raop_cbs, "/usr/share/shairplay/airport.key", NULL); + if (raop == NULL) { + fprintf(stderr, "Could not initialize the RAOP service\n"); + fprintf(stderr, "Please make sure the airport.key file is in the current directory.\n"); diff --git a/multimedia/shairplay/patches/002-libavahi-compat-dnssd.patch b/multimedia/shairplay/patches/002-libavahi-compat-dnssd.patch new file mode 100644 index 000000000..ff70e24a6 --- /dev/null +++ b/multimedia/shairplay/patches/002-libavahi-compat-dnssd.patch @@ -0,0 +1,11 @@ +--- a/src/lib/dnssd.c ++++ b/src/lib/dnssd.c +@@ -167,7 +167,7 @@ dnssd_init(int *error) + return NULL; + } + #elif USE_LIBDL +- dnssd->module = dlopen("libdns_sd.so", RTLD_LAZY); ++ dnssd->module = dlopen("libdns_sd.so.1", RTLD_LAZY); + if (!dnssd->module) { + if (error) *error = DNSSD_ERROR_LIBNOTFOUND; + free(dnssd); diff --git a/multimedia/shairplay/patches/003-fix_big-endian.patch b/multimedia/shairplay/patches/003-fix_big-endian.patch new file mode 100644 index 000000000..7764aabc6 --- /dev/null +++ b/multimedia/shairplay/patches/003-fix_big-endian.patch @@ -0,0 +1,24 @@ +--- a/src/lib/alac/alac.c ++++ b/src/lib/alac/alac.c +@@ -29,11 +29,7 @@ + * + */ + +-#ifdef __BIG_ENDIAN__ +-static const int host_bigendian = 1; +-#else +-static const int host_bigendian = 0; +-#endif ++static int host_bigendian = 0; + + #include + #include +@@ -1181,6 +1177,8 @@ alac_file *create_alac(int samplesize, i + { + alac_file *newfile = malloc(sizeof(alac_file)); + ++ host_bigendian = (htonl(42) == 42); ++ + newfile->samplesize = samplesize; + newfile->numchannels = numchannels; + newfile->bytespersample = (samplesize / 8) * numchannels;