diff --git a/.cvsignore b/.cvsignore index a8974a7..1bfecb2 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -apmd_3.0final-1.tar.gz +apmd-3.0.2.tar.bz2 diff --git a/apmd.conf b/apmd.conf index 8b4b9c3..5dd0ff6 100644 --- a/apmd.conf +++ b/apmd.conf @@ -40,6 +40,12 @@ RESTORESOUND="no" RESTORESOUNDPROGS="no" SOUNDMODULES="sb uart401 sound soundcore maestro cs4281" +# some services might need restarting after a suspend/resume cycle - for +# example, named will shut down if all network interfaces go down. +# Any valid service (as in "ls /etc/init.d/") can be listed, and will be +# restarted if it was running at suspend time. +RESTORESERVICES="named" + # I got frequent problems mainly with scsi-pcmcia-cards on the cardbus. Use # PCMCIARESTART="yes" to stop the whole pcmcia-subsystem on a suspend and # to start it again after a resume. This can slow down your suspend and resume @@ -89,3 +95,10 @@ NETFS_RESTART="yes" # use an apmcontinue script. LOWPOWER_SERVICES="atd crond" +# Some broken BIOSes (e.g. the ones found in Toshiba Satellite Pro 4600 +# Notebooks) need some time to settle down before really entering suspend +# mode. +# +# If your BIOS is broken, uncomment the line below, and possibly change the +# value (e.g. "5s = Wait 5 seconds before allowing to suspend"). +#DELAYSUSPEND="3s" diff --git a/apmd.spec b/apmd.spec index 1ba49bf..588890f 100644 --- a/apmd.spec +++ b/apmd.spec @@ -1,24 +1,21 @@ -%define SCRIPT_VERSION 1.4.12 Summary: Advanced Power Management (APM) BIOS utilities for laptops. Name: apmd -Version: 3.0final -Release: 35 -Source: ftp://ftp.debian.org/debian/dists/unstable/main/source/admin/%{name}_%{version}-1.tar.gz +Version: 3.0.2 +Release: 9 +Source: http://www.worldvisions.ca/~apenwarr/apmd/%{name}-%{version}.tar.bz2 Source1: apmd.init Source2: apmscript Source3: apmd.conf -Patch: apmd-3.0-FHS.patch -Patch1: apmd-typo.patch -Patch2: apmd-3.0-obsoleteopts.patch -Patch3: apmd-3.0-security.patch -Patch4: apmd-kernel24.patch +Patch: apmd-3.0.2-FHS.patch +Patch1: apmd-3.0-security.patch +Patch2: apmd-3.0.2-kernel2418.patch +Epoch: 1 License: GPL Group: System Environment/Daemons Requires(post,preun): chkconfig Requires(post): initscripts >= 5.53 -BuildPrereq: tar >= 1.13.18 BuildRoot: %{_tmppath}/%{name}-%{version}-root -ExclusiveArch: i386 i486 i586 i686 alpha +ExclusiveArch: %{ix86} %description APMD is a set of programs for controlling the Advanced Power @@ -33,10 +30,8 @@ on your laptop. %prep %setup -q -n apmd %patch -p1 -b .FHS -%patch1 -p1 -b .typo -%patch2 -p1 -b .obsolete -%patch3 -p1 -b .sec -%patch4 -p1 -b .k24 +%patch1 -p1 -b .sec +%patch2 -p1 -b .kernel %build make CFLAGS="$RPM_OPT_FLAGS" LDFLAGS=-s @@ -50,7 +45,8 @@ mkdir -p $RPM_BUILD_ROOT/etc/{sysconfig/apm-scripts,rc.d/init.d} install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/apmd install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/apm-scripts/ -install -m 755 %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/apmd +install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/apmd +rm -f $RPM_BUILD_ROOT%{_bindir}/xapm %clean rm -rf $RPM_BUILD_ROOT @@ -76,6 +72,7 @@ fi %defattr(-,root,root) %doc ANNOUNCE ChangeLog README README.transfer LSM %{_mandir}/man?/* +%lang(fr) %{_mandir}/fr/man?/* %{_bindir}/* %{_sbindir}/* %{_includedir}/* @@ -85,9 +82,52 @@ fi %config /etc/sysconfig/apm-scripts/* %changelog -* Wed Apr 10 2002 Philip Copeland 3.0final-34 -- Simple recompile of apmd to allow for alpha arch - (yes we know it makes no real sense...) +* Fri Apr 12 2002 Bernhard Rosenkraenzer 3.0.2-9 +- Fix bug in screen locking mechanism (typo: `/sbin/pidof` should + have been `/sbin/pidof X`) + +* Wed Apr 3 2002 Bernhard Rosenkraenzer 3.0.2-8 +- Fix interoperability with hotplug (#62045) +- Fix build with current kernel headers + +* Mon Mar 11 2002 Bill Nottingham 3.0.2-7 +- add epoch so we can upgrade 3.0final + +* Tue Feb 26 2002 Bernhard Rosenkraenzer 3.0.2-6 +- Fix up network device detection (#59447) +- Adapt hwclock calls to current hwclock behavior (#59994) +- Fix net device resume (#59009, #49918) +- Re-add pre-{suspend,resume} hooks (#44603) +- Move LOW_POWER notification file to /var/run/apmd (#56389) +- Determine if X is running before anything else (#20892) +- Run hwclock earlier on resume (#28234) +- Change permissions on /etc/sysconfig/apmd, 0644 is sufficient (#54222) +- Fix stab location (#56718) +- Don't mess up terminal beep on resume (#57955) + +* Wed Jan 23 2002 Tim Powers +- really remove xapm + +* Tue Jan 22 2002 Bernhard Rosenkraenzer 3.0.2-4 +- Remove xapm + +* Sat Jan 19 2002 Bernhard Rosenkraenzer 3.0.2-2 +- Try to work around some more BIOS bugs +- Log which network devices are up when entering suspend mode; the old + way, only ONBOOT network devices would come back up. + +* Wed Jan 09 2002 Tim Powers +- automated rebuild + +* Mon Nov 26 2001 Bernhard Rosenkraenzer 3.0.2-1 +- 3.0.2 + +* Fri Nov 16 2001 Bernhard Rosenkraenzer 3.0final-36 +- Add yet another workaround for broken BIOSes, #56368 +- Don't restart network/netfs unless it was running at suspend time, #54041 + +* Fri Nov 9 2001 Bernhard Rosenkraenzer 3.0final-35 +- Add RESTORESERVICES option, fixes #55885 * Tue Jul 24 2001 Bernhard Rosenkraenzer 3.0final-34 - Add support for kernels with modular apm (RFE #49683) diff --git a/apmscript b/apmscript index 4d63a7e..8390e3d 100755 --- a/apmscript +++ b/apmscript @@ -1,4 +1,9 @@ #!/bin/bash +# +# Red Hat APM suspend/resume script +# version 1.5.3 +# (c) 1999-2002 Bernhard Rosenkraenzer +# # DO NOT EDIT THIS SCRIPT, CREATE AND EDIT apmcontinue IN THIS DIRECTORY; you # can put your stuff into apmcontinue for every link you create to apmscript; # for a start and definitely enough for most laptops we have two links and @@ -8,25 +13,40 @@ # reinitialising some PCMCIA-Card) there; apmcontinue will get the name # as which it was called as $1; for debugging see the logfiles # -# If you think something in this script needs to be changed anyway, please report -# it to http://bugzilla.redhat.com/bugzilla/ or bero@redhat.com +# If you think something in this script needs to be changed anyway, please +# report it to http://bugzilla.redhat.com/bugzilla/ or bero@redhat.com # # This script can be controlled by editing /etc/sysconfig/apmd. PROG="$1" LOCKFILE=/var/lock/subsys/resume +LANG="C" # We're parsing the output of some scripts, better not i18n it [ -e /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard [ -e /etc/sysconfig/apmd ] && . /etc/sysconfig/apmd [ -e /etc/sysconfig/clock ] && . /etc/sysconfig/clock [ -z "$UTC" ] && UTC="no" [ -z "$CHANGEVT" ] && CHANGEVT="0" [ -z "$CLOCK_SYNC" ] && CLOCK_SYNC="no" +if [ -n "`/sbin/pidof X`" ]; then + X_RUNNING=1 +fi -CLOCK="" -[ "$UTC" = "yes" -o "$UTC" = "true" -o "$UTC" = 1 ] && CLOCK="-u" +CLOCK="--localtime" +[ "$UTC" = "yes" -o "$UTC" = "true" -o "$UTC" = 1 ] && CLOCK="--utc" case "$PROG" in suspend|standby) + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre + # Stop services that might break + echo "#!/bin/sh" >/var/run/apm-resume-post + if [ -n "$RESTORESERVICES" ]; then + for i in $RESTORESERVICES; do + if /sbin/service $i status &>/dev/null; then + echo "/sbin/service $i start" >>/var/run/apm-resume-post + /sbin/service $i stop &>/dev/null + fi + done + fi # Remove sound progs and modules if requested if [ "$RESTORESOUND" = "yes" -o "$RESTORESOUNDPROGS" = "yes" ]; then # Find all programs using sound and kill them... @@ -79,23 +99,33 @@ case "$PROG" in fi sync - [ "$NETFS_RESTART" = "yes" ] && /etc/rc.d/init.d/netfs stop + unset NEED_NETFS_START || : + if [ "$NETFS_RESTART" = "yes" ]; then + NEED_NETFS_START=yes + /sbin/service netfs stop + fi if [ "$NET_RESTART" = "yes" ] ; then - /etc/rc.d/init.d/network stop + # Make an educated guess at what interfaces need restarting + NETDEVICES=`service network status |grep -A1 "Currently active devices" |tail -n1` + if [ "$?" = "0" ]; then + for i in $NETDEVICES; do + echo "/sbin/ifup $i" >>/var/run/apm-resume-post + done + echo "touch /var/lock/subsys/network" >>/var/run/apm-resume-post + fi + /sbin/service network stop interfaces=`cat /etc/modules.conf|grep eth[0-9]|sed 's/alias eth[0-9] //g'` for i in $interfaces; do /sbin/modprobe -r $i done fi + [ -n "$NEED_NETFS_START" ] && echo "/sbin/service netfs start" >>/var/run/apm-resume-post [ "$PCMCIARESTART" = "yes" ] && { - if [ "$PCMCIABIOSBUG" = "yes" ]; then - /sbin/cardctl eject - else - /sbin/cardctl suspend - fi + /sbin/cardctl suspend + /sbin/cardctl eject } if [ "$PCMCIAWAIT" = "yes" ]; then - until [ `grep "Socket .: empty" /var/run/stab|wc -l` = `grep "Socket" /var/run/stab|wc -l` ]; do + until [ `grep "Socket .: empty" /var/lib/pcmcia/stab|wc -l` = `grep "Socket" /var/lib/pcmcia/stab|wc -l` ]; do logger "Waiting for pcmcia-device to be removed..." sleep 10 done @@ -108,7 +138,7 @@ case "$PROG" in done # Don't try to restore the terminal or lock X if X isn't running... - [ "x`pidof X`" != x ] && { + [ -n "$X_RUNNING" ] && { [ "$CHANGEVT" != "0" ] && chvt 1 [ "x$LOCK_X" = "xyes" -o "x$LOCK_X" = "x1" ] && { # Lock X, based on patch from Hannu Martikka @@ -151,7 +181,11 @@ case "$PROG" in fi sync - [ -f /etc/sysconfig/apm-scripts/apmcontinue ] && . /etc/sysconfig/apm-scripts/apmcontinue "$PROG" + [ -f /etc/sysconfig/apm-scripts/apmcontinue ] && . /etc/sysconfig/apm-scripts/apmcontinue "$@" + + [ -e /var/run/apm-resume-post ] && chmod 0755 /var/run/apm-resume-post + + [ -n "$DELAYSUSPEND" ] && sleep $DELAYSUSPEND sync ;; @@ -167,6 +201,15 @@ case "$PROG" in fi done fi + + # Read the hardware clock + if test $CLOCK_SYNC != "no"; then + hwclock $CLOCK --hctosys + fi + + + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre + # as some displays don't like being waked up from power-off # state directly into graphics mode, we can switch to console # 1 during suspend and back to console n (where we assume X11 @@ -176,7 +219,7 @@ case "$PROG" in # variables used here. echo $$ >> "$LOCKFILE" - if [ "$TERMINALBEEP" != "" ]; then + if [ -n "$TERMINALBEEP" -a "$TERMINALBEEP" != "no" -a "$TERMINALBEEP" != "n" ]; then # first we set the beep-length for t in 1 2 3 4 5 6 7 8 9; do setterm -blength $BEEPLENGTH >/dev/tty$t @@ -215,23 +258,22 @@ case "$PROG" in # restore X if necessary [ "$CHANGEVT" != "0" ] && [ "x`pidof X`" != x ] && chvt "$CHANGEVT" - if [ "$PCMCIARESTART" = "yes" ] ; then - if [ "$PCMCIABIOSBUG" = "yes" ]; then - /sbin/cardctl insert - else - /sbin/cardctl resume - fi + # Restart services if necessary + if [ -x /var/run/apm-resume-post ]; then + /var/run/apm-resume-post &>/dev/null + rm -f /var/run/apm-resume-post fi - [ "$NET_RESTART" = "yes" ] && /etc/rc.d/init.d/network start + + # Restore network and PCMCIA [ "$NETFS_RESTART" = "yes" ] && /etc/rc.d/init.d/netfs start - sync + if [ "$PCMCIARESTART" = "yes" ] ; then + /sbin/cardctl insert + /sbin/cardctl resume + fi - [ -f /etc/sysconfig/apm-scripts/apmcontinue ] && . /etc/sysconfig/apm-scripts/apmcontinue "$PROG" + sync - # Read the hardware clock - if test $CLOCK_SYNC != "no"; then - hwclock $CLOCK --hctosys - fi + [ -f /etc/sysconfig/apm-scripts/apmcontinue ] && . /etc/sysconfig/apm-scripts/apmcontinue "$@" # Finally, run anacron to catch up cron stuff we missed... # If anacron is installed and we're on AC power or we want @@ -256,14 +298,15 @@ case "$PROG" in rm -f "$LOCKFILE" ;; change) + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre case $2 in power) # Change from battery power to AC power or vice versa. if [ -n "$POWER_SERVICES" ]; then if apm |grep -q on-line &>/dev/null; then what="start" - if [ -n "$LOWPOWER_SERVICES" -a -e /tmp/LOW_POWER ]; then - rm -f /tmp/LOW_POWER + if [ -n "$LOWPOWER_SERVICES" -a -e /var/run/apmd/LOW_POWER ]; then + rm -f /var/run/apmd/LOW_POWER for i in $LOWPOWER_SERVICES; do /sbin/service $i start done @@ -280,7 +323,7 @@ case "$PROG" in # Battery low. If you want to be on the safe side, maybe put # the harddisk into extreme powersaving, or "apm -s" here. if [ -n "$LOWPOWER_SERVICES" ]; then - touch /tmp/LOW_POWER + touch /var/run/apmd/LOW_POWER for i in $LOWPOWER_SERVICES; do /sbin/service $i stop done @@ -303,7 +346,7 @@ case "$PROG" in ;; *) if [ -f /etc/sysconfig/apm-scripts/apmcontinue ]; then - . /etc/sysconfig/apm-scripts/apmcontinue "$PROG" + . /etc/sysconfig/apm-scripts/apmcontinue "$@" else logger "FAIL: Wrong parameter \"$PROG\" in apmscript!" exit 1 diff --git a/sources b/sources index bcae8ce..61f9418 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -faa5bcadb9aa6b9e62f0b60d5699b2cd apmd_3.0final-1.tar.gz +2b8bd655f1ef8b02b93445e81c677427 apmd-3.0.2.tar.bz2