mirror of
https://github.com/apple/container.git
synced 2026-09-13 19:25:47 +00:00
Closes #227 Previously, the bootlog was supplied once in the constructor to VZVirtualMachineManager which meant that if you used this same manager for multiple ctrs that all logs would end up going to the same file, which becomes quite cumbersome to follow.. This change moves bootlog to be a container configuration param and also moves it to be a VMConfiguration param, so it can be threaded through from LinuxContainer -> vmm.create() and be truly container unique now. The largest driver for this was the integration tests which today every single test spits out logs to a singular file, making guest investigations tricky to actually look into. Result after: ``` ➜ containerization git:(bootlog-per-ctr) ✗ ls -alh bin/bootlogs total 1520 drwxr-xr-x@ 24 dcantah staff 768B Oct 22 17:34 . drwxr-xr-x@ 8 dcantah staff 256B Oct 22 17:34 .. -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-cat-mount.log -rw-------@ 1 dcantah staff 22K Oct 22 17:34 test-cgroup-limits.log -rw-------@ 1 dcantah staff 249K Oct 22 17:34 test-concurrent-processes-output-stress.log -rw-------@ 1 dcantah staff 167K Oct 22 17:34 test-concurrent-processes.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-devconsole.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-hostname.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-hosts-file.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-manager.log -rw-------@ 1 dcantah staff 22K Oct 22 17:34 test-container-reuse.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-statistics.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-container-stdin.log -rw-------@ 1 dcantah staff 0B Oct 22 17:34 test-nested-virt.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-pause-resume-io.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-pause-resume-wait.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-pause-resume.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-custom-home-envvar.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-echo-hi.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-false.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-home-envvar.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-true.log -rw-------@ 1 dcantah staff 11K Oct 22 17:34 test-process-tty-envvar.log -rw-------@ 1 dcantah staff 38K Oct 22 17:34 test-process-user.log ```
179 lines
5.9 KiB
Makefile
179 lines
5.9 KiB
Makefile
# Copyright © 2025 Apple Inc. and the Containerization 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.
|
|
|
|
# Build configuration variables
|
|
# The default version ID 0.0.0 indicates a local development build or PRB
|
|
BUILD_CONFIGURATION ?= debug
|
|
WARNINGS_AS_ERRORS ?= true
|
|
SWIFT_CONFIGURATION = $(if $(filter-out false,$(WARNINGS_AS_ERRORS)),-Xswiftc -warnings-as-errors)
|
|
|
|
# Commonly used locations
|
|
SWIFT := "/usr/bin/swift"
|
|
ROOT_DIR := $(shell git rev-parse --show-toplevel)
|
|
BUILD_BIN_DIR = $(shell $(SWIFT) build -c $(BUILD_CONFIGURATION) --show-bin-path)
|
|
COV_DATA_DIR = $(shell $(SWIFT) test --show-coverage-path | xargs dirname)
|
|
COV_REPORT_FILE = $(ROOT_DIR)/code-coverage-report
|
|
|
|
# Variables for libarchive integration
|
|
LIBARCHIVE_UPSTREAM_REPO := https://github.com/libarchive/libarchive
|
|
LIBARCHIVE_UPSTREAM_VERSION := v3.7.7
|
|
LIBARCHIVE_LOCAL_DIR := workdir/libarchive
|
|
|
|
KATA_BINARY_PACKAGE := https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz
|
|
|
|
include Protobuf.Makefile
|
|
.DEFAULT_GOAL := all
|
|
|
|
.PHONY: all
|
|
all: containerization
|
|
all: init
|
|
|
|
.PHONY: release
|
|
release: BUILD_CONFIGURATION = release
|
|
release: all
|
|
|
|
.PHONY: containerization
|
|
containerization:
|
|
@echo Building containerization binaries...
|
|
@$(SWIFT) --version
|
|
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)
|
|
|
|
@echo Copying containerization binaries...
|
|
@mkdir -p bin
|
|
@install "$(BUILD_BIN_DIR)/cctl" ./bin/
|
|
@install "$(BUILD_BIN_DIR)/containerization-integration" ./bin/
|
|
|
|
@echo Signing containerization binaries...
|
|
@codesign --force --sign - --timestamp=none --entitlements=signing/vz.entitlements bin/cctl
|
|
@codesign --force --sign - --timestamp=none --entitlements=signing/vz.entitlements bin/containerization-integration
|
|
|
|
.PHONY: init
|
|
init: containerization vminitd
|
|
@echo Creating init.ext4...
|
|
@rm -f bin/init.rootfs.tar.gz bin/init.block
|
|
@./bin/cctl rootfs create \
|
|
--vminitd vminitd/bin/vminitd \
|
|
--vmexec vminitd/bin/vmexec \
|
|
--label org.opencontainers.image.source=https://github.com/apple/containerization \
|
|
--image vminit:latest \
|
|
bin/init.rootfs.tar.gz
|
|
|
|
.PHONY: cross-prep
|
|
cross-prep:
|
|
@"$(MAKE)" -C vminitd cross-prep
|
|
|
|
.PHONY: vminitd
|
|
vminitd:
|
|
@mkdir -p ./bin
|
|
@"$(MAKE)" -C vminitd BUILD_CONFIGURATION=$(BUILD_CONFIGURATION) WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS)
|
|
|
|
.PHONY: update-libarchive-source
|
|
update-libarchive-source:
|
|
@echo Updating the libarchive source files...
|
|
@git clone $(LIBARCHIVE_UPSTREAM_REPO) --depth 1 --branch $(LIBARCHIVE_UPSTREAM_VERSION) "$(LIBARCHIVE_LOCAL_DIR)"
|
|
@cp "$(LIBARCHIVE_LOCAL_DIR)/libarchive/archive_entry.h" Sources/ContainerizationArchive/CArchive/include
|
|
@cp "$(LIBARCHIVE_LOCAL_DIR)/libarchive/archive.h" Sources/ContainerizationArchive/CArchive/include
|
|
@cp "$(LIBARCHIVE_LOCAL_DIR)/COPYING" Sources/ContainerizationArchive/CArchive/COPYING
|
|
@rm -rf "$(LIBARCHIVE_LOCAL_DIR)"
|
|
|
|
.PHONY: test
|
|
test:
|
|
@echo Testing all test targets...
|
|
@$(SWIFT) test --enable-code-coverage $(SWIFT_CONFIGURATION)
|
|
|
|
.PHONY: coverage
|
|
coverage: test
|
|
@echo Generating code coverage report...
|
|
@xcrun llvm-cov show --compilation-dir=`pwd` \
|
|
-instr-profile=$(COV_DATA_DIR)/default.profdata \
|
|
--ignore-filename-regex=".build/" \
|
|
--ignore-filename-regex=".pb.swift" \
|
|
--ignore-filename-regex=".proto" \
|
|
--ignore-filename-regex=".grpc.swift" \
|
|
$(BUILD_BIN_DIR)/containerizationPackageTests.xctest/Contents/MacOS/containerizationPackageTests > $(COV_REPORT_FILE)
|
|
@echo Code coverage report generated: $(COV_REPORT_FILE)
|
|
|
|
.PHONY: integration
|
|
integration:
|
|
ifeq (,$(wildcard bin/vmlinux))
|
|
@echo No bin/vmlinux kernel found. See fetch-default-kernel target.
|
|
@exit 1
|
|
endif
|
|
@echo Running the integration tests...
|
|
@./bin/containerization-integration
|
|
|
|
.PHONY: fetch-default-kernel
|
|
fetch-default-kernel:
|
|
@mkdir -p .local/ bin/
|
|
ifeq (,$(wildcard .local/kata.tar.gz))
|
|
@curl -SsL -o .local/kata.tar.gz ${KATA_BINARY_PACKAGE}
|
|
endif
|
|
ifeq (,$(wildcard .local/vmlinux))
|
|
@tar -zxf .local/kata.tar.gz -C .local/ --strip-components=1
|
|
@cp -L .local/opt/kata/share/kata-containers/vmlinux.container .local/vmlinux
|
|
endif
|
|
ifeq (,$(wildcard bin/vmlinux))
|
|
@cp .local/vmlinux bin/vmlinux
|
|
endif
|
|
|
|
.PHONY: fmt
|
|
fmt: swift-fmt update-licenses
|
|
|
|
.PHONY: swift-fmt
|
|
SWIFT_SRC = $(shell find . -type f -name '*.swift' -not -path "*/.*" -not -path "*.pb.swift" -not -path "*.grpc.swift" -not -path "*/checkouts/*")
|
|
swift-fmt:
|
|
@echo Applying the standard code formatting...
|
|
@$(SWIFT) format --recursive --configuration .swift-format -i $(SWIFT_SRC)
|
|
|
|
.PHONY: update-licenses
|
|
update-licenses:
|
|
@echo Updating license headers...
|
|
@./scripts/ensure-hawkeye-exists.sh
|
|
@.local/bin/hawkeye format --fail-if-unknown --fail-if-updated false
|
|
|
|
.PHONY: check-licenses
|
|
check-licenses:
|
|
@echo Checking license headers existence in source files...
|
|
@./scripts/ensure-hawkeye-exists.sh
|
|
@.local/bin/hawkeye check --fail-if-unknown
|
|
|
|
.PHONY: serve-docs
|
|
serve-docs:
|
|
@echo 'to browse: open http://127.0.0.1:8000/containerization/documentation/'
|
|
@rm -rf _serve
|
|
@mkdir -p _serve
|
|
@cp -a _site _serve/containerization
|
|
@python3 -m http.server --bind 127.0.0.1 --directory ./_serve
|
|
|
|
.PHONY: docs
|
|
docs:
|
|
@echo Updating API documentation...
|
|
@rm -rf _site
|
|
@scripts/make-docs.sh _site containerization
|
|
|
|
.PHONY: cleancontent
|
|
cleancontent:
|
|
@echo Cleaning the content...
|
|
@rm -rf ~/Library/Application\ Support/com.apple.containerization
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
@echo Cleaning build files...
|
|
@rm -rf bin/
|
|
@rm -rf _site/
|
|
@rm -rf _serve/
|
|
@rm -f $(COV_REPORT_FILE)
|
|
@$(SWIFT) package clean
|
|
@"$(MAKE)" -C vminitd clean
|