diff options
Diffstat (limited to 'bundles')
14 files changed, 144 insertions, 22 deletions
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 f38645299..2292a4efb 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.core;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-ClassPath: . Bundle-Activator: org.eclipse.equinox.internal.p2.core.Activator Bundle-Vendor: %providerName diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java index b7fb78d38..7712732df 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java @@ -36,6 +36,7 @@ public class Tracing { public static boolean DEBUG_REMOVE_REPO = false; public static boolean DEBUG_UPDATE_CHECK = false; public static boolean DEBUG_EVENTS_CLIENT = false; + public static boolean DEBUG_VERIFIER = false; static { DebugOptions options = (DebugOptions) ServiceHelper.getService(Activator.context, DebugOptions.class.getName()); @@ -55,6 +56,7 @@ public class Tracing { DEBUG_RECONCILER = options.getBooleanOption(Activator.ID + "/reconciler", false); //$NON-NLS-1$ DEBUG_REMOVE_REPO = options.getBooleanOption(Activator.ID + "/core/removeRepo", false); //$NON-NLS-1$ DEBUG_UPDATE_CHECK = options.getBooleanOption(Activator.ID + "/updatechecker", false); //$NON-NLS-1$ + DEBUG_VERIFIER = options.getBooleanOption(Activator.ID + "/verifier", false); //$NON-NLS-1$ } } } 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); + +} diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF index 9ec20c51e..8ebbd31a0 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.directorywatcher;singleton:=true -Bundle-Version: 1.0.200.qualifier +Bundle-Version: 1.0.201.qualifier Bundle-Activator: org.eclipse.equinox.internal.provisional.p2.directorywatcher.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java index e8213eda8..36302dd32 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java @@ -73,7 +73,7 @@ public class RepositoryListener extends DirectoryChangeListener { info.setArtifactRepository(artifactRepository); info.setMetadataRepository(metadataRepository); info.addAdvice(advice); - info.setArtifactOptions(IPublisherInfo.A_INDEX); + info.setArtifactOptions(IPublisherInfo.A_INDEX | IPublisherInfo.A_NO_MD5); } protected CachingArtifactRepository initializeArtifactRepository(String repositoryName, URI repositoryLocation, boolean hidden) { diff --git a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF index f73f932c9..38a06f1b3 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.publisher;singleton:=true -Bundle-Version: 1.1.0.qualifier +Bundle-Version: 1.1.1.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.publisher.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherInfo.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherInfo.java index e804e2d08..bba320f9c 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherInfo.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/IPublisherInfo.java @@ -35,6 +35,13 @@ public interface IPublisherInfo { public static final int A_OVERWRITE = 4; /** + * A bitwise flag indicating that MD5 hash should not be generated when + * publishing an artifact. When this flag is not specified the MD5 hash will + * be generated by default. + */ + public static final int A_NO_MD5 = 8; + + /** * Returns the artifact repository into which any publishable artifacts are published * or <code>null</code> if none. * @return a destination artifact repository or <code>null</code> diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java index e64e63c2a..3da9abb03 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java @@ -116,8 +116,8 @@ public class BundlesAction extends AbstractPublisherAction { Version hostVersion = Version.parseVersion(configInfo.getVersion()); VersionRange range = hostVersion == Version.emptyVersion ? VersionRange.emptyRange : new VersionRange(hostVersion, true, Version.MAX_VERSION, true); cu.setHost(new IRequirement[] { // - MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, hostId, range, null, false, false, true), // - MetadataFactory.createRequirement(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), false), null, false, false, false)}); + MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, hostId, range, null, false, false, true), // + MetadataFactory.createRequirement(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), false), null, false, false, false)}); //Adds capabilities for fragment, self, and describing the flavor supported cu.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); @@ -593,7 +593,7 @@ public class BundlesAction extends AbstractPublisherAction { try { if (bundles == null) bundles = getBundleDescriptions(expandLocations(locations), monitor); - generateBundleIUs(bundles, results, monitor); + generateBundleIUs(bundles, publisherInfo, results, monitor); bundles = null; } catch (OperationCanceledException e) { return Status.CANCEL_STATUS; @@ -659,7 +659,12 @@ public class BundlesAction extends AbstractPublisherAction { } } + //TODO remove this method protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherResult result, IProgressMonitor monitor) { + generateBundleIUs(bundleDescriptions, null, result, monitor); + } + + protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherInfo info, IPublisherResult result, IProgressMonitor monitor) { // This assumes that hosts are processed before fragments because for each fragment the host // is queried for the strings that should be translated. @@ -679,7 +684,7 @@ public class BundlesAction extends AbstractPublisherAction { } File location = new File(bd.getLocation()); - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(info.getArtifactRepository(), key, location); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(info, key, location); processArtifactPropertiesAdvice(bundleIU, ad, info); // Publish according to the shape on disk diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java index 892c9d508..72f059c3a 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java @@ -605,7 +605,7 @@ public class FeaturesAction extends AbstractPublisherAction { Collection<IArtifactKey> artifacts = featureIU.getArtifacts(); for (IArtifactKey artifactKey : artifacts) { File file = new File(feature.getLocation()); - ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info.getArtifactRepository(), artifactKey, file); + ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, artifactKey, file); processArtifactPropertiesAdvice(featureIU, ad, publisherInfo); ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP); // if the artifact is a dir then zip it up. diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java index 6d2e2f035..9136fa894 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/PublisherHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 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 @@ -88,10 +88,26 @@ public class PublisherHelper { public static final IProvidedCapability FEATURE_CAPABILITY = MetadataFactory.createProvidedCapability(NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_FEATURE, Version.createOSGi(1, 0, 0)); public static IArtifactDescriptor createArtifactDescriptor(IArtifactKey key, File pathOnDisk) { - return createArtifactDescriptor(null, key, pathOnDisk); + return createArtifactDescriptor(null, null, key, pathOnDisk); } + //TODO remove because the method with IPublisherInfo is more powerful public static IArtifactDescriptor createArtifactDescriptor(IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk) { + return createArtifactDescriptor(null, artifactRepo, key, pathOnDisk); + } + + /** + * Creates an artifact descriptor for the given key and path. + * @param info the publisher info + * @param key the key of the artifact to publish + * @param pathOnDisk the path of the artifact on disk + * @return a new artifact descriptor + */ + public static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactKey key, File pathOnDisk) { + return createArtifactDescriptor(info, info.getArtifactRepository(), key, pathOnDisk); + } + + private static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk) { IArtifactDescriptor result = artifactRepo != null ? artifactRepo.createArtifactDescriptor(key) : new ArtifactDescriptor(key); if (result instanceof ArtifactDescriptor) { ArtifactDescriptor descriptor = (ArtifactDescriptor) result; @@ -99,9 +115,11 @@ public class PublisherHelper { descriptor.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, Long.toString(pathOnDisk.length())); descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); } - String md5 = computeMD5(pathOnDisk); - if (md5 != null) - descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, md5); + if (info == null || (info.getArtifactOptions() & IPublisherInfo.A_NO_MD5) == 0) { + String md5 = computeMD5(pathOnDisk); + if (md5 != null) + descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, md5); + } } return result; } 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 ded4824cf..0a75a5982 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 @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.touchpoint.eclipse;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java index 7ee7ae534..be55efdb3 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java @@ -12,8 +12,7 @@ package org.eclipse.equinox.internal.p2.update; import java.io.*; import java.net.*; -import java.util.HashMap; -import java.util.Map; +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.URLUtil; @@ -36,11 +35,10 @@ public class ConfigurationWriter implements ConfigurationConstants { writer = new XMLWriter(output); Map<String, String> args = new HashMap<String, String>(); - String value = configuration.getDate(); - if (value != null) - args.put(ATTRIBUTE_DATE, value); + // always write out an up-to-date timestamp + args.put(ATTRIBUTE_DATE, Long.toString(new Date().getTime())); - value = configuration.getSharedUR(); + String value = configuration.getSharedUR(); if (value != null) args.put(ATTRIBUTE_SHARED_UR, value); |