|
@@ -1,16 +1,37 @@
|
|
|
/**
|
|
/**
|
|
|
- * `usm rebuild <package>` — rebuild an installed package from its
|
|
|
|
|
- * cached sources through {@link Usm.Transaction.rebuild_package}, the
|
|
|
|
|
|
|
+ * `usm rebuild <package> [--clean]` — rebuild an installed package from
|
|
|
|
|
+ * its cached sources through {@link Usm.Transaction.rebuild_package}, the
|
|
|
* standard pipeline with build-cache restore and a clean retry on
|
|
* standard pipeline with build-cache restore and a clean retry on
|
|
|
* failure, then reinstall its resources. Non-destructive (same version,
|
|
* failure, then reinstall its resources. Non-destructive (same version,
|
|
|
* same state directory), so no confirmation is needed.
|
|
* same state directory), so no confirmation is needed.
|
|
|
|
|
+ *
|
|
|
|
|
+ * `--clean` discards the build cache (build directory + build.tar.xz)
|
|
|
|
|
+ * before rebuilding, forcing a from-scratch compilation.
|
|
|
*/
|
|
*/
|
|
|
private int rebuild_main(string[] args) {
|
|
private int rebuild_main(string[] args) {
|
|
|
|
|
|
|
|
- if(args.length != 3 || args[2].has_prefix("-")) {
|
|
|
|
|
|
|
+ bool clean_build = false;
|
|
|
|
|
+ string? package_name = null;
|
|
|
|
|
+
|
|
|
|
|
+ for(int i = 2; i < args.length; i++) {
|
|
|
|
|
+ var arg = args[i];
|
|
|
|
|
+ if(arg == "--clean") {
|
|
|
|
|
+ clean_build = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(arg.has_prefix("-")) {
|
|
|
|
|
+ return rebuild_usage();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(package_name == null) {
|
|
|
|
|
+ package_name = arg;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ return rebuild_usage();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(package_name == null) {
|
|
|
return rebuild_usage();
|
|
return rebuild_usage();
|
|
|
}
|
|
}
|
|
|
- var package_name = args[2];
|
|
|
|
|
|
|
|
|
|
var progress = new Usm.Cli.ProgressBar();
|
|
var progress = new Usm.Cli.ProgressBar();
|
|
|
|
|
|
|
@@ -30,6 +51,11 @@ private int rebuild_main(string[] args) {
|
|
|
return 254;
|
|
return 254;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(clean_build) {
|
|
|
|
|
+ target.clean_build_cache();
|
|
|
|
|
+ print("Cleared build cache for %s\n", target.package_name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
var transaction = new Usm.Transaction() {
|
|
var transaction = new Usm.Transaction() {
|
|
|
paths = paths,
|
|
paths = paths,
|
|
|
resource_finder = new Usm.ResourceFinder(paths),
|
|
resource_finder = new Usm.ResourceFinder(paths),
|
|
@@ -51,6 +77,6 @@ private int rebuild_main(string[] args) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private int rebuild_usage() {
|
|
private int rebuild_usage() {
|
|
|
- printerr("USAGE:\n\tusm rebuild <package>\n");
|
|
|
|
|
|
|
+ printerr("USAGE:\n\tusm rebuild <package> [--clean]\n");
|
|
|
return 255;
|
|
return 255;
|
|
|
}
|
|
}
|