Package: laptop-detect
Version: 0.13.1
Severity: normal
Tags: patch

The bug was reported in Ubuntu: https://bugs.launchpad.net/bugs/40503

If laptop-detect is run early (for instance when casper configures X) the 
battery module 
has not been loaded and the acpi batteries are therefore not detected.

The patch loads "battery" before probing for apci batteries.

Additionally, I added a version dependency on dmidecode, since laptop-detect 
uses the 
"chassis-type" string value which is not available in old versions.

And a few cosmetic clean-ups.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-2-486
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages laptop-detect depends on:
ii  dmidecode                     2.9-1      Dump Desktop Management Interface 

laptop-detect recommends no packages.

-- no debconf information
diff -Nru /tmp/vsJb0801FP/laptop-detect-0.13.1/debian/changelog 
/tmp/dHrfGaKKhA/laptop-detect-0.13.2/debian/changelog
--- /tmp/vsJb0801FP/laptop-detect-0.13.1/debian/changelog       2007-05-26 
15:27:57.000000000 +0200
+++ /tmp/dHrfGaKKhA/laptop-detect-0.13.2/debian/changelog       2007-07-09 
21:08:32.000000000 +0200
@@ -1,3 +1,11 @@
+laptop-detect (0.13.2) unstable; urgency=low
+
+  * laptop-detect.in: Load battery module before probing for acpi
+    batteries
+  * debian/rules: Versioned dependency on dmidecode
+
+ -- Tormod Volden <[EMAIL PROTECTED]>  Mon, 09 Jul 2007 21:05:48 +0200
+
 laptop-detect (0.13.1) unstable; urgency=low
 
   * Change package priority to important to match override.
diff -Nru /tmp/vsJb0801FP/laptop-detect-0.13.1/debian/rules 
/tmp/dHrfGaKKhA/laptop-detect-0.13.2/debian/rules
--- /tmp/vsJb0801FP/laptop-detect-0.13.1/debian/rules   2007-05-26 
15:26:45.000000000 +0200
+++ /tmp/dHrfGaKKhA/laptop-detect-0.13.2/debian/rules   2007-07-09 
21:00:59.000000000 +0200
@@ -6,10 +6,10 @@
 # supports architecture specific dependencies.
 DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
 ifeq ($(DEB_HOST_ARCH),i386)
-DEB_DH_GENCONTROL_ARGS := -- -Vdmidecode-depends=dmidecode
+DEB_DH_GENCONTROL_ARGS := -- -Vdmidecode-depends="dmidecode (>= 2.8-2)"
 endif
 ifeq ($(DEB_HOST_ARCH),amd64)
-DEB_DH_GENCONTROL_ARGS := -- -Vdmidecode-depends=dmidecode
+DEB_DH_GENCONTROL_ARGS := -- -Vdmidecode-depends="dmidecode (>= 2.8-2)"
 endif
 
 VERSION=$(shell dpkg-parsechangelog \
diff -Nru /tmp/vsJb0801FP/laptop-detect-0.13.1/laptop-detect.in 
/tmp/dHrfGaKKhA/laptop-detect-0.13.2/laptop-detect.in
--- /tmp/vsJb0801FP/laptop-detect-0.13.1/laptop-detect.in       2007-05-25 
15:36:50.000000000 +0200
+++ /tmp/dHrfGaKKhA/laptop-detect-0.13.2/laptop-detect.in       2007-07-09 
21:30:10.000000000 +0200
@@ -40,7 +40,7 @@
 
 # Are we a mac?
 if test -d /proc/pmu; then
-        batteries=$(grep Battery /proc/pmu/info| cut -f2 -d:)
+        batteries=$(grep Battery /proc/pmu/info | cut -f2 -d:)
         if test "$batteries" -ne 0; then
             $PRINTIT "We're a laptop (Mac: batteries found)" >&2;
             exit 0
@@ -53,7 +53,7 @@
         dmitype=$(dmidecode --string chassis-type)
 
         if test "$dmitype" = "Notebook" || test "$dmitype" = "Portable"; then
-                   $PRINTIT "We're a laptop (dmidecode returned $dmitype)" >&2
+            $PRINTIT "We're a laptop (dmidecode returned $dmitype)" >&2
             exit 0
         fi
 
@@ -62,10 +62,11 @@
 fi
 
 # check for any ACPI batteries
+/sbin/modprobe battery || true
 if [ -d /proc/acpi/battery ]; then
-        results=`find /proc/acpi/battery/ -mindepth 1 -type d`
+        results=`find /proc/acpi/battery -mindepth 1 -type d`
         if [ ! -z "$results" ]; then
-            $PRINTIT "We're a laptop (ACPI batterie(s) found)" >&2
+            $PRINTIT "We're a laptop (ACPI batteries found)" >&2
             exit 0
         fi
 fi
@@ -75,8 +76,8 @@
 if [ -f /proc/apm ]; then
     battery=`awk '{print $6}' </proc/apm`
     if [ "$battery" != "0xff" ] && [ "$battery" != "0x80" ]; then
-        $PRINTIT "We're a laptop (ACPI batterie(s) found)" >&2
-           exit 0
+        $PRINTIT "We're a laptop (APM batteries found)" >&2
+        exit 0
     fi
 fi
 

Reply via email to