[Esbox-commits] r2350 - branches/work_Ed/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/scratchbox/adapters
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Fri Oct 23 22:57:34 EEST 2009
Author: eswartz
Date: 2009-10-23 22:57:26 +0300 (Fri, 23 Oct 2009)
New Revision: 2350
Modified:
branches/work_Ed/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/scratchbox/adapters/ESboxMaemoTargetEnvironmentModifierAdapter.java
Log:
Fix Mica #4650 -- get correct DBUS_SESSION_BUS_ADDRESS
Modified: branches/work_Ed/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/scratchbox/adapters/ESboxMaemoTargetEnvironmentModifierAdapter.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/scratchbox/adapters/ESboxMaemoTargetEnvironmentModifierAdapter.java 2009-10-23 19:22:10 UTC (rev 2349)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/scratchbox/adapters/ESboxMaemoTargetEnvironmentModifierAdapter.java 2009-10-23 19:57:26 UTC (rev 2350)
@@ -11,13 +11,30 @@
package org.maemo.esbox.internal.scratchbox.adapters;
+import java.text.MessageFormat;
+import java.util.Properties;
+
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.ScratchboxCacheUtils;
+import org.maemo.esbox.internal.scratchbox.core.Activator;
import org.maemo.esbox.maemosdk.core.MaemoEnvironmentUtils;
+import org.maemo.mica.common.core.ICache;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.TimeoutProgressMonitor;
import org.maemo.mica.common.core.env.EnvironmentModifierBlock;
+import org.maemo.mica.common.core.env.EnvironmentProperties;
import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.process.ProcessLauncherParameters;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils.LaunchResults;
import org.maemo.mica.common.core.sdk.ISDKTarget;
import org.maemo.mica.common.launch.adapters.ITargetEnvironmentModifierAdapter;
import org.maemo.mica.common.launch.core.ILaunchProxy;
import org.maemo.mica.internal.api.common.launch.core.AbstractLocalLaunchProxy;
+import org.maemo.mica.internal.api.common.launch.core.AbstractRemoteLaunchProxy;
+import org.maemo.mica.internal.api.common.launch.core.IRemoteLaunchParameterAccessor;
+import org.maemo.mica.internal.api.protocol.sbrsh.ISBRSHMachine;
+import org.maemo.mica.maemosdk.core.IMaemoSDKPlatform;
/**
* Provide the necessary variables for maemo launches.
@@ -26,6 +43,10 @@
*/
public class ESboxMaemoTargetEnvironmentModifierAdapter implements ITargetEnvironmentModifierAdapter {
+ /**
+ *
+ */
+ private static final String DBUS_SESSION_BUS_ADDRESS = "DBUS_SESSION_BUS_ADDRESS";
private final ISDKTarget sdkTarget;
/**
@@ -42,8 +63,66 @@
IEnvironmentModifierBlock envBlock = new EnvironmentModifierBlock();
// first, all launches need proper DBUS access
- envBlock.define("DBUS_SESSION_BUS_ADDRESS", "unix:path=/tmp/session_bus_socket");
+ // this is a fallback
+ envBlock.define(DBUS_SESSION_BUS_ADDRESS, "unix:path=/tmp/session_bus_socket");
+
+ // on remote Fremantle devices, we need to find out for real, since there is no
+ // longer a simple file
+ if (launchProxy instanceof AbstractRemoteLaunchProxy
+ && sdkTarget.getPlatform().getVersion().compareTo(IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0) {
+ // need to fetch from the actual environment
+ IRemoteLaunchParameterAccessor remoteLaunchParameterAccessor = (IRemoteLaunchParameterAccessor) ((AbstractRemoteLaunchProxy) launchProxy).getLaunchParameterAccessor();
+ IMachine machine = remoteLaunchParameterAccessor.getMachine();
+
+ // fetch directly from the device; don't be tricked by the host or build machine
+ if (machine instanceof ISBRSHMachine) {
+ machine = ((ISBRSHMachine) machine).getDeviceMachine();
+ }
+
+ String value = null;
+ ICache cache = ScratchboxCacheUtils.getCache(machine);
+ value = (String) cache.get(DBUS_SESSION_BUS_ADDRESS, String.class);
+
+ if (value == null) {
+
+ LaunchResults results;
+ try {
+ results = ProcessLauncherUtils.launchAndReadStandardStreams(
+ machine.getProcessLauncherFactory().createProcessLauncher(
+ ProcessLauncherParameters.create("run-standalone.sh", "set")),
+ new TimeoutProgressMonitor(15 * 1000));
+ Properties env = EnvironmentProperties.createFromShellEnvDump(results.stdout);
+ value = env.getProperty(DBUS_SESSION_BUS_ADDRESS);
+
+ } catch (MicaException e) {
+ Activator.getErrorLogger().logError(MessageFormat.format(
+ "Could not read environment from {0}",
+ machine.getName()), null);
+ }
+
+
+ if (value == null) {
+ value = machine.getStandardEnvironmentVariable(DBUS_SESSION_BUS_ADDRESS);
+ }
+
+ if (value != null) {
+ cache.set(DBUS_SESSION_BUS_ADDRESS, value);
+ }
+
+ if (value == null) {
+ Activator.getErrorLogger().logError(MessageFormat.format(
+ "Could not detect DBUS_SESSION_BUS_ADDRESS from {0}; please refresh the Maemo > Installed Targets",
+ machine.getName()), null);
+ value = "unix:path=/tmp/session_bus_socket";
+ }
+
+
+ }
+
+ envBlock.define(DBUS_SESSION_BUS_ADDRESS, "unix:path=/tmp/session_bus_socket");
+ }
+
if (launchProxy instanceof AbstractLocalLaunchProxy) {
// define DISPLAY for a local launch
More information about the Esbox-commits
mailing list