Import upower 0.9.10:

UPower is an abstraction for enumerating power devices, listening to
device events and querying history and statistics. Any application or
service on the system can access the org.freedesktop.UPower service
via the DBUS system message bus.

OpenBSD specific backend written by yours truly with help from upstream
developer. So far, battery levels and ac status works, using either apm
or acpibat/acpiac if available.

As a sidenote, if udev, udisks and friends were designed with the same
clear separation between os-specific and generic parts, porting to
'alternative OSes' would be much simpler. UPower is a nice example of
'how to design a portable service'.

with a patch for glib version check, tweaks and ok ajacoutot@
This commit is contained in:
landry 2011-05-23 19:04:57 +00:00
parent 99cbaafb32
commit f7272cc878
10 changed files with 264 additions and 0 deletions

51
sysutils/upower/Makefile Normal file
View File

@ -0,0 +1,51 @@
# $OpenBSD: Makefile,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
COMMENT = userland power management interface
DISTNAME = upower-0.9.10
CATEGORIES = sysutils
SHARED_LIBS += upower-glib 0.0 # 1.1
HOMEPAGE = http://upower.freedesktop.org/
MASTER_SITES = ${HOMEPAGE}/releases/
MAINTAINER = Landry Breuil <landry@openbsd.org>
#GPLv2+
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
CONFIGURE_STYLE = gnu
CONFIGURE_ARGS += ${CONFIGURE_SHARED} \
--disable-silent-rules \
--disable-gtk-doc \
--enable-introspection \
--enable-man-pages \
--with-backend=openbsd \
--without-idevice
CONFIGURE_ENV+= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"
FAKE_FLAGS = sysconfdir=${PREFIX}/share/examples/upower
USE_GMAKE = Yes
USE_LIBTOOL = Yes
MODULES = devel/gettext \
textproc/intltool
LIB_DEPENDS = sysutils/polkit>=0.101 \
x11/dbus-glib
BUILD_DEPENDS = textproc/libxslt,-main \
textproc/docbook-xsl
WANTLIB = c dbus-1 dbus-glib-1 glib-2.0 gobject-2.0 m \
polkit-gobject-1 pthread gthread-2.0 gio-2.0 \
gmodule-2.0 pcre z
post-extract:
cp ${FILESDIR}/up-apm-native.h ${WRKSRC}/src/openbsd
.include <bsd.port.mk>

5
sysutils/upower/distinfo Normal file
View File

@ -0,0 +1,5 @@
MD5 (upower-0.9.10.tar.gz) = K18+M6wyIj4nxQUQ+q1znw==
RMD160 (upower-0.9.10.tar.gz) = xs6d1F49Q/gZh9hNNrZ6O8mFX4g=
SHA1 (upower-0.9.10.tar.gz) = cb9p6sDWfq5P1Lbcn/nraRj4QSE=
SHA256 (upower-0.9.10.tar.gz) = e+Tf3gTb/4lEGcZuusB6QfoGXqMBnsx2YUIi5mI82/k=
SIZE (upower-0.9.10.tar.gz) = 631469

View File

@ -0,0 +1,78 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2011 Landry Breuil <landry@openbsd.org>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __UP_APM_NATIVE_H__
#define __UP_APM_NATIVE_H__
/* os-specific headers */
#include <errno.h> /* errno */
#include <fcntl.h> /* open() */
/* kevent() */
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#include <sys/ioctl.h> /* ioctl() */
/* APM macros */
#include <machine/apmvar.h>
/* sensor struct defs */
#include <sys/sensors.h>
/* sysctl() */
#include <sys/param.h>
#include <sys/sysctl.h>
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define UP_TYPE_APM_NATIVE (up_apm_native_get_type ())
#define UP_APM_NATIVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_APM_NATIVE, UpApmNative))
#define UP_APM_NATIVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_APM_NATIVE, UpApmNativeClass))
#define UP_IS_APM_NATIVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_APM_NATIVE))
#define UP_IS_APM_NATIVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_APM_NATIVE))
#define UP_APM_NATIVE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_APM_NATIVE, UpApmNativeClass))
typedef struct
{
GObject parent;
gchar* path;
} UpApmNative;
typedef struct
{
GObjectClass parent_class;
} UpApmNativeClass;
// XX in .c ?
//GType up_apm_native_get_type (void);
//G_DEFINE_TYPE (UpApmNative, up_apm_native, G_TYPE_OBJECT)
UpApmNative* up_apm_native_new (const char*);
const gchar * up_apm_native_get_path(UpApmNative*);
gboolean up_native_is_laptop();
gboolean up_native_get_sensordev(const char*, struct sensordev*);
G_END_DECLS
#endif

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-configure,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
--- configure.orig Mon Mar 21 19:42:08 2011
+++ configure Sat May 21 13:07:51 2011
@@ -14138,10 +14138,6 @@ else
fi
-if test "x$GCC" = "xyes"; then
- LDFLAGS="-Wl,--as-needed $LDFLAGS"
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5
$as_echo_n "checking whether NLS is requested... " >&6; }

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-src_Makefile_in,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
no need for var/lib/upower
--- src/Makefile.in.orig Tue Apr 26 14:41:41 2011
+++ src/Makefile.in Sat May 21 13:07:51 2011
@@ -1542,9 +1542,6 @@ $(dbusconf_DATA): $(dbusconf_in_files) Makefile
cp $< $@
install-data-hook:
- if test -w $(DESTDIR)$(prefix)/; then \
- mkdir -p $(DESTDIR)$(localstatedir)/lib/upower; \
- fi
clean-local :
rm -f *~ $(service_DATA) $(dbusconf_DATA)

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-src_up-main_c,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
glib-unix.h and g_unix_signal_add_watch_full appeared in glib 2.29.5
--- src/up-main.c.orig Sun May 22 22:35:09 2011
+++ src/up-main.c Sun May 22 22:35:14 2011
@@ -41,7 +41,7 @@
#include "up-kbd-backlight.h"
#include "up-wakeups.h"
-#if GLIB_CHECK_VERSION(2,28,7)
+#if GLIB_CHECK_VERSION(2,29,5)
#include <glib-unix.h>
#endif
@@ -92,7 +92,7 @@ out:
return ret;
}
-#if GLIB_CHECK_VERSION(2,28,7)
+#if GLIB_CHECK_VERSION(2,29,5)
/**
* up_main_sigint_cb:
@@ -201,7 +201,7 @@ main (gint argc, gchar **argv)
goto out;
}
-#if GLIB_CHECK_VERSION(2,28,7)
+#if GLIB_CHECK_VERSION(2,29,5)
/* do stuff on ctrl-c */
g_unix_signal_add_watch_full (SIGINT,
G_PRIORITY_DEFAULT,

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-tools_Makefile_in,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
--- tools/Makefile.in.orig Mon Mar 21 19:42:07 2011
+++ tools/Makefile.in Sat May 21 13:07:51 2011
@@ -292,6 +292,7 @@ upower_LDFLAGS = -pthread
upower_LDADD = \
$(DBUS_GLIB_LIBS) \
$(UPOWER_LIBS) \
+ -pthread \
$(POLKIT_DBUS_LIBS)
CLEANFILES = $(BUILT_SOURCES)

View File

@ -0,0 +1,4 @@
UPower is an abstraction for enumerating power devices, listening to
device events and querying history and statistics. Any application or
service on the system can access the org.freedesktop.UPower service
via the DBUS system message bus.

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
@lib lib/libupower-glib.so.${LIBupower-glib_VERSION}

54
sysutils/upower/pkg/PLIST Normal file
View File

@ -0,0 +1,54 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2011/05/23 19:04:57 landry Exp $
%%SHARED%%
@bin bin/upower
include/libupower-glib/
include/libupower-glib/up-client.h
include/libupower-glib/up-device.h
include/libupower-glib/up-history-item.h
include/libupower-glib/up-qos-item.h
include/libupower-glib/up-stats-item.h
include/libupower-glib/up-types.h
include/libupower-glib/up-version.h
include/libupower-glib/up-wakeup-item.h
include/libupower-glib/up-wakeups.h
include/libupower-glib/upower.h
lib/girepository-1.0/
lib/girepository-1.0/UPowerGlib-1.0.typelib
lib/libupower-glib.a
lib/libupower-glib.la
lib/pkgconfig/
lib/pkgconfig/upower-glib.pc
@bin libexec/upowerd
@man man/man1/upower.1
@man man/man7/UPower.7
@man man/man8/upowerd.8
share/dbus-1/
share/dbus-1/interfaces/
share/dbus-1/interfaces/org.freedesktop.UPower.Device.xml
share/dbus-1/interfaces/org.freedesktop.UPower.KbdBacklight.xml
share/dbus-1/interfaces/org.freedesktop.UPower.QoS.xml
share/dbus-1/interfaces/org.freedesktop.UPower.Wakeups.xml
share/dbus-1/interfaces/org.freedesktop.UPower.xml
share/dbus-1/system-services/
share/dbus-1/system-services/org.freedesktop.UPower.service
share/examples/upower/
share/examples/upower/UPower/
@sample ${SYSCONFDIR}/UPower/
share/examples/upower/UPower/UPower.conf
@sample ${SYSCONFDIR}/UPower/UPower.conf
share/examples/upower/dbus-1/
@sample ${SYSCONFDIR}/dbus-1/
share/examples/upower/dbus-1/system.d/
@sample ${SYSCONFDIR}/dbus-1/system.d/
share/examples/upower/dbus-1/system.d/org.freedesktop.UPower.conf
@sample ${SYSCONFDIR}/dbus-1/system.d/org.freedesktop.UPower.conf
share/gir-1.0/
share/gir-1.0/UPowerGlib-1.0.gir
share/locale/fr/LC_MESSAGES/upower.mo
share/locale/it/LC_MESSAGES/upower.mo
share/locale/pl/LC_MESSAGES/upower.mo
share/locale/sv/LC_MESSAGES/upower.mo
share/polkit-1/
share/polkit-1/actions/
share/polkit-1/actions/org.freedesktop.upower.policy
share/polkit-1/actions/org.freedesktop.upower.qos.policy