summaryrefslogtreecommitdiffstats
path: root/openembedded/packages/apmd
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2005-08-31 10:45:47 +0000
committerRichard Purdie <richard@openedhand.com>2005-08-31 10:45:47 +0000
commit4b46c1f6e891b1ddd5968536440b888661fade3e (patch)
treee0ba2c1f56f61b868bf746da5c4feabb25b800b2 /openembedded/packages/apmd
downloadpoky-4b46c1f6e891b1ddd5968536440b888661fade3e.tar.gz
Initial population
git-svn-id: https://svn.o-hand.com/repos/poky@1 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'openembedded/packages/apmd')
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/apmd_proxy91
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/apmd_proxy.conf16
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/apmwrapper9
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/debian.patch54
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/default8
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/devfs.patch11
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/hwclock16
-rwxr-xr-xopenembedded/packages/apmd/apmd-3.2.2/init44
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid13
-rw-r--r--openembedded/packages/apmd/apmd-3.2.2/workaround.patch55
-rw-r--r--openembedded/packages/apmd/apmd_3.2.2.bb83
11 files changed, 400 insertions, 0 deletions
diff --git a/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy b/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy
new file mode 100644
index 0000000000..c48ee4e5d5
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy
@@ -0,0 +1,91 @@
1#!/bin/sh
2#
3# apmd_proxy - program dispatcher for APM daemon
4#
5# Written by Craig Markwardt (craigm@lheamail.gsfc.nasa.gov) 21 May 1999
6# Modified for Debian by Avery Pennarun
7#
8# This shell script is called by the APM daemon (apmd) when a power
9# management event occurs. Its first and second arguments describe the
10# event. For example, apmd will call "apmd_proxy suspend system" just
11# before the system is suspended.
12#
13# Here are the possible arguments:
14#
15# start - APM daemon has started
16# stop - APM daemon is shutting down
17# suspend critical - APM system indicates critical suspend (++)
18# suspend system - APM system has requested suspend mode
19# suspend user - User has requested suspend mode
20# standby system - APM system has requested standby mode
21# standby user - User has requested standby mode
22# resume suspend - System has resumed from suspend mode
23# resume standby - System has resumed from standby mode
24# resume critical - System has resumed from critical suspend
25# change battery - APM system reported low battery
26# change power - APM system reported AC/battery change
27# change time - APM system reported time change (*)
28# change capability - APM system reported config. change (+)
29#
30# (*) - APM daemon may be configured to not call these sequences
31# (+) - Available if APM kernel supports it.
32# (++) - "suspend critical" is never passed to apmd from the kernel,
33# so we will never see it here. Scripts that process "resume
34# critical" events need to take this into account.
35#
36# It is the proxy script's responsibility to examine the APM status
37# (via /proc/apm) or other status and to take appropriate actions.
38# For example, the script might unmount network drives before the
39# machine is suspended.
40#
41# In Debian, the usual way of adding functionality to the proxy is to
42# add a script to /etc/apm/event.d. This script will be called by
43# apmd_proxy (via run-parts) with the same arguments.
44#
45# If it is important that a certain set of script be run in a certain
46# order on suspend and in a different order on resume, then put all
47# the scripts in /etc/apm/scripts.d instead of /etc/apm/event.d and
48# symlink to these from /etc/apm/suspend.d, /etc/apm/resume.d and
49# /etc/apm/other.d using names whose lexicographical order is the same
50# as the desired order of execution.
51#
52# If the kernel's APM driver supports it, apmd_proxy can return a non-zero
53# exit status on suspend and standby events, indicating that the suspend
54# or standby event should be rejected.
55#
56# *******************************************************************
57
58set -e
59
60# The following doesn't yet work, because current kernels (up to at least
61# 2.4.20) do not support rejection of APM events. Supporting this would
62# require substantial modifications to the APM driver. We will re-enable
63# this feature if the driver is ever modified. -- cph@debian.org
64#
65#SUSPEND_ON_AC=false
66#[ -r /etc/apm/apmd_proxy.conf ] && . /etc/apm/apmd_proxy.conf
67#
68#if [ "${SUSPEND_ON_AC}" = "false" -a "${2}" = "system" ] \
69# && on_ac_power >/dev/null; then
70# # Reject system suspends and standbys if we are on AC power
71# exit 1 # Reject (NOTE kernel support must be enabled)
72#fi
73
74if [ "${1}" = "suspend" -o "${1}" = "standby" ]; then
75 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
76 if [ -d /etc/apm/suspend.d ]; then
77 run-parts -a "${1}" -a "${2}" /etc/apm/suspend.d
78 fi
79elif [ "${1}" = "resume" ]; then
80 if [ -d /etc/apm/resume.d ]; then
81 run-parts -a "${1}" -a "${2}" /etc/apm/resume.d
82 fi
83 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
84else
85 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
86 if [ -d /etc/apm/other.d ]; then
87 run-parts -a "${1}" -a "${2}" /etc/apm/other.d
88 fi
89fi
90
91exit 0
diff --git a/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy.conf b/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy.conf
new file mode 100644
index 0000000000..751145c522
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/apmd_proxy.conf
@@ -0,0 +1,16 @@
1# /etc/apm/apmd_proxy.conf: configuration file for apmd.
2#
3# This file is managed by debconf when installing or reconfiguring the
4# package. It is generated by merging the answers gathered by debconf
5# into the template file "/usr/share/apmd/apmd_proxy.conf".
6
7# The following doesn't yet work, because current kernels (up to at least
8# 2.4.20) do not support rejection of APM events. Supporting this would
9# require substantial modifications to the APM driver. We will re-enable
10# this feature if the driver is ever modified. -- cph@debian.org
11#
12# Set the following to "false" if you want to reject system suspend or
13# system standby requests when the computer is running on AC power.
14# Otherwise set this to "true". Such requests are never rejected when
15# the computer is running on battery power.
16#SUSPEND_ON_AC=true
diff --git a/openembedded/packages/apmd/apmd-3.2.2/apmwrapper b/openembedded/packages/apmd/apmd-3.2.2/apmwrapper
new file mode 100644
index 0000000000..3bc9bece3d
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/apmwrapper
@@ -0,0 +1,9 @@
1#!/bin/sh
2
3if ( cat /proc/cpuinfo|grep -i hardware|grep -i SHARP ) && \
4 [ ".$@" = ".-s" -o ".$@" = ".--suspend" ]; then
5 killall -USR1 apmd || /usr/bin/apm.orig -s
6else
7 /usr/bin/apm.orig "$@"
8fi
9
diff --git a/openembedded/packages/apmd/apmd-3.2.2/debian.patch b/openembedded/packages/apmd/apmd-3.2.2/debian.patch
new file mode 100644
index 0000000000..d49e524bbd
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/debian.patch
@@ -0,0 +1,54 @@
1--- apmd-3.2.2.orig/apmd.c
2+++ apmd-3.2.2/apmd.c
3@@ -343,7 +343,7 @@
4 /* parent */
5 int status, retval;
6 ssize_t len;
7- time_t time_limit;
8+ time_t countdown;
9
10 if (pid < 0) {
11 /* Couldn't fork */
12@@ -356,8 +356,9 @@
13 /* Capture the child's output, if any, but only until it terminates */
14 close(fds[1]);
15 fcntl(fds[0], F_SETFL, O_RDONLY|O_NONBLOCK);
16- time_limit = time(0) + proxy_timeout;
17+ countdown = proxy_timeout;
18 do {
19+ countdown -= 1;
20 while ((len = read(fds[0], line, sizeof(line)-1)) > 0) {
21 line[len] = 0;
22 APMD_SYSLOG(LOG_INFO, "+ %s", line);
23@@ -372,16 +373,16 @@
24 goto proxy_done;
25 }
26
27- sleep(1);
28+ while (sleep(1) > 0) ;
29 } while (
30- (time(0) < time_limit)
31+ (countdown >= 0)
32 || (proxy_timeout < 0)
33 );
34
35 APMD_SYSLOG(LOG_NOTICE, "Proxy has been running more than %d seconds; killing it", proxy_timeout);
36
37 kill(pid, SIGTERM);
38- time_limit = time(0) + 5;
39+ countdown = 5;
40 do {
41 retval = waitpid(pid, &status, WNOHANG);
42 if (retval == pid)
43@@ -392,9 +393,9 @@
44 goto proxy_done;
45 }
46
47- sleep(1);
48+ while (sleep(1) > 0) ;
49
50- } while (time(0) < time_limit);
51+ } while (countdown >= 0);
52
53 kill(pid, SIGKILL);
54 status = __W_EXITCODE(0, SIGKILL);
diff --git a/openembedded/packages/apmd/apmd-3.2.2/default b/openembedded/packages/apmd/apmd-3.2.2/default
new file mode 100644
index 0000000000..4b7965abf8
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/default
@@ -0,0 +1,8 @@
1#
2# Default for /etc/init.d/apmd
3#
4
5# As apmd can be called with arguments, we use the following variable
6# to store them, e.g., APMD="-w 5 -p 2".
7# See the manual page apmd(8) for details.
8APMD="--proxy-timeout 30"
diff --git a/openembedded/packages/apmd/apmd-3.2.2/devfs.patch b/openembedded/packages/apmd/apmd-3.2.2/devfs.patch
new file mode 100644
index 0000000000..b11e01929b
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/devfs.patch
@@ -0,0 +1,11 @@
1--- apmd-3.2.0.orig/apm.h~devfs
2+++ apmd-3.2.0.orig/apm.h
3@@ -24,7 +24,7 @@
4 #include <sys/types.h>
5
6 #define APM_PROC "/proc/apm"
7-#define APM_DEVICE "/dev/apm_bios"
8+#define APM_DEVICE "/dev/misc/apm_bios"
9
10 #define APM_DEV "/proc/devices"
11 #define APM_NAME "apm_bios"
diff --git a/openembedded/packages/apmd/apmd-3.2.2/hwclock b/openembedded/packages/apmd/apmd-3.2.2/hwclock
new file mode 100644
index 0000000000..a1c1c2294c
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/hwclock
@@ -0,0 +1,16 @@
1#!/bin/sh
2# Preserve the system clock around suspend/resume.
3
4INIT="/etc/init.d/hwclock.sh"
5[ -x "${INIT}" ] || exit 0
6
7case "${1},${2}" in
8(suspend,*)
9 "${INIT}" stop
10 ;;
11(resume,suspend)
12 "${INIT}" start
13 ;;
14esac
15
16exit 0
diff --git a/openembedded/packages/apmd/apmd-3.2.2/init b/openembedded/packages/apmd/apmd-3.2.2/init
new file mode 100755
index 0000000000..f1098a752d
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/init
@@ -0,0 +1,44 @@
1#!/bin/sh
2#
3# Start or stop the Advanced Power Management daemon.
4#
5# Written by Dirk Eddelbuettel <edd@debian.org>
6# Greatly modified by Avery Pennarun <apenwarr@debian.org>
7#
8# I think this script is now free of bashisms.
9# Please correct me if I'm wrong!
10
11PATH=/bin:/usr/bin:/sbin:/usr/sbin
12
13[ -f /etc/default/rcS ] && . /etc/default/rcS
14[ -f /etc/default/apmd ] && . /etc/default/apmd
15
16case "$1" in
17 start)
18 echo -n "Starting advanced power management daemon: "
19 start-stop-daemon -S -x /usr/sbin/apmd -- \
20 -P /etc/apm/apmd_proxy $APMD
21 if [ $? = 0 ]; then
22 echo "apmd."
23 else
24 echo "(failed.)"
25 fi
26 ;;
27 stop)
28 echo -n "Stopping advanced power management daemon: "
29 start-stop-daemon -K \
30 -x /usr/sbin/apmd
31 echo "apmd."
32 ;;
33 restart|force-reload)
34 $0 stop
35 $0 start
36 exit
37 ;;
38 *)
39 echo "Usage: /etc/init.d/apmd {start|stop|restart|force-reload}"
40 exit 1
41 ;;
42esac
43
44exit 0
diff --git a/openembedded/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid b/openembedded/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid
new file mode 100644
index 0000000000..de37f01a2d
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid
@@ -0,0 +1,13 @@
1apmd\[[0-9]+\]: (Normal|Standby|Critical) Resume
2apmd\[[0-9]+\]: (Now using|Using) (AC|battery|backup) power
3apmd\[[0-9]+\]: (System|User) (Standby|Suspend)
4apmd\[[0-9]+\]: (apmd_)?call_proxy:
5apmd\[[0-9]+\]: Battery: [0-9]+%,
6apmd\[[0-9]+\]: Battery: absent
7apmd\[[0-9]+\]: Capability Change
8apmd\[[0-9]+\]: Exiting
9apmd\[[0-9]+\]: Performing APM status check
10apmd\[[0-9]+\]: Suspending now
11apmd\[[0-9]+\]: Update Time
12apmd\[[0-9]+\]: Version: apmd [0-9.]+, (apm )?driver [0-9.]+, APM BIOS [0-9.]+
13apmd\[[0-9]+\]: apmd [0-9.]+ interfacing with apm driver [0-9.]+ and APM BIOS [0-9.]+
diff --git a/openembedded/packages/apmd/apmd-3.2.2/workaround.patch b/openembedded/packages/apmd/apmd-3.2.2/workaround.patch
new file mode 100644
index 0000000000..19cf073115
--- /dev/null
+++ b/openembedded/packages/apmd/apmd-3.2.2/workaround.patch
@@ -0,0 +1,55 @@
1
2#
3# Patch managed by http://www.holgerschurig.de/patcher.html
4#
5
6--- apmd-3.2.2.orig/apmd.c~workaround.patch
7+++ apmd-3.2.2.orig/apmd.c
8@@ -158,6 +158,7 @@
9 static int quiet_bios_batlow; /* = 0 */
10 static int verbosity = DEFAULT_VERBOSITY;
11 static int warn_level = 10;
12+static int sleep_now = 0; /* ntp */
13
14 static uid_t apmd_uid = 0;
15 static int apmd_fd = -1;
16@@ -942,6 +943,12 @@
17 exit(0);
18 }
19
20+/* ntp */
21+static void sig_usr1(int sig)
22+{
23+ sleep_now = 1;
24+}
25+
26 int main(int argc, char **argv)
27 {
28 int c;
29@@ -1151,6 +1158,8 @@
30 openlog("apmd", (verbosity>=LOG_DEBUG)?LOG_PERROR:0 | LOG_PID | LOG_CONS, LOG_DAEMON);
31
32 /* Set up signal handler */
33+ if (signal(SIGUSR1, SIG_IGN) != SIG_IGN)
34+ signal(SIGUSR1, sig_usr1); /* ntp */
35 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
36 signal(SIGINT, sig_handler);
37 if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
38@@ -1230,9 +1239,16 @@
39
40 for (;;)
41 {
42- int num_events = apm_get_events(apmd_fd, check_interval, events, MAX_EVENTS);
43+ int num_events;
44 int e, a;
45
46+ /* ntp */
47+ if (sleep_now) {
48+ sleep_now = 0;
49+ handle_event(APM_USER_SUSPEND, &apminfo);
50+ }
51+
52+ num_events = apm_get_events(apmd_fd, check_interval, events, MAX_EVENTS);
53 apm_read(&apminfo);
54
55 if (num_events == 0) {
diff --git a/openembedded/packages/apmd/apmd_3.2.2.bb b/openembedded/packages/apmd/apmd_3.2.2.bb
new file mode 100644
index 0000000000..0e8b364458
--- /dev/null
+++ b/openembedded/packages/apmd/apmd_3.2.2.bb
@@ -0,0 +1,83 @@
1DESCRIPTION = "Set of tools for managing notebook power consumption."
2SECTION = "base"
3PRIORITY = "required"
4DEPENDS = "libtool-cross"
5LICENSE = "GPL"
6PR = "r5"
7
8SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.orig.tar.gz; \
9 file://debian.patch;patch=1 \
10 file://workaround.patch;patch=1 \
11 file://apmwrapper \
12 file://init \
13 file://default \
14 file://apmd_proxy \
15 file://apmd_proxy.conf"
16
17S = "${WORKDIR}/apmd-${PV}.orig"
18
19inherit update-rc.d
20
21INITSCRIPT_NAME = "apmd"
22INITSCRIPT_PARAMS = "defaults"
23
24do_compile() {
25 oe_runmake "LIBTOOL=${STAGING_BINDIR}/${TARGET_PREFIX}libtool" apm apmd
26}
27
28do_stage() {
29 install -m 0644 apm.h ${STAGING_INCDIR}
30 oe_libinstall -so libapm ${STAGING_LIBDIR}
31}
32
33do_install() {
34 install -d ${D}${sysconfdir}
35 install -d ${D}${sysconfdir}/apm
36 install -d ${D}${sysconfdir}/apm/event.d
37 install -d ${D}${sysconfdir}/apm/other.d
38 install -d ${D}${sysconfdir}/apm/suspend.d
39 install -d ${D}${sysconfdir}/apm/resume.d
40 install -d ${D}${sysconfdir}/apm/scripts.d
41 install -d ${D}${sysconfdir}/default
42 install -d ${D}${sysconfdir}/init.d
43 install -d ${D}${sbindir}
44 install -d ${D}${bindir}
45 install -d ${D}${libdir}
46 install -d ${D}${datadir}/apmd
47#
48# only Zaurus 2.4-embedix kernels need a breadead apm hack
49#
50#
51 case ${MACHINE} in
52 collie | poodle | tosa | c7x0 | akita | spitz | borzoi)
53 if [ "${KERNEL_VERSION}" == "2.6" ]
54 then
55 install -m 4577 ${S}/.libs/apm ${D}${bindir}/apm
56 else
57 install -m 4755 ${S}/.libs/apm ${D}${bindir}/apm.orig
58 install -m 0755 ${WORKDIR}/apmwrapper ${D}${bindir}/apm
59 fi
60 ;;
61 *)
62 install -m 4577 ${S}/.libs/apm ${D}${bindir}/apm
63 ;;
64 esac
65
66 install -m 0755 ${S}/.libs/apmd ${D}${sbindir}/apmd
67 install -m 0755 ${WORKDIR}/apmd_proxy ${D}${sysconfdir}/apm/
68 install -m 0644 ${WORKDIR}/apmd_proxy.conf ${D}${datadir}/apmd/
69 install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/apmd
70 oe_libinstall -so libapm ${D}${libdir}
71 install -m 0644 apm.h ${D}${includedir}
72
73 cat ${WORKDIR}/init | sed -e 's,/usr/sbin,${sbindir},g; s,/etc,${sysconfdir},g;' > ${D}${sysconfdir}/init.d/apmd
74 chmod 755 ${D}${sysconfdir}/init.d/apmd
75}
76
77PACKAGES =+ "libapm libapm-dev apm"
78
79FILES_libapm = "${libdir}/libapm.so.*"
80FILES_libapm-dev = "${libdir}/libapm.* ${includedir}"
81FILES_apm = "${bindir}/apm*"
82
83