Skip to content

package and version inference, build driver persistence#17

Open
mikonse wants to merge 20 commits intomainfrom
milo/package-and-version-inference
Open

package and version inference, build driver persistence#17
mikonse wants to merge 20 commits intomainfrom
milo/package-and-version-inference

Conversation

@mikonse
Copy link
Member

@mikonse mikonse commented Jan 14, 2026

No description provided.

@mikonse mikonse force-pushed the milo/package-and-version-inference branch from 90d9022 to ad295ac Compare January 14, 2026 21:14
@mikonse mikonse marked this pull request as ready for review February 12, 2026 21:45
@TheJJ TheJJ requested a review from Copilot February 14, 2026 13:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/changelog and use a structured PackageVersion.
  • Introduce persistent build driver configuration and new Docker driver implementation under pack/.
  • Update CLI (buildpack), 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_shell for 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 in pack.rs for bare builds. Consider restoring the previous behavior (spawn $SHELL/bash) and use the provided cwd so the shell opens in the build directory.
    packages/debmagic/src/pack.rs:276
  • copy_dir_all copies files to dst.join(relative_path) but doesn’t ensure the destination parent directory exists for file entries. ignore::Walk ordering isn’t guaranteed to yield directories before files, so this can fail with No such file or directory for nested files. Create dst.join(relative_path).parent() (if any) before calling fs::copy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +84 to 89
fn interactive_shell(&self, _cwd: &Path) -> std::io::Result<()> {
println!(
"source directory of current package build in {}",
self.config.build_source_dir().display()
);
Ok(())
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(about = "Build a a debian package")]
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a duplicated word in the subcommand description: "Build a a debian package" → "Build a debian package".

Suggested change
#[command(about = "Build a a debian package")]
#[command(about = "Build a debian package")]

Copilot uses AI. Check for mistakes.
} 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();
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
re_epoch.replace(version, "$1").to_string();

Copilot uses AI. Check for mistakes.
Comment on lines 51 to 56
/// 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()
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
num_attached += 1;
}
"detach" => {
num_attached = std::cmp::max(0, num_attached - 1);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
num_attached = std::cmp::max(0, num_attached - 1);
num_attached = num_attached.saturating_sub(1);

Copilot uses AI. Check for mistakes.
Comment on lines +278 to +283
/// 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(
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +301 to +304
(_, None) => Err(anyhow!(
"changelog contains multiple distributions ({}), please specify which one to build for with --distro-version",
changelog_distros.join(", ")
)),
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
"{}-{}-{}",
self.package_identifier, self.distro, self.distro_version
)
format!("{}-{}", self.package_identifier, self.distro.codename)
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
format!("{}-{}", self.package_identifier, self.distro.codename)
format!("{}-{:?}", self.package_identifier, self.distro)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant