jkang / rpms / eclipse

Forked from rpms/eclipse 4 years ago
Clone
Krzysztof Daniel 2d61ac2
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
Krzysztof Daniel 2d61ac2
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
Krzysztof Daniel 2d61ac2
@@ -7,6 +7,7 @@
Krzysztof Daniel 2d61ac2
  * Contributors: 
Krzysztof Daniel 2d61ac2
  *     IBM Corporation - initial API and implementation
Krzysztof Daniel 2d61ac2
  *     Ericsson AB - ongoing development
Krzysztof Daniel 2d61ac2
+ *     Red Hat, Inc. - Bug 408138
Krzysztof Daniel 2d61ac2
  ******************************************************************************/
Krzysztof Daniel 2d61ac2
 package org.eclipse.equinox.internal.p2.engine;
Krzysztof Daniel 2d61ac2
 
Krzysztof Daniel 2d61ac2
@@ -38,6 +39,7 @@ import org.xml.sax.SAXException;
Krzysztof Daniel 2d61ac2
 
Krzysztof Daniel 2d61ac2
 public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
Krzysztof Daniel 2d61ac2
 
Krzysztof Daniel 2d61ac2
+	private static final String PROP_IGNORE_USER_CONFIGURATION = "eclipse.ignoreUserConfiguration"; //$NON-NLS-1$
Krzysztof Daniel 2d61ac2
 	private static final String SIMPLE_PROFILE_REGISTRY_INTERNAL = "_simpleProfileRegistry_internal_"; //$NON-NLS-1$
Krzysztof Daniel 2d61ac2
 	private static final String PROFILE_REGISTRY = "profile registry"; //$NON-NLS-1$
Krzysztof Daniel 2d61ac2
 	private static final String PROFILE_PROPERTIES_FILE = "state.properties"; //$NON-NLS-1$
Krzysztof Daniel 2d61ac2
@@ -263,6 +265,14 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
Krzysztof Daniel 2d61ac2
 					internalSetProfileStateProperty(profile, profile.getTimestamp(), IProfile.STATE_PROP_SHARED_INSTALL, IProfile.STATE_SHARED_INSTALL_VALUE_NEW);
Krzysztof Daniel 2d61ac2
 					internalSetProfileStateProperty(profile, profile.getTimestamp(), SIMPLE_PROFILE_REGISTRY_INTERNAL + getBaseTimestamp(profile.getProfileId()), getBaseTimestamp(id));
Krzysztof Daniel 2d61ac2
 					agent.registerService(SERVICE_SHARED_INSTALL_NEW_TIMESTAMP, Long.toString(profile.getTimestamp()));
Krzysztof Daniel 2d61ac2
+
Krzysztof Daniel 2d61ac2
+					// this looks like a hack, but:
Krzysztof Daniel 2d61ac2
+					// (1) SimpleConfigurationImpl keeps returning master configuration as long as the property is set
Krzysztof Daniel 2d61ac2
+					// (2) SimpleConfigurationImpl sets the propery after it drops user configuration
Krzysztof Daniel 2d61ac2
+					// therefore dropins reconciliation can't load dropins plugins installed into user configuration
Krzysztof Daniel 2d61ac2
+					// after the user configuration has been dropped.
Krzysztof Daniel 2d61ac2
+					// It is necessary to unset this property.
Krzysztof Daniel 82a9557
+					//System.setProperty(PROP_IGNORE_USER_CONFIGURATION, "processed_and_unset"); //$NON-NLS-1$ //$NON-NLS-2$
Krzysztof Daniel 2d61ac2
 				} else {
Krzysztof Daniel 2d61ac2
 					//This is the first time we create the shared profile. Tag it as such and also remember the timestamp of the base
Krzysztof Daniel 2d61ac2
 					internalSetProfileStateProperty(profile, profile.getTimestamp(), IProfile.STATE_PROP_SHARED_INSTALL, IProfile.STATE_SHARED_INSTALL_VALUE_INITIAL);
Krzysztof Daniel 2d61ac2
@@ -279,6 +289,12 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
Krzysztof Daniel 2d61ac2
 		if (agent.getService(SERVICE_SHARED_INSTALL_NEW_TIMESTAMP) != null)
Krzysztof Daniel 2d61ac2
 			return false;
Krzysztof Daniel 2d61ac2
 
Krzysztof Daniel 2d61ac2
+		// if the property is set by OSGI, and there is no new timestamp (because of the previous condition)
Krzysztof Daniel 2d61ac2
+		// ignore current profile. This will happen only once, because SERVICE_SHARED_INSTALL_NEW_TIMESTAMP
Krzysztof Daniel 2d61ac2
+		// is set during profile reset.
Krzysztof Daniel 82a9557
+		if ("true".equals(System.getProperty(PROP_IGNORE_USER_CONFIGURATION))){ //$NON-NLS-1$ //$NON-NLS-2$
Krzysztof Daniel 82a9557
+			System.setProperty(PROP_IGNORE_USER_CONFIGURATION, "processed_and_unset"); //$NON-NLS-1$ //$NON-NLS-2$
Krzysztof Daniel 82a9557
+			return true;}
Krzysztof Daniel 2d61ac2
 		String baseTimestamp = getBaseTimestamp(profile.getProfileId());
Krzysztof Daniel 2d61ac2
 		if (baseTimestamp == null)
Krzysztof Daniel 2d61ac2
 			return false;
Krzysztof Daniel 82a9557
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
Krzysztof Daniel 82a9557
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
Krzysztof Daniel 82a9557
@@ -570,6 +570,7 @@
Krzysztof Daniel 82a9557
 
Krzysztof Daniel 82a9557
 		// get all IUs from all our repos 
Krzysztof Daniel 82a9557
 		IQueryResult<IInstallableUnit> allIUs = getAllIUsFromRepos();
Krzysztof Daniel 82a9557
+		HashSet<IInstallableUnit> removedFromAllIUs = new HashSet<IInstallableUnit>();
Krzysztof Daniel 82a9557
 		for (Iterator<IInstallableUnit> iter = allIUs.iterator(); iter.hasNext();) {
Krzysztof Daniel 82a9557
 			final IInstallableUnit iu = iter.next();
Krzysztof Daniel 82a9557
 			IInstallableUnit existing = profileIUs.get(iu);
Krzysztof Daniel 82a9557
@@ -583,6 +584,7 @@
Krzysztof Daniel 82a9557
 				// (and more expensive) way to find this out is to do an IU profile property query.
Krzysztof Daniel 82a9557
 				if (two == null) {
Krzysztof Daniel 82a9557
 					// the IU is already installed so don't mark it as a dropin now - see bug 404619.
Krzysztof Daniel 82a9557
+					removedFromAllIUs.add(iu);
Krzysztof Daniel 82a9557
 					iter.remove();
Krzysztof Daniel 82a9557
 					continue;
Krzysztof Daniel 82a9557
 				}
Krzysztof Daniel 82a9557
@@ -625,7 +627,7 @@
Krzysztof Daniel 82a9557
 			}
Krzysztof Daniel 82a9557
 			// if the IU from the profile is in the "all available" list, then it is already added
Krzysztof Daniel 82a9557
 			// otherwise if it isn't in the repo then we have to remove it from the profile.
Krzysztof Daniel 82a9557
-			if (!all.contains(iu))
Krzysztof Daniel 82a9557
+			if (!all.contains(iu) && !removedFromAllIUs.contains(iu))
Krzysztof Daniel 82a9557
 				toRemove.add(iu);
Krzysztof Daniel 82a9557
 		}
Krzysztof Daniel 82a9557
 
Krzysztof Daniel 82a9557
@@ -799,8 +801,8 @@
Krzysztof Daniel 82a9557
 			IStatus installerPlanStatus = engine.perform(plan.getInstallerPlan(), phaseSet, monitor);
Krzysztof Daniel 82a9557
 			if (!installerPlanStatus.isOK())
Krzysztof Daniel 82a9557
 				return installerPlanStatus;
Krzysztof Daniel 82a9557
-
Krzysztof Daniel 82a9557
-			applyConfiguration(true);
Krzysztof Daniel 82a9557
+			if (isReconciliationApplicationRunning())
Krzysztof Daniel 82a9557
+				applyConfiguration(true);
Krzysztof Daniel 82a9557
 		}
Krzysztof Daniel 82a9557
 		return engine.perform(plan, phaseSet, monitor);
Krzysztof Daniel 82a9557
 	}
Krzysztof Daniel 8592bf0
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java.bak	2013-06-10 09:33:20.000000000 +0200
Krzysztof Daniel 8592bf0
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java	2013-06-11 15:44:28.654682088 +0200
Krzysztof Daniel 8592bf0
@@ -144,7 +144,7 @@
Krzysztof Daniel 8592bf0
 	}
Krzysztof Daniel 8592bf0
 
Krzysztof Daniel 8592bf0
 	public boolean performCancel() {
Krzysztof Daniel 8592bf0
-		String[] buttons = new String[] {IDialogConstants.YES_LABEL, ProvUIMessages.ImportFromInstallationPag_LATER_BUTTON, IDialogConstants.NO_LABEL};
Krzysztof Daniel 8592bf0
+		String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL};
Krzysztof Daniel 8592bf0
 		MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_TITLE, null, ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);
Krzysztof Daniel 8592bf0
 
Krzysztof Daniel 8592bf0
 		return rememberCancellationDecision(dialog.open());
Krzysztof Daniel 049ca94
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java
Krzysztof Daniel 049ca94
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationPage_c.java
Krzysztof Daniel 049ca94
@@ -15,6 +15,7 @@ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;
Krzysztof Daniel 049ca94
 import java.net.URI;
Krzysztof Daniel 049ca94
 import org.eclipse.core.runtime.Platform;
Krzysztof Daniel 049ca94
 import org.eclipse.equinox.internal.p2.ui.ProvUI;
Krzysztof Daniel 049ca94
+import org.eclipse.equinox.internal.p2.ui.QueryProvider;
Krzysztof Daniel 049ca94
 import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
Krzysztof Daniel 049ca94
 import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard;
Krzysztof Daniel 049ca94
 import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
Krzysztof Daniel 049ca94
@@ -103,6 +104,12 @@ public class ImportFromInstallationPage_c extends AbstractImportPage_c implement
Krzysztof Daniel 049ca94
 				public org.eclipse.equinox.p2.query.IQueryable getQueryable() {
Krzysztof Daniel 049ca94
 					return toBeImportedProfile;
Krzysztof Daniel 049ca94
 				}
Krzysztof Daniel 049ca94
+
Krzysztof Daniel 049ca94
+				@Override
Krzysztof Daniel 049ca94
+				public int getQueryType() {
Krzysztof Daniel 049ca94
+					return QueryProvider.STRICT_INSTALLED_IUS;
Krzysztof Daniel 049ca94
+				}
Krzysztof Daniel 049ca94
+
Krzysztof Daniel 049ca94
 			};
Krzysztof Daniel 049ca94
 			element.setQueryable(toBeImportedProfile);
Krzysztof Daniel 049ca94
 			input = element;
Krzysztof Daniel 049ca94
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
Krzysztof Daniel 049ca94
index 9cb6a53..b758ae7 100644
Krzysztof Daniel 049ca94
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
Krzysztof Daniel 049ca94
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
Krzysztof Daniel 049ca94
@@ -43,6 +43,7 @@ public class QueryProvider {
Krzysztof Daniel 049ca94
 	public static final int AVAILABLE_UPDATES = 5;
Krzysztof Daniel 049ca94
 	public static final int INSTALLED_IUS = 6;
Krzysztof Daniel 049ca94
 	public static final int AVAILABLE_ARTIFACTS = 7;
Krzysztof Daniel 049ca94
+	public static final int STRICT_INSTALLED_IUS = 8;
Krzysztof Daniel 049ca94
 
Krzysztof Daniel 049ca94
 	public QueryProvider(ProvisioningUI ui) {
Krzysztof Daniel 049ca94
 		this.ui = ui;
Krzysztof Daniel 049ca94
@@ -224,6 +225,31 @@ public class QueryProvider {
Krzysztof Daniel 049ca94
 					return null;
Krzysztof Daniel 049ca94
 				return new ElementQueryDescriptor(queryable, ArtifactKeyQuery.ALL_KEYS, new Collector<Object>(), new ArtifactKeyWrapper((IArtifactRepository) queryable, element));
Krzysztof Daniel 049ca94
 
Krzysztof Daniel 049ca94
+			case STRICT_INSTALLED_IUS :
Krzysztof Daniel 049ca94
+				// Querying of IU's.  We are drilling down into the requirements.
Krzysztof Daniel 049ca94
+				if (element instanceof IIUElement && context.getShowInstallChildren()) {
Krzysztof Daniel 049ca94
+					Collection<IRequirement> reqs = ((IIUElement) element).getRequirements();
Krzysztof Daniel 049ca94
+					IExpression[] requirementExpressions = new IExpression[reqs.size()];
Krzysztof Daniel 049ca94
+					int i = 0;
Krzysztof Daniel 049ca94
+					for (IRequirement req : reqs) {
Krzysztof Daniel 049ca94
+						requirementExpressions[i++] = req.getMatches();
Krzysztof Daniel 049ca94
+					}
Krzysztof Daniel 049ca94
+					IExpressionFactory factory = ExpressionUtil.getFactory();
Krzysztof Daniel 049ca94
+					IQuery<IInstallableUnit> meetsAnyRequirementQuery = QueryUtil.createMatchQuery(factory.or(requirementExpressions));
Krzysztof Daniel 049ca94
+					IQuery<IInstallableUnit> visibleAsAvailableQuery = policy.getVisibleAvailableIUQuery();
Krzysztof Daniel 049ca94
+					//dropins things have no file property
Krzysztof Daniel 049ca94
+					IQuery<IInstallableUnit> strictQuery = QueryUtil.createIUPropertyQuery("file.name", null); //$NON-NLS-1$
Krzysztof Daniel 049ca94
+					IQuery<IInstallableUnit> createCompoundQuery = QueryUtil.createCompoundQuery(QueryUtil.createCompoundQuery(visibleAsAvailableQuery, meetsAnyRequirementQuery, true), strictQuery, true);
Krzysztof Daniel 049ca94
+					return new ElementQueryDescriptor(queryable, createCompoundQuery, new Collector<IInstallableUnit>(), new InstalledIUElementWrapper(queryable, element));
Krzysztof Daniel 049ca94
+				}
Krzysztof Daniel 049ca94
+
Krzysztof Daniel 049ca94
+				profile = ProvUI.getAdapter(element, IProfile.class);
Krzysztof Daniel 049ca94
+				if (profile == null)
Krzysztof Daniel 049ca94
+					return null;
Krzysztof Daniel 049ca94
+				//dropins things have no file property
Krzysztof Daniel 049ca94
+				IQuery<IInstallableUnit> installedNotDropinsQuery = QueryUtil.createCompoundQuery(policy.getVisibleInstalledIUQuery(), QueryUtil.createIUPropertyQuery("file.name", null), true);
Krzysztof Daniel 049ca94
+				return new ElementQueryDescriptor(profile, installedNotDropinsQuery, new Collector<IInstallableUnit>(), new InstalledIUElementWrapper(profile, element)); //$NON-NLS-1$
Krzysztof Daniel 049ca94
+
Krzysztof Daniel 049ca94
 			default :
Krzysztof Daniel 049ca94
 				return null;
Krzysztof Daniel 049ca94
 		}