Skip to content

ArchiveWriter: support explicit entries and rewrite internal symlinks#652

Open
mazdak wants to merge 2 commits into
apple:mainfrom
mazdak:mazdak/archive-writer-symlink
Open

ArchiveWriter: support explicit entries and rewrite internal symlinks#652
mazdak wants to merge 2 commits into
apple:mainfrom
mazdak:mazdak/archive-writer-symlink

Conversation

@mazdak

@mazdak mazdak commented Apr 5, 2026

Copy link
Copy Markdown

Context and Motivation

While building out a Docker Compose-style plugin and validating it against our own real development stack, we ran into two classes of problems in the build-context path, and to fix them we had to make changes to the container app, but part of the changes were archive-authoring concerns and belong in ContainerizationArchive, not in higher-level callers. The result is a reusable API for explicit archive creation and more portable archives when symlinks point to other archived content.

(Related container PR: apple/container#1391)

This PR adds a generic explicit-entry archive API to ContainerizationArchive and improves symlink handling so archives remain relocatable after extraction.

In addition to archiveDirectory(_:), callers can now provide an ordered list of source entries to archive. This makes it possible to archive a precomputed file set without rewalking the source tree and centralizes symlink handling in the archive layer itself.

Testing

  • add regression coverage for explicit-entry archive creation
  • add round-trip tests for:
    • internal absolute symlinks rewritten to archive-relative paths
    • external absolute symlinks preserved unchanged
    • canonicalized internal absolute symlinks through symlinked ancestors
  • verify existing archive-directory symlink behavior still passes

Passed:

  • swift test --filter archiveEntries
  • swift test --filter archiveDirectoryRewritesInternalAbsoluteSymlink
  • swift test --filter archiveDirectorySymlinkInside
  • swift test --filter archiveDirectorySymlinkOutsideExcluded
@jglogan

jglogan commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

@mazdak Sorry I've not looked closely enough at the changes yet, I've been swamped.

I'll get some feedback on this by Friday. I still need to look at the code more closely to see where this best fits.

@mazdak mazdak force-pushed the mazdak/archive-writer-symlink branch from a25f55e to d04d8dc Compare June 3, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants