Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox')
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RelaxedUpdateInstallOperation.java111
3 files changed, 117 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java
index b170e415c..918011323 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java
@@ -66,6 +66,9 @@ public class Messages extends NLS {
public static String UpdateOperation_ResolveJobName;
public static String UpdateOperation_UpdateJobName;
+ public static String RelaxedUpdateOperation_ResolveJobName;
+ public static String RelaxedUpdateOperation_UpdateJobName;
+
public static String OperationFactory_noAgent;
public static String OperationFactory_noIUFound;
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties
index 48fa2ae64..2d2253ea5 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties
@@ -42,6 +42,9 @@ UninstallOperation_ResolveJobName=Calculating Uninstall Validity
UpdateOperation_ProfileChangeRequestProgress=Computing update request
UpdateOperation_ResolveJobName=Computing Update Requirements
UpdateOperation_UpdateJobName=Updating Software
+RelaxedUpdateOperation_ResolveJobName=Computing Update Requirements
+RelaxedUpdateOperation_UpdateJobName=Updating Software
+
OperationFactory_noAgent=This installation has not been configured properly. No provisioning agent can be found.
OperationFactory_noIUFound=No IU could be found for {0}. \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RelaxedUpdateInstallOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RelaxedUpdateInstallOperation.java
new file mode 100644
index 000000000..a0e20dd60
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RelaxedUpdateInstallOperation.java
@@ -0,0 +1,111 @@
+package org.eclipse.equinox.p2.operations;
+
+import java.util.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.internal.p2.metadata.query.UpdateQuery;
+import org.eclipse.equinox.internal.p2.operations.Messages;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.planner.*;
+import org.eclipse.equinox.p2.query.*;
+
+/**
+ * An operation that updates IUs with relaxed p2 constraints
+ *
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @noreference
+ */
+public class RelaxedUpdateInstallOperation extends ProfileChangeOperation {
+
+ public RelaxedUpdateInstallOperation(ProvisioningSession session) {
+ super(session);
+ }
+
+ @Override
+ protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) {
+ IProfileRegistry profileRegistry = (IProfileRegistry) session.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IPlanner plan = (IPlanner) session.getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ IProfile prof = profileRegistry.getProfile(getProfileId());
+
+ final String INCLUSION_RULES = "org.eclipse.equinox.p2.internal.inclusion.rules"; //$NON-NLS-1$
+ final String INCLUSION_OPTIONAL = "OPTIONAL"; //$NON-NLS-1$
+ final String INCLUSION_STRICT = "STRICT"; //$NON-NLS-1$
+
+ IQueryResult<IInstallableUnit> strictRoots = prof.query(new IUProfilePropertyQuery(INCLUSION_RULES, INCLUSION_STRICT), null);
+ IQueryResult<IInstallableUnit> optionalRoots = prof.query(new IUProfilePropertyQuery(INCLUSION_RULES, INCLUSION_OPTIONAL), null);
+ Set<IInstallableUnit> tmpRoots = new HashSet<IInstallableUnit>(strictRoots.toUnmodifiableSet());
+ tmpRoots.addAll(optionalRoots.toUnmodifiableSet());
+ CollectionResult<IInstallableUnit> allRoots = new CollectionResult<IInstallableUnit>(tmpRoots);
+
+ request = (ProfileChangeRequest) plan.createChangeRequest(prof);
+ Collection<IRequirement> limitingRequirements = new ArrayList<IRequirement>();
+
+ for (Iterator<IInstallableUnit> iterator = allRoots.query(QueryUtil.ALL_UNITS, null).iterator(); iterator.hasNext();) {
+ IInstallableUnit currentlyInstalled = iterator.next();
+
+ //find all the potential updates for the currentlyInstalled iu
+ IQueryResult<IInstallableUnit> updatesAvailable = plan.updatesFor(currentlyInstalled, context, null);
+ for (Iterator<IInstallableUnit> iterator2 = updatesAvailable.iterator(); iterator2.hasNext();) {
+ IInstallableUnit update = iterator2.next();
+ request.add(update);
+ request.setInstallableUnitInclusionRules(update, ProfileInclusionRules.createOptionalInclusionRule(update));
+ }
+ if (!updatesAvailable.isEmpty()) {
+ //force the original IU to optional, but make sure that the solution at least includes it
+ request.setInstallableUnitInclusionRules(currentlyInstalled, ProfileInclusionRules.createOptionalInclusionRule(currentlyInstalled));
+ limitingRequirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, currentlyInstalled.getId(), new VersionRange(currentlyInstalled.getVersion(), true, Version.MAX_VERSION, true), null, false, false));
+ }
+ }
+
+ IProvisioningPlan updateFinderPlan = plan.getProvisioningPlan(request, context, null);
+ if (updateFinderPlan.getAdditions().query(QueryUtil.ALL_UNITS, null).isEmpty()) {
+ return;
+ }
+
+ //Take into account all the removals
+ IProfileChangeRequest finalChangeRequest = plan.createChangeRequest(prof);
+ IQueryResult<IInstallableUnit> removals = updateFinderPlan.getRemovals().query(QueryUtil.ALL_UNITS, null);
+ for (Iterator<IInstallableUnit> iterator = removals.iterator(); iterator.hasNext();) {
+ IInstallableUnit iu = iterator.next();
+ if (!allRoots.query(QueryUtil.createIUQuery(iu), null).isEmpty()) {
+ finalChangeRequest.remove(iu);
+ }
+ }
+
+ //Take into account the additions for stricts
+ for (Iterator<IInstallableUnit> iterator = strictRoots.iterator(); iterator.hasNext();) {
+ IInstallableUnit formerRoot = iterator.next();
+ IQueryResult<IInstallableUnit> update = updateFinderPlan.getAdditions().query(new UpdateQuery(formerRoot), null);
+ if (!update.isEmpty())
+ finalChangeRequest.addAll(update.toUnmodifiableSet());
+ }
+
+ //Take into account the additions for optionals
+ for (Iterator<IInstallableUnit> iterator = optionalRoots.iterator(); iterator.hasNext();) {
+ IInstallableUnit formerRoot = iterator.next();
+ IQueryResult<IInstallableUnit> update = updateFinderPlan.getAdditions().query(new UpdateQuery(formerRoot), null);
+ if (!update.isEmpty()) {
+ for (Iterator<IInstallableUnit> it = update.iterator(); it.hasNext();) {
+ IInstallableUnit updatedOptionalIU = it.next();
+ finalChangeRequest.add(updatedOptionalIU);
+ finalChangeRequest.setInstallableUnitInclusionRules(updatedOptionalIU, ProfileInclusionRules.createOptionalInclusionRule(updatedOptionalIU));
+ }
+ }
+ }
+ //return planner.getProvisioningPlan(finalChangeRequest, context, null);
+ }
+
+ @Override
+ protected String getResolveJobName() {
+ return Messages.RelaxedUpdateOperation_ResolveJobName;
+ }
+
+ @Override
+ protected String getProvisioningJobName() {
+ return Messages.RelaxedUpdateOperation_UpdateJobName;
+ }
+
+} \ No newline at end of file

Back to the top