From 603e6f1ae11fd6134ac6c707590620c1060fbe9e Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 24 Aug 2012 23:15:16 -0500
Subject: acpid: 2.0    no need to patch for run-it

---
 abs/core/acpid/Makefile               | 56 -----------------------
 abs/core/acpid/PKGBUILD               | 75 ++++++++++++++++++------------
 abs/core/acpid/acpid                  | 37 ---------------
 abs/core/acpid/acpid-1.0.4-gcc4.patch | 20 --------
 abs/core/acpid/acpid.conf             |  5 ++
 abs/core/acpid/acpid.conf.d           |  6 ---
 abs/core/acpid/acpid.rc               | 40 ++++++++++++++++
 abs/core/acpid/acpid.service          | 11 +++++
 abs/core/acpid/acpid.socket           |  8 ++++
 abs/core/acpid/default                | 20 --------
 abs/core/acpid/handler.sh             | 86 +++++++++++++++++++++++++++++++++++
 11 files changed, 196 insertions(+), 168 deletions(-)
 delete mode 100644 abs/core/acpid/Makefile
 delete mode 100644 abs/core/acpid/acpid
 delete mode 100644 abs/core/acpid/acpid-1.0.4-gcc4.patch
 create mode 100644 abs/core/acpid/acpid.conf
 delete mode 100644 abs/core/acpid/acpid.conf.d
 create mode 100644 abs/core/acpid/acpid.rc
 create mode 100644 abs/core/acpid/acpid.service
 create mode 100644 abs/core/acpid/acpid.socket
 delete mode 100644 abs/core/acpid/default
 create mode 100644 abs/core/acpid/handler.sh

diff --git a/abs/core/acpid/Makefile b/abs/core/acpid/Makefile
deleted file mode 100644
index a5fe385..0000000
--- a/abs/core/acpid/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# Makefile for ACPI daemon
-
-# update these numbers for new releases
-VERSION = 1.0.6
-
-INSTPREFIX =
-BINDIR = $(INSTPREFIX)/usr/bin
-SBINDIR = $(INSTPREFIX)/usr/sbin
-MAN8DIR = $(INSTPREFIX)/usr/share/man/man8
-
-SBIN_PROGS = acpid
-BIN_PROGS = acpi_listen
-PROGS = $(SBIN_PROGS) $(BIN_PROGS)
-
-acpid_SRCS = acpid.c event.c ud_socket.c
-acpid_OBJS = $(acpid_SRCS:.c=.o)
-
-acpi_listen_SRCS = acpi_listen.c ud_socket.c
-acpi_listen_OBJS = $(acpi_listen_SRCS:.c=.o)
-
-MAN8 = acpid.8 acpi_listen.8
-MAN8GZ = $(MAN8:.8=.8.gz)
-
-CFLAGS = -Wall -Werror -g $(DEFS) -D_GNU_SOURCE
-DEFS = -DVERSION="\"$(VERSION)\""
-
-all: $(PROGS)
-
-acpid: $(acpid_OBJS)
-
-acpi_listen: $(acpi_listen_OBJS)
-
-man: $(MAN8)
-	for a in $^; do gzip -f -9 -c $$a > $$a.gz; done
-
-install: $(PROGS) man
-	mkdir -p $(SBINDIR)
-	mkdir -p $(BINDIR)
-	install -m 750 acpid $(SBINDIR)
-	install -m 755 acpi_listen $(BINDIR)
-	mkdir -p $(MAN8DIR)
-	install -m 644 $(MAN8GZ) $(MAN8DIR)
-
-DISTTMP=/tmp
-dist:
-	rm -rf $(DISTTMP)/acpid-$(VERSION)
-	mkdir -p $(DISTTMP)/acpid-$(VERSION)
-	cp -a * $(DISTTMP)/acpid-$(VERSION)
-	find $(DISTTMP)/acpid-$(VERSION) -type d -name CVS | xargs rm -rf
-	make -C $(DISTTMP)/acpid-$(VERSION) clean
-	tar -C $(DISTTMP) -zcvf acpid-$(VERSION).tar.gz acpid-$(VERSION)
-	rm -rf $(DISTTMP)/acpid-$(VERSION)
-
-clean:
-	$(RM) $(PROGS) $(MAN8GZ) *.o
-
diff --git a/abs/core/acpid/PKGBUILD b/abs/core/acpid/PKGBUILD
index 911f04b..a4d931a 100644
--- a/abs/core/acpid/PKGBUILD
+++ b/abs/core/acpid/PKGBUILD
@@ -1,41 +1,58 @@
-# $Id: PKGBUILD 65397 2010-01-28 19:48:01Z thayer $
-# Maintainer: Thayer Williams <thayer@archlinux.org>
+# $Id: PKGBUILD 71877 2012-06-02 17:57:44Z seblu $
+# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
+# Contributor: xduugu
 # Contributor: Manolis Tzanidakis
-# Contributor: Judd Vinet <jvinet@zeroflux.org>
+# Contributor: Jonathan Schmidt <j.schmidt@archlinux.us
 
 pkgname=acpid
-pkgver=1.0.10
+pkgver=2.0.16
 pkgrel=3
-pkgdesc="A daemon for delivering ACPI power management events"
+pkgdesc='A daemon for delivering ACPI power management events with netlink support'
 arch=('i686' 'x86_64')
-url="http://acpid.sourceforge.net"
+url='http://tedfelix.com/linux/acpid-netlink.html'
 license=('GPL')
-depends=(glibc)
-source=(http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz
-    acpid
-    acpid.conf.d
-    anything
-    handler.sh.runit)
+depends=('bash')
+optdepends=('perl: use perl based examples')
+replaces=('acpid2')
 backup=('etc/acpi/handler.sh' 'etc/acpi/events/anything' 'etc/conf.d/acpid')
+source=("http://www.tedfelix.com/linux/$pkgname-$pkgver.tar.xz"
+        'acpid.rc'
+        'acpid.conf'
+        'acpid.socket'
+        'acpid.service'
+        'anything'
+        'handler.sh')
+md5sums=('d59fc02c9c34f0d5c137495302e2c074'
+         '077475c75fbdd9de75f9a397130ccd91'
+         '929c6d2e91295c22ed9ec6212d7eabef'
+         'ee6cb99e50e580c50331a73045412ae9'
+         '7f545754db5be7296d2dd97c049062ee'
+         '2d37b98d6e74bab815604b8b48c6cfd4'
+         '74ee3c33714ff5cb44f30c9a0dceeef0')
 
 build() {
-    cd $srcdir/$pkgname-$pkgver
-    /usr/bin/make || return 1
-    /bin/install -d -m0755 $pkgdir/usr/bin || return 1
-    /usr/bin/make INSTPREFIX=$pkgdir \
-        MAN8DIR=$pkgdir/usr/share/man/man8 install || return 1
+  cd $pkgname-$pkgver
+  ./configure --prefix=/usr
+  make
+}
+
+package() {
+  pushd $pkgname-$pkgver
+  make DESTDIR="$pkgdir" install
+  popd
 
-    # install our supplementary scripts
-    /bin/install -D -m0755 $srcdir/acpid $pkgdir/etc/rc.d/acpid || return 1
-    /bin/install -D -m0644 $srcdir/acpid.conf.d $pkgdir/etc/conf.d/acpid || return 1
-    /bin/install -D -m0644 $srcdir/anything $pkgdir/etc/acpi/events/anything || return 1
-    /bin/install -D -m0755 $srcdir/handler.sh.runit $pkgdir/etc/acpi/handler.sh || return 1
+  # default config
+  install -Dm644 anything "$pkgdir/etc/acpi/events/anything"
+  install -Dm755 handler.sh "$pkgdir/etc/acpi/handler.sh"
 
-    # set world readable bit on the acpid binary
-    /bin/chmod 755 $pkgdir/usr/sbin/acpid || return 1
+  # initscripts
+  install -Dm755 acpid.rc "$pkgdir/etc/rc.d/acpid"
+  install -Dm644 acpid.conf "$pkgdir/etc/conf.d/acpid"
+  install -Dm644 acpid.socket "$pkgdir/usr/lib/systemd/system/acpid.socket"
+  install -Dm644 acpid.service "$pkgdir/usr/lib/systemd/system/acpid.service"
+
+  # fix acpid rights
+  chmod 755 "$pkgdir/usr/sbin/acpid"
 }
-md5sums=('61156ef32015c56dc0f2e3317f4ae09e'
-         'd9ca7f71f520238a0448fab105a23fe9'
-         '91fdb3709c878eed757d192a420251a1'
-         '2d37b98d6e74bab815604b8b48c6cfd4'
-         'e2c6fccd6ba099045b358fb1128a4905')
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/abs/core/acpid/acpid b/abs/core/acpid/acpid
deleted file mode 100644
index 9a4ab8a..0000000
--- a/abs/core/acpid/acpid
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-. /etc/rc.conf
-. /etc/rc.d/functions
-
-[ -f /etc/conf.d/acpid ] && . /etc/conf.d/acpid
-
-PID=`pidof -o %PPID /usr/sbin/acpid`
-case "$1" in
-  start)
-    stat_busy "Starting acpid"
-    [ -z "$PID" ] && /usr/sbin/acpid $ACPID_ARGS
-    if [ $? -gt 0 ]; then
-      stat_fail
-    else
-      add_daemon acpid
-      stat_done
-    fi
-    ;;
-  stop)
-    stat_busy "Stopping acpid"
-    [ ! -z "$PID" ]  && kill $PID &> /dev/null
-    if [ $? -gt 0 ]; then
-      stat_fail
-    else
-      rm_daemon acpid
-      stat_done
-    fi
-    ;;
-  restart)
-    $0 stop
-    $0 start
-    ;;
-  *)
-    echo "usage: $0 {start|stop|restart}"  
-esac
-exit 0
diff --git a/abs/core/acpid/acpid-1.0.4-gcc4.patch b/abs/core/acpid/acpid-1.0.4-gcc4.patch
deleted file mode 100644
index b56901d..0000000
--- a/abs/core/acpid/acpid-1.0.4-gcc4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- acpid-1.0.4/ud_socket.c	2005-04-26 10:26:29.000000000 +0000
-+++ acpid-1.0.4.az/ud_socket.c	2005-04-26 10:27:09.000000000 +0000
-@@ -60,7 +60,7 @@
- 		struct sockaddr_un cliaddr;
- 		int len = sizeof(struct sockaddr_un);
- 
--		newsock = accept(listenfd, (struct sockaddr *)&cliaddr, &len);
-+		newsock = accept(listenfd, (struct sockaddr *)&cliaddr, (socklen_t *)&len);
- 		if (newsock < 0) {
- 			if (errno == EINTR) {
- 				continue; /* signal */
-@@ -71,7 +71,7 @@
- 
- 		if (cred) {
- 			len = sizeof(struct ucred);
--			getsockopt(newsock, SOL_SOCKET, SO_PEERCRED,cred,&len);
-+			getsockopt(newsock, SOL_SOCKET, SO_PEERCRED,cred,(socklen_t *)&len);
- 		}
- 
- 		return newsock;
diff --git a/abs/core/acpid/acpid.conf b/abs/core/acpid/acpid.conf
new file mode 100644
index 0000000..b60103a
--- /dev/null
+++ b/abs/core/acpid/acpid.conf
@@ -0,0 +1,5 @@
+#
+# Arguments to be passed to the acpid daemon
+#
+
+ACPID_ARGS=""
diff --git a/abs/core/acpid/acpid.conf.d b/abs/core/acpid/acpid.conf.d
deleted file mode 100644
index 25c9cc1..0000000
--- a/abs/core/acpid/acpid.conf.d
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Arguments to be passed to the acpid daemon
-#
-
-ACPID_ARGS=""
-
diff --git a/abs/core/acpid/acpid.rc b/abs/core/acpid/acpid.rc
new file mode 100644
index 0000000..674f462
--- /dev/null
+++ b/abs/core/acpid/acpid.rc
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+[[ -f /etc/conf.d/acpid ]] && . /etc/conf.d/acpid
+
+PID=$(pidof -o %PPID /usr/sbin/acpid)
+case "$1" in
+  start)
+    stat_busy "Starting acpid"
+    [ -z "$PID" ] && /usr/sbin/acpid $ACPID_ARGS
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      add_daemon acpid
+      stat_done
+    fi
+    ;;
+  stop)
+    stat_busy "Stopping acpid"
+    [ ! -z "$PID" ] && kill $PID &> /dev/null
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      rm_daemon acpid
+      stat_done
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/abs/core/acpid/acpid.service b/abs/core/acpid/acpid.service
new file mode 100644
index 0000000..4c0e073
--- /dev/null
+++ b/abs/core/acpid/acpid.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=ACPI event daemon
+Requires=acpid.socket
+
+[Service]
+EnvironmentFile=/etc/conf.d/acpid
+ExecStart=/usr/sbin/acpid -f $ACPID_ARGS
+
+[Install]
+WantedBy=multi-user.target
+Also=acpid.socket
diff --git a/abs/core/acpid/acpid.socket b/abs/core/acpid/acpid.socket
new file mode 100644
index 0000000..1e5365b
--- /dev/null
+++ b/abs/core/acpid/acpid.socket
@@ -0,0 +1,8 @@
+[Unit]
+Description=ACPID Listen Socket
+
+[Socket]
+ListenStream=/run/acpid.socket
+
+[Install]
+WantedBy=sockets.target
diff --git a/abs/core/acpid/default b/abs/core/acpid/default
deleted file mode 100644
index 93944aa..0000000
--- a/abs/core/acpid/default
+++ /dev/null
@@ -1,20 +0,0 @@
-# This is the ACPID default configuration, it takes all
-# events and passes them to /etc/acpi/default.sh for further
-# processing.
-
-# event keeps a regular expression matching the event. To get
-# power events only, just use something like "event=button power.*"
-# to catch it.
-# action keeps the command to be executed after an event occurs
-#This halts the computer when the Power button is pressed.
-
-event=button power.*
-#action=/sbin/shutdown -h now
-action=/usr/local/sbin/shutdown.sh
-
-# Optionally you can specify the placeholder %e. It will pass
-# through the whole kernel event message to the program you've
-# specified.
-
-event=.*
-action=/etc/acpi/acpi_handler.sh %e
diff --git a/abs/core/acpid/handler.sh b/abs/core/acpid/handler.sh
new file mode 100644
index 0000000..b5a548f
--- /dev/null
+++ b/abs/core/acpid/handler.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+# Default acpi script that takes an entry for all actions
+
+minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
+maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
+setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
+
+set $*
+
+case "$1" in
+    button/power)
+        case "$2" in
+            PBTN|PWRF)
+                logger "PowerButton pressed: $2"
+                poweroff
+                ;;
+            *)
+                logger "ACPI action undefined: $2"
+                ;;
+        esac
+        ;;
+    button/sleep)
+        case "$2" in
+            SLPB|SBTN)
+                echo -n mem >/sys/power/state
+                ;;
+            *)
+                logger "ACPI action undefined: $2"
+                ;;
+        esac
+        ;;
+    ac_adapter)
+        case "$2" in
+            AC|ACAD|ADP0)
+                case "$4" in
+                    00000000)
+                        echo -n $minspeed >$setspeed
+                        #/etc/laptop-mode/laptop-mode start
+                        ;;
+                    00000001)
+                        echo -n $maxspeed >$setspeed
+                        #/etc/laptop-mode/laptop-mode stop
+                        ;;
+                esac
+                ;;
+            *)
+                logger "ACPI action undefined: $2"
+                ;;
+        esac
+        ;;
+    battery)
+        case "$2" in
+            BAT0)
+                case "$4" in
+                    00000000)
+                        logger 'Battery online'
+                        ;;
+                    00000001)
+                        logger 'Battery offline'
+                        ;;
+                esac
+                ;;
+            CPU0)
+                ;;
+            *)  logger "ACPI action undefined: $2" ;;
+        esac
+        ;;
+    button/lid)
+        case "$3" in
+            close)
+                logger 'LID closed'
+                ;;
+            open)
+                logger 'LID opened'
+                ;;
+            *)
+                logger "ACPI action undefined: $3"
+                ;;
+    esac
+    ;;
+    *)
+        logger "ACPI group/action undefined: $1 / $2"
+        ;;
+esac
+
+# vim:set ts=4 sw=4 ft=sh et:
-- 
cgit v0.12

