Skip to content

tar: Add support for archiving directories #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

euanh
Copy link
Collaborator

@euanh euanh commented Mar 18, 2025

Motivation

The tar writer currently provides helper functions which can create tar archives containing single executable files. In order to include resource bundles in container images (#48) the tar writer must be able create archives containing multiple files and directories.

Modifications

  • A new Archive type representing a tar archive allows multiple files to be added before being written out as an array of bytes.
  • Helper functions allow files and directories to be added to the archive.

Result

The tar writer is able to create archives containing files and directories.

Test Plan

New tests exercise creating archives containing multiple members, including directories.

@euanh euanh force-pushed the tar-archive-directories branch from 566f881 to 7e7ec1c Compare March 18, 2025 11:55
@euanh euanh added the semver/none No version bump required. label Mar 18, 2025
@euanh euanh force-pushed the tar-archive-directories branch 5 times, most recently from 504338d to 504050b Compare March 18, 2025 14:05
@euanh euanh force-pushed the tar-archive-directories branch from 504050b to fdfa139 Compare March 18, 2025 14:12
@euanh euanh marked this pull request as ready for review March 18, 2025 14:46
@euanh euanh merged commit 10b7ef5 into apple:main Mar 18, 2025
19 checks passed
@euanh euanh deleted the tar-archive-directories branch March 18, 2025 14:47
euanh added a commit that referenced this pull request Apr 11, 2025
…ages (#78)

Motivation
----------

A target in `Package.swift` can include
[resources](https://developer.apple.com/documentation/packagedescription/target/resources).
When the target is built, the resources are copied into a bundle
directory and a
[`Bundle`](https://developer.apple.com/documentation/foundation/bundle)
class is generated, giving the executable a convenient way to retrieve
them at run time.

A target with resources should be able to access them when it is
packaged in a container image. For example, a web server might bundle
resources such as images or fonts.

Fixes #48 

Modifications
-------------

* Add a new `--resource` parameter to `containertool`. This specifies a
resource bundle directory which is added to the container image using
the directory archiving support added to the `Tar` module in #74. When
`containertool` is used alone, multiple `--resource` flags can be
specified and will be added to the image in the order in which they
appear on the command line. A target in `Package.swift` can only define
one resource bundle, so when used through the plugin only one bundle
will be added.
* Update the plugin to pass the `--resource` flag to `containertool`
when an executable target has resources.

Result
------

If a target includes resources, the resource bundle will be copied into
the container image at a path where the generated `Bundle` class can
find it.
If a target does not include resources, the container image will only
include the executable.

Test Plan
---------

* Existing tests continue to pass.
* New integration tests verify that all expected resources are present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant