summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2014-03-25 14:59:37 -0400
committerKrzysztof Daniel2014-05-06 13:20:53 -0400
commit539a3f4e846c317185f76f0177c00c23f603c857 (patch)
tree62d9c5d45ecb79d07b783055844e4fbede3f7215
parent98b51fa43286c184fdbdacd4b48d3525bb80f1f0 (diff)
downloadrt.equinox.p2-539a3f4e846c317185f76f0177c00c23f603c857.zip
rt.equinox.p2-539a3f4e846c317185f76f0177c00c23f603c857.tar.gz
rt.equinox.p2-539a3f4e846c317185f76f0177c00c23f603c857.tar.xz
Instead of parsing each fragment.profile individually and adding its metadata to the shared profile, use the metadata from the runnable repository as it should be identical. This allows us to eliminate 'fragment.profile' from the p2 Droplets format. Change-Id: I6b727e6433168a3527241a3d5de3ebbd09ff8db0 Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java62
1 files changed, 29 insertions, 33 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
index 666f5d8..0b258bb 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
@@ -12,16 +12,15 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
-import java.io.*;
+import java.io.File;
import java.lang.ref.SoftReference;
import java.net.*;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.engine.ProfileParser.ProfileHandler;
-import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.Parser;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
@@ -30,6 +29,7 @@ import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
@@ -224,40 +224,36 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
File[] extensionLocations = EngineActivator.getExtensionsDirectories();
Set<IInstallableUnit> added = new HashSet<IInstallableUnit>();
for (File extension : extensionLocations) {
- if (extension.isDirectory()) {
- File[] listFiles = extension.listFiles(new FileFilter() {
-
- public boolean accept(File pathname) {
- if (pathname.getName().endsWith(".profile")) { //$NON-NLS-1$
- return true;
- }
- return false;
- }
- });
- for (File profileFile : listFiles) {
- Parser extensionParser = profileRegistry.new Parser(EngineActivator.getContext(), EngineActivator.ID);
- try {
- extensionParser.parse(profileFile);
- //there is only one profile as we read only one
- String key = extensionParser.getProfileHandlers().keySet().iterator().next();
-
- ProfileHandler extensionHandler = extensionParser.getProfileHandlers().get(key);
- IInstallableUnit[] installableUnits = extensionHandler.getInstallableUnits();
- for (IInstallableUnit unit : installableUnits) {
- if (!added.contains(unit)) {
- added.add(unit);
- sharedProfile.addInstallableUnit(unit);
- }
- Map<String, String> iuProperties = extensionHandler.getIUProperties(unit);
- if (iuProperties != null && !iuProperties.isEmpty()) {
- sharedProfile.addInstallableUnitProperties(unit, iuProperties);
+ try {
+ IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepository repo = metaManager.loadRepository(extension.toURI(), new NullProgressMonitor());
+ Set<IInstallableUnit> installableUnits = repo.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).toUnmodifiableSet();
+ for (IInstallableUnit unit : installableUnits) {
+ Collection<IProvidedCapability> capabilities = unit.getProvidedCapabilities();
+ boolean featureOrBundle = false;
+ for (IProvidedCapability cap : capabilities) {
+ if ("org.eclipse.equinox.p2.eclipse.type".equals(cap.getNamespace())) { //$NON-NLS-1$
+ if ("bundle".equals(cap.getName()) //$NON-NLS-1$
+ || "source".equals(cap.getName()) //$NON-NLS-1$
+ || "feature".equals(cap.getName())) { //$NON-NLS-1$
+ featureOrBundle = true;
}
+ } else if (Boolean.TRUE.equals(unit.getProperties().get("org.eclipse.equinox.p2.type.group"))) { //$NON-NLS-1$
+ featureOrBundle = true;
}
- } catch (IOException e) {
- LogHelper.log(new Status(IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.SurrogateProfileHandler_1, profileFile), e));
+ }
+ if (featureOrBundle && !added.contains(unit)) {
+ added.add(unit);
+ sharedProfile.addInstallableUnit(unit);
+ }
+
+ Map<String, String> iuProperties = unit.getProperties();
+ if (iuProperties != null && !iuProperties.isEmpty()) {
+ sharedProfile.addInstallableUnitProperties(unit, iuProperties);
}
}
- continue;
+ } catch (ProvisionException e) {
+ LogHelper.log(new Status(IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.SurrogateProfileHandler_1, extension), e));
}
}