I have made the following changes intended for : CE:Adaptation:N900 / dsme
Please review and accept ASAP - BOSS has already processed this request and suggests ??? See the "Messages from BOSS" section below https://build.pub.meego.com/request/show/2605 Thank You, bossbot ([email protected]) [This message was auto-generated] --- Request # 2605: Messages from BOSS: None State: new 2011-10-24T11:57:01 bossbot Reviews: from bossbot :BOSS suggests accepting this review. See email for more details. BOSS accepted this review because: Target repo CE_Mer_Core_armv7hl found. accepted on No date Changes: submit: home:stskeeps:mer:hw:n900 / dsme -> CE:Adaptation:N900 / dsme Index: dsme.changes =================================================================== --- dsme.changes (revision 0) +++ dsme.changes (revision 2) @@ -0,0 +1,98 @@ +* Thu Sep 15 2011 Marko Saukko <[email protected]> - 0.61.28 +- Moved dsme socket location, because tmp is cleaned up at times. + +* Mon Sep 12 2011 Carsten Munk <[email protected]> - 0.61.28 +- DSME stays up, exec instead, no need for a 'sh' stuck in memory + +* Wed Sep 07 2011 Kalle Lampila <[email protected]> - 0.61.28 +- systemd support + +* Wed Mar 23 2011 Markus Lehtonen <[email protected]> - 0.61.28 +- Add dbus-autoconnector.patch (fixes BMC#13368) + +* Tue Feb 15 2011 Markus Lehtonen <[email protected]> - dsme-0.61.28 +- Update pwrkeymonitor.patch (BMC#13105) +- Remove SysV init script of DSME as it was merged into fastinit + +* Tue Dec 21 2010 Markus Lehtonen <[email protected]> - dsme-0.61.28 +- Change RPM group tag in .spec according to MeeGo Domain/Subsystem view + +* Sat Oct 30 2010 Markus Lehtonen <[email protected]> - dsme-0.61.28 +- rename libiphb.so in order to avoid conflict with libiphb package + +* Fri Oct 29 2010 Markus Lehtonen <[email protected]> - dsme-0.61.28 +- Version bump (bug fixes, MeeGo path fix patch upstreamed) + +* Tue Oct 26 2010 Markus Lehtonen <[email protected]> - dsme-0.61.27 +- Version bump. Biggest change is that libiphb is now removed from dsme + (separated in upstream to its own source package) +- Fixed pwrkeymonitor plugin +- Updated URL + +* Wed Oct 20 2010 Markus Lehtonen <[email protected]> - dsme-0.61.25.git267e8257 +- Version bump to upstream HEAD: DSME now uses autotools, most of the MeeGo + patches upstreamed/unnecessary. + +* Wed Oct 13 2010 Markus Lehtonen <[email protected]> - 0.61.25 +- Fix BMC#8330 by modifying dbus.conf + +* Fri Oct 01 2010 Markus Lehtonen <[email protected]> - 0.61.25 +- Version bump to 0.61.25 +- Bugfixes plus some of the previous MeeGo-patches now merged upstream + +* Thu Sep 23 2010 Markus Lehtonen <[email protected]> - 0.61.21 +- Introduce pwrkeymonitor plugin (for N900), partial solution + to BMC#4048 +- Mapping of DSME states to MeeGo runlevels (BMC#4048) + +* Wed Sep 01 2010 Markus Lehtonen <[email protected]> - 0.61.21 +- Increase DSME's startup priority (chkconfig in init script) to make sure that DSME start early on. + +* Tue Aug 31 2010 Markus Lehtonen <[email protected]> - 0.61.21 +- Use librunlevel plugin instead of libupstart - plays more nicely with SysV + +* Thu Aug 26 2010 Markus Lehtonen <[email protected]> - 0.61.21 +- Version bump to 0.61.21 +- Packaging fixes and changed to use spectacle +- Startup script updated to more MeeGo/LSB compatible + +* Sun Jul 11 2010 Anas Nashif <[email protected]> - 0.61.15 +- Fixed build with new compiler/glibc + +* Tue Jun 15 2010 Markus Lehtonen <[email protected]> - 0.61.15 +- init script made more lsb/fastinit compatible +- bootstate default added to init script +- init script now checks if '/etc/resource_limits.conf' is found + +* Mon May 31 2010 Markus Lehtonen <[email protected]> - 0.61.15 +- Incorporates a patch (originally by Carsten Munk) that removes BME build-time dependency +- bme_ipc is enabled (and used if bme is installed) + +* Sat May 29 2010 Markus Lehtonen <[email protected]> - 0.61.15 +- Version bump to 0.61.15 + +* Sat May 29 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- Init script fixed to read R&D flags from caltool or conf file +- Minor packaging fixes + +* Thu May 20 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- enable utils + +* Wed May 19 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- post and postun added to iphb packages +- patches fixed + +* Wed May 19 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- rpmlintrc removed + +* Wed May 19 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- Enable compilation without Nokia closed parts + +* Wed May 19 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- Buildrequirements fixed + +* Tue May 18 2010 Markus Lehtonen <[email protected]> - 0.61.13 +- Version bump to 0.61.13 + +* Tue Mar 30 2010 Marko Saukko <[email protected]> - 0.61.13 +- Initial spec file for dsme version 0.60.39. Index: dsme-0.61.28.tar.gz =================================================================== Binary file dsme-0.61.28.tar.gz added Index: Removed-variables-set-but-not-used-Werror-unused-but.patch =================================================================== --- Removed-variables-set-but-not-used-Werror-unused-but.patch (revision 0) +++ Removed-variables-set-but-not-used-Werror-unused-but.patch (revision 2) @@ -0,0 +1,42 @@ +From 257a05d68a9eb271d40b88387bf0a8a7407b65eb Mon Sep 17 00:00:00 2001 +From: Kalle Lampila <[email protected]> +Date: Tue, 30 Aug 2011 18:18:37 +0300 +Subject: [PATCH] Removed variables set but not used (unused-but-set-variable) + +Signed-off-by: Kalle Lampila <[email protected]> +--- + dsme/dsme-wdd-wd.c | 3 +++ + dsme/oom.c | 2 -- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/dsme/dsme-wdd-wd.c b/dsme/dsme-wdd-wd.c +index cde972d..69c4db8 100644 +--- a/dsme/dsme-wdd-wd.c ++++ b/dsme/dsme-wdd-wd.c +@@ -84,6 +84,9 @@ void dsme_wd_kick(void) + dummy = write(STDERR_FILENO, msg, DSME_STATIC_STRLEN(msg)); + dummy = write(STDERR_FILENO, wd[i].file, strlen(wd[i].file)); + dummy = write(STDERR_FILENO, "\n", 1); ++ if (dummy < 0) { ++ break; ++ } + + /* must not kick later wd's if an earlier one fails */ + break; +diff --git a/dsme/oom.c b/dsme/oom.c +index 0267354..28478ba 100644 +--- a/dsme/oom.c ++++ b/dsme/oom.c +@@ -42,9 +42,7 @@ static bool set_oom_adj_value(int i) + } + + if (fprintf(file, "%i", i) < 0) { +- int tmp = errno; + (void)fclose(file); +- tmp = errno; + return false; + } + +-- +1.7.2.3 + Index: dbus-policy-fix.patch =================================================================== --- dbus-policy-fix.patch (revision 0) +++ dbus-policy-fix.patch (revision 2) @@ -0,0 +1,16 @@ +Index: dsme-0.61.25.git267e8257/dsme/dsme.conf +=================================================================== +--- dsme-0.61.25.git267e8257.orig/dsme/dsme.conf 2010-10-20 12:06:10.973332925 +0300 ++++ dsme-0.61.25.git267e8257/dsme/dsme.conf 2010-10-20 12:06:27.123613258 +0300 +@@ -12,11 +12,6 @@ + <deny send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_reboot"/> + <deny send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_powerup"/> + </policy> +- <policy creds="dsme::DeviceStateControl"> +- <allow send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_shutdown"/> +- <allow send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_reboot"/> +- <allow send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_powerup"/> +- </policy> + <policy user="root"> + <allow send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_shutdown"/> + <allow send_destination="com.nokia.dsme" send_interface="com.nokia.dsme.request" send_member="req_reboot"/> Index: dsme.spec =================================================================== --- dsme.spec (revision 0) +++ dsme.spec (revision 2) @@ -0,0 +1,123 @@ +# +# Do NOT Edit the Auto-generated Part! +# Generated by: spectacle version 0.23 +# +# >> macros +# << macros + +Name: dsme +Summary: Device State Management Entity +Version: 0.61.28 +Release: 0 +Group: System/System Control +License: LGPLv2+ +URL: http://meego.gitorious.org/meego-middleware/dsme +Source0: %{name}-%{version}.tar.gz +Source1: dsme.service +Source2: dsme-start.sh +Source100: dsme.yaml +Patch0: libiphb-rename.patch +Patch1: no-bmeipc.patch +Patch2: pwrkeymonitor.patch +Patch3: meego-state-to-runlevel-mapping.patch +Patch4: dbus-policy-fix.patch +Patch5: dbus-autoconnector.patch +Patch6: Removed-variables-set-but-not-used-Werror-unused-but.patch +Patch7: fixed-missing-sys-stat.h-include.patch +Requires: systemd +Requires(preun): systemd +Requires(post): systemd +Requires(postun): systemd +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(dbus-glib-1) +BuildRequires: pkgconfig(libiphb) +BuildRequires: pkgconfig(dsme) +BuildRequires: python + + +%description +Device State Management Entity (with debug symbols). This package contains the Device State Management Entity which provides state management features such as service monitoring, process watchdog and inactivity tracking. + + + + +%prep +%setup -q -n %{name}-%{version} + +# libiphb-rename.patch +%patch0 -p1 +# no-bmeipc.patch +%patch1 -p1 +# pwrkeymonitor.patch +%patch2 -p1 +# meego-state-to-runlevel-mapping.patch +%patch3 -p1 +# dbus-policy-fix.patch +%patch4 -p1 +# dbus-autoconnector.patch +%patch5 -p1 +# Removed-variables-set-but-not-used-Werror-unused-but.patch +%patch6 -p1 +# fixed-missing-sys-stat.h-include.patch +%patch7 -p1 +# >> setup +# << setup + +%build +unset LD_AS_NEEDED +# >> build pre +chmod a+x autogen.sh +./autogen.sh +chmod a+x configure +# << build pre + +%configure --disable-static \ + --without-bmeipc \ + --disable-poweron-timer \ + --disable-upstart \ + --enable-runlevel \ + --enable-pwrkeymonitor + +make %{?jobs:-j%jobs} + +# >> build post +# << build post +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%make_install + +# >> install post +install -D -m 644 %{SOURCE1} %{buildroot}/lib/systemd/system/%{name}.service +install -d %{buildroot}/lib/systemd/system/sysinit.target.wants/ +ln -s ../%{name}.service %{buildroot}/lib/systemd/system/sysinit.target.wants/%{name}.service +install -D -m 0755 %{SOURCE2} %{buildroot}/usr/sbin/dsme-start.sh +# << install post + + +%preun +systemctl stop %{name}.service + +%post +systemctl daemon-reload +systemctl reload-or-try-restart %{name}.service + +%postun +systemctl daemon-reload + + +%files +%defattr(-,root,root,-) +%{_libdir}/dsme/* +%attr(755,root,root)%{_sbindir}/* +%config %{_sysconfdir}/dsme/lifeguard.uids +%config %{_sysconfdir}/dbus-1/system.d/dsme.conf +%doc debian/copyright COPYING +/lib/systemd/system/%{name}.service +/lib/systemd/system/sysinit.target.wants/%{name}.service +# >> files +# << files + + Index: dsme-rpmlintrc =================================================================== --- dsme-rpmlintrc (revision 0) +++ dsme-rpmlintrc (revision 2) @@ -0,0 +1,1 @@ +addFilter("dsme.* devel-file-in-non-devel-package")Index: pwrkeymonitor.patch =================================================================== --- pwrkeymonitor.patch (revision 0) +++ pwrkeymonitor.patch (revision 2) @@ -0,0 +1,443 @@ +From b329d9ed1969454340273edd73d79db1b101d9ef Mon Sep 17 00:00:00 2001 +From: Markus Lehtonen <[email protected]> +Date: Wed, 15 Sep 2010 14:28:02 +0300 +Subject: [PATCH] Introduce pwrkeymonitor plugin + +Pwrkeymonitor is intended for "fallback poweroff", in case the UI (or other +component) responsible for handling powerkey events has died or become +unresponsible. In reading powerkey status, it currently only supports +evdev interface of the kernel. The plugin is written for Nokia N900 but it +could relatively easily be modified to support other platforms as well, namely +by adding run-time configurability. Currently, the plugin searches for evdev +driver whose name includes substring "pwrbutton". It sends a shutdown event if +powerkey has been continously pressed for 5 seconds. + +The plugin does not support udev. Thus, the kernel driver providing the input +interface must be loaded at dsme startup. +--- + configure.ac | 13 ++ + modules/Makefile.am | 10 ++ + modules/pwrkeymonitor.c | 351 +++++++++++++++++++++++++++++++++++++++++++++++ + modules/startup.c | 3 + + 4 files changed, 377 insertions(+), 0 deletions(-) + create mode 100644 modules/pwrkeymonitor.c + +Index: src/configure.ac +=================================================================== +--- src.orig/configure.ac 2011-02-15 10:59:40.192894273 +0200 ++++ src/configure.ac 2011-02-15 12:14:24.344306499 +0200 +@@ -78,6 +78,19 @@ + [AC_DEFINE([DSME_MEMORY_THERMAL_MGMT], [1])]) + AM_CONDITIONAL([WANT_MEMORY_THERMAL_MGMT], [test x$enable_memory_thermal_mgmt != xno]) + ++# ++# pwrkeymonitor ++# ++AC_ARG_ENABLE([pwrkeymonitor], ++ [AS_HELP_STRING([--enable-pwrkeymonitor], ++ [enable pwrkeymonitor plugin (libpwrkeymonitor)])], ++ [], ++ [enable_pwrkeymonitor=no]) ++ ++AS_IF([test "x$enable_pwrkeymonitor" != xno], ++ [AC_DEFINE([DSME_PWRKEY_MONITOR], [1], [Enable pwrkeymonitor plugin])]) ++AM_CONDITIONAL([WANT_PWRKEY_MONITOR], [test x$enable_pwrkeymonitor != xno]) ++ + + # + # Compiler and linker flags +Index: src/modules/Makefile.am +=================================================================== +--- src.orig/modules/Makefile.am 2011-02-15 12:14:22.104265779 +0200 ++++ src/modules/Makefile.am 2011-02-15 12:14:24.344306499 +0200 +@@ -51,6 +51,10 @@ + pkglib_LTLIBRARIES += libupstart.la + endif + ++if WANT_PWRKEY_MONITOR ++pkglib_LTLIBRARIES += libpwrkeymonitor.la ++endif ++ + libstartup_la_SOURCES = startup.c + + libheartbeat_la_SOURCES = heartbeat.c +@@ -116,3 +120,9 @@ + libpowerontimer_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) + libpowerontimer_la_LIBADD = -lcal -lrt + endif ++ ++if WANT_PWRKEY_MONITOR ++libpwrkeymonitor_la_SOURCES = pwrkeymonitor.c ++libpwrkeymonitor_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) ++libpwrkeymonitor_la_LIBADD = $(GLIB_LIBS) ++endif +Index: src/modules/pwrkeymonitor.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ src/modules/pwrkeymonitor.c 2011-02-15 12:45:40.028811953 +0200 +@@ -0,0 +1,351 @@ ++/** ++ @file pwrkeymonitor.c ++ ++ @brief Power key monitor plugin for forced poweroff. ++ ++ Pwrkeymonitor is intended for "fallback poweroff", in case the UI (or other ++ component) responsible for handling powerkey events has died or become ++ unresponsible. In reading powerkey status, it currently only supports ++ evdev interface of the kernel. The plugin is written for Nokia N900 but it ++ could relatively easily be modified to support other platforms as well, name ++ by adding run-time configurability. Currently, the plugin searches for evdev ++ driver whose name includes substring "pwrbutton". It sends a shutdown event ++ powerkey has been continously pressed for 5 seconds. ++ <p> ++ Copyright (C) 2010 Nokia Corporation. ++ ++ @author Markus Lehtonen <[email protected]> ++ ++ This file is part of Dsme. ++ ++ Dsme is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License ++ version 2.1 as published by the Free Software Foundation. ++ ++ Dsme 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with Dsme. If not, see <http://www.gnu.org/licenses/>. ++*/ ++ ++#include "dsme/modules.h" ++#include "dsme/logging.h" ++#include "dsme/mainloop.h" ++#include "dsme/timers.h" ++#include "runlevel.h" ++#include "state-internal.h" ++ ++#include <stdio.h> ++#include <stdlib.h> ++#include <fcntl.h> ++#include <sys/ioctl.h> ++#include <string.h> ++#include <errno.h> ++#include <unistd.h> ++ ++#include <glib.h> ++#include <glib/gprintf.h> ++#include <glib/gstdio.h> ++ ++#include <linux/input.h> ++ ++#define EVDEV_DEV_DIR_PATH "/dev/input/" ++#define EVDEV_NAME_MATCH "pwrbutton" ++#define EVDEV_FALLBACK_DEV_PATH "/dev/input/event3" ++#define PWRKEY_TIMER_SECONDS 5 ++ ++/* Use nonblock read. This is safer as it ensures that the read of event data ++ * will newer block and, thus, the execution of dsme-server is newer stalled ++ * there. ++ */ ++#define PWRKEY_READ_NONBLOCK 1 ++ ++/* TODO: Run-time configurability (configuration file?) for pwrkeymonitor. ++ * Options to configure: device name, device path, timer timeout ++ * TODO: Fallback device path is not used for anything ++ */ ++ ++static dsme_timer_t pwrkey_timer = 0; ++static GIOChannel *evdev_chan = NULL; ++static guint evdev_watch = 0; ++ ++static int ++match_device(const gchar * devdir, const gchar * namematch) ++{ ++ GDir *dir = NULL; ++ const gchar *filename = NULL; ++ GError *error = NULL; ++ gchar devname[256] = ""; ++ ++ dir = g_dir_open(devdir, 0, &error); ++ if (dir == NULL) ++ { ++ dsme_log(LOG_WARNING, "pwrkeymonitor: Unable to open device dir"); ++ goto err; ++ } ++ ++ while ((filename = g_dir_read_name(dir))) ++ { ++ if (!g_file_test ++ (filename, G_FILE_TEST_IS_SYMLINK | G_FILE_TEST_IS_DIR)) ++ { ++ int fd; ++ int ret; ++ gchar *abspath; ++ ++ abspath = g_strjoin("/", devdir, filename, NULL); ++ ++ dsme_log(LOG_DEBUG, ++ "pwrkeymonitor: Trying dev \"%s\"...", abspath); ++ fd = g_open(abspath, O_RDONLY); ++ ++ if (fd <= 0) ++ { ++ dsme_log(LOG_DEBUG, ++ "pwrkeymonitor: Unable to open file (\"%s\")", ++ abspath); ++ g_free(abspath); ++ continue; ++ } ++ ++ ret = ioctl(fd, EVIOCGNAME(sizeof(devname)), devname); ++ if (ret == -1) ++ { ++ dsme_log(LOG_DEBUG, ++ "pwrkeymonitor: Unable to read device name of %s", ++ abspath); ++ } ++ else if (g_strstr_len(devname, sizeof(devname), namematch)) ++ { (243 more lines skipped) Index: dsme-start.sh =================================================================== --- dsme-start.sh (revision 0) +++ dsme-start.sh (revision 2) @@ -0,0 +1,33 @@ +#!/bin/sh + +prog=dsme + +# Get boot state +GETBOOTSTATE=/sbin/getbootstate +if [ -x $GETBOOTSTATE ]; then + export BOOTSTATE=`getbootstate 2>/dev/null` +else + # A reasonable default to prevent reboot/shutdown + export BOOTSTATE="USER" +fi + +touch /tmp/$BOOTSTATE +echo $BOOTSTATE > /tmp/STATE + +if [ -x /etc/resource_limits.conf ]; then + source /etc/resource_limits.conf +fi + +# Get R&D flags +CALTOOL=/usr/bin/cal-tool +RDMODE_CONF_FILE=/etc/dsme/rdmode +if [ -x $CALTOOL ]; then + $CALTOOL --get-rd-mode | grep -q enabled \ + && export DSME_RD_FLAGS=`$CALTOOL --get-rd-flags` +elif [ -f $RDMODE_CONF_FILE ]; then + export DSME_RD_FLAGS=`cat $RDMODE_CONF_FILE` +fi + +exec /usr/sbin/$prog -p /usr/lib/dsme/libstartup.so + +exit $? Index: Makefile =================================================================== --- Makefile (revision 0) +++ Makefile (revision 2) @@ -0,0 +1,6 @@ +PKG_NAME := dsme +SPECFILE = $(addsuffix .spec, $(PKG_NAME)) +YAMLFILE = $(addsuffix .yaml, $(PKG_NAME)) + + +include /usr/share/packaging-tools/Makefile.common Index: dsme.service =================================================================== --- dsme.service (revision 0) +++ dsme.service (revision 2) @@ -0,0 +1,11 @@ +[Unit] +Description=DSME +After=syslog.target + +[Service] +Environment=DSME_SOCKFILE=/run/dsme.socket +ExecStart=/usr/sbin/dsme-start.sh +Restart=always + +[Install] +WantedBy=default.target Index: dbus-autoconnector.patch =================================================================== --- dbus-autoconnector.patch (revision 0) +++ dbus-autoconnector.patch (revision 2) @@ -0,0 +1,281 @@ +From eb864b40fa2b5ae8941775c84071cefbb79b4bf6 Mon Sep 17 00:00:00 2001 +From: Semi Malinen <[email protected]> +Date: Fri, 4 Mar 2011 18:26:34 +0200 +Subject: [PATCH] Add a module to automatically connect dsme to D-Bus System bus + +--- + modules/Makefile.am | 7 ++- + modules/dbusautoconnector.c | 186 +++++++++++++++++++++++++++++++++++++++++++ + modules/dsme_dbus.c | 8 ++- + modules/dsme_dbus.h | 2 + + modules/startup.c | 1 + + 5 files changed, 202 insertions(+), 2 deletions(-) + create mode 100644 modules/dbusautoconnector.c + +Index: src/modules/Makefile.am +=================================================================== +--- src.orig/modules/Makefile.am 2011-03-24 09:49:10.709169123 +0200 ++++ src/modules/Makefile.am 2011-03-24 09:50:45.041137546 +0200 +@@ -16,7 +16,8 @@ + libemergencycalltracker.la \ + libusbtracker.la \ + libiphbservice.la \ +- librebootloopdetector.la ++ librebootloopdetector.la \ ++ libdbusautoconnector.la + + noinst_HEADERS = dsme_dbus.h \ + runlevel.h \ +@@ -97,6 +98,10 @@ + + librebootloopdetector_la_SOURCES = rebootloopdetector.c + ++libdbusautoconnector_la_SOURCES = dbusautoconnector.c ++libdbusautoconnector_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) ++libdbusautoconnector_la_LIBADD = $(GLIB_LIBS) ++ + if WANT_BMEIPC + libthermalobject_surface_la_SOURCES = thermalobject_surface.c \ + thermalsensor_battery.c \ +Index: src/modules/dbusautoconnector.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ src/modules/dbusautoconnector.c 2011-03-24 09:50:45.051137753 +0200 +@@ -0,0 +1,186 @@ ++/** ++ @file dbusautoconnector.c ++ ++ Automatically connect Dsme to D-Bus System Bus when it is available. ++ <p> ++ Copyright (C) 2010 Nokia Corporation. ++ ++ @author Semi Malinen <[email protected]> ++ ++ This file is part of Dsme. ++ ++ Dsme is free software; you can redistribute it and/or modify ++ it under the terms of the GNU Lesser General Public License ++ version 2.1 as published by the Free Software Foundation. ++ ++ Dsme 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 ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with Dsme. If not, see <http://www.gnu.org/licenses/>. ++*/ ++ ++#define _GNU_SOURCE ++ ++#include "dsme_dbus.h" ++#include "dbusproxy.h" ++#include "dsme/modules.h" ++#include "dsme/logging.h" ++ ++#include <dsme/protocol.h> ++#include <unistd.h> ++#include <errno.h> ++#include <sys/inotify.h> ++#include <glib.h> ++#include <stdio.h> ++#include <stdlib.h> ++ ++ ++#define DSME_SYSTEM_BUS_DIR "/var/run/dbus" ++#define DSME_SYSTEM_BUS_FILE "system_bus_socket" ++#define DSME_INOTIFY_BUF_SIZE (sizeof(struct inotify_event) + PATH_MAX + 1) ++ ++ ++static void stop_dbus_watch(void); ++ ++ ++int inotify_fd = -1; ++int watch_fd = -1; ++GIOChannel* channel = 0; ++ ++ ++static void connect_to_dbus(void) ++{ ++ DSM_MSGTYPE_DBUS_CONNECT msg = DSME_MSG_INIT(DSM_MSGTYPE_DBUS_CONNECT); ++ ++ broadcast_internally(&msg); ++} ++ ++static gboolean handle_inotify_event(GIOChannel* source, ++ GIOCondition condition, ++ gpointer data) ++{ ++ bool keep_watching = true; ++ ++ if (condition & G_IO_IN) { ++ dsme_log(LOG_NOTICE, "Got D-Bus dir inotify watch event"); ++ ++ char buf[DSME_INOTIFY_BUF_SIZE]; ++ int n; ++ ++ n = TEMP_FAILURE_RETRY(read(inotify_fd, buf, DSME_INOTIFY_BUF_SIZE)); ++ if (n < sizeof(struct inotify_event)) { ++ dsme_log(LOG_ERR, "Error receiving D-Bus dir inotify watch event"); ++ keep_watching = false; ++ } else { ++ struct inotify_event* event = (struct inotify_event*)&buf[0]; ++ ++ if (event->mask & IN_CREATE && ++ event->len > 0 && ++ strcmp(event->name, DSME_SYSTEM_BUS_FILE) == 0) ++ { ++ dsme_log(LOG_INFO, "D-Bus System bus socket created; connect"); ++ connect_to_dbus(); ++ keep_watching = false; // TODO: add support for re-connect ++ } ++ } ++ } ++ if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) { ++ dsme_log(LOG_ERR, "ERR, HUP or NVAL on D-Bus dir inotify watch"); ++ keep_watching = false; ++ } ++ ++ if(!keep_watching) { ++ stop_dbus_watch(); ++ } ++ ++ return keep_watching; ++} ++ ++static bool set_up_watch_for_dbus(void) ++{ ++ dsme_log(LOG_DEBUG, "setting up a watch for D-Bus System bus socket dir"); ++ ++ if ((inotify_fd = inotify_init()) == -1) { ++ dsme_log(LOG_ERR, "Error initializing inotify for D-Bus: %m"); ++ goto fail; ++ } ++ if ((watch_fd = inotify_add_watch(inotify_fd, ++ DSME_SYSTEM_BUS_DIR, ++ IN_CREATE)) ++ == -1) ++ { ++ dsme_log(LOG_ERR, "Error adding inotify watch for D-Bus: %m"); ++ goto close_inotify_and_fail; ++ } ++ ++ if ((channel = g_io_channel_unix_new(inotify_fd)) == 0) { ++ dsme_log(LOG_ERR, "Error creating channel to watch for D-Bus"); ++ goto close_fds_and_fail; ++ } ++ g_io_channel_set_close_on_unref(channel, FALSE); ++ ++ guint watch = 0; ++ watch = g_io_add_watch(channel, ++ (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL), ++ handle_inotify_event, ++ 0); ++ g_io_channel_unref(channel); ++ if (!watch) { ++ dsme_log(LOG_ERR, "Error adding watch for D-Bus"); ++ goto close_inotify_and_fail; ++ } ++ ++ return true; ++ ++ ++close_fds_and_fail: ++ inotify_rm_watch(inotify_fd, watch_fd); ++close_inotify_and_fail: ++ close(inotify_fd); ++fail: ++ return false; ++} ++ ++static void stop_dbus_watch(void) ++{ ++ dsme_log(LOG_DEBUG, "stopping D-Bus System bus dir watching"); ++ ++ if (channel) { ++ g_io_channel_shutdown(channel, FALSE, 0); ++ channel = 0; ++ } ++ ++ if (inotify_fd != -1) { (81 more lines skipped) Index: no-bmeipc.patch =================================================================== --- no-bmeipc.patch (revision 0) +++ no-bmeipc.patch (revision 2) @@ -0,0 +1,146 @@ +Index: dsme-0.61.28/modules/Makefile.am +=================================================================== +--- dsme-0.61.28.orig/modules/Makefile.am 2010-10-30 10:45:50.018513861 +0300 ++++ dsme-0.61.28/modules/Makefile.am 2010-10-30 10:46:58.128785428 +0300 +@@ -89,7 +89,7 @@ + libiphbservice_la_SOURCES = iphbservice.c + libiphbservice_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) + libiphbservice_la_CPPFLAGS = $(AM_CPPFLAGS) +-libiphbservice_la_LIBADD = -lbmeipc $(GLIB_LIBS) ++libiphbservice_la_LIBADD = $(GLIB_LIBS) + + librebootloopdetector_la_SOURCES = rebootloopdetector.c + +@@ -98,7 +98,7 @@ + thermalsensor_battery.c \ + thermalsensor_battery.h + libthermalobject_surface_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) +-libthermalobject_surface_la_LIBADD = -lbmeipc $(GLIB_LIBS) ++libthermalobject_surface_la_LIBADD = $(GLIB_LIBS) + endif + + if WANT_MEMORY_THERMAL_MGMT +Index: dsme-0.61.28/modules/thermalsensor_battery.c +=================================================================== +--- dsme-0.61.28.orig/modules/thermalsensor_battery.c 2010-10-29 15:49:44.000000000 +0300 ++++ dsme-0.61.28/modules/thermalsensor_battery.c 2010-10-30 10:46:02.128525542 +0300 +@@ -41,10 +41,119 @@ + /* these need to be #defined in order to pick up thermal stuff from bme */ + #define TESTSERVER + ++#ifdef GOT_BMEIPC_HEADERS ++ + #include <bme/bmeipc.h> + #include <bme/bmemsg.h> + #include <bme/em_isi.h> + ++#else /* GOT_BMEIPC_HEADERS */ ++ ++#include <stdio.h> ++#include <stdarg.h> ++#include <stdlib.h> ++#include <unistd.h> ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <sys/un.h> ++ ++#define BME_SRV_SOCK_PATH "/tmp/.bmesrv" ++#define BME_SRV_COOKIE "BMentity" ++ ++#define EM_BATTERY_INFO_REQ 0x06 ++#define EM_BATTERY_TEMP 0x0004 /* -------------1-- */ ++ ++struct emsg_battery_info_req { ++ uint16 type, subtype; ++ uint32 flags; ++}; ++ ++/* Battery info reply */ ++struct emsg_battery_info_reply { ++ uint32 a; ++ uint32 flags; ++ uint16 c; ++ uint16 d; ++ uint16 temp; ++ uint16 f; ++ uint16 g; ++ uint16 h; ++ uint16 i; ++ uint16 j; ++ uint16 k; ++ uint16 l; ++}; ++ ++union emsg_battery_info { ++ struct emsg_battery_info_req request; ++ struct emsg_battery_info_reply reply; ++}; ++ ++static int bme_socket = -1; ++ ++static int32_t bme_read(void *msg, int32_t bytes); ++static int32_t bme_write(const void *msg, int32_t bytes); ++static void bme_disconnect(void); ++static int32_t bme_connect(void); ++ ++int32_t bme_read(void *msg, int32_t bytes) ++{ ++ if (bme_socket == -1) ++ { ++ return -1; ++ } ++ return recv(bme_socket, msg, bytes, 0); ++} ++ ++int32_t bme_write(const void *msg, int32_t bytes) ++{ ++ if (bme_socket == -1) ++ { ++ return -1; ++ } ++ return send(bme_socket, msg, bytes, 0); ++} ++ ++void bme_disconnect(void) ++{ ++ if (bme_socket >= 0) ++ close(bme_socket); ++ bme_socket = -1; ++} ++ ++int32_t bme_connect(void) ++{ ++ struct sockaddr_un sa; ++ char ch; ++ ++ memset(&sa, 0, sizeof(sa)); ++ sa.sun_family = PF_UNIX; ++ ++ strcpy(sa.sun_path, BME_SRV_SOCK_PATH); ++ if ((bme_socket = socket(PF_UNIX,SOCK_STREAM, 0)) < 0) ++ return bme_socket; ++ ++ if (connect(bme_socket, (struct sockaddr *) &sa, sizeof(struct sockaddr_un)) < 0) ++ { ++ bme_disconnect(); ++ return bme_socket; ++ } ++ ++ /* Send cookie */ ++ if (bme_write(BME_SRV_COOKIE, strlen(BME_SRV_COOKIE)) < strlen(BME_SRV_COOKIE)) ++ { ++ bme_disconnect(); ++ return bme_socket; ++ } ++ ++ if (bme_read(&ch, 1) < 1 || ch != '\n') ++ { ++ bme_disconnect(); ++ return bme_socket; ++ } ++ return bme_socket; ++} ++#endif /* GOT_BMEIPC_HEADERS */ + + static gboolean handle_battery_temperature_response(GIOChannel* source, + GIOCondition condition, Index: fixed-missing-sys-stat.h-include.patch =================================================================== --- fixed-missing-sys-stat.h-include.patch (revision 0) +++ fixed-missing-sys-stat.h-include.patch (revision 2) @@ -0,0 +1,25 @@ +From 8d622c51289d70fec2641a01ab417ace8f0b0f20 Mon Sep 17 00:00:00 2001 +From: Kalle Lampila <[email protected]> +Date: Wed, 31 Aug 2011 11:23:56 +0300 +Subject: [PATCH] fixed missing sys/stat.h include + +Signed-off-by: Kalle Lampila <[email protected]> +--- + modules/iphbservice.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/modules/iphbservice.c b/modules/iphbservice.c +index 25e7b3e..b8ccc1a 100644 +--- a/modules/iphbservice.c ++++ b/modules/iphbservice.c +@@ -47,6 +47,7 @@ + #include <sys/socket.h> + #include <sys/un.h> + #include <sys/time.h> ++#include <sys/stat.h> + + #include <glib.h> + +-- +1.7.2.3 + Index: libiphb-rename.patch =================================================================== --- libiphb-rename.patch (revision 0) +++ libiphb-rename.patch (revision 2) @@ -0,0 +1,1779 @@ +diff --git a/modules/Makefile.am b/modules/Makefile.am +index 597f143..6e3c2ac 100644 +--- a/modules/Makefile.am ++++ b/modules/Makefile.am +@@ -15,7 +15,7 @@ pkglib_LTLIBRARIES = libstartup.la \ + libthermalmanager.la \ + libemergencycalltracker.la \ + libusbtracker.la \ +- libiphb.la \ ++ libiphbservice.la \ + librebootloopdetector.la + + noinst_HEADERS = dsme_dbus.h \ +@@ -86,10 +86,10 @@ libemergencycalltracker_la_SOURCES = emergencycalltracker.c + + libusbtracker_la_SOURCES = usbtracker.c + +-libiphb_la_SOURCES = iphb.c +-libiphb_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) +-libiphb_la_CPPFLAGS = $(AM_CPPFLAGS) +-libiphb_la_LIBADD = -lbmeipc $(GLIB_LIBS) ++libiphbservice_la_SOURCES = iphbservice.c ++libiphbservice_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) ++libiphbservice_la_CPPFLAGS = $(AM_CPPFLAGS) ++libiphbservice_la_LIBADD = -lbmeipc $(GLIB_LIBS) + + librebootloopdetector_la_SOURCES = rebootloopdetector.c + +diff --git a/modules/iphb.c b/modules/iphb.c +deleted file mode 100644 +index 430609f..0000000 +--- a/modules/iphb.c ++++ /dev/null +@@ -1,863 +0,0 @@ +-/** +- @brief IP heartbeat service dsme plug-in +- +- @file iphbd.c +- +- IP heartbeat service dsme plug-in +- +- <p> +- Copyright (C) 2010 Nokia. All rights reserved. +- +- @author Raimo Vuonnala <[email protected]> +- @author Semi Malinen <[email protected]> +- +- This file is part of Dsme. +- +- Dsme is free software; you can redistribute it and/or modify +- it under the terms of the GNU Lesser General Public License +- version 2.1 as published by the Free Software Foundation. +- +- Dsme 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 +- Lesser General Public License for more details. +- +- You should have received a copy of the GNU Lesser General Public +- License along with Dsme. If not, see <http://www.gnu.org/licenses/>. +-*/ +- +-#define _ISOC99_SOURCE +-#define _GNU_SOURCE +- +-#include <iphbd/libiphb.h> +-#include <iphbd/iphb_internal.h> +- +-#include "heartbeat.h" +-#include "dsme/modules.h" +-#include "dsme/modulebase.h" +-#include "dsme/logging.h" +-#include "dsme/timers.h" +-#include "dsme/dsme-wdd-wd.h" +- +-#include <stdlib.h> +-#include <fcntl.h> +-#include <unistd.h> +-#include <errno.h> +-#include <sys/epoll.h> +-#include <sys/socket.h> +-#include <sys/un.h> +-#include <sys/time.h> +- +-#include <glib.h> +- +- +-#define DSME_MAX_EPOLL_EVENTS 10 +- +- +- +-/**@brief Allocated structure of one client in the linked client list in iphbd */ +-typedef struct _client_t { +- int fd; /*!< IPC (Unix domain) socket or -1 */ +- endpoint_t* conn; /*!< internal client endpoint (if fd == -1) */ +- void* data; /*!< internal client cookie (if fd == -1) */ +- time_t wait_started; /*!< 0 if client has not subscribed to wake-up call */ +- unsigned short mintime; /*!< min time to sleep in secs */ +- unsigned short maxtime; /*!< max time to sleep in secs */ +- pid_t pid; /*!< client process ID */ +- struct _client_t* next; /*!< pointer to the next client in the list (NULL if none) */ +-} client_t; +- +-typedef bool (condition_func)(client_t* client, time_t now); +- +- +-static bool epoll_add(int fd, void* ptr); +- +-static gboolean read_epoll(GIOChannel* source, +- GIOCondition condition, +- gpointer data); +-static int handle_wakeup_timeout(void* unused); +-static bool handle_client_req(struct epoll_event* event, time_t now); +-static bool handle_wait_req(const struct _iphb_wait_req_t* req, +- client_t* client, +- time_t now); +-static condition_func mintime_passed; +-static condition_func maxtime_passed; +-static void wakeup_clients_if(condition_func should_wake_up, time_t now); +-static int wakeup_clients_if2(condition_func should_wake_up, time_t now); +-static bool wakeup(client_t* client, time_t now); +-static void delete_clients(void); +-static void delete_client(client_t* client); +-static void remove_client(client_t* client, client_t* prev); +-static void close_and_free_client(client_t* client); +-static void sync_hwwd_feeder(void); +-static void stop_wakeup_timer(void); +- +- +-static client_t* clients = NULL; /* linked lits of connected clients */ +- +-static int listenfd = -1; /* IPC client listen/accept handle */ +-static int kernelfd = -1; /* handle to the kernel */ +-static int epollfd = -1; /* handle to the epoll instance */ +- +-static dsme_timer_t wakeup_timer = 0; +- +- +-/** +- Open kernel module handle - retry later if fails (meaning LKM is not loaded) +-*/ +-static void open_kernel_fd(void) +-{ +- static bool kernel_module_load_error_logged = false; +- +- kernelfd = open(HB_KERNEL_DEVICE, O_RDWR, 0644); +- if (kernelfd == -1) { +- kernelfd = open(HB_KERNEL_DEVICE_TEST, O_RDWR, 0644); +- } +- if (kernelfd == -1) { +- if (!kernel_module_load_error_logged) { +- kernel_module_load_error_logged = true; +- dsme_log(LOG_ERR, +- "failed to open kernel connection '%s' (%s)", +- HB_KERNEL_DEVICE, +- strerror(errno)); +- } +- } else { +- const char *msg; +- +- msg = HB_LKM_KICK_ME_PERIOD; +- +- dsme_log(LOG_DEBUG, +- "opened kernel socket %d to %s, wakeup from kernel=%s", +- kernelfd, +- HB_KERNEL_DEVICE, +- msg); +- +- if (write(kernelfd, msg, strlen(msg) + 1) == -1) { +- dsme_log(LOG_ERR, +- "failed to write kernel message (%s)", +- strerror(errno)); +- // TODO: do something clever? +- } else if (!epoll_add(kernelfd, &kernelfd)) { +- dsme_log(LOG_ERR, "failed to add kernel fd to epoll set"); +- // TODO: do something clever? +- } +- } +-} +- +-static void close_kernel_fd(void) +-{ +- if (kernelfd != -1) { +- if (epoll_ctl(epollfd, EPOLL_CTL_DEL, kernelfd, 0) == -1) { +- dsme_log(LOG_ERR, "failed to remove kernel fd from epoll set"); +- // TODO: do something clever? +- } +- (void)close(kernelfd); +- dsme_log(LOG_DEBUG, "closed kernel socket %d", kernelfd); +- kernelfd = -1; +- } +-} +- +- +- +- +-/** +- Start up daemon. Does not fail if kernel module is not loaded +-*/ +-// TODO: clean up in error cases (good god, C sucks here) (1579 more lines skipped) Index: meego-state-to-runlevel-mapping.patch =================================================================== --- meego-state-to-runlevel-mapping.patch (revision 0) +++ meego-state-to-runlevel-mapping.patch (revision 2) @@ -0,0 +1,34 @@ +From ffe84c4b56be5f2f6f5449b003de4dd03e0081ea Mon Sep 17 00:00:00 2001 +From: Markus Lehtonen <[email protected]> +Date: Wed, 22 Sep 2010 15:26:24 +0300 +Subject: [PATCH 2/2] meego state to runlevel mapping + +--- + modules/runlevel.h | 10 +++++----- + 1 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/modules/runlevel.h b/modules/runlevel.h +index 2277452..a0e1c43 100644 +--- a/modules/runlevel.h ++++ b/modules/runlevel.h +@@ -29,12 +29,12 @@ + + typedef enum { + DSME_RUNLEVEL_SHUTDOWN = 0, +- DSME_RUNLEVEL_TEST = 1, +- DSME_RUNLEVEL_USER = 2, +- DSME_RUNLEVEL_LOCAL = 3, +- DSME_RUNLEVEL_ACTDEAD = 5, ++ DSME_RUNLEVEL_LOCAL = 0, /* MeeGo -> map to 'halt' */ ++ DSME_RUNLEVEL_ACTDEAD = 0, /* MeeGo -> map to 'halt' */ ++ DSME_RUNLEVEL_MALF = 0, /* MeeGo -> map to 'halt' */ ++ DSME_RUNLEVEL_TEST = 3, /* MeeGo -> map to 'multiuser' */ ++ DSME_RUNLEVEL_USER = 5, /* MeeGo -> map to 'X11' */ + DSME_RUNLEVEL_REBOOT = 6, +- DSME_RUNLEVEL_MALF = 8, + } dsme_runlevel_t; + + typedef struct { +-- +1.7.0.4 + Index: dsme.yaml =================================================================== --- dsme.yaml (revision 0) +++ dsme.yaml (revision 2) @@ -0,0 +1,53 @@ +Name: dsme +Summary: Device State Management Entity +Version: 0.61.28 +Release: 0 +Group: System/System Control +License: LGPLv2+ +URL: http://meego.gitorious.org/meego-middleware/dsme +Description: | + Device State Management Entity (with debug symbols). This package contains the Device State Management Entity which provides state management features such as service monitoring, process watchdog and inactivity tracking. + +#Configure: none +ConfigOptions: + - "--without-bmeipc" + - "--disable-poweron-timer" + - "--disable-upstart" + - "--enable-runlevel" + - "--enable-pwrkeymonitor" + +Sources: + - "%{name}-%{version}.tar.gz" + - "dsme.service" + - "dsme-start.sh" +Patches: + - "libiphb-rename.patch" + - "no-bmeipc.patch" + - "pwrkeymonitor.patch" + - "meego-state-to-runlevel-mapping.patch" + - "dbus-policy-fix.patch" + - "dbus-autoconnector.patch" + - "Removed-variables-set-but-not-used-Werror-unused-but.patch" + - "fixed-missing-sys-stat.h-include.patch" + +PkgConfigBR: + - glib-2.0 + - dbus-1 + - dbus-glib-1 + - libiphb + - dsme + +PkgBR: + - python + +UseAsNeeded: no + +Files: + - "%{_libdir}/dsme/*" + - "%attr(755,root,root)%{_sbindir}/*" + - "%config %{_sysconfdir}/dsme/lifeguard.uids" + - "%config %{_sysconfdir}/dbus-1/system.d/dsme.conf" + - "%doc debian/copyright COPYING" + - "/lib/systemd/system/%{name}.service" + - "/lib/systemd/system/sysinit.target.wants/%{name}.service" +
