Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java36
1 files changed, 33 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
index 1ec41ba81..971480495 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
@@ -94,7 +94,7 @@ public class Projector {
for (int i = 0; i < ius.length; i++) {
createMustHaves(ius[i]);
}
- createOptimizationFunction();
+ createOptimizationFunction(ius);
persist();
if (DEBUG) {
long stop = System.currentTimeMillis();
@@ -115,7 +115,7 @@ public class Projector {
}
//Create an optimization function favoring the highest version of each IU
- private void createOptimizationFunction() {
+ private void createOptimizationFunction(IInstallableUnit[] ius) {
final String MIN_STR = "min:"; //$NON-NLS-1$
objective = new StringBuffer(MIN_STR);
@@ -154,13 +154,33 @@ public class Projector {
objective.append(" -").append(maxWeight).append(" ").append((String) iterator.next()); //$NON-NLS-1$ //$NON-NLS-2$
}
- if (MIN_STR.equals(objective.toString())) {
+ maxWeight *= POWER;
+ objective.append(' ').append(getPatchesWeight(ius, maxWeight));
+
+ if (MIN_STR.equals(objective.toString().trim())) {
objective = new StringBuffer();
} else {
objective.append(" ;"); //$NON-NLS-1$
}
}
+ protected StringBuffer getPatchesWeight(IInstallableUnit ius[], long weight) {
+ StringBuffer patchesWeight = new StringBuffer();
+ if (patches == null)
+ return patchesWeight;
+ for (int i = 0; i < ius.length; i++) {
+ RequiredCapability[] reqs = ius[i].getRequiredCapabilities();
+ for (int j = 0; j < reqs.length; j++) {
+ Collector matches = patches.query(new CapabilityQuery(reqs[j]), new Collector(), null);
+ for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
+ IInstallableUnitPatch match = (IInstallableUnitPatch) iterator.next();
+ patchesWeight.append('-').append(weight).append(' ').append(getVariable(match)).append(' ');
+ }
+ }
+ }
+ return patchesWeight;
+ }
+
private void createMustHaves(IInstallableUnit iu) {
tautologies.add(" +1 " + getVariable(iu) + " = 1;"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -298,6 +318,7 @@ public class Projector {
}
Collector patches = getApplicablePatches(iu);
+ expandLifeCycle(iu);
//No patches apply, normal code path
if (patches.size() == 0) {
RequiredCapability[] reqs = iu.getRequiredCapabilities();
@@ -367,6 +388,15 @@ public class Projector {
}
}
+ private void expandLifeCycle(IInstallableUnit iu) {
+ if (!(iu instanceof IInstallableUnitPatch))
+ return;
+ IInstallableUnitPatch patch = (IInstallableUnitPatch) iu;
+ if (patch.getLifeCycle() == null)
+ return;
+ expandNormalRequirement(null, iu, patch.getLifeCycle());
+ }
+
private void genericExpandRequirement(String var, IInstallableUnit iu, RequiredCapability req, String value, String negationExpression) {
if (req.isOptional())
genericOptionalRequirementExpansion(var, iu, req, value);

Back to the top