Codebase list battery-stats / c88c5b0
Dropped 01-skip-non-battery.patch and build-depend on libacpi-dev (>= 0.2-4.1) as the workaround is no longer needed. Petter Reinholdtsen 8 years ago
3 changed file(s) with 7 addition(s) and 61 deletion(s). Raw diff Collapse all Expand all
11 Section: admin
22 Priority: extra
33 Maintainer: Antonio Radici <antonio@dyne.org>
4 Build-Depends: debhelper (>= 7), libapm-dev, libacpi-dev [i386 amd64 ia64], cdbs, autotools-dev, gnuplot-nox (>= 4) | gnuplot-qt, imagemagick
4 Build-Depends: debhelper (>= 7),
5 libapm-dev,
6 libacpi-dev (>= 0.2-4.1) [i386 amd64 ia64],
7 cdbs,
8 autotools-dev,
9 gnuplot-nox (>= 4) | gnuplot-qt,
10 imagemagick
511 Standards-Version: 3.9.7
612 Homepage: https://github.com/krf/battery-stats
713 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/battery-stats.git
+0
-59
debian/patches/01-skip-non-battery.patch less more
0 Description: Rewrite to skip "AC" battery reported by libaci.
1 This get the program working again using current libaci with
2 recent kernels. Workaround for bug #479096 in libacpi.
3 Author: Petter Reinholdtsen <pere@debian.org>
4 Bug-Debian: https://bugs.debian.org/574678
5 Forwarded: no
6 Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
7 Last-Update: 2016-03-11
8
9 --- battery-stats-0.3.6.orig/src/battery-stats-collector.c
10 +++ battery-stats-0.3.6/src/battery-stats-collector.c
11 @@ -26,6 +26,7 @@
12 #include <getopt.h>
13 #include <errno.h>
14 #include <time.h>
15 +#include <assert.h>
16 #include <apm.h>
17 #include <syslog.h>
18
19 @@ -59,12 +60,24 @@ static void show_usage(void);
20 static char *myname = "battery-stats-collector";
21 static char *myversion = "0.3.3";
22
23 -static int battery_num = 0;
24 +static int battery_num = -1;
25
26 static int do_syslog = 0;
27 #define COMPLAIN(loglevel, args...) if (do_syslog) syslog(loglevel, ## args); \
28 else { fprintf(stderr,"%s: ", myname); fprintf(stderr, ##args); }
29
30 +static int first_battery_num(global_t *libacpi_global)
31 +{
32 + int i;
33 + assert(NULL != libacpi_global);
34 + for (i = 0; i < libacpi_global->batt_count; ++i) {
35 + if (0 != strcmp("AC", batteries[i].name)) {
36 + return i;
37 + }
38 + }
39 + return -1;
40 +}
41 +
42 int main(int argc, char **argv)
43 {
44 int sample_interval_secs = 30;
45 @@ -201,6 +214,13 @@ int main(int argc, char **argv)
46 COMPLAIN(LOG_INFO, "Number of batteries: %i.\n",
47 libacpi_global->batt_count);
48 if (libacpi_global->batt_count > 1) {
49 + /*
50 + * Make sure to skip "battery" AC, which is the power
51 + * socket and not a battery.
52 + */
53 + if (-1 == battery_num) {
54 + battery_num = first_battery_num(libacpi_global);
55 + }
56 COMPLAIN(LOG_INFO,
57 "Reading info from battery %d only.\n", battery_num);
58 }
+0
-1
debian/patches/series less more
0 01-skip-non-battery.patch