summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2013-01-18 20:06:14 (EST)
committerPascal Rapicault2013-01-18 20:06:14 (EST)
commit4b675832b97be3028cd5f8bd4f0b49ea49e60b06 (patch)
tree4df6029b132a96bdf83bfc4028381ced25b71d30
parentb8f8ce20eb92966f3b14e039d29155921813b8f6 (diff)
downloadrt.equinox.p2-4b675832b97be3028cd5f8bd4f0b49ea49e60b06.zip
rt.equinox.p2-4b675832b97be3028cd5f8bd4f0b49ea49e60b06.tar.gz
rt.equinox.p2-4b675832b97be3028cd5f8bd4f0b49ea49e60b06.tar.bz2
Bug 396147 - Add support for feature/plugin updates from one namespacev20130119-010614
to another
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/AvailableIUWrapper.java13
2 files changed, 39 insertions, 24 deletions
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 d1dbff9..7c15716 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 IBM Corporation and others.
+ * Copyright (c) 2009, 2013 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
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Sonatype, Inc. - ongoing development
+ * Rapicorp, Inc (Pascal Rapicault) - Bug 396147 - 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/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 1bc569d..ebc5b7d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* EclipseSource - ongoing development
+ * Rapicorp, Inc (Pascal Rapicault) - Bug 396147 - Add support for updates from one namespace to another
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.query;
@@ -84,16 +85,18 @@ public class AvailableIUWrapper extends QueriedElementWrapper {
boolean isInstalled = false;
boolean isPatch = iu == null ? false : Boolean.valueOf(iu.getProperty(InstallableUnitDescription.PROP_TYPE_PATCH));
if (profile != null && iu != null) {
- IQueryResult<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUQuery(iu.getId()), null);
+ IQuery<IInstallableUnit> query = QueryUtil.isGroup(iu) ? QueryUtil.createIUGroupQuery() : QueryUtil.ALL_UNITS;
+ IQueryResult<IInstallableUnit> queryResult = profile.query(query, null);
Iterator<IInstallableUnit> iter = queryResult.iterator();
// We are typically iterating over only one IU unless it's a non-singleton.
while (iter.hasNext()) {
IInstallableUnit installed = iter.next();
- if (installed.getVersion().compareTo(iu.getVersion()) < 0)
- isUpdate = true;
- else {
+ if (iu.getId().equals(installed.getId()) && installed.getVersion().compareTo(iu.getVersion()) >= 0) {
isUpdate = false;
isInstalled = true;
+ } else {
+ if (iu.getUpdateDescriptor() != null && iu.getUpdateDescriptor().isUpdateOf(installed))
+ isUpdate = true;
}
}
}