Skip to content

Imports: resolve a leading ./ in an apt index entry's Filename, as apt does - #846

Merged
schmitch merged 1 commit into
mainfrom
claude/754-apt-import-dot-filename
Nov 3, 2026
Merged

schmitch merged 1 commit into
mainfrom
claude/754-apt-import-dot-filename

Conversation

@schmitch

@schmitch schmitch commented Nov 3, 2026

Copy link
Copy Markdown
Member

Fixes #754

Problem

Repositories made with dpkg-scanpackages ./pool or apt-ftparchive packages ./pool list Filename: ./pool/main/h/hello/hello_1.0_amd64.deb. Entry::problem checks that path with files::validate_path, which refuses a . segment, so an import of such a repository failed every package with "is no path below the repository".

Change

  • crates/formats/apt/src/import.rs: new resolve_filename drops a Filename's . segments. read_packages applies it when it reads the field, so the resolved path is the only one an Entry carries: Entry::problem checks it, the download URL is built from it, and the import item stores it. A .., an empty segment and a leading / stay in the path, and validate_path still refuses them.
  • Unit test a_filename_is_resolved_as_apt_resolves_it: ./ and inner . segments are resolved, and ./../x.deb, pool/./../x.deb, /./pool/x.deb and ./ are still refused.
  • crates/server/tests/apt_import.rs: the static-repository test's fine package is now listed as ./pool/.... It is imported and downloaded once from pool/.... Without the fix this test fails: the dry run plans 4 packages instead of 5.
  • Changelog fragment docs/changes/2.2.0/754.fixed.md.

Tests

  • cargo test -p forge-format-apt: 49 passed
  • cargo test -p forge-server --test apt_import (PostgreSQL via testcontainers through mirror.gcr.io): 3 passed
  • cargo test -p forge-server --lib import: 17 passed
  • cargo clippy -p forge-format-apt -p forge-server --all-targets -- -D warnings, cargo fmt --all -- --check and cargo xtask changelog --check: all clean

Generated by Claude Code

Indexes made with `dpkg-scanpackages ./pool` or `apt-ftparchive packages
./pool` list `Filename: ./pool/...`, which `files::validate_path` refuses,
so an import of such a repository failed every package. The parser now
drops a Filename's `.` segments (resolve_filename), so the check, the
download and the item's stored Filename all see the resolved path; `..`,
empty segments and a leading `/` stay and are still refused.

Fixes #754

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012e6DJaER1FpBfS1RFru5JP
@schmitch
schmitch added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 60b5aac Nov 3, 2026
19 checks passed
@schmitch
schmitch deleted the claude/754-apt-import-dot-filename branch November 3, 2026 17:16
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.

Imports: apt index entries whose Filename starts with ./ all fail ("no path below the repository")

2 participants