|
@@ -1,4 +1,5 @@
|
|
|
using Invercargill;
|
|
using Invercargill;
|
|
|
|
|
+using Invercargill.DataStructures;
|
|
|
|
|
|
|
|
namespace Usm {
|
|
namespace Usm {
|
|
|
|
|
|
|
@@ -9,10 +10,10 @@ namespace Usm {
|
|
|
public Set<CachedPackage> to_install { get; set; }
|
|
public Set<CachedPackage> to_install { get; set; }
|
|
|
public Set<CachedPackage> to_remove { get; set; }
|
|
public Set<CachedPackage> to_remove { get; set; }
|
|
|
|
|
|
|
|
- public signal void progress_updated(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress);
|
|
|
|
|
|
|
+ public signal void progress_updated(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress);
|
|
|
|
|
|
|
|
- private int task_count = 0;
|
|
|
|
|
- private int current_task = 0;
|
|
|
|
|
|
|
+ private uint task_count = 0;
|
|
|
|
|
+ private uint current_task = 0;
|
|
|
private string current_subject = "transaction";
|
|
private string current_subject = "transaction";
|
|
|
private Vector<Vector<CachedPackage>> install_lots;
|
|
private Vector<Vector<CachedPackage>> install_lots;
|
|
|
private Vector<CachedPackage> remove_order;
|
|
private Vector<CachedPackage> remove_order;
|
|
@@ -44,7 +45,7 @@ namespace Usm {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private string previous_key = "";
|
|
private string previous_key = "";
|
|
|
- public void print_progress(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress) {
|
|
|
|
|
|
|
+ public void print_progress(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress) {
|
|
|
var verb = task_type.get_verb();
|
|
var verb = task_type.get_verb();
|
|
|
verb = verb[0].toupper().to_string() + verb.substring(1);
|
|
verb = verb[0].toupper().to_string() + verb.substring(1);
|
|
|
var percent = (int)(task_progress * 100.0f);
|
|
var percent = (int)(task_progress * 100.0f);
|
|
@@ -56,7 +57,7 @@ namespace Usm {
|
|
|
printerr(@"$prefix[$(current_task+1)/$total_tasks] $verb $subject ($percent%)\n");
|
|
printerr(@"$prefix[$(current_task+1)/$total_tasks] $verb $subject ($percent%)\n");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void print_progress_simple(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress) {
|
|
|
|
|
|
|
+ public void print_progress_simple(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress) {
|
|
|
var verb = task_type.get_verb();
|
|
var verb = task_type.get_verb();
|
|
|
verb = verb[0].toupper().to_string() + verb.substring(1);
|
|
verb = verb[0].toupper().to_string() + verb.substring(1);
|
|
|
var percent = (int)(task_progress * 100.0f);
|
|
var percent = (int)(task_progress * 100.0f);
|
|
@@ -65,8 +66,8 @@ namespace Usm {
|
|
|
|
|
|
|
|
public void strategise() throws TransactionError {
|
|
public void strategise() throws TransactionError {
|
|
|
task_count = (to_install.count() * 4) + (to_remove.count() * 3) + 1;
|
|
task_count = (to_install.count() * 4) + (to_remove.count() * 3) + 1;
|
|
|
- var strategise_worst_case_task_count = (to_remove.count() * to_remove.count()) + (to_install.count() * to_install.count());
|
|
|
|
|
- var strategise_current_task = 0;
|
|
|
|
|
|
|
+ uint strategise_worst_case_task_count = (to_remove.count() * to_remove.count()) + (to_install.count() * to_install.count());
|
|
|
|
|
+ uint strategise_current_task = 0;
|
|
|
|
|
|
|
|
report_progress(TransactionTask.STRATEGISING, 0.0f);
|
|
report_progress(TransactionTask.STRATEGISING, 0.0f);
|
|
|
|
|
|
|
@@ -78,12 +79,12 @@ namespace Usm {
|
|
|
while(true) {
|
|
while(true) {
|
|
|
strategise_current_task = round * to_install.count();
|
|
strategise_current_task = round * to_install.count();
|
|
|
var lot = new Vector<CachedPackage>();
|
|
var lot = new Vector<CachedPackage>();
|
|
|
- var remaining = to_install.difference(touched);
|
|
|
|
|
|
|
+ var remaining = to_install.exclude(touched);
|
|
|
if(remaining.count() == 0) {
|
|
if(remaining.count() == 0) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- foreach (var package in to_install.difference(touched)) {
|
|
|
|
|
|
|
+ foreach (var package in to_install.exclude(touched)) {
|
|
|
report_progress(TransactionTask.STRATEGISING, (float)strategise_current_task / (float)strategise_worst_case_task_count);
|
|
report_progress(TransactionTask.STRATEGISING, (float)strategise_current_task / (float)strategise_worst_case_task_count);
|
|
|
try {
|
|
try {
|
|
|
var manifest = package.get_manifest();
|
|
var manifest = package.get_manifest();
|
|
@@ -91,7 +92,7 @@ namespace Usm {
|
|
|
if(installtime_dependencies.all(d => d.is_satisfied() || available_resources.any(r => d.satisfied_by(r)))) {
|
|
if(installtime_dependencies.all(d => d.is_satisfied() || available_resources.any(r => d.satisfied_by(r)))) {
|
|
|
lot.add(package);
|
|
lot.add(package);
|
|
|
touched.add(package);
|
|
touched.add(package);
|
|
|
- available_resources.add_all(manifest.provides.select<ResourceRef>(p => p.key));
|
|
|
|
|
|
|
+ available_resources.union_with(manifest.provides.select<ResourceRef>(p => p.key));
|
|
|
}
|
|
}
|
|
|
strategise_current_task++;
|
|
strategise_current_task++;
|
|
|
}
|
|
}
|
|
@@ -101,7 +102,7 @@ namespace Usm {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(lot.count() == 0) {
|
|
if(lot.count() == 0) {
|
|
|
- var packages = to_install.difference(touched).to_string(p => p.package_name, ", ");
|
|
|
|
|
|
|
+ var packages = to_install.exclude(touched).to_string(p => p.package_name, ", ");
|
|
|
throw new TransactionError.INVALID_TRANSACTION(@"Could not build a transaction strategy, packages $(packages) have unmet or cyclical dependencies");
|
|
throw new TransactionError.INVALID_TRANSACTION(@"Could not build a transaction strategy, packages $(packages) have unmet or cyclical dependencies");
|
|
|
}
|
|
}
|
|
|
|
|
|