Browse Source

acpid: Import from oldpackages, update to latest version, add myself as

maintainer, ensure musl compatibility

 - with acpid kvm based setups can react on acpi shutdown and reboot
 actions

Signed-off-by: heil <heil@terminal-consulting.de>
heil 9 years ago
parent
commit
3661e01a0d

+ 68
- 0
utils/acpid/Makefile View File

@@ -0,0 +1,68 @@
1
+#
2
+# Copyright (C) 2012-2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=acpid
11
+PKG_VERSION:=2.0.23
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15
+PKG_SOURCE_URL:=@SF/acpid2 
16
+PKG_MD5SUM:=d7bcdcdefcd53b03730e50ba842554ea
17
+PKG_MAINTAINER:=Thomas Heil<heil@terminal-consulting.de>
18
+PKG_LICENSE:=GPL-2.0
19
+PKG_LICENSE_FILES:=COPYING
20
+
21
+include $(INCLUDE_DIR)/package.mk
22
+
23
+define Package/acpid
24
+  SECTION:=utils
25
+  CATEGORY:=Utilities
26
+  TITLE:=The ACPI Daemon (acpid) With Netlink Support
27
+  URL:=http://tedfelix.com/linux/acpid-netlink.html
28
+  DEPENDS:=@(TARGET_x86||TARGET_x86_64) +kmod-input-evdev 
29
+endef
30
+
31
+define Package/acpid/description
32
+  The ACPI Daemon (acpid) With Netlink Support
33
+endef
34
+
35
+define Build/Compile
36
+	$(MAKE) -C $(PKG_BUILD_DIR) \
37
+		CC="$(TARGET_CC)" \
38
+		LD="$(TARGET_CC)" \
39
+		LDFLAGS="$(TARGET_LDFLAGS)" \
40
+		all
41
+endef
42
+
43
+define Package/acpid/install
44
+	$(INSTALL_DIR) $(1)/usr/sbin
45
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpid $(1)/usr/sbin/
46
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpi_listen $(1)/usr/sbin/
47
+	$(INSTALL_DIR) $(1)/etc/acpi/events
48
+	$(INSTALL_CONF) ./files/default $(1)/etc/acpi/events/default
49
+	$(INSTALL_DIR) $(1)/etc/init.d
50
+	$(INSTALL_CONF) ./files/acpid.init $(1)/etc/init.d/acpid
51
+	chmod 0750 $(1)/etc/init.d/acpid
52
+	$(INSTALL_DIR) $(1)/etc/hotplug.d/input/
53
+	$(INSTALL_CONF) ./files/acpid.hotplug $(1)/etc/hotplug.d/input/
54
+endef
55
+
56
+define Package/acpid/postinst
57
+#!/bin/sh
58
+[ -n "$${IPKG_INSTROOT}" ] || {
59
+	echo "waiting for input devices to come up"
60
+	/etc/init.d/acpid enable
61
+	sleep 5
62
+	/etc/init.d/acpid start
63
+	echo "please try the power button"
64
+	exit 0
65
+}
66
+endef
67
+
68
+$(eval $(call BuildPackage,acpid))

+ 7
- 0
utils/acpid/files/acpid.hotplug View File

@@ -0,0 +1,7 @@
1
+#!/bin/sh
2
+
3
+. /lib/functions.sh
4
+
5
+if [ "$ACTION" = add ] && [ "$DEVICENAME" = event0 ]; then
6
+        ( /etc/init.d/acpid/stop; sleep 3; /usr/sbin/acpid )&
7
+fi

+ 25
- 0
utils/acpid/files/acpid.init View File

@@ -0,0 +1,25 @@
1
+#!/bin/ash /etc/rc.common
2
+# Copyright (C) 2009-2010 OpenWrt.org
3
+
4
+START=99
5
+STOP=80
6
+
7
+ACPID_BIN="/usr/sbin/acpid"
8
+ACPID_PID="/var/run/acpid.pid"
9
+
10
+start() {
11
+    [ -x "$ACPID_BIN" ] || return 1
12
+    start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
13
+}
14
+
15
+boot() {
16
+	# Do nothing on boot
17
+    	[ -x "$ACPID_BIN" ] || return 1
18
+	start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
19
+	exit 0
20
+}
21
+
22
+stop() {
23
+	service_kill ${ACPID_BIN##*/} $ACPID_PID
24
+	rm -f $ACPID_PID
25
+}

+ 5
- 0
utils/acpid/files/default View File

@@ -0,0 +1,5 @@
1
+# This is a sample ACPID configuration
2
+
3
+event=button/power.*
4
+action=/sbin/poweroff 
5
+

+ 129
- 0
utils/acpid/patches/001-musl-compat.patch View File

@@ -0,0 +1,129 @@
1
+Index: acpid-2.0.23/tempfailure.h
2
+===================================================================
3
+--- /dev/null
4
++++ acpid-2.0.23/tempfailure.h
5
+@@ -0,0 +1,8 @@
6
++#ifndef TEMP_FAILURE_RETRY
7
++#define TEMP_FAILURE_RETRY(expression) \
8
++  (__extension__                                                              \
9
++    ({ long int __result;                                                     \
10
++       do __result = (long int) (expression);                                 \
11
++       while (__result == -1L && errno == EINTR);                             \
12
++       __result; }))
13
++#endif
14
+Index: acpid-2.0.23/acpi_listen.c
15
+===================================================================
16
+--- acpid-2.0.23.orig/acpi_listen.c
17
++++ acpid-2.0.23/acpi_listen.c
18
+@@ -39,6 +39,8 @@
19
+ #include "acpid.h"
20
+ #include "ud_socket.h"
21
+ 
22
++#include "tempfailure.h"
23
++
24
+ static int handle_cmdline(int *argc, char ***argv);
25
+ static char *read_line(int fd);
26
+ 
27
+Index: acpid-2.0.23/acpid.c
28
+===================================================================
29
+--- acpid-2.0.23.orig/acpid.c
30
++++ acpid-2.0.23/acpid.c
31
+@@ -41,6 +41,7 @@
32
+ #include "input_layer.h"
33
+ #include "inotify_handler.h"
34
+ #include "netlink.h"
35
++#include "tempfailure.h"
36
+ 
37
+ static int handle_cmdline(int *argc, char ***argv);
38
+ static void close_fds(void);
39
+Index: acpid-2.0.23/event.c
40
+===================================================================
41
+--- acpid-2.0.23.orig/event.c
42
++++ acpid-2.0.23/event.c
43
+@@ -40,6 +40,9 @@
44
+ #include "sock.h"
45
+ #include "ud_socket.h"
46
+ #include "event.h"
47
++
48
++#include "tempfailure.h"
49
++
50
+ /*
51
+  * What is a rule?  It's polymorphic, pretty much.
52
+  */
53
+Index: acpid-2.0.23/input_layer.c
54
+===================================================================
55
+--- acpid-2.0.23.orig/input_layer.c
56
++++ acpid-2.0.23/input_layer.c
57
+@@ -47,6 +47,8 @@
58
+ 
59
+ #define DIM(a)  (sizeof(a) / sizeof(a[0]))
60
+ 
61
++#include "tempfailure.h"
62
++
63
+ struct evtab_entry {
64
+ 	struct input_event event;
65
+ 	const char *str;
66
+Index: acpid-2.0.23/kacpimon/libnetlink.c
67
+===================================================================
68
+--- acpid-2.0.23.orig/kacpimon/libnetlink.c
69
++++ acpid-2.0.23/kacpimon/libnetlink.c
70
+@@ -26,6 +26,8 @@
71
+ 
72
+ #include "libnetlink.h"
73
+ 
74
++#include "../tempfailure.h"
75
++
76
+ void rtnl_close(struct rtnl_handle *rth)
77
+ {
78
+ 	if (rth->fd >= 0) {
79
+Index: acpid-2.0.23/netlink.c
80
+===================================================================
81
+--- acpid-2.0.23.orig/netlink.c
82
++++ acpid-2.0.23/netlink.c
83
+@@ -46,6 +46,7 @@
84
+ #include "connection_list.h"
85
+ 
86
+ #include "netlink.h"
87
++#include "tempfailure.h"
88
+ 
89
+ static void
90
+ format_netlink(struct nlmsghdr *msg)
91
+Index: acpid-2.0.23/proc.c
92
+===================================================================
93
+--- acpid-2.0.23.orig/proc.c
94
++++ acpid-2.0.23/proc.c
95
+@@ -34,6 +34,8 @@
96
+ 
97
+ #include "proc.h"
98
+ 
99
++#include "tempfailure.h"
100
++
101
+ const char *eventfile = ACPID_EVENTFILE;
102
+ 
103
+ static char *read_line(int fd);
104
+Index: acpid-2.0.23/ud_socket.c
105
+===================================================================
106
+--- acpid-2.0.23.orig/ud_socket.c
107
++++ acpid-2.0.23/ud_socket.c
108
+@@ -22,6 +22,8 @@
109
+ #include "log.h"
110
+ #include "ud_socket.h"
111
+ 
112
++#include "tempfailure.h"
113
++
114
+ int
115
+ ud_create_socket(const char *name, mode_t socketmode)
116
+ {
117
+Index: acpid-2.0.23/libnetlink.c
118
+===================================================================
119
+--- acpid-2.0.23.orig/libnetlink.c
120
++++ acpid-2.0.23/libnetlink.c
121
+@@ -26,6 +26,8 @@
122
+ 
123
+ #include "libnetlink.h"
124
+ 
125
++#include "tempfailure.h"
126
++
127
+ void rtnl_close(struct rtnl_handle *rth)
128
+ {
129
+ 	if (rth->fd >= 0) {

+ 21
- 0
utils/acpid/patches/002-dont-use-isfdtype.patch View File

@@ -0,0 +1,21 @@
1
+Partially roll back upstream commit 4711119089e1ad08dad206f4fded68f1972fdeed
2
+since released versions of uClibc don't support isfdtype().
3
+
4
+Signed-off-by: Gustavo Zaarias <gustavo@zacarias.com.ar>
5
+
6
+Index: acpid-2.0.23/sock.c
7
+===================================================================
8
+--- acpid-2.0.23.orig/sock.c
9
++++ acpid-2.0.23/sock.c
10
+@@ -53,7 +53,10 @@ int non_root_clients;
11
+ int
12
+ is_socket(int fd)
13
+ {
14
+-    return (isfdtype(fd, S_IFSOCK) == 1);
15
++	int v;
16
++	socklen_t l = sizeof(int);
17
++
18
++	return (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
19
+ }
20
+ 
21
+ /* accept a new client connection */