瀏覽代碼

shairport: Update config and init scripts, fix build, remove libao dependency, add myself as pkg maintainer

Signed-off-by: Ted Hess <thess@kitschensync.net>
thess 10 年之前
父節點
當前提交
7fba5f8bee

+ 7
- 7
multimedia/shairport/Makefile 查看文件

@@ -1,5 +1,5 @@
1 1
 #
2
-# Copyright (C) 2013 OpenWrt.org
2
+# Copyright (C) 2013-2014 OpenWrt.org
3 3
 #
4 4
 # This is free software, licensed under the GNU General Public License v2.
5 5
 # See /LICENSE for more information.
@@ -9,21 +9,21 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=shairport
11 11
 PKG_VERSION:=2014-05-08
12
-PKG_RELEASE:=$(PKG_SOURCE_VERSION)
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_SOURCE_PROTO:=git
15 15
 PKG_SOURCE_URL:=git://github.com/abrasive/shairport.git
16 16
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 17
 PKG_SOURCE_VERSION:=078b21043cdcef6ffad7452db27f036770b23b0c
18 18
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
19
+PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
19 20
 
20 21
 include $(INCLUDE_DIR)/package.mk
21 22
 
22 23
 define Package/shairport
23 24
   SECTION:=multimedia
24 25
   CATEGORY:=Multimedia
25
-  DEPENDS:=+libpthread +avahi-utils +libopenssl +libao +libavahi-client \
26
-	+alsa-utils
26
+  DEPENDS:=+libpthread +avahi-utils +libopenssl +libavahi-client +alsa-utils
27 27
   TITLE:=ShairPort AirPort Express emulator
28 28
 endef
29 29
 
@@ -39,15 +39,15 @@ endef
39 39
 
40 40
 TARGET_CFLAGS += $(FPIC)
41 41
 
42
-LIBS:=-lao -lm -lcrypto -lpthread -lavahi-common -lavahi-client -lasound
42
+LIBS:=-lm -lcrypto -lpthread -lavahi-common -lavahi-client -lasound
43 43
 
44 44
 MAKE_FLAGS += \
45 45
 	CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
46 46
 	LDFLAGS="$(TARGET_LDFLAGS) $(LIBS)"
47 47
 
48 48
 define Package/shairport/install
49
-	$(INSTALL_DIR) $(1)/usr/sbin
50
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/shairport $(1)/usr/sbin/
49
+	$(INSTALL_DIR) $(1)/usr/bin
50
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/shairport $(1)/usr/bin/
51 51
 	$(INSTALL_DIR) $(1)/etc/init.d/
52 52
 	$(INSTALL_BIN) files/shairport.init $(1)/etc/init.d/shairport
53 53
 	$(INSTALL_DIR) $(1)/etc/config

+ 13
- 6
multimedia/shairport/files/shairport.config 查看文件

@@ -1,11 +1,18 @@
1
-config shairport
2
-	option name 'AirPort'
1
+config shairport main
2
+	option bname 'AirPort'
3 3
 	option password ''
4 4
 	option port '5002'
5 5
 	option buffer '256'
6
-	option log '/var/log/shairport'
6
+	option log ''
7 7
 	option cmd_start ''
8 8
 	option cmd_stop ''
9
-	option cmd_wait '0'
10
-	option audio_output ''
11
-	option mdns ''
9
+	option cmd_wait ''
10
+	option audio_output 'alsa'
11
+	option mdns 'avahi'
12
+
13
+	# options for alsa output
14
+	option output_dev ''
15
+	option mixer_dev ''
16
+	option mixer_type ''
17
+	option mixer_control ''
18
+	option mixer_index ''

+ 82
- 44
multimedia/shairport/files/shairport.init 查看文件

@@ -1,53 +1,91 @@
1 1
 #!/bin/sh /etc/rc.common
2
-# Copyright (C) 2013-2014 OpenWrt.org
3 2
 
4
-START=50
5
-USE_PROCD=1
3
+NAME=shairport
4
+START=94
6 5
 
7
-config_shairport() {
6
+SERVICE_DAEMONIZE=1
7
+SERVICE_WRITE_PID=1
8
+
9
+AP_PIDDIR=/var/run
10
+AP_BIN=/usr/bin/shairport
11
+
12
+append_arg() {
13
+        local cfg="$1"
14
+        local var="$2"
15
+        local opt="$3"
16
+        local def="$4"
17
+        local val
18
+
19
+        config_get val "$cfg" "$var"
20
+        [ -n "$val" -o -n "$def" ] && append AP_ARGS "$opt ${val:-$def}"
21
+}
22
+
23
+append_bool() {
24
+        local cfg="$1"
25
+        local var="$2"
26
+        local opt="$3"
27
+        local def="$4"
28
+        local val
29
+
30
+        config_get_bool val "$cfg" "$var" "$def"
31
+        [ "$val" = 1 ] && append AP_ARGS "$opt"
32
+}
33
+
34
+start_instance() {
35
+	AP_ARGS=""
36
+	local cfg="$1"
37
+	local ao dev
38
+
39
+	append_arg "$cfg" bname "-a" "AirPort"
40
+	append_arg "$cfg" log "-l"
41
+	append_arg "$cfg" initbuf "-b" "256"
42
+	append_arg "$cfg" port "-p" "5002"
43
+	append_arg "$cfg" password "-k"
44
+	append_arg "$cfg" mdns "-m"
45
+
46
+	append_arg "$cfg" cmd_start "-B"
47
+	append_arg "$cfg" cmd_stop "-E"
48
+	append_bool "$cfg" cmd_wait "-w"
49
+
50
+	append_arg "$cfg" audio_output "-o"
51
+
52
+	config_get ao "$cfg" audio_output ""
53
+	if [ "$ao" = "alsa" ]; then
54
+		config_get dev "$cfg" output_device ""
55
+		if [ -n "$dev" ]; then
56
+			append AP_ARGS "--"
57
+			append_arg "$cfg" output_device "-d"
58
+			append_arg "$cfg" mixer_device "-m"
59
+			append_arg "$cfg" mixer_type "-t"
60
+			append_arg "$cfg" mixer-control "-c"
61
+			append_arg "$cfg" mixer-index "-i"
62
+		fi
63
+	fi
64
+
65
+	SERVICE_PID_FILE=${AP_PIDDIR}/${NAME}_${cfg}.pid
66
+	service_start $AP_BIN $AP_ARGS
67
+
68
+	# Check if daemon is running, if not then
69
+	# re-execute in foreground to display error.
70
+	sleep 1 && service_check $AP_BIN || \
71
+		$AP_BIN $AP_ARGS
72
+}
73
+
74
+stop_instance()
75
+{
8 76
 	local cfg="$1"
9 77
 
10
-	local cfg_name
11
-	local cfg_password
12
-	local cfg_port
13
-	local cfg_buffer
14
-	local cfg_log
15
-	local cfg_cmd_start
16
-	local cfg_cmd_stop
17
-	local cfg_cmd_wait
18
-	local cfg_audio_output
19
-	local cfg_mdns
20
-
21
-	config_get cfg_name $cfg 'name' 'AirPort'
22
-	config_get cfg_password $cfg 'password' ''
23
-	config_get cfg_port $cfg 'port' '5002'
24
-	config_get cfg_buffer $cfg 'buffer' '256'
25
-	config_get cfg_log $cfg 'log' '/var/log/shairport'
26
-	config_get cfg_cmd_start $cfg 'cmd_start' ''
27
-	config_get cfg_cmd_stop $cfg 'cmd_stop' ''
28
-	config_get_bool cfg_cmd_wait $cfg 'cmd_wait' '0'
29
-	config_get cfg_audio_output $cfg 'audio_output' ''
30
-	config_get cfg_mdns $cfg 'mdns' ''
31
-
32
-	procd_open_instance
33
-
34
-	procd_set_param command /usr/sbin/shairport
35
-	procd_append_param command -a "$cfg_name"
36
-	[ ! -z "$cfg_password" ] && procd_append_param command -k "$cfg_password"
37
-	procd_append_param command -p $cfg_port
38
-	procd_append_param command -b $cfg_buffer
39
-	procd_append_param command -l $cfg_log
40
-	[ ! -z "$cfg_cmd_start" ] && procd_append_param command -B "$cfg_cmd_start"
41
-	[ ! -z "$cfg_cmd_stop" ] && procd_append_param command -E "$cfg_cmd_stop"
42
-	[ "$cfg_cmd_wait" -eq 1 ] && procd_append_param command -w
43
-	[ ! -z "$cfg_audio_output" ] && procd_append_param command -o "$cfg_audio_output"
44
-	[ ! -z "$cfg_mdns" ] && procd_append_param command -m "$cfg_mdns"
45
-
46
-	procd_set_param respawn
47
-	procd_close_instance
78
+	SERVICE_PID_FILE=${AP_PIDDIR}/${NAME}_${cfg}.pid
79
+	SERVICE_SIG_STOP="INT"
80
+	service_stop $AP_BIN
81
+}
82
+
83
+start() {
84
+	config_load shairport
85
+	config_foreach start_instance shairport
48 86
 }
49 87
 
50
-start_service() {
88
+stop() {
51 89
 	config_load shairport
52
-	config_foreach config_shairport shairport
90
+	config_foreach stop_instance shairport
53 91
 }

+ 2
- 1
multimedia/shairport/patches/001-disable_pulseaudio.patch 查看文件

@@ -3,8 +3,9 @@
3 3
 @@ -59,7 +59,7 @@ do_pkg_config()
4 4
  
5 5
  do_pkg_config OpenSSL       openssl
6
- do_pkg_config libao         ao              CONFIG_AO
6
+-do_pkg_config libao         ao              CONFIG_AO
7 7
 -do_pkg_config PulseAudio    libpulse-simple CONFIG_PULSE
8
++#do_pkg_config libao         ao              CONFIG_AO
8 9
 +#do_pkg_config PulseAudio    libpulse-simple CONFIG_PULSE
9 10
  do_pkg_config ALSA          alsa            CONFIG_ALSA
10 11
  do_pkg_config Avahi\ client avahi-client    CONFIG_AVAHI