From 3ae7052955faa45c91b29e331a7e221cdd15562c Mon Sep 17 00:00:00 2001 From: Pascal Rapicault Date: Fri, 27 Apr 2012 21:10:50 -0400 Subject: Support for bundled macosx - http://bugs.eclipse.org/57349 --- .../equinox/EclipseLauncherParser.java | 8 +++-- .../frameworkadmin/equinox/ParserUtils.java | 6 +++- .../frameworkadmin/equinox/utils/FileUtils.java | 9 +++-- .../META-INF/MANIFEST.MF | 2 +- .../internal/p2/core/DefaultAgentProvider.java | 1 + .../org/eclipse/equinox/p2/core/spi/Constants.java | 19 ++++++++++ .../META-INF/MANIFEST.MF | 1 + .../p2/director/app/DirectorApplication.java | 7 ++-- .../META-INF/MANIFEST.MF | 1 + .../publisher/eclipse/EquinoxExecutableAction.java | 41 ++++++++++++++++++---- .../p2/publisher/AbstractPublisherAction.java | 12 +++++-- .../META-INF/MANIFEST.MF | 1 + .../p2/touchpoint/eclipse/LazyManipulator.java | 5 +-- .../internal/p2/touchpoint/eclipse/Messages.java | 4 ++- .../eclipse/PlatformConfigurationWrapper.java | 10 +++++- .../internal/p2/touchpoint/eclipse/Util.java | 19 ++++++++-- .../p2/touchpoint/eclipse/messages.properties | 4 ++- 17 files changed, 126 insertions(+), 24 deletions(-) create mode 100644 bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/spi/Constants.java (limited to 'bundles') diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java index b714e8e06..8daad28df 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.frameworkadmin.equinox; @@ -25,6 +26,7 @@ import org.osgi.service.log.LogService; public class EclipseLauncherParser { private static final String MAC_OS_APP_FOLDER = ".app/Contents/MacOS"; //$NON-NLS-1$ private static final String CONFIGURATION_FOLDER = "configuration"; //$NON-NLS-1$ + public static final String MACOSX_BUNDLED = "macosx-bundled"; //$NON-NLS-1$ //this figures out the location of the data area on partial data read from the .ini private URI getOSGiInstallArea(List lines, URI base, LauncherData launcherData) { @@ -47,7 +49,9 @@ public class EclipseLauncherParser { String launcherString = launcherFolder.getAbsolutePath().replace('\\', '/'); if (launcherString.endsWith(MAC_OS_APP_FOLDER)) { //We can do 3 calls to getParentFile without checking because - launcherFolder = launcherFolder.getParentFile().getParentFile().getParentFile(); + launcherFolder = launcherFolder.getParentFile().getParentFile(); + if (!launcherData.getOS().endsWith(MACOSX_BUNDLED)) + launcherFolder = launcherFolder.getParentFile(); } if (!ParserUtils.fromOSGiJarToOSGiInstallArea(launcherData.getFwJar().getAbsolutePath()).equals(launcherFolder)) { ParserUtils.setValueForArgument(EquinoxConstants.OPTION_INSTALL, launcherFolder.getAbsolutePath().replace('\\', '/'), lines); diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java index ff4c32b12..9626ad0d5 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.frameworkadmin.equinox; @@ -57,6 +58,9 @@ public class ParserUtils { return launcherPath.toFile(); } } + if (EclipseLauncherParser.MACOSX_BUNDLED.equals(launcherData.getOS())) { + Log.log(LogService.LOG_WARNING, "Problem figuring out the osgi install area. The bundled mode of macosx requires a -startup argument to be specified."); //$NON-NLS-1$ + } return launcherFile.getParentFile(); } return null; diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/utils/FileUtils.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/utils/FileUtils.java index e5a439fc3..a74c4941d 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/utils/FileUtils.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/utils/FileUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.frameworkadmin.equinox.utils; @@ -14,12 +15,12 @@ import java.io.*; import java.net.*; import java.util.*; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxConstants; -import org.eclipse.equinox.internal.frameworkadmin.equinox.ParserUtils; +import org.eclipse.equinox.internal.frameworkadmin.equinox.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; import org.eclipse.osgi.service.environment.Constants; import org.osgi.framework.Version; +import org.osgi.service.log.LogService; public class FileUtils { private static String FILE_SCHEME = "file"; //$NON-NLS-1$ @@ -79,6 +80,8 @@ public class FileUtils { launcherPath = launcherPath.removeLastSegments(4); launcherDir = launcherPath.toFile(); } + } else if (EclipseLauncherParser.MACOSX_BUNDLED.equals(launcherData.getOS())) { + Log.log(LogService.LOG_WARNING, "Problem figuring out the osgi install area. The bundled mode of macosx requires a -startup argument to be specified."); //$NON-NLS-1$ } else launcherDir = launcherData.getLauncher().getParentFile(); pluginsDir = new File(launcherDir, EquinoxConstants.PLUGINS_DIR); diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF index af0028fa4..239237849 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -63,7 +63,7 @@ Export-Package: org.eclipse.equinox.internal.p2.core;x-friends:="org.eclipse.equ org.eclipse.equinox.p2.director.app, org.eclipse.equinox.p2.transport.ecf", org.eclipse.equinox.p2.core;version="2.0.0", - org.eclipse.equinox.p2.core.spi;version="2.0.0" + org.eclipse.equinox.p2.core.spi;version="2.1.0" Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.5, J2SE-1.4, diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java index d4d11ee1e..ede8c0187 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java @@ -15,6 +15,7 @@ import java.util.Dictionary; import java.util.Hashtable; import org.eclipse.equinox.p2.core.*; import org.osgi.framework.*; +import org.osgi.framework.Constants; /** * Default implementation of {@link IProvisioningAgentProvider}. diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/spi/Constants.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/spi/Constants.java new file mode 100644 index 000000000..d9de98d93 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/spi/Constants.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c)2012 Pascal Rapicault and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pascal Rapicault - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.core.spi; + +public interface Constants { + /* + * This constant is used internally in p2 to represent the case of a bundled macos application (the case where all the files are contained in the .app folder. + * It is typically used as an environment property in a profile. + */ + public final String MACOSX_BUNDLED = "macosx-bundled"; //$NON-NLS-1$ +} diff --git a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF index ab36a5845..afb9cc100 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: org.eclipse.equinox.app, org.eclipse.equinox.internal.provisional.p2.director, org.eclipse.equinox.internal.provisional.p2.repository, org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)", + org.eclipse.equinox.p2.core.spi;version="[2.1.0,3.0.0)", org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.engine.query;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)", diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java index 409e1b58f..c9aa5a342 100644 --- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java +++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ * Cloudsmith - https://bugs.eclipse.org/bugs/show_bug.cgi?id=226401 * EclipseSource - ongoing development * Sonatype, Inc. - ongoing development + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.p2.director.app; @@ -34,7 +35,6 @@ import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.planner.IProfileChangeRequest; import org.eclipse.equinox.p2.query.*; @@ -495,6 +495,9 @@ public class DirectorApplication implements IApplication, ProvisioningListener { props.put(IProfile.PROP_ROAMING, Boolean.TRUE.toString()); String env = getEnvironmentProperty(); + //Detect the desire to have a bundled mac application and tweak the environemtn + if (org.eclipse.osgi.service.environment.Constants.OS_MACOSX.equals(os) && destination.getName().endsWith(".app")) //$NON-NLS-1$ + env += ',' + org.eclipse.equinox.p2.core.spi.Constants.MACOSX_BUNDLED + "=true"; //$NON-NLS-1$ if (env != null) props.put(IProfile.PROP_ENVIRONMENTS, env); if (profileProperties != null) diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF index 941497863..2884ece1d 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: org.eclipse.equinox.app;version="[1.0.0,2.0.0)", org.eclipse.equinox.internal.p2.publisher, org.eclipse.equinox.internal.provisional.frameworkadmin, org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)", + org.eclipse.equinox.p2.core.spi;version="[2.1.0,3.0.0)", org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.metadata.expression;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.publisher, diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java index 9cd4e3517..423ec92e0 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java @@ -7,6 +7,7 @@ * Contributors: * Code 9 - initial API and implementation * IBM - ongoing development + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 ******************************************************************************/ package org.eclipse.equinox.p2.publisher.eclipse; @@ -14,6 +15,7 @@ import java.io.File; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; +import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; import org.eclipse.equinox.internal.p2.publisher.eclipse.BrandingIron; import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor; import org.eclipse.equinox.p2.metadata.*; @@ -151,6 +153,21 @@ public class EquinoxExecutableAction extends AbstractPublisherAction { // Create the CU that installs (e.g., unzips) the executable private void publishExecutableCU(ExecutablesDescriptor execDescriptor, IPublisherResult result) { + InstallableUnitFragmentDescription cu = createSkeletonExecutableCU(execDescriptor); + String[] config = parseConfigSpec(configSpec); + String os = config[1]; + Map touchpointData = computeInstallActions(execDescriptor, os); + cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); + if (Constants.OS_MACOSX.equals(os)) { + result.addIU(createBundledMacIU(execDescriptor), IPublisherResult.ROOT); + cu.setFilter(InstallableUnit.parseFilter("(& (!(macosx-bundled=*)) " + createLDAPString(configSpec) + ")")); //$NON-NLS-1$ //$NON-NLS-2$ + } + IInstallableUnit unit = MetadataFactory.createInstallableUnit(cu); + result.addIU(unit, IPublisherResult.ROOT); + + } + + private InstallableUnitFragmentDescription createSkeletonExecutableCU(ExecutablesDescriptor execDescriptor) { InstallableUnitFragmentDescription cu = new InstallableUnitFragmentDescription(); String id = createCUIdString(idBase, TYPE, flavor, configSpec); cu.setId(id); @@ -162,18 +179,30 @@ public class EquinoxExecutableAction extends AbstractPublisherAction { //TODO bug 218890, would like the fragment to provide the launcher capability as well, but can't right now. cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(id, version)}); cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE); - String[] config = parseConfigSpec(configSpec); - String os = config[1]; - Map touchpointData = computeInstallActions(execDescriptor, os); + return cu; + } + + private IInstallableUnit createBundledMacIU(ExecutablesDescriptor execDescriptor) { + InstallableUnitFragmentDescription cu = createSkeletonExecutableCU(execDescriptor); + String baseId = createCUIdString(idBase, TYPE, flavor, configSpec); + String id = baseId + "-bundled"; //$NON-NLS-1$ + cu.setId(id); + cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(baseId, version), MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, id, version)}); + cu.setFilter(InstallableUnit.parseFilter("(&(macosx-bundled=true)" + createLDAPString(configSpec) + ")")); //$NON-NLS-1$//$NON-NLS-2$ + Map touchpointData = computeInstallActions(execDescriptor, org.eclipse.equinox.p2.core.spi.Constants.MACOSX_BUNDLED); cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); - IInstallableUnit unit = MetadataFactory.createInstallableUnit(cu); - result.addIU(unit, IPublisherResult.ROOT); + return MetadataFactory.createInstallableUnit(cu); } private Map computeInstallActions(ExecutablesDescriptor execDescriptor, String os) { Map touchpointData = new HashMap(); String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$ - if (Constants.OS_MACOSX.equals(os)) { + if (org.eclipse.equinox.p2.core.spi.Constants.MACOSX_BUNDLED.equals(os)) { + String execName = execDescriptor.getExecutableName(); + String appName = guessMacAppName(execName); + configurationData = "unzip(source:@artifact, target:${installFolder}, path:" + appName + ".app);"; //$NON-NLS-1$ //$NON-NLS-2$ + configurationData += " chmod(targetDir:${installFolder}/Contents/MacOS/, targetFile:" + execName + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$ + } else if (Constants.OS_MACOSX.equals(os)) { String execName = execDescriptor.getExecutableName(); String appName = guessMacAppName(execName); configurationData += " chmod(targetDir:${installFolder}/" + appName + ".app/Contents/MacOS/, targetFile:" + execName + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java index 8fa15b253..dd780e619 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2012 Code 9 and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -8,6 +8,7 @@ * Code 9 - initial API and implementation * IBM - ongoing development * SAP - ongoing development + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 ******************************************************************************/ package org.eclipse.equinox.p2.publisher; @@ -102,6 +103,13 @@ public abstract class AbstractPublisherAction implements IPublisherAction { * parse into a filter. */ protected IMatchExpression createFilterSpec(String configSpec) { + String ldap = createLDAPString(configSpec); + if (ldap == null) + return null; + return InstallableUnit.parseFilter(ldap); + } + + protected String createLDAPString(String configSpec) { String[] config = parseConfigSpec(configSpec); if (config[0] != null || config[1] != null || config[2] != null) { String filterWs = config[0] != null && !CONFIG_ANY.equalsIgnoreCase(config[0]) ? "(osgi.ws=" + config[0] + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -109,7 +117,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction { String filterArch = config[2] != null && !CONFIG_ANY.equalsIgnoreCase(config[2]) ? "(osgi.arch=" + config[2] + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (filterWs.length() == 0 && filterOs.length() == 0 && filterArch.length() == 0) return null; - return InstallableUnit.parseFilter("(& " + filterWs + filterOs + filterArch + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + return "(& " + filterWs + filterOs + filterArch + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } return null; } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF index b3489952f..49a5fba04 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF @@ -25,6 +25,7 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.p2.repository, org.eclipse.equinox.internal.simpleconfigurator.manipulator, org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)", + org.eclipse.equinox.p2.core.spi;version="[2.1.0,3.0.0)", org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.engine.spi;version="[2.0.0,3.0.0)", org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)", diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java index cafd922c4..4e8857043 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; @@ -47,7 +48,7 @@ public class LazyManipulator implements Manipulator { launcherData.setFwConfigLocation(Util.getConfigurationFolder(profile)); launcherData.setLauncher(Util.getLauncherPath(profile)); launcherData.setLauncherConfigLocation(Util.getLauncherConfigLocation(profile)); - launcherData.setOS(Util.getOSFromProfile(profile)); + launcherData.setOS(Util.isMacOSBundled(profile) ? org.eclipse.equinox.p2.core.spi.Constants.MACOSX_BUNDLED : Util.getOSFromProfile(profile)); launcherData.setHome(Util.getInstallFolder(profile)); try { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java index 22f91b576..7af3b4186 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; @@ -33,6 +34,7 @@ public class Messages extends NLS { public static String platform_config_unavailable; public static String unexpected_prepareiu_error; public static String error_validating_profile; + public static String invalid_macox_bundled_setup; static { // load message values from bundle file and assign to fields below 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 6554a21b7..93578df48 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; @@ -15,6 +16,7 @@ import java.net.*; import java.util.List; import org.eclipse.core.runtime.*; import org.eclipse.equinox.frameworkadmin.BundleInfo; +import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.update.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; @@ -87,6 +89,12 @@ public class PlatformConfigurationWrapper { } } } + if (org.eclipse.equinox.p2.core.spi.Constants.MACOSX_BUNDLED.equals(launcherData.getOS())) { + //We are in a situation where the launcher path is not set in the launcher file. + //The laid out installation is not going to work because the macos launcher looks 3 levels up for the launcher jars (see previous if). + //Log this fact and move on. Though we should probably fail. + LogHelper.log(Util.createError(Messages.invalid_macox_bundled_setup)); + } try { return launcherFile.getParentFile().toURI().toURL(); } catch (MalformedURLException e) { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java index 982e90f21..da9d01141 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Red Hat Incorporated - fix for bug 225145 * Code 9 - ongoing development + * Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; @@ -21,6 +22,7 @@ import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.p2.core.*; +import org.eclipse.equinox.p2.core.spi.Constants; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.repository.IRepository; @@ -250,10 +252,19 @@ public class Util { String name = profile.getProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME); if (name == null || name.length() == 0) name = "eclipse"; //$NON-NLS-1$ - String launcherName = getLauncherName(name, getOSFromProfile(profile), getInstallFolder(profile)); + String launcherName = getLauncherName(name, (isMacOSBundled(profile) ? Constants.MACOSX_BUNDLED : getOSFromProfile(profile)), getInstallFolder(profile)); return launcherName == null ? null : new File(getInstallFolder(profile), launcherName); } + public static boolean isMacOSBundled(IProfile profile) { + String environments = profile.getProperty(IProfile.PROP_ENVIRONMENTS); + if (environments == null) + return false; + if (environments.indexOf(Constants.MACOSX_BUNDLED + "=true") != -1) //$NON-NLS-1$ + return true; + return false; + } + /** * Returns the name of the Eclipse application launcher. */ @@ -271,6 +282,10 @@ public class Util { return name; return name + ".exe"; //$NON-NLS-1$ } + if (os.equals(Constants.MACOSX_BUNDLED)) { + return "/Contents/MacOS/" + name; //$NON-NLS-1$ + } + if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_MACOSX)) { IPath path = new Path(name); if (path.segment(0).endsWith(".app")) //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties index 81f1ab022..02939593a 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2008, 2009 IBM Corporation and others. +# Copyright (c) 2008, 2012 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Pascal Rapicault - Support for bundled macosx http://bugs.eclipse.org/57349 ############################################################################### error_loading_manipulator=Error while loading manipulator. @@ -28,3 +29,4 @@ platform_config_unavailable=Platform configuration not available. unexpected_prepareiu_error=Unexpected state: prepareIU error_validating_profile=Error validating profile {0}. iu_contains_no_arifacts=Installable unit contains no artifacts: {0}. +invalid_macox_bundled_setup=This macos bundled application is not setup correctly and will not start because of missing arguments in the eclipse.ini. Please review your p2 metadata in order to have the '-startup' argument be generated. -- cgit v1.2.3