Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ To build the `container` project, you need:
- macOS 15 minimum, macOS 26 beta recommended
- Xcode 26 beta

> [!IMPORTANT]
> There is a bug in the `vmnet` framework on macOS 26 beta that causes network creation to fail if the `container` helper applications are located under your `Documents` or `Desktop` directories. If you use `make install`, you can simply run the `container` binary in `/usr/local`. If you prefer to use the binaries that `make all` creates in your project `bin` and `libexec` directories, locate your project elsewhere, such as `~/projects/container`, until this issue is resolved.

## Compile and test

Build `container` and the background services from source, and run basic and integration tests:
Expand Down Expand Up @@ -38,58 +41,60 @@ to prepare your build environment.

2. In your development shell, go to the `container` project directory.

```
```bash
cd container
```

3. If the `container` services are already running, stop them.

```
```bash
bin/container system stop
```

4. Configure the environment variable `CONTAINERIZATION_PATH` to refer to your Containerization project, and update your `Package.resolved` file.

```
export CONTAINERIZATION_PATH=../containerization
swift package update containerization
```

5. Build the init filesystem for your local copy of the Containerization project.
4. Use the Swift package manager to configure use your local `containerization` package and update your `Package.resolved` file.

```
(cd ${CONTAINERIZATION_PATH} && make clean all)
```bash
/usr/bin/swift package edit --path ../containerization containerization
/usr/bin/swift package update containerization
```

6. Build `container`.
> [!IMPORTANT]
> If you are using Xcode, you will need to temporarily modify `Package.swift` instead of using `swift package edit`, using a path dependency in place of the versioned `container` dependency:
>
> ```swift
> .package(.path: "../containerization"),
> ```
5. Build `container`.

```
make clean all
```

7. Start the `container` services.
6. Restart the `container` services.

```
bin/container system stop
bin/container system start
```

To revert to using the Containerization dependency from your `Package.swift`:

1. Unset your `CONTAINERIZATION_PATH` environment variable, and update `Package.resolved`.
1. Use the Swift package manager to restore the normal `containerization` dependency and update your `Package.resolved` file. If you are using Xcode, revert your `Package.swift` change instead of using `swift package unedit`.

```
unset CONTAINERIZATION_PATH
swift package update containerization
```bash
/usr/bin/swift package unedit containerization
/usr/bin/swift package update containerization
```

2. Rebuild `container`.

```
```bash
make clean all
```

3. Restart the `container` services.

```
bin/container system restart
```bash
bin/container system stop
bin/container system start
```
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,9 @@
import Foundation
import PackageDescription

let scDependency: Package.Dependency
let scVersion: String
if let path = ProcessInfo.processInfo.environment["CONTAINERIZATION_PATH"] {
scDependency = .package(path: path)
scVersion = "latest"
} else {
scVersion = "0.3.0"
scDependency = .package(url: "https://github.com/apple/containerization.git", exact: Version(stringLiteral: scVersion))
}

let releaseVersion = ProcessInfo.processInfo.environment["RELEASE_VERSION"] ?? "0.0.0"
let gitCommit = ProcessInfo.processInfo.environment["GIT_COMMIT"] ?? "unspecified"
let scVersion = "0.3.0"
let builderShimVersion = "0.3.0"

let package = Package(
Expand All @@ -58,7 +49,7 @@ let package = Package(
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.20.1"),
.package(url: "https://github.com/orlandos-nl/DNSClient.git", from: "2.4.1"),
.package(url: "https://github.com/Bouke/DNS.git", from: "1.2.0"),
scDependency,
.package(url: "https://github.com/apple/containerization.git", exact: Version(stringLiteral: scVersion)),
],
targets: [
.executableTarget(
Expand Down
10 changes: 7 additions & 3 deletions scripts/install-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ IMAGE_NAME="vminit:latest"
DESTDIR="${1:-$(git rev-parse --show-toplevel)/bin}"
mkdir -p "${DESTDIR}"

CONTAINERIZATION_VERSION="${CONTAINERIZATION_VERSION:-$(${SWIFT} package show-dependencies --format json | jq -r '.dependencies[] | select(.identity == "containerization") | .version')}"
if [ ! -z "${CONTAINERIZATION_PATH}" -o "${CONTAINERIZATION_VERSION}" == "unspecified" ] ; then
CONTAINERIZATION_PATH="${CONTAINERIZATION_PATH:-$(${SWIFT} package show-dependencies --format json | jq -r '.dependencies[] | select(.identity == "containerization") | .path')}"
CONTAINERIZATION_VERSION="$(${SWIFT} package show-dependencies --format json | jq -r '.dependencies[] | select(.identity == "containerization") | .version')"
if [ "${CONTAINERIZATION_VERSION}" == "unspecified" ] ; then
CONTAINERIZATION_PATH="$(${SWIFT} package show-dependencies --format json | jq -r '.dependencies[] | select(.identity == "containerization") | .path')"
if [ ! -d "${CONTAINERIZATION_PATH}" ] ; then
echo "editable containerization directory at ${CONTAINERIZATION_PATH} does not exist"
exit 1
fi
echo "Creating InitImage"
make -C ${CONTAINERIZATION_PATH} init
${CONTAINERIZATION_PATH}/bin/cctl images save -o /tmp/init.tar ${IMAGE_NAME}
Expand Down