chore: import upstream snapshot with attribution
container project - merge build / Invoke build (push) Successful in 1s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:06:18 +08:00
commit e84fb4a79e
474 changed files with 68321 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
[SWIFT_STYLE]
firstLine = '//===----------------------------------------------------------------------===//'
endLine = "//===----------------------------------------------------------------------===//\n"
beforeEachLine = '// '
afterEachLine = ''
allowBlankLines = false
multipleLines = true
padLines = false
firstLineDetectionPattern = '//\s?==='
lastLineDetectionPattern = '//\s?==='
skipLinePattern = '// swift-tools-version'
+75
View File
@@ -0,0 +1,75 @@
#! /bin/bash -f
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ALL_DOMAINS=false
usage() {
echo "Usage: $0 [-a] [-h]"
echo "Stop container services"
echo
echo "Options:"
echo "a Stop container services in all launchd domains."
echo "h Show this help message."
echo
exit 1
}
while getopts ":ah" arg; do
case "$arg" in
a)
ALL_DOMAINS=true
;;
h)
usage
;;
*)
echo "Invalid option: -${OPTARG}"
usage
;;
esac
done
if $ALL_DOMAINS; then
uid=$(id -u)
for domain in "gui/$uid" "user/$uid" "system"; do
if [ "$domain" = "system" ] && [ "$uid" -ne 0 ]; then
continue
fi
launchctl print "$domain" 2>/dev/null \
| grep -oE 'com\.apple\.container\.[^ ]+' \
| sort -u \
| while read -r service; do
launchctl bootout "$domain/$service" 2>/dev/null || true
done
done
else
domain_string=""
launchd_domain=$(launchctl managername)
if [[ "$launchd_domain" == "System" ]]; then
domain_string="system"
elif [[ "$launchd_domain" == "Aqua" ]]; then
domain_string="gui/$(id -u)"
elif [[ "$launchd_domain" == "Background" ]]; then
domain_string="user/$(id -u)"
else
echo "Unsupported launchd domain. Exiting"
exit 1
fi
launchctl list | grep -e 'com\.apple\.container\W' | awk '{print $3}' \
| xargs -I % sh -c 'launchctl bootout '"$domain_string"'/% 2>/dev/null || true'
fi
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
auto_install=0
for arg in "$@"; do
case "$arg" in
--auto-install|-y)
auto_install=1
;;
-h|--help)
cat <<EOF
Usage: $(basename "$0") [--auto-install|-y]
Checks for a working hawkeye installation under .local/bin/.
If hawkeye is missing, prompts before running scripts/install-hawkeye.sh.
Skip the prompt non-interactively in either of two ways:
--auto-install, -y pass on the command line
HAWKEYE_AUTO_INSTALL=1 set in the environment
EOF
exit 0
;;
*)
echo "unknown argument: $arg" >&2
echo "see '$(basename "$0") --help' for usage" >&2
exit 2
;;
esac
done
if [[ "${HAWKEYE_AUTO_INSTALL:-}" == "1" ]]; then
auto_install=1
fi
echo "Checking existence of hawkeye..."
if command -v .local/bin/hawkeye >/dev/null 2>&1; then
echo "hawkeye found!"
exit 0
fi
cat <<EOF
hawkeye is not installed.
scripts/install-hawkeye.sh will install hawkeye by downloading the official release tarball
and installing the binary under `.local/bin`.
(See scripts/install-hawkeye.sh for the pinned version.)
EOF
if [[ "$auto_install" -eq 1 ]]; then
echo
echo "Auto-install enabled; proceeding."
elif [[ ! -t 0 ]]; then
echo
echo "Non-interactive context detected. Refusing to install silently." >&2
echo "Set HAWKEYE_AUTO_INSTALL=1 or pass --auto-install to proceed." >&2
exit 1
else
echo
read -r -p "Proceed with install? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
;;
*)
echo "please install hawkeye. For convenience, you can run scripts/install-hawkeye.sh"
exit 1
;;
esac
fi
exec "$(dirname "$0")/install-hawkeye.sh"
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
if command -v .local/bin/hawkeye >/dev/null 2>&1; then
echo "hawkeye already installed"
exit 0
fi
# This installer supports Apple silicon (arm64 macOS) only.
if [ "$(uname -s)" != "Darwin" ] || [ "$(uname -m)" != "arm64" ]; then
echo "error: install-hawkeye.sh supports Apple silicon (arm64 macOS) only" >&2
exit 1
fi
VERSION=v6.5.1
ARTIFACT="hawkeye-aarch64-apple-darwin.tar.xz"
ARTIFACT_URL="https://github.com/korandoru/hawkeye/releases/download/${VERSION}/${ARTIFACT}"
# Pinned SHA-256 of ${ARTIFACT} for ${VERSION}; update when bumping VERSION.
EXPECTED_SHA256="99777f21e4e56c9946ed93621885532c6a0476377f497565c583f5911f2cbb1f"
echo "Installing hawkeye ${VERSION}"
workdir="$(mktemp -d)"
trap 'rm -rf "${workdir}"' EXIT
tarball="${workdir}/${ARTIFACT}"
# Download the tarball, verify it against the pinned checksum (aborts on
# mismatch), then extract just the hawkeye binary into .local/bin.
curl --proto '=https' --tlsv1.2 -LsSf "${ARTIFACT_URL}" -o "${tarball}"
echo "${EXPECTED_SHA256} ${tarball}" | shasum -a 256 -c -
tar -xf "${tarball}" --strip-components 1 -C "${workdir}"
mkdir -p .local/bin
mv "${workdir}/hawkeye" .local/bin/hawkeye
chmod +x .local/bin/hawkeye
echo "hawkeye ${VERSION} installed to .local/bin/hawkeye"
+82
View File
@@ -0,0 +1,82 @@
#! /bin/bash -e
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
usage() {
cat <<EOF
Usage: $(basename "$0") [-a APP_ROOT | --app-root APP_ROOT] [-l LOG_ROOT | --log-root LOG_ROOT] [-h | --help]
Install the init image for container system.
Options:
-a, --app-root APP_ROOT Install the init image under the APP_ROOT path
-l, --log-root LOG_ROOT Install the init image under the LOG_ROOT path
-h, --help Show this help message
EOF
exit 0
}
# Parse command line options
START_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-a|--app-root)
if [[ -z "$2" || "$2" == -* ]]; then
echo "Option $1 requires an argument." >&2
usage
fi
START_ARGS+=(--app-root "$2")
shift 2
;;
-l|--log-root)
if [[ -z "$2" || "$2" == -* ]]; then
echo "Option $1 requires an argument." >&2
usage
fi
START_ARGS+=(--log-root "$2")
shift 2
;;
-h|--help)
usage
;;
*)
echo "Invalid option: $1" >&2
usage
;;
esac
done
SWIFT="/usr/bin/swift"
IMAGE_NAME="vminit:latest"
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}
# Sleep because commands after stop and start are racy.
bin/container system stop
sleep 3
bin/container --debug system start "${START_ARGS[@]}"
sleep 3
bin/container i load -i /tmp/init.tar
rm /tmp/init.tar
fi
+13
View File
@@ -0,0 +1,13 @@
Copyright ©{{ " " }}{%- set created = attrs.git_file_created_year or attrs.disk_file_created_year -%}{%- set modified = attrs.git_file_modified_year or created -%}{%- if created != modified -%} {{created}}-{{modified}}{%- else -%}{{created}}{%- endif -%}{{ " " }}{{ props["copyrightOwner"] }}.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+60
View File
@@ -0,0 +1,60 @@
#! /bin/bash -e
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
opts=()
opts+=("--allow-writing-to-directory" "$1")
opts+=("generate-documentation")
opts+=("--target" "ContainerAPIService")
opts+=("--target" "ContainerAPIClient")
opts+=("--target" "ContainerRuntimeClient")
opts+=("--target" "ContainerRuntimeLinuxClient")
opts+=("--target" "ContainerRuntimeLinuxServer")
opts+=("--target" "ContainerNetworkClient")
opts+=("--target" "ContainerNetworkServer")
opts+=("--target" "ContainerNetworkVmnetServer")
opts+=("--target" "ContainerImagesService")
opts+=("--target" "ContainerImagesServiceClient")
opts+=("--target" "ContainerResource")
opts+=("--target" "ContainerLog")
opts+=("--target" "ContainerPlugin")
opts+=("--target" "ContainerXPC")
opts+=("--target" "TerminalProgress")
opts+=("--output-path" "$1")
opts+=("--disable-indexing")
opts+=("--transform-for-static-hosting")
opts+=("--enable-experimental-combined-documentation")
opts+=("--experimental-documentation-coverage")
if [ ! -z "$2" ] ; then
opts+=("--hosting-base-path" "$2")
fi
/usr/bin/swift package ${opts[@]}
echo '{}' > "$1/theme-settings.json"
cat > "$1/index.html" <<'EOF'
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url=./documentation/">
</head>
<body>
<p>If you are not redirected automatically, <a href="./documentation/">click here</a>.</p>
</body>
</html>
EOF
+16
View File
@@ -0,0 +1,16 @@
#! /bin/bash -e
setup_error() {
echo failed to run: $1 1>&2
echo run '"make pre-commit"' and try again 1>&2
exit 1
}
if [ ! -z "${PRECOMMIT_NOFMT}" ] ; then
exit 0
fi
echo checking formatting and licenses 1>&2
project_pathname=$(git rev-parse --show-toplevel)
cd "${project_pathname}"
make check
+90
View File
@@ -0,0 +1,90 @@
#!/bin/bash
# Copyright © 2025-2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -uo pipefail
INSTALL_DIR="/usr/local"
DELETE_DATA=
OPTS=0
usage() {
echo "Usage: $0 {-d | -k}"
echo "Uninstall container"
echo
echo "Options:"
echo "d Delete user data directory."
echo "k Don't delete user data directory."
echo
exit 1
}
while getopts ":dk" arg; do
case "$arg" in
d)
DELETE_DATA=true
((OPTS+=1))
;;
k)
DELETE_DATA=false
((OPTS+=1))
;;
*)
echo "Invalid option: -${OPTARG}"
usage
;;
esac
done
if [ $OPTS != 1 ]; then
echo "Invalid number of options. Must provide either -d OR -k"
usage
exit 1
fi
# check if container is still running
CONTAINER_RUNNING=$(launchctl list | grep -e 'com\.apple\.container\W')
if [ -n "$CONTAINER_RUNNING" ]; then
echo '`container` is still running. Please ensure the service is stopped by running `container system stop`'
exit 1
fi
if [ "$EUID" -ne 0 ]; then
echo "This script requires an administrator password to remove the application files from system directories."
fi
FILES=$(pkgutil --only-files --files com.apple.container-installer)
for i in ${FILES[@]}; do
# this command can fail for some of the reported files from pkgutil such as
# `/usr/local/bin/._uninstall-container.sh``
sudo rm $INSTALL_DIR/$i &> /dev/null
done
DIRS=($(pkgutil --only-dirs --files com.apple.container-installer))
for ((i=${#DIRS[@]}-1; i>=0; i--)); do
# this command will fail when trying to remove `bin` and `libexec` since those directories
# may not be empty
sudo rmdir $INSTALL_DIR/${DIRS[$i]} &> /dev/null
done
sudo pkgutil --forget com.apple.container-installer > /dev/null
echo 'Removed `container` tool and helpers'
if [ "$DELETE_DATA" = true ]; then
echo 'Removing `container` user data'
sudo rm -rf ~/Library/Application\ Support/com.apple.container
echo 'Removing `container` user defaults'
defaults delete com.apple.container.defaults > /dev/null 2>&1 || true
fi
+163
View File
@@ -0,0 +1,163 @@
#!/bin/bash
# Copyright © 2026 Apple Inc. and the container project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -uo pipefail
INSTALL_DIR="/usr/local"
OPTS=0
LATEST=false
VERSION=
FORCE=false
TMP_DIR=
# Release Info
RELEASE_URL=
RELEASE_JSON=
RELEASE_VERSION=
# Package Info
PKG_URL=
PKG_FILE=
SIGNED_PRIMARY_PKG=
SIGNED_FALLBACK_PKG=
UNSIGNED_PRIMARY_PKG=
UNSIGNED_FALLBACK_PKG=
check_installed_version() {
local target_version="$1"
if command -v container &>/dev/null; then
local installed_version
installed_version=$(container --version | awk '{print $4}')
installed_version=${installed_version%\)}
if [[ "$installed_version" == "$target_version" ]]; then
return 0
fi
fi
return 1
}
usage() {
echo "Usage: $0 {-v <version> | -f}"
echo "Update container"
echo
echo "Options:"
echo "v <version> Update to a specific release version"
echo "f Force update"
echo "No argument Defaults to the latest release version"
exit 1
}
while getopts ":v:f" arg; do
case "$arg" in
v)
VERSION="$OPTARG"
((OPTS+=1))
;;
f)
FORCE=true
;;
*)
echo "Invalid option: -${OPTARG}"
usage
;;
esac
done
# Default to upgrade to the latest release version
if [[ -z "$VERSION" ]]; then
LATEST=true
fi
# Check if container is still running
CONTAINER_RUNNING=$(launchctl list | grep -e 'com\.apple\.container\W')
if [ -n "$CONTAINER_RUNNING" ]; then
echo '`container` is still running. Please ensure the service is stopped by running `container system stop`'
exit 1
fi
if [ "$EUID" -ne 0 ]; then
echo "This script requires admin privileges to update files under $INSTALL_DIR"
fi
# Temporary directory creation for install/download
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
error() { echo "Error: $*" >&2; exit 1; }
# Determine the release URL and version
if [[ "$LATEST" == true ]]; then
RELEASE_URL="https://api.github.com/repos/apple/container/releases/latest"
RELEASE_VERSION=$(curl -fsSL "$RELEASE_URL" | jq -r '.tag_name')
if check_installed_version "$RELEASE_VERSION" && [[ "$FORCE" != true ]]; then
echo "Container is already on latest version $RELEASE_VERSION (use -f to force update)"
exit 0
else
echo "Updating to latest version $RELEASE_VERSION"
fi
elif [[ -n "$VERSION" ]]; then
RELEASE_URL="https://api.github.com/repos/apple/container/releases/tags/$VERSION"
RELEASE_VERSION="$VERSION"
if check_installed_version "$RELEASE_VERSION" && [[ "$FORCE" != true ]]; then
echo "Container is already on version $RELEASE_VERSION (use -f to force update)"
exit 0
else
echo "Updating to release version $RELEASE_VERSION"
fi
fi
# Fetch the release json
RELEASE_JSON=$(curl -fsSL "$RELEASE_URL") || {
error $([[ "$LATEST" == true ]] && echo "Failed fetching latest release" || echo "Release '$VERSION' not found")
}
# Possible package names
SIGNED_PRIMARY_PKG="container-installer-signed.pkg"
SIGNED_FALLBACK_PKG="container-$RELEASE_VERSION-installer-signed.pkg"
UNSIGNED_PRIMARY_PKG="container-installer-unsigned.pkg"
UNSIGNED_FALLBACK_PKG="container-$RELEASE_VERSION-installer-unsigned.pkg"
# Find the signed package
PKG_URL=$(echo "$RELEASE_JSON" | jq -r \
--arg primary "$SIGNED_PRIMARY_PKG" \
--arg fallback "$SIGNED_FALLBACK_PKG" \
'.assets[] | select(.name == $primary or .name == $fallback) | .browser_download_url' | head -n1)
# If no signed package found, prompt and try unsigned
if [[ -z "$PKG_URL" ]]; then
read -r -p "No signed package found. Upgrade using the unsigned package instead? (Y/n): " confirm
if [[ "$confirm" =~ ^[yY]([eE][sS])?$ ]]; then
echo "NOTE: re-run this script to upgrade to the signed package, when it becomes available"
PKG_URL=$(echo "$RELEASE_JSON" | jq -r \
--arg u1 "$UNSIGNED_PRIMARY_PKG" \
--arg u2 "$UNSIGNED_FALLBACK_PKG" \
'.assets[] | select(.name == $u1 or .name == $u2) | .browser_download_url' | head -n1)
else
echo "Exiting without updating"
exit 0
fi
fi
[[ -n "$PKG_URL" ]] || error "No suitable package found"
PKG_FILE="$TMP_DIR/$(basename "$PKG_URL")"
echo "Downloading package from: $PKG_URL..."
curl -fSL "$PKG_URL" -o "$PKG_FILE"
[[ -s "$PKG_FILE" ]] || error "Downloaded package is empty"
echo "Installing package to $INSTALL_DIR..."
sudo installer -pkg "$PKG_FILE" -target / >/dev/null 2>&1 || error "Installer failed"
echo "Updated successfully"
container --version || error "'container' command not found"