package and version inference, build driver persistence#17
package and version inference, build driver persistence#17
Conversation
- noop for the bare driver - will reuse the docker container instead of creating a new one -> enables reusing all kinds of caches, installed build deps etc while still having a fresh worktree and build
90d9022 to
ad295ac
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the debmagic CLI/build implementation to infer package name/version from debian/changelog, introduces driver persistence (esp. for Docker/incremental workflows), and updates tooling/CI accordingly.
Changes:
- Add package description inference from
debian/changelogand use a structuredPackageVersion. - Introduce persistent build driver configuration and new Docker driver implementation under
pack/. - Update CLI (
build→pack), integration tests, CI, and add Python tests for debmagic-pkg parsing/utilities.
Reviewed changes
Copilot reviewed 19 out of 26 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/test_packages.py | Updates integration test to run cargo run … pack and adjusts Docker base image flag / pip install args. |
| packages/debmagic/tests/assets/config1.toml | Adjusts test config fixture to new [driver] persistent config. |
| packages/debmagic/src/package.rs | Adds changelog-based package name/version inference. |
| packages/debmagic/src/pack/driver_docker.rs | New Docker build driver with optional persistence + metadata handling. |
| packages/debmagic/src/pack/driver_bare.rs | Refactors bare driver to use new shared driver config + updated trait signature. |
| packages/debmagic/src/pack/config.rs | Introduces shared DriverConfig with persistent + per-driver subconfigs. |
| packages/debmagic/src/pack/common.rs | Removes old PackageDescription, updates BuildConfig, changes interactive_shell signature. |
| packages/debmagic/src/pack.rs | Main packaging flow; improves error context and replaces tree copy with ignore walker. |
| packages/debmagic/src/main.rs | Switches CLI subcommand to pack, changes config discovery path, wires CLI overrides. |
| packages/debmagic/src/config.rs | Updates config model (replaces dry_run with incremental) and adjusts tests. |
| packages/debmagic/src/cli.rs | Restructures CLI args, adds docker base-image flag and persistence/incremental flags. |
| packages/debmagic/src/build/driver_docker.rs | Removes old build-module Docker driver implementation. |
| packages/debmagic/src/build/config.rs | Removes old build-module driver config. |
| packages/debmagic/Cargo.toml | Adds dependencies for changelog parsing + ignore-based walking + common crate. |
| packages/debmagic-pkg/tests/test_versioning.py | Adds Python tests for version parsing parity. |
| packages/debmagic-pkg/tests/test_package.py | Adds Python tests for source package parsing. |
| packages/debmagic-pkg/tests/test_exec.py | Adds Python tests for subprocess helper behavior. |
| packages/debmagic-pkg/tests/test_changelog.py | Adds Python tests for changelog parsing (including timestamp parsing). |
| packages/debmagic-pkg/tests/assets/pkg1/debian/control | Adds fixture Debian control file for Python tests. |
| packages/debmagic-pkg/tests/assets/pkg1/debian/changelog | Adds fixture changelog file for Python tests. |
| packages/debmagic-common/src/debian/version.rs | Refactors PackageVersion to Option fields + adds Display. |
| debian/control | Adds new Rust build-deps and removes ${python3:Depends} from debmagic package. |
| Cargo.toml | Adds workspace deps for debmagic-common, debian-changelog, and ignore. |
| Cargo.lock | Locks newly added Rust dependencies. |
| .pre-commit-config.yaml | Adds a clippy pre-commit hook. |
| .github/workflows/ci.yml | Updates CI self-build step to use debmagic pack. |
Comments suppressed due to low confidence (2)
packages/debmagic/src/pack/driver_bare.rs:82
interactive_shellfor the bare driver no longer opens an interactive shell; it only prints the build source directory. This breaks the “drop into shell on failure” workflow inpack.rsfor bare builds. Consider restoring the previous behavior (spawn$SHELL/bash) and use the providedcwdso the shell opens in the build directory.
packages/debmagic/src/pack.rs:276copy_dir_allcopies files todst.join(relative_path)but doesn’t ensure the destination parent directory exists for file entries.ignore::Walkordering isn’t guaranteed to yield directories before files, so this can fail withNo such file or directoryfor nested files. Createdst.join(relative_path).parent()(if any) before callingfs::copy.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
includes other small changes - proper error handling during version parsing - avoid lossy conversions in subcommand arg passing
Allows to place a base image override per distro version in the debmagic config.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 28 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn interactive_shell(&self, _cwd: &Path) -> std::io::Result<()> { | ||
| println!( | ||
| "source directory of current package build in {}", | ||
| self.config.build_source_dir().display() | ||
| ); | ||
| Ok(()) |
There was a problem hiding this comment.
DriverBare::interactive_shell no longer starts an interactive shell (it just prints a message). This breaks the shell subcommand’s contract (“Open an interactive shell…”) for the bare driver and also makes the "Dropping into shell…" fallback non-interactive. Consider restoring the previous behavior (spawn $SHELL/bash and current_dir(cwd)) now that the trait provides cwd.
|
|
||
| #[derive(Subcommand, Debug)] | ||
| pub enum Commands { | ||
| #[command(about = "Build a a debian package")] |
There was a problem hiding this comment.
There is a duplicated word in the subcommand description: "Build a a debian package" → "Build a debian package".
| #[command(about = "Build a a debian package")] | |
| #[command(about = "Build a debian package")] |
| } else { | ||
| let re_epoch = Regex::new(r"^([0-9]+):.*$").map_err(|_| VersionParseError)?; | ||
| re_epoch.replace(version, "$1").to_string() | ||
| re_epoch.replace(version, "$1").to_string(); |
There was a problem hiding this comment.
re_epoch.replace(version, "$1").to_string(); is a no-op (the result is immediately discarded) and will likely trigger a unused_must_use/clippy warning. Since pre-commit runs cargo clippy -D warnings, this will fail CI; remove the stray statement and keep only the assignment used for parsing.
| re_epoch.replace(version, "$1").to_string(); |
| /// distro epoch plus upstream version | ||
| pub fn upstream_revision(&self) -> String { | ||
| if !self.revision.is_empty() { | ||
| return format!("{}-{}", self.upstream, self.revision); | ||
| if let Some(revision) = &self.revision { | ||
| return format!("{}-{}", self.upstream, revision); | ||
| } | ||
| self.upstream.clone() |
There was a problem hiding this comment.
The doc comment on upstream_revision() currently says "distro epoch plus upstream version", but the method formats upstream + optional revision. Updating the comment will prevent misleading API docs.
| num_attached += 1; | ||
| } | ||
| "detach" => { | ||
| num_attached = std::cmp::max(0, num_attached - 1); |
There was a problem hiding this comment.
In the socket server, num_attached is a u64, but the detach branch does std::cmp::max(0, num_attached - 1). This is both a type mismatch (0 defaults to i32) and can underflow when num_attached == 0 (wrapping in release / panic in debug). Use a saturating/checked decrement (e.g., num_attached = num_attached.saturating_sub(1)) instead.
| num_attached = std::cmp::max(0, num_attached - 1); | |
| num_attached = num_attached.saturating_sub(1); |
| /// Determine which distro version to use for the build. | ||
| /// | ||
| /// If only one distro version is specified in the changelog, it's used automatically. | ||
| /// If multiple distro versions are specified, an explicit --distro-version is required. | ||
| /// If --distro-version is provided, it's validated against the changelog versions. | ||
| fn resolve_distro_version( |
There was a problem hiding this comment.
The documentation comment refers to --distro-version, but the CLI flag introduced in cli.rs is --distro. To avoid confusing users, update the docs here (and any related messages) to match the actual flag name.
| (_, None) => Err(anyhow!( | ||
| "changelog contains multiple distributions ({}), please specify which one to build for with --distro-version", | ||
| changelog_distros.join(", ") | ||
| )), |
There was a problem hiding this comment.
This error message tells users to pass --distro-version, but the CLI flag is --distro. The suggested flag name should match the actual CLI option so users can resolve the error.
| "{}-{}-{}", | ||
| self.package_identifier, self.distro, self.distro_version | ||
| ) | ||
| format!("{}-{}", self.package_identifier, self.distro.codename) |
There was a problem hiding this comment.
BuildConfig::build_identifier() now only includes the distro codename, which can lead to identifier/container-name collisions if two distros share a codename (or if distro support expands). Including both distro and codename (or the full DistroVersion) would make identifiers stable and unambiguous.
| format!("{}-{}", self.package_identifier, self.distro.codename) | |
| format!("{}-{:?}", self.package_identifier, self.distro) |
No description provided.