rpms/libacpi/devel import.log, NONE, 1.1 libacpi-0.2-sysfs.patch, NONE, 1.1 libacpi-0.2.patch, NONE, 1.1 libacpi.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
Sven Lankes
slankes at fedoraproject.org
Mon Aug 25 18:30:18 UTC 2008
Author: slankes
Update of /cvs/pkgs/rpms/libacpi/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13281/devel
Modified Files:
.cvsignore sources
Added Files:
import.log libacpi-0.2-sysfs.patch libacpi-0.2.patch
libacpi.spec
Log Message:
Initial import
--- NEW FILE import.log ---
libacpi-0_2-12_fc10:HEAD:libacpi-0.2-12.fc10.src.rpm:1219688733
libacpi-0.2-sysfs.patch:
--- NEW FILE libacpi-0.2-sysfs.patch ---
diff -Naur libacpi-0.2-orig/libacpi.c libacpi-0.2/libacpi.c
--- libacpi-0.2-orig/libacpi.c 2007-07-29 14:09:34.000000000 +0200
+++ libacpi-0.2/libacpi.c 2008-08-02 10:41:11.000000000 +0200
@@ -14,8 +14,9 @@
#include "libacpi.h"
#include "list.h"
-static int read_acpi_battinfo(const int num);
-static int read_acpi_battalarm(const int num);
+
+static int read_acpi_battinfo(const int num, const int sysstyle);
+static int read_acpi_battalarm(const int num, const int sysstyle);
static int read_acpi_battstate(const int num);
static void read_acpi_thermalzones(global_t *globals);
@@ -144,8 +145,15 @@
int i = 0;
globals->batt_count = 0;
+ globals->sysstyle = 0;
if((lst = dir_list(PROC_ACPI "battery")) == NULL || !lst->top)
- return NOT_SUPPORTED;
+ {
+ /* check for new Linux 2.6.24+ layout */
+ if((lst = dir_list(SYS_POWER)) == NULL || !lst->top)
+ return NOT_SUPPORTED;
+ else
+ globals->sysstyle = 1;
+ }
for(node = lst->top; node; node=node->next){
if((names[globals->batt_count] = strdup(node->name)) == NULL){
delete_list(lst);
@@ -174,11 +182,20 @@
for (i=0; i < globals->batt_count && i < MAX_ITEMS; i++){
binfo = &batteries[i];
snprintf(binfo->name, MAX_NAME, "%s", names[i]);
- snprintf(binfo->state_file, MAX_NAME, PROC_ACPI "battery/%s/state", names[i]);
- snprintf(binfo->info_file, MAX_NAME, PROC_ACPI "battery/%s/info", names[i]);
- snprintf(binfo->alarm_file, MAX_NAME, PROC_ACPI "battery/%s/alarm", names[i]);
- read_acpi_battinfo(i);
- read_acpi_battalarm(i);
+ if(globals->sysstyle)
+ {
+ snprintf(binfo->state_file, MAX_NAME, "/%s/present", names[i]);
+ snprintf(binfo->info_file, MAX_NAME, SYS_POWER "/%s", names[i]);
+ snprintf(binfo->alarm_file, MAX_NAME, SYS_POWER "/%s/alarm", names[i]);
+ }
+ else
+ {
+ snprintf(binfo->state_file, MAX_NAME, PROC_ACPI "battery/%s/state", names[i]);
+ snprintf(binfo->info_file, MAX_NAME, PROC_ACPI "battery/%s/info", names[i]);
+ snprintf(binfo->alarm_file, MAX_NAME, PROC_ACPI "battery/%s/alarm", names[i]);
+ }
+ read_acpi_battinfo(i, globals->sysstyle);
+ read_acpi_battalarm(i, globals->sysstyle);
free(names[i]);
}
delete_list(lst);
@@ -196,11 +213,22 @@
ac->ac_state = P_ERR;
return;
}
- if((tmp = scan_acpi_value(buf, "state:")) && !strncmp(tmp, "on-line", 7))
- ac->ac_state = P_AC;
- else if(tmp && !strncmp(tmp, "off-line", 8))
- ac->ac_state = P_BATT;
- else ac->ac_state = P_ERR;
+ if(globals->sysstyle)
+ {
+ if(!strcmp(buf, "1"))
+ ac->ac_state = P_AC;
+ else if(!strcmp(buf, "0"))
+ ac->ac_state = P_BATT;
+ else ac->ac_state = P_ERR;
+ }
+ else
+ {
+ if((tmp = scan_acpi_value(buf, "state:")) && !strncmp(tmp, "on-line", 7))
+ ac->ac_state = P_AC;
+ else if(tmp && !strncmp(tmp, "off-line", 8))
+ ac->ac_state = P_BATT;
+ else ac->ac_state = P_ERR;
+ }
free(buf);
free(tmp);
}
@@ -212,14 +240,22 @@
list_t *lst = NULL;
adapter_t *ac = &globals->adapt;
+ globals->sysstyle = 0;
if((lst = dir_list(PROC_ACPI "ac_adapter")) == NULL || !lst->top)
- return NOT_SUPPORTED;
-
+ {
+ if((lst = dir_list(SYS_POWER "/AC")) == NULL || !lst->top)
+ return NOT_SUPPORTED;
+ else
+ globals->sysstyle = 1;
+ }
if((!lst->top->name || ((ac->name = strdup(lst->top->name)) == NULL))){
delete_list(lst);
return ALLOC_ERR;
}
- snprintf(ac->state_file, MAX_NAME, PROC_ACPI "ac_adapter/%s/state", ac->name);
+ if(globals->sysstyle)
+ snprintf(ac->state_file, MAX_NAME, SYS_POWER "/AC/online");
+ else
+ snprintf(ac->state_file, MAX_NAME, PROC_ACPI "ac_adapter/%s/state", ac->name);
delete_list(lst);
read_acpi_acstate(globals);
return SUCCESS;
@@ -450,7 +486,7 @@
/* read alarm capacity, return 0 on success, negative values on error */
static int
-read_acpi_battalarm(const int num){
+read_acpi_battalarm(const int num, const int sysstyle){
char *buf = NULL;
char *tmp = NULL;
battery_t *info = &batteries[num];
@@ -458,10 +494,22 @@
if((buf = get_acpi_content(info->alarm_file)) == NULL)
return NOT_SUPPORTED;
- if((tmp = scan_acpi_value(buf, "alarm:")) && tmp[0] != 'u')
- info->alarm = strtol(tmp, NULL, 10);
+ if(sysstyle)
+ {
+ if(!strcmp(buf, "0"))
+ info->alarm = 0;
+ else if(!strcmp(buf, "1"))
+ info->alarm = 1;
+ else
+ info->alarm = NOT_SUPPORTED;
+ }
else
- info->alarm = NOT_SUPPORTED;
+ {
+ if((tmp = scan_acpi_value(buf, "alarm:")) && tmp[0] != 'u')
+ info->alarm = strtol(tmp, NULL, 10);
+ else
+ info->alarm = NOT_SUPPORTED;
+ }
free(buf);
free(tmp);
return SUCCESS;
@@ -469,11 +517,58 @@
/* reads static values for a battery (info file), returns SUCCESS */
static int
-read_acpi_battinfo(const int num){
+read_acpi_battinfo(const int num, const int sysstyle){
char *buf = NULL;
char *tmp = NULL;
battery_t *info = &batteries[num];
int i = 0;
+ char sysfile[MAX_NAME];
+
+ if(sysstyle)
+ {
+ snprintf(sysfile, MAX_NAME, "%s/present", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ if(!strcmp(buf, "1")) {
+ info->present = 1;
+ } else {
+ info->present = 0;
+ return NOT_PRESENT;
+ }
+
+ snprintf(sysfile, MAX_NAME, "%s/charge_full_design", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->design_cap = strtol(buf, NULL, 10);
+
+ snprintf(sysfile, MAX_NAME, "%s/charge_full", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->last_full_cap = strtol(buf, NULL, 10);
+
+ snprintf(sysfile, MAX_NAME, "%s/charge_now", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->remaining_cap = strtol(buf, NULL, 10);
+
+ snprintf(sysfile, MAX_NAME, "%s/voltage_min_design", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->design_voltage = strtol(buf, NULL, 10);
+
+ snprintf(sysfile, MAX_NAME, "%s/voltage_now", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->present_voltage = strtol(buf, NULL, 10);
+
+ /* FIXME: is rate == current here? */
+ snprintf(sysfile, MAX_NAME, "%s/current_now", info->info_file);
+ if((buf = get_acpi_content(sysfile)) == NULL)
+ return NOT_SUPPORTED;
+ info->present_rate = strtol(buf, NULL, 10);
+
+ return SUCCESS;
+ }
if((buf = get_acpi_content(info->info_file)) == NULL)
return NOT_SUPPORTED;
@@ -608,7 +703,7 @@
read_acpi_batt(const int num){
if(num > MAX_ITEMS) return ITEM_EXCEED;
read_acpi_battstate(num);
- read_acpi_battalarm(num);
+ read_acpi_battalarm(num, 0);
calc_remain_perc(num);
calc_remain_chargetime(num);
calc_remain_time(num);
diff -Naur libacpi-0.2-orig/libacpi.h libacpi-0.2/libacpi.h
--- libacpi-0.2-orig/libacpi.h 2007-07-29 14:09:34.000000000 +0200
+++ libacpi-0.2/libacpi.h 2008-08-02 10:41:11.000000000 +0200
@@ -12,6 +12,8 @@
#define __LIBACPI_H__
#define PROC_ACPI "/proc/acpi/"
+#define SYS_POWER "/sys/class/power_supply"
+
#define LINE_MAX 256
#define MAX_NAME 512
#define MAX_BUF 1024
@@ -177,6 +179,7 @@
int fan_count; /**< number of found fans */
int temperature; /**< system temperature if we only have on thermal zone */
adapter_t adapt; /**< ac adapter */
+ int sysstyle;
} global_t;
/**
@@ -239,6 +242,7 @@
* Looks up if the ac adapter is plugged in or not
* and sets the values in a struct
* @param globals pointer to the global acpi structure
+ * @param sysstyle whether or not to use the /sys interface
*/
void read_acpi_acstate(global_t *globals);
/**
diff -Naur libacpi-0.2-orig/test-libacpi.c libacpi-0.2/test-libacpi.c
--- libacpi-0.2-orig/test-libacpi.c 2007-07-29 14:09:34.000000000 +0200
+++ libacpi-0.2/test-libacpi.c 2008-08-02 10:41:11.000000000 +0200
@@ -46,6 +46,7 @@
read_acpi_batt(i);
if(binfo->present)
+ {
printf("\n%s:\tpresent: %d\n"
"\tdesign capacity: %d\n"
"\tlast full capacity: %d\n"
@@ -65,6 +66,9 @@
binfo->batt_state, binfo->percentage,
binfo->charge_time / 60, binfo->charge_time % 60,
binfo->remaining_time / 60, binfo->remaining_time % 60);
+ if(binfo->alarm)
+ printf("%s: Alarm!\n", binfo->name);
+ }
}
} else printf("Battery information:\tnot supported\n");
libacpi-0.2.patch:
--- NEW FILE libacpi-0.2.patch ---
diff -Naur libacpi-0.2.orig/Makefile libacpi-0.2/Makefile
--- libacpi-0.2.orig/Makefile 2007-07-29 14:09:34.000000000 +0200
+++ libacpi-0.2/Makefile 2008-05-06 23:09:14.000000000 +0200
@@ -40,25 +40,23 @@
install: all
@echo installing header to ${DESTDIR}${PREFIX}/include
@mkdir -p ${DESTDIR}${PREFIX}/include
- @cp -f libacpi.h ${DESTDIR}${PREFIX}/include
+ @cp -f -p libacpi.h ${DESTDIR}${PREFIX}/include
@chmod 644 ${DESTDIR}${PREFIX}/include/libacpi.h
- @echo installing library to ${DESTDIR}${PREFIX}/lib
- @mkdir -p ${DESTDIR}${PREFIX}/lib
- @cp -f libacpi.a ${DESTDIR}${PREFIX}/lib
- @chmod 644 ${DESTDIR}${PREFIX}/lib/libacpi.a
- @cp -f ${SONAME} ${DESTDIR}${PREFIX}/lib/
- @chmod 644 ${DESTDIR}${PREFIX}/lib/${SONAME}
- @ln -s ${SONAME} ${DESTDIR}${PREFIX}/lib/libacpi.so
+ @echo installing library to ${DESTDIR}${LIBDIR}
+ @mkdir -p ${DESTDIR}${LIBDIR}
+ @cp -f -p ${SONAME} ${DESTDIR}${LIBDIR}/
+ @chmod 644 ${DESTDIR}${LIBDIR}/${SONAME}
+ @ln -s ${SONAME} ${DESTDIR}${LIBDIR}/libacpi.so
@echo installing test-libacpi to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
- @cp -f test-libacpi ${DESTDIR}${PREFIX}/bin
+ @cp -f -p test-libacpi ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/test-libacpi
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man3
@mkdir -p ${DESTDIR}${MANPREFIX}/man3
- @cp libacpi.3 ${DESTDIR}${MANPREFIX}/man3
+ @cp -p libacpi.3 ${DESTDIR}${MANPREFIX}/man3
@echo installing documentation and misc files to ${DESTDIR}${PREFIX}/share/doc/libacpi
@mkdir -p ${DESTDIR}${PREFIX}/share/doc/libacpi
- @cp -r AUTHORS CHANGES README LICENSE doc ${DESTDIR}${PREFIX}/share/doc/libacpi
+ @cp -r -p AUTHORS CHANGES README LICENSE doc ${DESTDIR}${PREFIX}/share/doc/libacpi
@echo finished installation
uninstall:
--- NEW FILE libacpi.spec ---
Name: libacpi
Version: 0.2
Release: 12%{?dist}
Summary: General purpose library for ACPI
Group: System Environment/Libraries
License: MIT
URL: http://www.ngolde.de/libacpi.html
Source0: http://www.ngolde.de/download/%{name}-%{version}.tar.gz
Patch0: %{name}-%{version}.patch
Patch1: %{name}-%{version}-sysfs.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
ExcludeArch: ppc ppc64
%description
libacpi is a general purpose shared library for programs gathering
ACPI data on Linux. Features: Thermal zones support, Battery support,
Fan support, AC support
Note: This is no portable code, it will only run on i386/x86_64 Linux systems.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
sed -i "s/CFLAGS += .*/CFLAGS += -fPIC $RPM_OPT_FLAGS/;s&usr/local&usr&" config.mk
sed -i "s&share/doc/%{name}&share/doc/%{name}-%{version}&g" Makefile
%build
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT LIBDIR=%_libdir
chmod +x $RPM_BUILD_ROOT%{_libdir}/%{name}.so.*
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%{_mandir}/man3/*
%dir %{_defaultdocdir}/%{name}-%{version}
%doc %{_defaultdocdir}/%{name}-%{version}/AUTHORS
%doc %{_defaultdocdir}/%{name}-%{version}/CHANGES
%doc %{_defaultdocdir}/%{name}-%{version}/README
%doc %{_defaultdocdir}/%{name}-%{version}/LICENSE
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root,-)
%dir %{_defaultdocdir}/%{name}-%{version}/doc
%doc %{_defaultdocdir}/%{name}-%{version}/doc/*
%{_bindir}/test-libacpi
%{_includedir}/*
%{_libdir}/*.so
%changelog
* Tue Aug 19 2008 Sven Lankes <sven at lank.es> - 0.2-12
- Add ExcludeArch for ppc/ppc64
* Sat Aug 2 2008 Sven Lankes <sven at lank.es> - 0.2-11
- redo sysfs patch to apply without fuzz
- fix patch invocation
* Mon Jul 7 2008 slankes <sven at lank.es> - 0.2-10
- minor specfile-tweaks
* Thu May 8 2008 slankes <sven at lank.es> - 0.2-9
- save docs in name-version instead of name
* Thu May 8 2008 slankes <sven at lank.es> - 0.2-8
- add missing docdir
* Tue May 6 2008 slankes <sven at lank.es> - 0.2-7
- patch Makefile to preserve timestamps
- only use sed to mangle config.mk
- add patch from debian-package to use sysfs for battery readout
needs at least kernel 2.6.24
* Mon May 5 2008 slankes <sven at lank.es> - 0.2-6
- Mark library as executable so that rpmbuild will strip it
- replace upstream CFLAGS
* Mon May 5 2008 slankes <sven at lank.es> - 0.2-5
- Various SPECFILE cleanups
- Remove .a
- do not strip library
* Sat May 3 2008 slankes <sven at lank.es> - 0.2-4
- First version of the package
Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/libacpi/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 24 Aug 2008 19:12:21 -0000 1.1
+++ .cvsignore 25 Aug 2008 18:29:48 -0000 1.2
@@ -0,0 +1 @@
+libacpi-0.2.tar.gz
Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/libacpi/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources 24 Aug 2008 19:12:21 -0000 1.1
+++ sources 25 Aug 2008 18:29:48 -0000 1.2
@@ -0,0 +1 @@
+05b53dd7bead66dda35fec502b91066c libacpi-0.2.tar.gz
More information about the fedora-extras-commits
mailing list