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>
This commit is contained in:
parent
73a853e1cf
commit
3661e01a0d
6 changed files with 255 additions and 0 deletions
68
utils/acpid/Makefile
Normal file
68
utils/acpid/Makefile
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012-2015 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:=acpid
|
||||||
|
PKG_VERSION:=2.0.23
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
|
PKG_SOURCE_URL:=@SF/acpid2
|
||||||
|
PKG_MD5SUM:=d7bcdcdefcd53b03730e50ba842554ea
|
||||||
|
PKG_MAINTAINER:=Thomas Heil<heil@terminal-consulting.de>
|
||||||
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
PKG_LICENSE_FILES:=COPYING
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/acpid
|
||||||
|
SECTION:=utils
|
||||||
|
CATEGORY:=Utilities
|
||||||
|
TITLE:=The ACPI Daemon (acpid) With Netlink Support
|
||||||
|
URL:=http://tedfelix.com/linux/acpid-netlink.html
|
||||||
|
DEPENDS:=@(TARGET_x86||TARGET_x86_64) +kmod-input-evdev
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/acpid/description
|
||||||
|
The ACPI Daemon (acpid) With Netlink Support
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||||
|
CC="$(TARGET_CC)" \
|
||||||
|
LD="$(TARGET_CC)" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
|
all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/acpid/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpid $(1)/usr/sbin/
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpi_listen $(1)/usr/sbin/
|
||||||
|
$(INSTALL_DIR) $(1)/etc/acpi/events
|
||||||
|
$(INSTALL_CONF) ./files/default $(1)/etc/acpi/events/default
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_CONF) ./files/acpid.init $(1)/etc/init.d/acpid
|
||||||
|
chmod 0750 $(1)/etc/init.d/acpid
|
||||||
|
$(INSTALL_DIR) $(1)/etc/hotplug.d/input/
|
||||||
|
$(INSTALL_CONF) ./files/acpid.hotplug $(1)/etc/hotplug.d/input/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/acpid/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
[ -n "$${IPKG_INSTROOT}" ] || {
|
||||||
|
echo "waiting for input devices to come up"
|
||||||
|
/etc/init.d/acpid enable
|
||||||
|
sleep 5
|
||||||
|
/etc/init.d/acpid start
|
||||||
|
echo "please try the power button"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,acpid))
|
7
utils/acpid/files/acpid.hotplug
Normal file
7
utils/acpid/files/acpid.hotplug
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
if [ "$ACTION" = add ] && [ "$DEVICENAME" = event0 ]; then
|
||||||
|
( /etc/init.d/acpid/stop; sleep 3; /usr/sbin/acpid )&
|
||||||
|
fi
|
25
utils/acpid/files/acpid.init
Normal file
25
utils/acpid/files/acpid.init
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/ash /etc/rc.common
|
||||||
|
# Copyright (C) 2009-2010 OpenWrt.org
|
||||||
|
|
||||||
|
START=99
|
||||||
|
STOP=80
|
||||||
|
|
||||||
|
ACPID_BIN="/usr/sbin/acpid"
|
||||||
|
ACPID_PID="/var/run/acpid.pid"
|
||||||
|
|
||||||
|
start() {
|
||||||
|
[ -x "$ACPID_BIN" ] || return 1
|
||||||
|
start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
|
||||||
|
}
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
# Do nothing on boot
|
||||||
|
[ -x "$ACPID_BIN" ] || return 1
|
||||||
|
start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
service_kill ${ACPID_BIN##*/} $ACPID_PID
|
||||||
|
rm -f $ACPID_PID
|
||||||
|
}
|
5
utils/acpid/files/default
Normal file
5
utils/acpid/files/default
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# This is a sample ACPID configuration
|
||||||
|
|
||||||
|
event=button/power.*
|
||||||
|
action=/sbin/poweroff
|
||||||
|
|
129
utils/acpid/patches/001-musl-compat.patch
Normal file
129
utils/acpid/patches/001-musl-compat.patch
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
Index: acpid-2.0.23/tempfailure.h
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ acpid-2.0.23/tempfailure.h
|
||||||
|
@@ -0,0 +1,8 @@
|
||||||
|
+#ifndef TEMP_FAILURE_RETRY
|
||||||
|
+#define TEMP_FAILURE_RETRY(expression) \
|
||||||
|
+ (__extension__ \
|
||||||
|
+ ({ long int __result; \
|
||||||
|
+ do __result = (long int) (expression); \
|
||||||
|
+ while (__result == -1L && errno == EINTR); \
|
||||||
|
+ __result; }))
|
||||||
|
+#endif
|
||||||
|
Index: acpid-2.0.23/acpi_listen.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/acpi_listen.c
|
||||||
|
+++ acpid-2.0.23/acpi_listen.c
|
||||||
|
@@ -39,6 +39,8 @@
|
||||||
|
#include "acpid.h"
|
||||||
|
#include "ud_socket.h"
|
||||||
|
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
static int handle_cmdline(int *argc, char ***argv);
|
||||||
|
static char *read_line(int fd);
|
||||||
|
|
||||||
|
Index: acpid-2.0.23/acpid.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/acpid.c
|
||||||
|
+++ acpid-2.0.23/acpid.c
|
||||||
|
@@ -41,6 +41,7 @@
|
||||||
|
#include "input_layer.h"
|
||||||
|
#include "inotify_handler.h"
|
||||||
|
#include "netlink.h"
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
|
||||||
|
static int handle_cmdline(int *argc, char ***argv);
|
||||||
|
static void close_fds(void);
|
||||||
|
Index: acpid-2.0.23/event.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/event.c
|
||||||
|
+++ acpid-2.0.23/event.c
|
||||||
|
@@ -40,6 +40,9 @@
|
||||||
|
#include "sock.h"
|
||||||
|
#include "ud_socket.h"
|
||||||
|
#include "event.h"
|
||||||
|
+
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* What is a rule? It's polymorphic, pretty much.
|
||||||
|
*/
|
||||||
|
Index: acpid-2.0.23/input_layer.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/input_layer.c
|
||||||
|
+++ acpid-2.0.23/input_layer.c
|
||||||
|
@@ -47,6 +47,8 @@
|
||||||
|
|
||||||
|
#define DIM(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
struct evtab_entry {
|
||||||
|
struct input_event event;
|
||||||
|
const char *str;
|
||||||
|
Index: acpid-2.0.23/kacpimon/libnetlink.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/kacpimon/libnetlink.c
|
||||||
|
+++ acpid-2.0.23/kacpimon/libnetlink.c
|
||||||
|
@@ -26,6 +26,8 @@
|
||||||
|
|
||||||
|
#include "libnetlink.h"
|
||||||
|
|
||||||
|
+#include "../tempfailure.h"
|
||||||
|
+
|
||||||
|
void rtnl_close(struct rtnl_handle *rth)
|
||||||
|
{
|
||||||
|
if (rth->fd >= 0) {
|
||||||
|
Index: acpid-2.0.23/netlink.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/netlink.c
|
||||||
|
+++ acpid-2.0.23/netlink.c
|
||||||
|
@@ -46,6 +46,7 @@
|
||||||
|
#include "connection_list.h"
|
||||||
|
|
||||||
|
#include "netlink.h"
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
format_netlink(struct nlmsghdr *msg)
|
||||||
|
Index: acpid-2.0.23/proc.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/proc.c
|
||||||
|
+++ acpid-2.0.23/proc.c
|
||||||
|
@@ -34,6 +34,8 @@
|
||||||
|
|
||||||
|
#include "proc.h"
|
||||||
|
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
const char *eventfile = ACPID_EVENTFILE;
|
||||||
|
|
||||||
|
static char *read_line(int fd);
|
||||||
|
Index: acpid-2.0.23/ud_socket.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/ud_socket.c
|
||||||
|
+++ acpid-2.0.23/ud_socket.c
|
||||||
|
@@ -22,6 +22,8 @@
|
||||||
|
#include "log.h"
|
||||||
|
#include "ud_socket.h"
|
||||||
|
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
int
|
||||||
|
ud_create_socket(const char *name, mode_t socketmode)
|
||||||
|
{
|
||||||
|
Index: acpid-2.0.23/libnetlink.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/libnetlink.c
|
||||||
|
+++ acpid-2.0.23/libnetlink.c
|
||||||
|
@@ -26,6 +26,8 @@
|
||||||
|
|
||||||
|
#include "libnetlink.h"
|
||||||
|
|
||||||
|
+#include "tempfailure.h"
|
||||||
|
+
|
||||||
|
void rtnl_close(struct rtnl_handle *rth)
|
||||||
|
{
|
||||||
|
if (rth->fd >= 0) {
|
21
utils/acpid/patches/002-dont-use-isfdtype.patch
Normal file
21
utils/acpid/patches/002-dont-use-isfdtype.patch
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Partially roll back upstream commit 4711119089e1ad08dad206f4fded68f1972fdeed
|
||||||
|
since released versions of uClibc don't support isfdtype().
|
||||||
|
|
||||||
|
Signed-off-by: Gustavo Zaarias <gustavo@zacarias.com.ar>
|
||||||
|
|
||||||
|
Index: acpid-2.0.23/sock.c
|
||||||
|
===================================================================
|
||||||
|
--- acpid-2.0.23.orig/sock.c
|
||||||
|
+++ acpid-2.0.23/sock.c
|
||||||
|
@@ -53,7 +53,10 @@ int non_root_clients;
|
||||||
|
int
|
||||||
|
is_socket(int fd)
|
||||||
|
{
|
||||||
|
- return (isfdtype(fd, S_IFSOCK) == 1);
|
||||||
|
+ int v;
|
||||||
|
+ socklen_t l = sizeof(int);
|
||||||
|
+
|
||||||
|
+ return (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* accept a new client connection */
|
Loading…
Reference in a new issue