From f7272cc878c49a193363fbab74d00ac7eaf1acc0 Mon Sep 17 00:00:00 2001 From: landry Date: Mon, 23 May 2011 19:04:57 +0000 Subject: [PATCH] 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@ --- sysutils/upower/Makefile | 51 ++++++++++++ sysutils/upower/distinfo | 5 ++ sysutils/upower/files/up-apm-native.h | 78 +++++++++++++++++++ sysutils/upower/patches/patch-configure | 14 ++++ sysutils/upower/patches/patch-src_Makefile_in | 14 ++++ sysutils/upower/patches/patch-src_up-main_c | 31 ++++++++ .../upower/patches/patch-tools_Makefile_in | 11 +++ sysutils/upower/pkg/DESCR | 4 + sysutils/upower/pkg/PFRAG.shared | 2 + sysutils/upower/pkg/PLIST | 54 +++++++++++++ 10 files changed, 264 insertions(+) create mode 100644 sysutils/upower/Makefile create mode 100644 sysutils/upower/distinfo create mode 100644 sysutils/upower/files/up-apm-native.h create mode 100644 sysutils/upower/patches/patch-configure create mode 100644 sysutils/upower/patches/patch-src_Makefile_in create mode 100644 sysutils/upower/patches/patch-src_up-main_c create mode 100644 sysutils/upower/patches/patch-tools_Makefile_in create mode 100644 sysutils/upower/pkg/DESCR create mode 100644 sysutils/upower/pkg/PFRAG.shared create mode 100644 sysutils/upower/pkg/PLIST diff --git a/sysutils/upower/Makefile b/sysutils/upower/Makefile new file mode 100644 index 00000000000..e3b425ac40a --- /dev/null +++ b/sysutils/upower/Makefile @@ -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 + +#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 diff --git a/sysutils/upower/distinfo b/sysutils/upower/distinfo new file mode 100644 index 00000000000..27b8b30040a --- /dev/null +++ b/sysutils/upower/distinfo @@ -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 diff --git a/sysutils/upower/files/up-apm-native.h b/sysutils/upower/files/up-apm-native.h new file mode 100644 index 00000000000..16ec85eca82 --- /dev/null +++ b/sysutils/upower/files/up-apm-native.h @@ -0,0 +1,78 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2011 Landry Breuil + * + * 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 */ +#include /* open() */ +/* kevent() */ +#include +#include +#include +#include /* ioctl() */ +/* APM macros */ + +#include + +/* sensor struct defs */ +#include + +/* sysctl() */ +#include +#include + +#include +#include + +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 diff --git a/sysutils/upower/patches/patch-configure b/sysutils/upower/patches/patch-configure new file mode 100644 index 00000000000..f456798790d --- /dev/null +++ b/sysutils/upower/patches/patch-configure @@ -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; } diff --git a/sysutils/upower/patches/patch-src_Makefile_in b/sysutils/upower/patches/patch-src_Makefile_in new file mode 100644 index 00000000000..321db2dab9b --- /dev/null +++ b/sysutils/upower/patches/patch-src_Makefile_in @@ -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) diff --git a/sysutils/upower/patches/patch-src_up-main_c b/sysutils/upower/patches/patch-src_up-main_c new file mode 100644 index 00000000000..e1ae3578916 --- /dev/null +++ b/sysutils/upower/patches/patch-src_up-main_c @@ -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 + #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, diff --git a/sysutils/upower/patches/patch-tools_Makefile_in b/sysutils/upower/patches/patch-tools_Makefile_in new file mode 100644 index 00000000000..f4571f39422 --- /dev/null +++ b/sysutils/upower/patches/patch-tools_Makefile_in @@ -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) diff --git a/sysutils/upower/pkg/DESCR b/sysutils/upower/pkg/DESCR new file mode 100644 index 00000000000..f60fcf214f4 --- /dev/null +++ b/sysutils/upower/pkg/DESCR @@ -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. diff --git a/sysutils/upower/pkg/PFRAG.shared b/sysutils/upower/pkg/PFRAG.shared new file mode 100644 index 00000000000..abbc212b6e6 --- /dev/null +++ b/sysutils/upower/pkg/PFRAG.shared @@ -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} diff --git a/sysutils/upower/pkg/PLIST b/sysutils/upower/pkg/PLIST new file mode 100644 index 00000000000..9cfd6d01bc8 --- /dev/null +++ b/sysutils/upower/pkg/PLIST @@ -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