Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2010-06-25 17:29:35 +0000
committerDJ Houghton2010-06-25 17:29:35 +0000
commit9d6e62c35a779515fa617ee76775ad3230df6f58 (patch)
tree8cb319b401bcb396a556c08726d90f59e874635f /bundles/org.eclipse.equinox.p2.director
parent7b05b6a3fd276f82bb2c57f5f1122f849a9a8016 (diff)
downloadrt.equinox.p2-9d6e62c35a779515fa617ee76775ad3230df6f58.tar.gz
rt.equinox.p2-9d6e62c35a779515fa617ee76775ad3230df6f58.tar.xz
rt.equinox.p2-9d6e62c35a779515fa617ee76775ad3230df6f58.zip
Bug 312254 - Plan verifier to allow third party plugin to veto a provisioning planv20100625R3_6_maintenance_patches
Bug 313905 - [reconciler] Second startup after update also slow Bug 313447 - Avoid MD5 computation for publishing from dropins reconciler
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director')
-rw-r--r--bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanVerifier.java25
3 files changed, 93 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
index a9490e15d..66cf0ffd8 100644
--- a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.director;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.0.1.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.equinox.internal.p2.director.DirectorActivator
Bundle-Vendor: %providerName
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index a42ac71c6..93080db13 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -31,6 +31,8 @@ import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescriptio
import org.eclipse.equinox.p2.planner.*;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
public class SimplePlanner implements IPlanner {
private static boolean DEBUG = Tracing.DEBUG_PLANNER_OPERANDS;
@@ -69,13 +71,77 @@ public class SimplePlanner implements IPlanner {
Map<IInstallableUnit, RequestStatus>[] changes = computeActualChangeRequest(toState, changeRequest);
Map<IInstallableUnit, RequestStatus> requestChanges = (changes == null) ? null : changes[0];
Map<IInstallableUnit, RequestStatus> requestSideEffects = (changes == null) ? null : changes[1];
+
QueryableArray plannedState = new QueryableArray(toState.toArray(new IInstallableUnit[toState.size()]));
PlannerStatus plannerStatus = new PlannerStatus(Status.OK_STATUS, null, requestChanges, requestSideEffects, plannedState);
+
plan.setStatus(plannerStatus);
plan.setInstallerPlan(installerPlan);
+
+ IStatus verificationStatus = verifyPlan(plan);
+ if (!verificationStatus.isOK())
+ plan.setStatus(verificationStatus);
+
return plan;
}
+ /*
+ * Give clients the opportunity to veto the given provisioning plan. Return a status
+ * indicating the result of the verifier's analysis of the plan. If a verifier is not
+ * registered, if verification is disabled, or if the verifier is misbehaving then
+ * return an OK status and continue with the provisioning operation as if the verifier
+ * had not run at all.
+ */
+ private IStatus verifyPlan(final IProvisioningPlan plan) {
+ final BundleContext context = DirectorActivator.context;
+ if (context == null)
+ return Status.OK_STATUS;
+ String value = context.getProperty("eclipse.p2.verifyPlan"); //$NON-NLS-1$
+ if ("false".equalsIgnoreCase(value)) { //$NON-NLS-1$
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Plan verification disabled by user."); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ ServiceReference ref = context.getServiceReference(PlanVerifier.class.getName());
+ if (ref == null) {
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Skipping plan verification. No verifier available."); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ final PlanVerifier verifier = (PlanVerifier) context.getService(ref);
+ if (verifier == null) {
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Skipping plan verification. No verifier available."); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ final IStatus[] result = new IStatus[1];
+ result[0] = Status.OK_STATUS;
+ ISafeRunnable job = new ISafeRunnable() {
+ public void handleException(Throwable exception) {
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Exception while running verifier. Check log for details."); //$NON-NLS-1$
+ // log the exception
+ LogHelper.log(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, "Exception while running plan verifier.", exception)); //$NON-NLS-1$
+ // don't let a bad verifier prevent the operation. fall through and return OK so execution of the plan continues
+ }
+
+ public void run() throws Exception {
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Running plan verifier."); //$NON-NLS-1$
+ long start = System.currentTimeMillis();
+ result[0] = verifier.verify(plan);
+ if (Tracing.DEBUG_VERIFIER)
+ Tracing.debug("Verification complete in " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ };
+ try {
+ SafeRunner.run(job);
+ } finally {
+ context.ungetService(ref);
+ }
+ return result[0];
+ }
+
private Map<IInstallableUnit, RequestStatus>[] buildDetailedErrors(ProfileChangeRequest changeRequest) {
Collection<IInstallableUnit> requestedAdditions = changeRequest.getAdditions();
Collection<IInstallableUnit> requestedRemovals = changeRequest.getRemovals();
@@ -829,4 +895,5 @@ public class SimplePlanner implements IPlanner {
public IProfileChangeRequest createChangeRequest(IProfile profileToChange) {
return new ProfileChangeRequest(profileToChange);
}
+
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanVerifier.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanVerifier.java
new file mode 100644
index 000000000..5231685b7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanVerifier.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.director;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.p2.engine.IProvisioningPlan;
+
+/**
+ * Verifier is responsible for checking plan sanity
+ */
+public abstract class PlanVerifier {
+ /**
+ * Verifies provisioning plan from P2 solver
+ */
+ public abstract IStatus verify(IProvisioningPlan plan);
+
+}

Back to the top