wok-next view libacpi/stuff/patches/libacpi_0.2-4.diff @ rev 19949
sane-backends: update bdeps
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Oct 16 12:17:41 2017 +0200 (2017-10-16) |
parents | |
children |
line source
1 --- libacpi-0.2.orig/libacpi.h
2 +++ libacpi-0.2/libacpi.h
3 @@ -12,6 +12,8 @@
4 #define __LIBACPI_H__
6 #define PROC_ACPI "/proc/acpi/"
7 +#define SYS_POWER "/sys/class/power_supply"
8 +
9 #define LINE_MAX 256
10 #define MAX_NAME 512
11 #define MAX_BUF 1024
12 @@ -177,6 +179,7 @@
13 int fan_count; /**< number of found fans */
14 int temperature; /**< system temperature if we only have on thermal zone */
15 adapter_t adapt; /**< ac adapter */
16 + int sysstyle;
17 } global_t;
19 /**
20 @@ -239,6 +242,7 @@
21 * Looks up if the ac adapter is plugged in or not
22 * and sets the values in a struct
23 * @param globals pointer to the global acpi structure
24 + * @param sysstyle whether or not to use the /sys interface
25 */
26 void read_acpi_acstate(global_t *globals);
27 /**
28 --- libacpi-0.2.orig/libacpi.c
29 +++ libacpi-0.2/libacpi.c
30 @@ -14,8 +14,9 @@
31 #include "libacpi.h"
32 #include "list.h"
34 -static int read_acpi_battinfo(const int num);
35 -static int read_acpi_battalarm(const int num);
36 +
37 +static int read_acpi_battinfo(const int num, const int sysstyle);
38 +static int read_acpi_battalarm(const int num, const int sysstyle);
39 static int read_acpi_battstate(const int num);
40 static void read_acpi_thermalzones(global_t *globals);
42 @@ -144,8 +145,15 @@
43 int i = 0;
45 globals->batt_count = 0;
46 + globals->sysstyle = 0;
47 if((lst = dir_list(PROC_ACPI "battery")) == NULL || !lst->top)
48 - return NOT_SUPPORTED;
49 + {
50 + /* check for new Linux 2.6.24+ layout */
51 + if((lst = dir_list(SYS_POWER)) == NULL || !lst->top)
52 + return NOT_SUPPORTED;
53 + else
54 + globals->sysstyle = 1;
55 + }
56 for(node = lst->top; node; node=node->next){
57 if((names[globals->batt_count] = strdup(node->name)) == NULL){
58 delete_list(lst);
59 @@ -174,11 +182,20 @@
60 for (i=0; i < globals->batt_count && i < MAX_ITEMS; i++){
61 binfo = &batteries[i];
62 snprintf(binfo->name, MAX_NAME, "%s", names[i]);
63 - snprintf(binfo->state_file, MAX_NAME, PROC_ACPI "battery/%s/state", names[i]);
64 - snprintf(binfo->info_file, MAX_NAME, PROC_ACPI "battery/%s/info", names[i]);
65 - snprintf(binfo->alarm_file, MAX_NAME, PROC_ACPI "battery/%s/alarm", names[i]);
66 - read_acpi_battinfo(i);
67 - read_acpi_battalarm(i);
68 + if(globals->sysstyle)
69 + {
70 + snprintf(binfo->state_file, MAX_NAME, "/%s/present", names[i]);
71 + snprintf(binfo->info_file, MAX_NAME, SYS_POWER "/%s", names[i]);
72 + snprintf(binfo->alarm_file, MAX_NAME, SYS_POWER "/%s/alarm", names[i]);
73 + }
74 + else
75 + {
76 + snprintf(binfo->state_file, MAX_NAME, PROC_ACPI "battery/%s/state", names[i]);
77 + snprintf(binfo->info_file, MAX_NAME, PROC_ACPI "battery/%s/info", names[i]);
78 + snprintf(binfo->alarm_file, MAX_NAME, PROC_ACPI "battery/%s/alarm", names[i]);
79 + }
80 + read_acpi_battinfo(i, globals->sysstyle);
81 + read_acpi_battalarm(i, globals->sysstyle);
82 free(names[i]);
83 }
84 delete_list(lst);
85 @@ -196,11 +213,22 @@
86 ac->ac_state = P_ERR;
87 return;
88 }
89 - if((tmp = scan_acpi_value(buf, "state:")) && !strncmp(tmp, "on-line", 7))
90 - ac->ac_state = P_AC;
91 - else if(tmp && !strncmp(tmp, "off-line", 8))
92 - ac->ac_state = P_BATT;
93 - else ac->ac_state = P_ERR;
94 + if(globals->sysstyle)
95 + {
96 + if(!strcmp(buf, "1"))
97 + ac->ac_state = P_AC;
98 + else if(!strcmp(buf, "0"))
99 + ac->ac_state = P_BATT;
100 + else ac->ac_state = P_ERR;
101 + }
102 + else
103 + {
104 + if((tmp = scan_acpi_value(buf, "state:")) && !strncmp(tmp, "on-line", 7))
105 + ac->ac_state = P_AC;
106 + else if(tmp && !strncmp(tmp, "off-line", 8))
107 + ac->ac_state = P_BATT;
108 + else ac->ac_state = P_ERR;
109 + }
110 free(buf);
111 free(tmp);
112 }
113 @@ -212,14 +240,22 @@
114 list_t *lst = NULL;
115 adapter_t *ac = &globals->adapt;
117 + globals->sysstyle = 0;
118 if((lst = dir_list(PROC_ACPI "ac_adapter")) == NULL || !lst->top)
119 - return NOT_SUPPORTED;
120 -
121 + {
122 + if((lst = dir_list(SYS_POWER "/AC")) == NULL || !lst->top)
123 + return NOT_SUPPORTED;
124 + else
125 + globals->sysstyle = 1;
126 + }
127 if((!lst->top->name || ((ac->name = strdup(lst->top->name)) == NULL))){
128 delete_list(lst);
129 return ALLOC_ERR;
130 }
131 - snprintf(ac->state_file, MAX_NAME, PROC_ACPI "ac_adapter/%s/state", ac->name);
132 + if(globals->sysstyle)
133 + snprintf(ac->state_file, MAX_NAME, SYS_POWER "/AC/online");
134 + else
135 + snprintf(ac->state_file, MAX_NAME, PROC_ACPI "ac_adapter/%s/state", ac->name);
136 delete_list(lst);
137 read_acpi_acstate(globals);
138 return SUCCESS;
139 @@ -450,7 +486,7 @@
141 /* read alarm capacity, return 0 on success, negative values on error */
142 static int
143 -read_acpi_battalarm(const int num){
144 +read_acpi_battalarm(const int num, const int sysstyle){
145 char *buf = NULL;
146 char *tmp = NULL;
147 battery_t *info = &batteries[num];
148 @@ -458,10 +494,22 @@
149 if((buf = get_acpi_content(info->alarm_file)) == NULL)
150 return NOT_SUPPORTED;
152 - if((tmp = scan_acpi_value(buf, "alarm:")) && tmp[0] != 'u')
153 - info->alarm = strtol(tmp, NULL, 10);
154 + if(sysstyle)
155 + {
156 + if(!strcmp(buf, "0"))
157 + info->alarm = 0;
158 + else if(!strcmp(buf, "1"))
159 + info->alarm = 1;
160 + else
161 + info->alarm = NOT_SUPPORTED;
162 + }
163 else
164 - info->alarm = NOT_SUPPORTED;
165 + {
166 + if((tmp = scan_acpi_value(buf, "alarm:")) && tmp[0] != 'u')
167 + info->alarm = strtol(tmp, NULL, 10);
168 + else
169 + info->alarm = NOT_SUPPORTED;
170 + }
171 free(buf);
172 free(tmp);
173 return SUCCESS;
174 @@ -469,11 +517,58 @@
176 /* reads static values for a battery (info file), returns SUCCESS */
177 static int
178 -read_acpi_battinfo(const int num){
179 +read_acpi_battinfo(const int num, const int sysstyle){
180 char *buf = NULL;
181 char *tmp = NULL;
182 battery_t *info = &batteries[num];
183 int i = 0;
184 + char sysfile[MAX_NAME];
185 +
186 + if(sysstyle)
187 + {
188 + snprintf(sysfile, MAX_NAME, "%s/present", info->info_file);
189 + if((buf = get_acpi_content(sysfile)) == NULL)
190 + return NOT_SUPPORTED;
191 + if(!strcmp(buf, "1")) {
192 + info->present = 1;
193 + } else {
194 + info->present = 0;
195 + return NOT_PRESENT;
196 + }
197 +
198 + snprintf(sysfile, MAX_NAME, "%s/charge_full_design", info->info_file);
199 + if((buf = get_acpi_content(sysfile)) == NULL)
200 + return NOT_SUPPORTED;
201 + info->design_cap = strtol(buf, NULL, 10);
202 +
203 + snprintf(sysfile, MAX_NAME, "%s/charge_full", info->info_file);
204 + if((buf = get_acpi_content(sysfile)) == NULL)
205 + return NOT_SUPPORTED;
206 + info->last_full_cap = strtol(buf, NULL, 10);
207 +
208 + snprintf(sysfile, MAX_NAME, "%s/charge_now", info->info_file);
209 + if((buf = get_acpi_content(sysfile)) == NULL)
210 + return NOT_SUPPORTED;
211 + info->remaining_cap = strtol(buf, NULL, 10);
212 +
213 + snprintf(sysfile, MAX_NAME, "%s/voltage_min_design", info->info_file);
214 + if((buf = get_acpi_content(sysfile)) == NULL)
215 + return NOT_SUPPORTED;
216 + info->design_voltage = strtol(buf, NULL, 10);
217 +
218 + snprintf(sysfile, MAX_NAME, "%s/voltage_now", info->info_file);
219 + if((buf = get_acpi_content(sysfile)) == NULL)
220 + return NOT_SUPPORTED;
221 + info->present_voltage = strtol(buf, NULL, 10);
222 +
223 + /* FIXME: is rate == current here? */
224 + snprintf(sysfile, MAX_NAME, "%s/current_now", info->info_file);
225 + if((buf = get_acpi_content(sysfile)) == NULL)
226 + return NOT_SUPPORTED;
227 + info->present_rate = strtol(buf, NULL, 10);
228 +
229 + return SUCCESS;
230 + }
232 if((buf = get_acpi_content(info->info_file)) == NULL)
233 return NOT_SUPPORTED;
234 @@ -608,7 +703,7 @@
235 read_acpi_batt(const int num){
236 if(num > MAX_ITEMS) return ITEM_EXCEED;
237 read_acpi_battstate(num);
238 - read_acpi_battalarm(num);
239 + read_acpi_battalarm(num, 0);
240 calc_remain_perc(num);
241 calc_remain_chargetime(num);
242 calc_remain_time(num);
243 --- libacpi-0.2.orig/test-libacpi.c
244 +++ libacpi-0.2/test-libacpi.c
245 @@ -46,6 +46,7 @@
246 read_acpi_batt(i);
248 if(binfo->present)
249 + {
250 printf("\n%s:\tpresent: %d\n"
251 "\tdesign capacity: %d\n"
252 "\tlast full capacity: %d\n"
253 @@ -65,6 +66,9 @@
254 binfo->batt_state, binfo->percentage,
255 binfo->charge_time / 60, binfo->charge_time % 60,
256 binfo->remaining_time / 60, binfo->remaining_time % 60);
257 + if(binfo->alarm)
258 + printf("%s: Alarm!\n", binfo->name);
259 + }
260 }
261 } else printf("Battery information:\tnot supported\n");
263 --- libacpi-0.2.orig/debian/control
264 +++ libacpi-0.2/debian/control
265 @@ -0,0 +1,30 @@
266 +Source: libacpi
267 +Priority: optional
268 +Maintainer: Nico Golde <nion@debian.org>
269 +Build-Depends: debhelper (>= 5)
270 +Standards-Version: 3.7.3
271 +Section: libs
272 +Homepage: http://www.ngolde.de/libacpi.html
273 +
274 +Package: libacpi-dev
275 +Section: libdevel
276 +Architecture: i386 ia64 amd64
277 +Depends: libacpi0 (= ${binary:Version})
278 +Description: development files for libacpi
279 + libacpi is a general purpose shared library for programs gathering
280 + ACPI data on Linux. It implements thermal zones, battery information,
281 + fan information and AC states.
282 + .
283 + This package contains the header files and static libraries needed to
284 + compile applications or shared objects that use libacpi.
285 +
286 +Package: libacpi0
287 +Section: libs
288 +Architecture: i386 ia64 amd64
289 +Depends: ${shlibs:Depends}, ${misc:Depends}
290 +Description: general purpose library for ACPI
291 + libacpi is a general purpose shared library for programs gathering
292 + ACPI data on Linux. It implements thermal zones, battery information,
293 + fan information and AC states.
294 + .
295 + This package contains the shared library for libacpi.
296 --- libacpi-0.2.orig/debian/libacpi-dev.install
297 +++ libacpi-0.2/debian/libacpi-dev.install
298 @@ -0,0 +1,4 @@
299 +usr/include/*
300 +usr/lib/lib*.a
301 +usr/lib/lib*.so
302 +usr/share/man/man3/libacpi.3
303 --- libacpi-0.2.orig/debian/compat
304 +++ libacpi-0.2/debian/compat
305 @@ -0,0 +1 @@
306 +5
307 --- libacpi-0.2.orig/debian/docs
308 +++ libacpi-0.2/debian/docs
309 @@ -0,0 +1 @@
310 +README
311 --- libacpi-0.2.orig/debian/changelog
312 +++ libacpi-0.2/debian/changelog
313 @@ -0,0 +1,44 @@
314 +libacpi (0.2-4) unstable; urgency=low
315 +
316 + * Fix interface incompatibilities introduced by last patch (Closes: #464276).
317 +
318 + -- Nico Golde <nion@debian.org> Wed, 06 Feb 2008 11:31:13 +0100
319 +
320 +libacpi (0.2-3) unstable; urgency=low
321 +
322 + * Temporary patch libacpi to make battery and ac status work with
323 + kernels >= 2.6.24. There will be a fixed upstream version
324 + which uses sysfs and procfs as fallback soon. Many thanks
325 + to Joseph Spillner for the patch! (Closes: #463986, #463982).
326 +
327 + -- Nico Golde <nion@debian.org> Mon, 04 Feb 2008 22:35:35 +0100
328 +
329 +libacpi (0.2-2) unstable; urgency=low
330 +
331 + * Bumped Standards Version, no changes needed.
332 + * Switched from Homepage tag to Homepage control field.
333 +
334 + -- Nico Golde <nion@debian.org> Wed, 02 Jan 2008 14:42:01 +0100
335 +
336 +libacpi (0.2-1) unstable; urgency=low
337 +
338 + * New upstream release.
339 + Fixed double header inclusion (Closes: #433399).
340 +
341 + -- Nico Golde <nion@debian.org> Sun, 29 Jul 2007 14:13:59 +0200
342 +
343 +libacpi (0.1-2) unstable; urgency=low
344 +
345 + * Just build this package for amd64,i386 and ia64 since
346 + the other archs have on ACPI support (Closes: #432432).
347 + * Switched from Source-Version to binary:Version.
348 + * Do not suppress make clean output any longer.
349 +
350 + -- Nico Golde <nion@debian.org> Tue, 10 Jul 2007 18:18:08 +0200
351 +
352 +libacpi (0.1-1) unstable; urgency=low
353 +
354 + * Initial release (Closes: #429573).
355 +
356 + -- Nico Golde <nion@debian.org> Mon, 18 Jun 2007 22:11:10 +0200
357 +
358 --- libacpi-0.2.orig/debian/libacpi0.install
359 +++ libacpi-0.2/debian/libacpi0.install
360 @@ -0,0 +1 @@
361 +usr/lib/lib*.so.*
362 --- libacpi-0.2.orig/debian/copyright
363 +++ libacpi-0.2/debian/copyright
364 @@ -0,0 +1,34 @@
365 +This package was debianized by Nico Golde <nion@debian.org> on
366 +Mon, 18 Jun 2007 22:11:10 +0200.
367 +
368 +It was downloaded from http://www.ngolde.de/libacpi.html
369 +
370 +Upstream Author: Nico Golde <nico@ngolde.de>
371 +
372 +Copyright: 2007 Nico Golde
373 +
374 +License:
375 +
376 + Copyright (C) 2007 Nico Golde <nico@ngolde.de>
377 +
378 + Permission is hereby granted, free of charge, to any person obtaining a
379 + copy of this software and associated documentation files (the
380 + "Software"), to deal in the Software without restriction, including
381 + without limitation the rights to use, copy, modify, merge, publish,
382 + distribute, sublicense, and/or sell copies of the Software, and to
383 + permit persons to whom the Software is furnished to do so, subject to
384 + the following conditions:
385 +
386 + The above copyright notice and this permission notice shall be included
387 + in all copies or substantial portions of the Software.
388 +
389 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
390 + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
391 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
392 + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
393 + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
394 + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
395 + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
396 +
397 +The Debian packaging is (C) 2007, Nico Golde <nion@debian.org> and
398 +is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
399 --- libacpi-0.2.orig/debian/rules
400 +++ libacpi-0.2/debian/rules
401 @@ -0,0 +1,57 @@
402 +#!/usr/bin/make -f
403 +#export DH_VERBOSE=1
404 +
405 +CFLAGS = -Wall -g
406 +
407 +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
408 + CFLAGS += -O0
409 +else
410 + CFLAGS += -O2
411 +endif
412 +
413 +build: build-stamp
414 +build-stamp:
415 + dh_testdir
416 + $(MAKE)
417 +
418 + touch $@
419 +
420 +clean:
421 + dh_testdir
422 + dh_testroot
423 + rm -f build-stamp
424 +
425 + $(MAKE) clean
426 + dh_clean
427 +
428 +install: build
429 + dh_testdir
430 + dh_testroot
431 + dh_clean -k
432 + dh_installdirs
433 +
434 + $(MAKE) DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr install
435 +
436 +binary-indep: build install
437 +
438 +binary-arch: build install
439 + dh_testdir
440 + dh_testroot
441 + dh_installchangelogs CHANGES
442 + dh_installdocs doc/
443 + dh_installexamples test-libacpi.c
444 + dh_install --sourcedir=debian/tmp --list-missing
445 + dh_link
446 + dh_strip
447 + dh_compress
448 + dh_fixperms
449 + dh_makeshlibs
450 + dh_makeshlibs
451 + dh_installdeb
452 + dh_shlibdeps
453 + dh_gencontrol
454 + dh_md5sums
455 + dh_builddeb
456 +
457 +binary: binary-indep binary-arch
458 +.PHONY: build clean binary-indep binary-arch binary install