diff options
author | Pascal Rapicault | 2012-11-25 05:02:52 +0000 |
---|---|---|
committer | Pascal Rapicault | 2012-11-25 05:19:09 +0000 |
commit | 3bf447faf9eaccac362a219a6e4f804698e81840 (patch) | |
tree | 2ffe1edf814c6bceaf447aa7446510127f944ea1 | |
parent | a00790dcb5cd1b944a818c0770501cf213fafb7f (diff) | |
download | rt.equinox.p2-3bf447faf9eaccac362a219a6e4f804698e81840.tar.gz rt.equinox.p2-3bf447faf9eaccac362a219a6e4f804698e81840.tar.xz rt.equinox.p2-3bf447faf9eaccac362a219a6e4f804698e81840.zip |
Bug 394156 - Add support for updates from one namespacev20121125-051909
to another
4 files changed, 41 insertions, 30 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF index f3205fc3c..cf4c946a3 100644 --- a/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.operations;singleton:=true -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.2.100.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.operations.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java index d1dbff919..1bd28f40e 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java @@ -8,10 +8,12 @@ * Contributors: * IBM Corporation - initial API and implementation * Sonatype, Inc. - ongoing development + * Rapicorp, Inc (Pascal Rapicault) - Bug 394156 - Add support for updates from one namespace to another ******************************************************************************/ package org.eclipse.equinox.p2.operations; import java.util.Collection; +import java.util.Iterator; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.director.Explanation; import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; @@ -70,8 +72,7 @@ public class InstallOperation extends ProfileChangeOperation { */ protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { request = ProfileChangeRequest.createByProfileId(session.getProvisioningAgent(), profileId); - IProfile profile; - profile = session.getProfileRegistry().getProfile(profileId); + IProfile profile = session.getProfileRegistry().getProfile(profileId); SubMonitor sub = SubMonitor.convert(monitor, Messages.InstallOperation_ComputeProfileChangeProgress, toInstall.size()); for (IInstallableUnit entryToInstall : toInstall) { // If the user is installing a patch, we mark it optional. This allows @@ -87,31 +88,22 @@ public class InstallOperation extends ProfileChangeOperation { if (!alreadyInstalled.isEmpty()) { // && installedIU.isSingleton() IInstallableUnit installedIU = alreadyInstalled.iterator().next(); int compareTo = entryToInstall.getVersion().compareTo(installedIU.getVersion()); - // If the iu is a newer version of something already installed, consider this an - // update request + // If the iu is a newer version of something already installed, consider this an update request if (compareTo > 0) { boolean lockedForUpdate = false; String value = profile.getInstallableUnitProperty(installedIU, IProfile.PROP_PROFILE_LOCKED_IU); if (value != null) lockedForUpdate = (Integer.parseInt(value) & IProfile.LOCK_UPDATE) == IProfile.LOCK_UPDATE; if (lockedForUpdate) { - // Add a status telling the user that this implies an update, but the - // iu should not be updated + // Add a status telling the user that this implies an update, but the iu should not be updated status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IGNORED_IMPLIED_UPDATE, entryToInstall)); } else { - request.add(entryToInstall); - request.remove(installedIU); - // Add a status informing the user that the update has been inferred - status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IMPLIED_UPDATE, entryToInstall)); - // Mark it as a root if it hasn't been already - if (!UserVisibleRootQuery.isUserVisible(installedIU, profile)) - request.setInstallableUnitProfileProperty(entryToInstall, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); + dealWithUpdates(status, profile, entryToInstall, installedIU); } } else if (compareTo < 0) { // An implied downgrade. We will not put this in the plan, add a status informing the user status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IGNORED_IMPLIED_DOWNGRADE, entryToInstall)); } else { - // if (rootMarkerKey != null) { if (UserVisibleRootQuery.isUserVisible(installedIU, profile)) // It is already a root, nothing to do. We tell the user it was already installed status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IGNORED_ALREADY_INSTALLED, entryToInstall)); @@ -121,12 +113,22 @@ public class InstallOperation extends ProfileChangeOperation { status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_PARTIAL_INSTALL, entryToInstall)); request.setInstallableUnitProfileProperty(entryToInstall, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); } - // } } } else { - // Install it and mark as a root - request.add(entryToInstall); - // if (rootMarkerKey != null) + //Deal with the case of updates with renames + boolean handled = false; + Iterator<IInstallableUnit> allIUsIterator = profile.query(QueryUtil.ALL_UNITS, null).iterator(); + while (allIUsIterator.hasNext()) { + IInstallableUnit iuAlreadyInstalled = allIUsIterator.next(); + if (entryToInstall.getUpdateDescriptor() != null && entryToInstall.getUpdateDescriptor().isUpdateOf(iuAlreadyInstalled)) { + dealWithUpdates(status, profile, entryToInstall, iuAlreadyInstalled); + handled = true; + break; + } + } + if (!handled) + // Install it and mark as a root + request.add(entryToInstall); request.setInstallableUnitProfileProperty(entryToInstall, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); } sub.worked(1); @@ -134,6 +136,16 @@ public class InstallOperation extends ProfileChangeOperation { sub.done(); } + private void dealWithUpdates(MultiStatus status, IProfile profile, IInstallableUnit entryToInstall, IInstallableUnit installedIU) { + request.add(entryToInstall); + request.remove(installedIU); + // Add a status informing the user that the update has been inferred + status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IMPLIED_UPDATE, entryToInstall)); + // Mark it as a root if it hasn't been already + if (!UserVisibleRootQuery.isUserVisible(installedIU, profile)) + request.setInstallableUnitProfileProperty(entryToInstall, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); + } + /* (non-Javadoc) * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getResolveJobName() */ diff --git a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF index 478ac385c..edbfa0420 100644 --- a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.ui;singleton:=true -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.2.100.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.ui.ProvUIActivator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/AvailableIUWrapper.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/AvailableIUWrapper.java index 1bc569d92..1d76e1c22 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/AvailableIUWrapper.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/AvailableIUWrapper.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * EclipseSource - ongoing development + * Rapicorp, Inc (Pascal Rapicault) - Bug 394156 - Add support for updates from one namespace to another *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.query; @@ -17,9 +18,10 @@ import org.eclipse.equinox.internal.p2.ui.ProvUI; import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; import org.eclipse.equinox.internal.p2.ui.model.*; import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; -import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.query.QueryUtil; /** * A wrapper that examines available IU's and wraps them in an @@ -82,18 +84,15 @@ public class AvailableIUWrapper extends QueriedElementWrapper { private InformationCache computeIUInformation(IInstallableUnit iu) { boolean isUpdate = false; boolean isInstalled = false; - boolean isPatch = iu == null ? false : Boolean.valueOf(iu.getProperty(InstallableUnitDescription.PROP_TYPE_PATCH)); + boolean isPatch = iu == null ? false : QueryUtil.isPatch(iu); if (profile != null && iu != null) { - IQueryResult<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUQuery(iu.getId()), null); - Iterator<IInstallableUnit> iter = queryResult.iterator(); - // We are typically iterating over only one IU unless it's a non-singleton. + isInstalled = !profile.query(QueryUtil.createIUQuery(iu), null).isEmpty(); + Iterator<IInstallableUnit> iter = profile.query(new UserVisibleRootQuery(), null).iterator(); while (iter.hasNext()) { IInstallableUnit installed = iter.next(); - if (installed.getVersion().compareTo(iu.getVersion()) < 0) + if (iu.getUpdateDescriptor() != null && iu.getUpdateDescriptor().isUpdateOf(installed)) { isUpdate = true; - else { - isUpdate = false; - isInstalled = true; + break; } } } |