|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved. |
2 |
* Copyright (c) 2007, 2009 IBM Corporation and others. All rights reserved. |
| 3 |
* This program and the accompanying materials are made available under the |
3 |
* This program and the accompanying materials are made available under the |
| 4 |
* terms of the Eclipse Public License v1.0 which accompanies this distribution, |
4 |
* terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 5 |
* and is available at http://www.eclipse.org/legal/epl-v10.html |
5 |
* and is available at http://www.eclipse.org/legal/epl-v10.html |
|
Lines 15-21
Link Here
|
| 15 |
import java.util.*; |
15 |
import java.util.*; |
| 16 |
import java.util.Map.Entry; |
16 |
import java.util.Map.Entry; |
| 17 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
| 18 |
import org.eclipse.equinox.internal.p2.core.helpers.*; |
18 |
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; |
|
|
19 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
| 19 |
import org.eclipse.equinox.internal.p2.extensionlocation.Constants; |
20 |
import org.eclipse.equinox.internal.p2.extensionlocation.Constants; |
| 20 |
import org.eclipse.equinox.internal.provisional.configurator.Configurator; |
21 |
import org.eclipse.equinox.internal.provisional.configurator.Configurator; |
| 21 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; |
22 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; |
|
Lines 82-99
Link Here
|
| 82 |
ProvisioningContext context = getContext(); |
83 |
ProvisioningContext context = getContext(); |
| 83 |
ProfileChangeRequest request = createProfileChangeRequest(context); |
84 |
ProfileChangeRequest request = createProfileChangeRequest(context); |
| 84 |
|
85 |
|
| 85 |
if (request == null) { |
86 |
if (request == null) |
| 86 |
if (Tracing.DEBUG_RECONCILER) |
|
|
| 87 |
Tracing.debug("[reconciler][plan] Empty request"); |
| 88 |
return Status.OK_STATUS; |
87 |
return Status.OK_STATUS; |
| 89 |
} |
|
|
| 90 |
debug(request); |
| 91 |
|
88 |
|
| 92 |
SubMonitor sub = SubMonitor.convert(monitor, 100); |
89 |
SubMonitor sub = SubMonitor.convert(monitor, 100); |
| 93 |
try { |
90 |
try { |
| 94 |
//create the provisioning plan |
91 |
//create the provisioning plan |
| 95 |
ProvisioningPlan plan = createProvisioningPlan(request, context, sub.newChild(50)); |
92 |
ProvisioningPlan plan = createProvisioningPlan(request, context, sub.newChild(50)); |
| 96 |
debug(request, plan); |
93 |
|
| 97 |
status = plan.getStatus(); |
94 |
status = plan.getStatus(); |
| 98 |
if (status.getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL || plan.getOperands().length == 0) |
95 |
if (status.getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL || plan.getOperands().length == 0) |
| 99 |
return status; |
96 |
return status; |
|
Lines 412-479
Link Here
|
| 412 |
} |
409 |
} |
| 413 |
return false; |
410 |
return false; |
| 414 |
} |
411 |
} |
| 415 |
|
|
|
| 416 |
private void debug(ProfileChangeRequest request) { |
| 417 |
if (!Tracing.DEBUG_RECONCILER) { |
| 418 |
return; |
| 419 |
} |
| 420 |
final String PREFIX = "[reconciler][request] "; //$NON-NLS-1$ |
| 421 |
IInstallableUnit[] toAdd = request.getAddedInstallableUnits(); |
| 422 |
if (toAdd == null || toAdd.length == 0) { |
| 423 |
Tracing.debug(PREFIX + "No installable units to add."); //$NON-NLS-1$ |
| 424 |
} else { |
| 425 |
for (int i = 0; i < toAdd.length; i++) { |
| 426 |
Tracing.debug(PREFIX + "Adding IU: " + toAdd[i].getId() + ' ' + toAdd[i].getVersion()); //$NON-NLS-1$ |
| 427 |
} |
| 428 |
} |
| 429 |
IInstallableUnit[] toRemove = request.getRemovedInstallableUnits(); |
| 430 |
if (toRemove == null || toRemove.length == 0) { |
| 431 |
Tracing.debug(PREFIX + "No installable units to remove."); //$NON-NLS-1$ |
| 432 |
} else { |
| 433 |
for (int i = 0; i < toRemove.length; i++) { |
| 434 |
Tracing.debug(PREFIX + "Removing IU: " + toRemove[i].getId() + ' ' + toRemove[i].getVersion()); //$NON-NLS-1$ |
| 435 |
} |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
private void debug(ProfileChangeRequest request, ProvisioningPlan plan) { |
| 440 |
if (!Tracing.DEBUG_RECONCILER) |
| 441 |
return; |
| 442 |
final String PREFIX = "[reconciler][plan] "; //$NON-NLS-1$ |
| 443 |
//get the request |
| 444 |
List toAdd = new ArrayList(); |
| 445 |
toAdd.addAll(Arrays.asList(request.getAddedInstallableUnits())); |
| 446 |
List toRemove = new ArrayList(); |
| 447 |
toRemove.addAll(Arrays.asList(request.getRemovedInstallableUnits())); |
| 448 |
|
| 449 |
//remove from the request everything what is in the plan |
| 450 |
Operand[] ops = plan.getOperands(); |
| 451 |
for (int i = 0; i < ops.length; i++) { |
| 452 |
if (ops[i] instanceof InstallableUnitOperand) { |
| 453 |
InstallableUnitOperand iuo = (InstallableUnitOperand) ops[i]; |
| 454 |
if (iuo.first() == null && iuo.second() != null) { |
| 455 |
toAdd.remove(iuo.second()); |
| 456 |
} |
| 457 |
if (iuo.first() != null && iuo.second() == null) { |
| 458 |
toRemove.remove(iuo.first()); |
| 459 |
} |
| 460 |
} |
| 461 |
} |
| 462 |
//if anything is left in the request, then something is wrong with the plan |
| 463 |
if (toAdd.size() == 0 && toRemove.size() == 0) { |
| 464 |
Tracing.debug(PREFIX + "Plan matches the request"); //$NON-NLS-1$ |
| 465 |
} |
| 466 |
if (toAdd.size() != 0) { |
| 467 |
Tracing.debug(PREFIX + "Some units will not be installed, because they are already installed or there are dependency issues:"); //$NON-NLS-1$ |
| 468 |
for (int i = 0; i < toAdd.size(); i++) { |
| 469 |
Tracing.debug(PREFIX + toAdd.get(i)); |
| 470 |
} |
| 471 |
} |
| 472 |
if (toRemove.size() != 0) { |
| 473 |
Tracing.debug(PREFIX + "Some units will not be uninstalled:"); //$NON-NLS-1$ |
| 474 |
for (int i = 0; i < toRemove.size(); i++) { |
| 475 |
Tracing.debug(PREFIX + toRemove.get(i)); |
| 476 |
} |
| 477 |
} |
| 478 |
} |
| 479 |
} |
412 |
} |