Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordj2011-08-31 19:58:13 +0000
committerdj2011-09-01 14:35:05 +0000
commit335a33422606f5d409e8eb5b727a56206adf93ac (patch)
treeaa7b24dfac3891efdbfe29fceefa93f857c4667d
parentc3e8b01f0e2964b19210477d658de9566b240a89 (diff)
downloadrt.equinox.p2-335a33422606f5d409e8eb5b727a56206adf93ac.tar.gz
rt.equinox.p2-335a33422606f5d409e8eb5b727a56206adf93ac.tar.xz
rt.equinox.p2-335a33422606f5d409e8eb5b727a56206adf93ac.zip
Bug 354888 - Cache extensions from parent lost in shared installv20110901-1435
Bug 354888 - Cache extensions from parent lost in shared install Bug 354888 - Cache extensions from parent lost in shared install
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java57
1 files changed, 56 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
index ee56e1c7e..6554a21b7 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
@@ -16,8 +16,10 @@ import java.util.List;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.update.*;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.util.NLS;
/**
@@ -39,8 +41,61 @@ public class PlatformConfigurationWrapper {
* Use the given manipulator to calculate the OSGi install location. We can't
* just use the Location service here because we may not be installing into
* ourselves. (see https://bugs.eclipse.org/354552)
+ *
+ * First try and calculate the location based relative to the data provided
+ * in the manipulator's launcher data. If that doesn't work then calculate
+ * it based on the location of known JARs. If that still doesn't work then
+ * return null.
*/
private static URL getOSGiInstallArea(Manipulator manipulator) {
+
+ // first see if the launcher home is set
+ LauncherData launcherData = manipulator.getLauncherData();
+ File home = launcherData.getHome();
+ if (home != null) {
+ try {
+ return home.toURI().toURL();
+ } catch (MalformedURLException e) {
+ // ignore - shouldn't happen
+ }
+ }
+
+ // next try and calculate the value based on the location of the framework (OSGi) jar.
+ File fwkJar = launcherData.getFwJar();
+ if (fwkJar != null) {
+ try {
+ return fromOSGiJarToOSGiInstallArea(fwkJar.getAbsolutePath()).toURI().toURL();
+ } catch (MalformedURLException e) {
+ // ignore - shouldn't happen
+ }
+ }
+
+ // finally calculate the value based on the location of the launcher executable itself
+ File launcherFile = launcherData.getLauncher();
+ if (launcherFile != null) {
+ if (Constants.OS_MACOSX.equals(launcherData.getOS())) {
+ //the equinox launcher will look 3 levels up on the mac when going from executable to launcher.jar
+ //see org.eclipse.equinox.executable/library/eclipse.c : findStartupJar();
+ IPath launcherPath = new Path(launcherFile.getAbsolutePath());
+ if (launcherPath.segmentCount() > 4) {
+ //removing "Eclipse.app/Contents/MacOS/eclipse"
+ launcherPath = launcherPath.removeLastSegments(4);
+ try {
+ return launcherPath.toFile().toURI().toURL();
+ } catch (MalformedURLException e) {
+ // ignore - shouldn't happen
+ }
+ }
+ }
+ try {
+ return launcherFile.getParentFile().toURI().toURL();
+ } catch (MalformedURLException e) {
+ // ignore - shouldn't happen
+ }
+ }
+
+ // we couldn't calculate it based on the info in the launcher data, so
+ // try to do it based on the location of known JARs.
final String OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
BundleInfo[] bis = manipulator.getConfigData().getBundles();
String searchFor = "org.eclipse.equinox.launcher"; //$NON-NLS-1$
@@ -49,7 +104,7 @@ public class PlatformConfigurationWrapper {
if (bis[i].getLocation() != null) {
try {
if (bis[i].getLocation().getScheme().equals("file")) //$NON-NLS-1$
- return fromOSGiJarToOSGiInstallArea(bis[i].getLocation().getPath()).toURL();
+ return fromOSGiJarToOSGiInstallArea(bis[i].getLocation().getPath()).toURI().toURL();
} catch (MalformedURLException e) {
//do nothing
}

Back to the top