deb: shrink records to upper, journal and log; keep metadata for every build
Records carried a full chroot each, and space turned out to be the hard constraint: five records per target multiplied by a multi-GB chroot does not fit. The chroot is now per-run scratch — every build extracts a fresh one from the sha-verified mmdebstrap tarball cache into its record's chroot/ dir and removes it at the end (success, failure and interrupt included); resume_chroot, the .pkh-ready probe and chroot_is_usable are gone, and crashed-run leftovers are swept when the next run of that identity starts. What a record keeps instead: manifest.json (renamed, now with the tarball sha it used, a kept_upper flag and a tree-only journal — the environment phases rerun in every fresh chroot), a log/build.log full tee of the build output (kept for EVERY build; plain runs become metadata-only records, so keep-iff-incremental now applies to the staged tree alone), and — for --incremental runs — tree-upper/ with its host-files.list. The fork gate carries a base's staged tree only while its recorded tarball sha still matches the cache and the changelog version is unchanged; a fork candidate is any record with a staged tree. The keep-last-5 cap now applies to staged trees: a sixth retention degrades the oldest record to metadata-only instead of deleting it. New `pkh deb log [-f] [<id>]` prints (or follows) a record's build log, and `pkh deb list` shows the staged-tree state and plain-run records too. README rewritten around the shrunk model.
This commit is contained in:
+38
-3
@@ -371,15 +371,22 @@ fn main() {
|
||||
.num_args(0..=1)
|
||||
.require_equals(false)
|
||||
.default_missing_value("")
|
||||
.help("Incremental build: fork a previous build record of this target and keep the result")
|
||||
.long_help("Incremental build: fork a previous build record of this target — its prepared chroot and installed build dependencies are copied into a new record, and at the same changelog version its build artifacts too (make recompiles only what changed).\nWithout a value, the newest successful record of the target (among the last five usable) is the base; with an ID (as shown by 'pkh deb list'), that exact record — a failed one is fine if its environment is.\nEvery --incremental run keeps its record, success or failure, so the next one can fork it; a plain 'pkh deb' is fully ephemeral (nothing is kept, even on failure or interrupt)."),
|
||||
.help("Incremental build: fork a previous build record of this target and keep its staged tree")
|
||||
.long_help("Incremental build: fork a previous build record of this target — at an unchanged changelog version and while the chroot tarball is unchanged, the base's staged tree is copied into a new record, so make recompiles only what changed.\nWithout a value, the newest successful record of the target (among the last five carrying a staged tree) is the base; with an ID (as shown by 'pkh deb list'), that exact record — a failed one is fine if its staged tree is.\nEvery --incremental run keeps its staged tree, success or failure, so the next one can fork it; a plain 'pkh deb' keeps only metadata and its build log (the chroot is per-run and always discarded)."),
|
||||
)
|
||||
.arg(arg!(--verbose "Show raw tool output instead of the live build view").required(false)
|
||||
.long_help("Show raw tool output instead of the live build view.\nAlso implied by RUST_LOG=debug for pkh's own logs."))
|
||||
.subcommand(
|
||||
Command::new("list")
|
||||
.about("List the build records recorded from this tree")
|
||||
.long_about("List the build records recorded from this tree, with their outcome, version, fork lineage and the id to pass to 'pkh deb --incremental <id>'.\nRead-only: never builds or removes anything (only the last five records per target are kept, 'pkh prune' removes the ones older than a week)."),
|
||||
.long_about("List the build records recorded from this tree (plain runs too, as metadata records), with their outcome, version, fork lineage, whether their staged tree is kept, and the id to pass to 'pkh deb --incremental <id>'.\nRead-only: never builds or removes anything (at most five staged trees per target are kept, 'pkh prune' removes records older than a week)."),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("log")
|
||||
.about("Print a recorded build's log")
|
||||
.long_about("Print the build log of a recorded build: the full tee of its output.\nWithout an ID, the newest record of this tree; with an ID (as shown by 'pkh deb list'), that exact record.\n--follow keeps reading a live build's log as it is written and exits once the build's record reaches a terminal state.")
|
||||
.arg(arg!([id] "Record id (default: the newest record of this tree)").required(false))
|
||||
.arg(arg!(-f --follow "Keep reading the log as the build writes it")),
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
@@ -896,6 +903,34 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
// `pkh deb log`: print a recorded build's log (optionally
|
||||
// following a live build); read-only too.
|
||||
if let Some(("log", log_matches)) = sub_matches.subcommand() {
|
||||
let tree = cwd.canonicalize().unwrap_or(cwd.clone());
|
||||
let id = log_matches.get_one::<String>("id").map(String::as_str);
|
||||
let follow = log_matches.get_flag("follow");
|
||||
let record = match pkh::deb::session::record_for_log(
|
||||
&pkh::deb::session::sessions_root(),
|
||||
&tree,
|
||||
id,
|
||||
) {
|
||||
Ok(record) => record,
|
||||
Err(e) => {
|
||||
error!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let mut out = std::io::stdout();
|
||||
if let Err(e) = pkh::deb::session::print_record_log(&record, follow, &mut out) {
|
||||
error!(
|
||||
"cannot print the build log of {}: {e}",
|
||||
record.root().display()
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Ctrl+C during the build must say what happened and release the
|
||||
// ephemeral chroot instead of dying on the default disposition.
|
||||
// The live view (when enabled) registers its own reporter on top
|
||||
|
||||
Reference in New Issue
Block a user