diff --git a/Formula/README.md b/Formula/README.md new file mode 100644 index 000000000..e5b2b583c --- /dev/null +++ b/Formula/README.md @@ -0,0 +1,76 @@ +# Homebrew Formula for Container + +This directory contains the Homebrew formula for installing the `container` tool. + +## Installation + +### Install from Local Formula + +If you have cloned this repository, you can install directly from the local formula: + +```bash +# From the repository root directory +brew install --HEAD ./Formula/container.rb +``` + +### Install from Homebrew Tap (when available) + +Once the formula is published to a Homebrew tap, you can install it with: + +```bash +brew tap apple/tap +brew install --HEAD container +``` + +## Usage + +After installation, start the container system service: + +```bash +container system start +``` + +## Upgrading + +To upgrade to the latest version: + +```bash +brew upgrade container +container system stop +container system start +``` + +## Uninstalling + +To uninstall the container tool: + +```bash +brew uninstall container +``` + +Or use the included uninstall script for a complete removal: + +```bash +uninstall-container.sh -d +``` + +The script will be available in your Homebrew bin directory (typically `/opt/homebrew/bin` on Apple Silicon or `/usr/local/bin` on Intel Macs). + +## Requirements + +- macOS 15 (Sequoia) or later (macOS 26 recommended) +- Apple Silicon (ARM64) Mac +- Xcode 16.0 or later + +## Formula Details + +The formula: +- Builds the project from source using Swift Package Manager +- Installs the main `container` CLI and `container-apiserver` binaries +- Installs helper plugin binaries in `libexec` +- Includes plugin configuration files +- Provides the uninstall script + +## Contributing + +If you encounter issues with the Homebrew formula, please file an issue in the main repository. diff --git a/Formula/container.rb b/Formula/container.rb new file mode 100644 index 000000000..f53707bb5 --- /dev/null +++ b/Formula/container.rb @@ -0,0 +1,66 @@ +class Container < Formula + desc "Create and run Linux containers as lightweight virtual machines on your Mac" + homepage "https://github.com/apple/container" + # Note: This formula is currently designed for HEAD installations only. + # Update the url, tag, and revision when creating a stable release. + url "https://github.com/apple/container.git", + tag: "v0.0.0", + revision: "0000000000000000000000000000000000000000" + license "Apache-2.0" + head "https://github.com/apple/container.git", branch: "main" + + depends_on :macos => :sequoia + depends_on arch: :arm64 + depends_on xcode: ["16.0", :build] + + def install + # Build the project using Swift Package Manager + system "swift", "build", "-c", "release", "--disable-sandbox" + + # Get the build directory + build_bin_dir = ".build/release" + + # Install main CLI binary + bin.install "#{build_bin_dir}/container" + bin.install "#{build_bin_dir}/container-apiserver" + + # Install helper scripts + bin.install "scripts/uninstall-container.sh" + + # Create libexec directories for plugins + (libexec/"container/plugins/container-runtime-linux/bin").mkpath + (libexec/"container/plugins/container-network-vmnet/bin").mkpath + (libexec/"container/plugins/container-core-images/bin").mkpath + + # Install plugin binaries + (libexec/"container/plugins/container-runtime-linux/bin").install "#{build_bin_dir}/container-runtime-linux" + (libexec/"container/plugins/container-network-vmnet/bin").install "#{build_bin_dir}/container-network-vmnet" + (libexec/"container/plugins/container-core-images/bin").install "#{build_bin_dir}/container-core-images" + + # Install plugin configurations + (libexec/"container/plugins/container-runtime-linux").install "config/container-runtime-linux-config.json" => "config.json" + (libexec/"container/plugins/container-network-vmnet").install "config/container-network-vmnet-config.json" => "config.json" + (libexec/"container/plugins/container-core-images").install "config/container-core-images-config.json" => "config.json" + end + + def caveats + <<~EOS + Before using container, you need to start the system service: + container system start + + To stop the service: + container system stop + + To uninstall container completely: + uninstall-container.sh -d + + Note: container is officially supported on macOS 26, which includes optimizations + for virtualization and networking. While this formula can build on macOS 15 (Sequoia), + full functionality and support are only guaranteed on macOS 26. + EOS + end + + test do + assert_match version.to_s, shell_output("#{bin}/container --version") + end +end diff --git a/README.md b/README.md index 3ef5c4e6f..1e238a707 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,37 @@ You need a Mac with Apple silicon to run `container`. To build it, see the [BUIL `container` is supported on macOS 26, since it takes advantage of new features and enhancements to virtualization and networking in this release. We do not support older versions of macOS and the `container` maintainers typically will not address issues that cannot be reproduced on the macOS 26. -### Install or upgrade +### Install with Homebrew + +You can install `container` using Homebrew by installing directly from the formula in this repository: + +```bash +# From the repository root directory +brew install --HEAD ./Formula/container.rb +``` + +Or if a Homebrew tap has been set up, you can install via: + +```bash +brew tap apple/tap +brew install --HEAD container +``` + +After installation, start the system service: + +```bash +container system start +``` + +To upgrade `container` installed via Homebrew: + +```bash +brew upgrade container +container system stop +container system start +``` + +### Install or upgrade (using installer package) If you're upgrading, first stop and uninstall your existing `container` (the `-k` flag keeps your user data, while `-d` removes it):