mirror of
https://github.com/apple/container.git
synced 2026-10-04 13:27:47 +00:00
Initial commit
This commit is contained in:
@@ -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'
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /bin/bash -f
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
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 % launchctl bootout $domain_string/%
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
echo "Checking existence of hawkeye..."
|
||||
|
||||
if command -v .local/bin/hawkeye >/dev/null 2>&1; then
|
||||
echo "hawkeye found!"
|
||||
else
|
||||
echo "hawkeye not found in PATH"
|
||||
echo "please install hawkeye. For convenience, you can run scripts/install-hawkeye.sh"
|
||||
exit 1
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
if command -v .local/bin/hawkeye >/dev/null 2>&1; then
|
||||
echo "hawkeye already installed"
|
||||
else
|
||||
echo "Installing hawkeye"
|
||||
export VERSION=v6.0.4
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/korandoru/hawkeye/releases/download/${VERSION}/hawkeye-installer.sh | CARGO_HOME=.local sh -s -- --no-modify-path
|
||||
fi
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /bin/bash -e
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
DESTDIR="${1:-$(git rev-parse --show-toplevel)/bin}"
|
||||
mkdir -p "${DESTDIR}"
|
||||
|
||||
IMAGE_NAME="vminit:latest"
|
||||
|
||||
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')}"
|
||||
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 system start && sleep 3
|
||||
bin/container i load -i /tmp/init.tar
|
||||
rm /tmp/init.tar
|
||||
fi
|
||||
@@ -0,0 +1,13 @@
|
||||
Copyright ©{{ " " }}{%- if attrs.git_file_modified_year != attrs.git_file_created_year -%}{{ attrs.git_file_created_year }}-{{ attrs.git_file_modified_year }}{%- else -%}{{ attrs.git_file_created_year }}{%- endif -%}{{ " " }}{{ props["copyrightOwner"] }}. All rights reserved.
|
||||
|
||||
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.
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#! /bin/bash -e
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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=()
|
||||
if [ ! -z "${CURRENT_SDK}" ] ; then
|
||||
opts+=("-Xswiftc" "-DCURRENT_SDK")
|
||||
fi
|
||||
opts+=("--allow-writing-to-directory" "$1")
|
||||
opts+=("generate-documentation")
|
||||
opts+=("--target" "Build")
|
||||
opts+=("--target" "Client")
|
||||
opts+=("--target" "DNSServer")
|
||||
opts+=("--target" "ImagesService")
|
||||
opts+=("--target" "LogSupport")
|
||||
opts+=("--target" "NetworkService")
|
||||
opts+=("--target" "Persistence")
|
||||
opts+=("--target" "Plugin")
|
||||
opts+=("--target" "SandboxService")
|
||||
opts+=("--target" "TerminalProgress")
|
||||
opts+=("--target" "XPCSupport")
|
||||
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"
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
# Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
|
||||
#
|
||||
# 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"
|
||||
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
|
||||
|
||||
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` application'
|
||||
|
||||
if [ "$DELETE_DATA" = true ]; then
|
||||
echo 'Removing `container` user data'
|
||||
sudo rm -rf ~/Library/Application\ Support/com.apple.container
|
||||
fi
|
||||
Reference in New Issue
Block a user