github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/Makefile (about) 1 ### 2 ### Makefile Navigation 3 ### 4 # 5 # This file is organized based on approximate end-to-end workflow: 6 # 7 # 1. Variables and common definitions are located at the top 8 # to make finding them quicker. 9 # 2. Main entry-point targets, like "default", "all", and "help" 10 # 3. Targets for code formatting and validation 11 # 4. Primary build targets, like podman and podman-remote 12 # 5. Secondary build targets, shell completions, static and multi-arch. 13 # 6. Targets that format and build documentation 14 # 7. Testing targets 15 # 8. Release and package-building targets 16 # 9. Targets that install tools, utilities, binaries and packages 17 # 10. Uninstall / Cleanup targets 18 # 19 ### 20 ### Variables & Definitions 21 ### 22 23 GO ?= go 24 GO_LDFLAGS:= $(shell if $(GO) version|grep -q gccgo ; then echo "-gccgoflags"; else echo "-ldflags"; fi) 25 GOCMD = CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) 26 COVERAGE_PATH ?= .coverage 27 DESTDIR ?= 28 EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD) 29 HEAD ?= HEAD 30 PROJECT := github.com/containers/podman 31 GIT_BASE_BRANCH ?= origin/main 32 LIBPOD_INSTANCE := libpod_dev 33 PREFIX ?= /usr/local 34 BINDIR ?= ${PREFIX}/bin 35 LIBEXECDIR ?= ${PREFIX}/libexec 36 LIBEXECPODMAN ?= ${LIBEXECDIR}/podman 37 MANDIR ?= ${PREFIX}/share/man 38 SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers 39 ETCDIR ?= ${PREFIX}/etc 40 TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d 41 MODULESLOADDIR ?= ${PREFIX}/lib/modules-load.d 42 SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system 43 USERSYSTEMDDIR ?= ${PREFIX}/lib/systemd/user 44 REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp 45 BUILDTAGS ?= \ 46 $(shell hack/apparmor_tag.sh) \ 47 $(shell hack/btrfs_installed_tag.sh) \ 48 $(shell hack/btrfs_tag.sh) \ 49 $(shell hack/selinux_tag.sh) \ 50 $(shell hack/systemd_tag.sh) \ 51 $(shell hack/libsubid_tag.sh) \ 52 exclude_graphdriver_devicemapper \ 53 seccomp 54 PYTHON ?= $(shell command -v python3 python|head -n1) 55 PKG_MANAGER ?= $(shell command -v dnf yum|head -n1) 56 # ~/.local/bin is not in PATH on all systems 57 PRE_COMMIT = $(shell command -v bin/venv/bin/pre-commit ~/.local/bin/pre-commit pre-commit | head -n1) 58 59 # This isn't what we actually build; it's a superset, used for target 60 # dependencies. Basically: all *.go and *.c files, except *_test.go, 61 # and except anything in a dot subdirectory. If any of these files is 62 # newer than our target (bin/podman{,-remote}), a rebuild is 63 # triggered. 64 SOURCES = $(shell find . -path './.*' -prune -o \( \( -name '*.go' -o -name '*.c' \) -a ! -name '*_test.go' \) -print) 65 66 BUILDTAGS_CROSS ?= containers_image_openpgp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_overlay 67 CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker) 68 OCI_RUNTIME ?= "" 69 70 MANPAGES_MD ?= $(wildcard docs/source/markdown/*.md pkg/*/docs/*.md) 71 MANPAGES ?= $(MANPAGES_MD:%.md=%) 72 MANPAGES_DEST ?= $(subst markdown,man, $(subst source,build,$(MANPAGES))) 73 74 BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions 75 ZSHINSTALLDIR=${PREFIX}/share/zsh/site-functions 76 FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d 77 78 SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z) 79 80 COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true) 81 GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),$(call err_if_empty,COMMIT_NO)-dirty,$(COMMIT_NO)) 82 DATE_FMT = %s 83 ifdef SOURCE_DATE_EPOCH 84 BUILD_INFO ?= $(shell date -u -d "@$(call err_if_empty,SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") 85 else 86 BUILD_INFO ?= $(shell date "+$(DATE_FMT)") 87 endif 88 LIBPOD := ${PROJECT}/v4/libpod 89 GOFLAGS ?= -trimpath 90 LDFLAGS_PODMAN ?= \ 91 $(if $(GIT_COMMIT),-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT),) \ 92 $(if $(BUILD_INFO),-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO),) \ 93 -X $(LIBPOD)/config._installPrefix=$(PREFIX) \ 94 -X $(LIBPOD)/config._etcDir=$(ETCDIR) \ 95 -X github.com/containers/common/pkg/config.additionalHelperBinariesDir=$(HELPER_BINARIES_DIR)\ 96 $(EXTRA_LDFLAGS) 97 LDFLAGS_PODMAN_STATIC ?= \ 98 $(LDFLAGS_PODMAN) \ 99 -extldflags=-static 100 #Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too. 101 LIBSECCOMP_COMMIT := v2.3.3 102 # Rarely if ever should integration tests take more than 50min, 103 # caller may override in special circumstances if needed. 104 GINKGOTIMEOUT ?= -timeout=90m 105 106 # Conditional required to produce empty-output if binary not built yet. 107 RELEASE_VERSION = $(shell if test -x test/version/version; then test/version/version; fi) 108 RELEASE_NUMBER = $(shell echo "$(call err_if_empty,RELEASE_VERSION)" | sed -e 's/^v\(.*\)/\1/') 109 110 # If non-empty, logs all output from server during remote system testing 111 PODMAN_SERVER_LOG ?= 112 113 # Ensure GOBIN is not set so the default (`go env GOPATH`/bin) is used. 114 override undefine GOBIN 115 # This must never include the 'hack' directory 116 export PATH := $(shell $(GO) env GOPATH)/bin:$(PATH) 117 118 GOMD2MAN ?= $(shell command -v go-md2man || echo './test/tools/build/go-md2man') 119 120 CROSS_BUILD_TARGETS := \ 121 bin/podman.cross.linux.amd64 \ 122 bin/podman.cross.linux.ppc64le \ 123 bin/podman.cross.linux.arm \ 124 bin/podman.cross.linux.arm64 \ 125 bin/podman.cross.linux.386 \ 126 bin/podman.cross.linux.s390x \ 127 bin/podman.cross.linux.mips \ 128 bin/podman.cross.linux.mipsle \ 129 bin/podman.cross.linux.mips64 \ 130 bin/podman.cross.linux.mips64le 131 132 # Dereference variable $(1), return value if non-empty, otherwise raise an error. 133 err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty)) 134 135 # Podman does not work w/o CGO_ENABLED, except in some very specific cases 136 CGO_ENABLED ?= 1 137 # Default to the native OS type and architecture unless otherwise specified 138 NATIVE_GOOS := $(shell env -u GOOS $(GO) env GOOS) 139 GOOS ?= $(call err_if_empty,NATIVE_GOOS) 140 # Default to the native architecture type 141 NATIVE_GOARCH := $(shell env -u GOARCH $(GO) env GOARCH) 142 GOARCH ?= $(NATIVE_GOARCH) 143 ifeq ($(call err_if_empty,GOOS),windows) 144 BINSFX := .exe 145 SRCBINDIR := bin/windows 146 else ifeq ($(GOOS),darwin) 147 BINSFX := 148 SRCBINDIR := bin/darwin 149 else 150 BINSFX := -remote 151 SRCBINDIR := bin 152 endif 153 # Necessary for nested-$(MAKE) calls and docs/remote-docs.sh 154 export GOOS GOARCH CGO_ENABLED BINSFX SRCBINDIR 155 156 # Need to use CGO for mDNS resolution, but cross builds need CGO disabled 157 # See https://github.com/golang/go/issues/12524 for details 158 DARWIN_GCO := 0 159 ifeq ($(call err_if_empty,NATIVE_GOOS),darwin) 160 ifdef HOMEBREW_PREFIX 161 DARWIN_GCO := 1 162 endif 163 endif 164 165 # win-sshproxy is checked out manually to keep from pulling in gvisor and it's transitive 166 # dependencies. This is only used for the Windows installer task (podman.msi), which must 167 # include this lightweight helper binary. 168 # 169 GV_GITURL=https://github.com/containers/gvisor-tap-vsock.git 170 GV_SHA=e943b1806d94d387c4c38d96719432d50a84bbd0 171 172 ### 173 ### Primary entry-point targets 174 ### 175 176 .PHONY: default 177 default: all 178 179 .PHONY: all 180 all: binaries docs 181 182 .PHONY: binaries 183 binaries: podman podman-remote rootlessport ## Build podman, podman-remote and rootlessport binaries 184 185 # Extract text following double-# for targets, as their description for 186 # the `help` target. Otherwise These simple-substitutions are resolved 187 # at reference-time (due to `=` and not `=:`). 188 _HLP_TGTS_RX = '^[[:print:]]+:.*?\#\# .*$$' 189 _HLP_TGTS_CMD = grep -E $(_HLP_TGTS_RX) $(MAKEFILE_LIST) 190 _HLP_TGTS_LEN = $(shell $(call err_if_empty,_HLP_TGTS_CMD) | cut -d : -f 1 | wc -L) 191 _HLPFMT = "%-$(call err_if_empty,_HLP_TGTS_LEN)s %s\n" 192 .PHONY: help 193 help: ## (Default) Print listing of key targets with their descriptions 194 @printf $(_HLPFMT) "Target:" "Description:" 195 @printf $(_HLPFMT) "--------------" "--------------------" 196 @$(_HLP_TGTS_CMD) | sort | \ 197 awk 'BEGIN {FS = ":(.*)?## "}; \ 198 {printf $(_HLPFMT), $$1, $$2}' 199 200 ### 201 ### Linting/Formatting/Code Validation targets 202 ### 203 204 .PHONY: .gitvalidation 205 .gitvalidation: 206 @echo "Validating vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'" 207 GIT_CHECK_EXCLUDE="./vendor:./test/tools/vendor:docs/make.bat:test/buildah-bud/buildah-tests.diff" ./test/tools/build/git-validation -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD) 208 209 .PHONY: lint 210 lint: golangci-lint 211 @echo "Linting vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'" 212 ifeq ($(PRE_COMMIT),) 213 @echo "FATAL: pre-commit was not found, make .install.pre-commit to installing it." >&2 214 @exit 2 215 endif 216 $(PRE_COMMIT) run -a 217 218 .PHONY: golangci-lint 219 golangci-lint: .install.golangci-lint 220 hack/golangci-lint.sh run 221 222 .PHONY: test/checkseccomp/checkseccomp 223 test/checkseccomp/checkseccomp: $(wildcard test/checkseccomp/*.go) 224 $(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ ./test/checkseccomp 225 226 .PHONY: test/testvol/testvol 227 test/testvol/testvol: $(wildcard test/testvol/*.go) 228 $(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -o $@ ./test/testvol 229 230 .PHONY: volume-plugin-test-image 231 volume-plugin-test-img: 232 podman build -t quay.io/libpod/volume-plugin-test-img -f Containerfile-testvol . 233 234 .PHONY: test/goecho/goecho 235 test/goecho/goecho: $(wildcard test/goecho/*.go) 236 $(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho 237 238 test/version/version: version/version.go 239 $(GO) build -o $@ ./test/version/ 240 241 .PHONY: codespell 242 codespell: 243 codespell -S bin,vendor,.git,go.sum,.cirrus.yml,"RELEASE_NOTES.md,*.xz,*.gz,*.ps1,*.tar,swagger.yaml,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L uint,iff,od,seeked,splitted,marge,ERRO,hist,ether -w 244 245 .PHONY: validate 246 validate: lint .gitvalidation validate.completions man-page-check swagger-check tests-included tests-expect-exit 247 248 .PHONY: build-all-new-commits 249 build-all-new-commits: 250 # Validate that all the commits build on top of $(GIT_BASE_BRANCH) 251 git rebase $(call err_if_empty,GIT_BASE_BRANCH) -x "$(MAKE)" 252 253 .PHONY: vendor 254 vendor: 255 $(GO) mod tidy 256 $(GO) mod vendor 257 $(GO) mod verify 258 259 .PHONY: vendor-in-container 260 vendor-in-container: 261 podman run --privileged --rm --env HOME=/root \ 262 -v $(CURDIR):/src -w /src \ 263 docker.io/library/golang:1.17 \ 264 make vendor 265 266 ### 267 ### Primary binary-build targets 268 ### 269 270 # Make sure to warn in case we're building without the systemd buildtag. 271 bin/podman: $(SOURCES) go.mod go.sum 272 ifeq (,$(findstring systemd,$(BUILDTAGS))) 273 @echo "Podman is being compiled without the systemd build tag. \ 274 Install libsystemd on Ubuntu or systemd-devel on rpm based \ 275 distro for journald support." 276 endif 277 $(GOCMD) build \ 278 $(BUILDFLAGS) \ 279 $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \ 280 -tags "$(BUILDTAGS)" \ 281 -o $@ ./cmd/podman 282 283 # Disambiguate Linux vs Darwin/Windows platform binaries under distinct "bin" dirs 284 $(SRCBINDIR): 285 mkdir -p $(SRCBINDIR) 286 287 $(SRCBINDIR)/podman$(BINSFX): $(SRCBINDIR) $(SOURCES) go.mod go.sum 288 $(GOCMD) build \ 289 $(BUILDFLAGS) \ 290 $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \ 291 -tags "${REMOTETAGS}" \ 292 -o $@ ./cmd/podman 293 294 $(SRCBINDIR)/podman-remote-static: $(SRCBINDIR) $(SOURCES) go.mod go.sum 295 CGO_ENABLED=0 \ 296 GOOS=linux \ 297 GOARCH=$(GOARCH) \ 298 $(GO) build \ 299 $(BUILDFLAGS) \ 300 $(GO_LDFLAGS) '$(LDFLAGS_PODMAN_STATIC)' \ 301 -tags "${REMOTETAGS}" \ 302 -o $@ ./cmd/podman 303 304 .PHONY: podman 305 podman: bin/podman 306 307 .PHONY: podman-remote 308 podman-remote: $(SRCBINDIR) $(SRCBINDIR)/podman$(BINSFX) ## Build podman-remote binary 309 310 # A wildcard podman-remote-% target incorrectly sets GOOS for release targets 311 .PHONY: podman-remote-linux 312 podman-remote-linux: ## Build podman-remote for Linux 313 $(MAKE) \ 314 CGO_ENABLED=0 \ 315 GOOS=linux \ 316 GOARCH=$(GOARCH) \ 317 bin/podman-remote 318 319 PHONY: podman-remote-static 320 podman-remote-static: $(SRCBINDIR)/podman-remote-static 321 322 .PHONY: podman-remote-windows 323 podman-remote-windows: ## Build podman-remote for Windows 324 $(MAKE) \ 325 CGO_ENABLED=0 \ 326 GOOS=windows \ 327 bin/windows/podman.exe 328 329 .PHONY: podman-winpath 330 podman-winpath: $(SOURCES) go.mod go.sum 331 CGO_ENABLED=0 \ 332 GOOS=windows \ 333 $(GO) build \ 334 $(BUILDFLAGS) \ 335 -ldflags -H=windowsgui \ 336 -o bin/windows/winpath.exe \ 337 ./cmd/winpath 338 339 .PHONY: podman-remote-darwin 340 podman-remote-darwin: podman-mac-helper ## Build podman-remote for macOS 341 $(MAKE) \ 342 CGO_ENABLED=$(DARWIN_GCO) \ 343 GOOS=darwin \ 344 GOARCH=$(GOARCH) \ 345 bin/darwin/podman 346 347 .PHONY: podman-mac-helper 348 podman-mac-helper: ## Build podman-mac-helper for macOS 349 CGO_ENABLED=0 \ 350 GOOS=darwin \ 351 GOARCH=$(GOARCH) \ 352 $(GO) build \ 353 $(BUILDFLAGS) \ 354 -o bin/darwin/podman-mac-helper \ 355 ./cmd/podman-mac-helper 356 357 bin/rootlessport: $(SOURCES) go.mod go.sum 358 CGO_ENABLED=$(CGO_ENABLED) \ 359 $(GO) build \ 360 $(BUILDFLAGS) \ 361 -o $@ ./cmd/rootlessport 362 363 .PHONY: rootlessport 364 rootlessport: bin/rootlessport 365 366 ### 367 ### Secondary binary-build targets 368 ### 369 370 .PHONY: generate-bindings 371 generate-bindings: 372 ifneq ($(GOOS),darwin) 373 $(GOCMD) generate ./pkg/bindings/... ; 374 endif 375 376 # DO NOT USE: use local-cross instead 377 bin/podman.cross.%: 378 TARGET="$*"; \ 379 GOOS="$${TARGET%%.*}"; \ 380 GOARCH="$${TARGET##*.}"; \ 381 CGO_ENABLED=0 \ 382 $(GO) build \ 383 $(BUILDFLAGS) \ 384 $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \ 385 -tags '$(BUILDTAGS_CROSS)' \ 386 -o "$@" ./cmd/podman 387 388 .PHONY: local-cross 389 local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures 390 391 .PHONY: cross 392 cross: local-cross 393 394 .PHONY: build-no-cgo 395 build-no-cgo: 396 BUILDTAGS="containers_image_openpgp exclude_graphdriver_btrfs \ 397 exclude_graphdriver_devicemapper exclude_disk_quota" \ 398 CGO_ENABLED=0 \ 399 $(MAKE) all 400 401 .PHONY: completions 402 completions: podman podman-remote 403 # key = shell, value = completion filename 404 declare -A outfiles=([bash]=%s [zsh]=_%s [fish]=%s.fish [powershell]=%s.ps1);\ 405 for shell in $${!outfiles[*]}; do \ 406 for remote in "" "-remote"; do \ 407 podman="podman$$remote"; \ 408 outfile=$$(printf "completions/$$shell/$${outfiles[$$shell]}" $$podman); \ 409 ./bin/$$podman completion $$shell >| $$outfile; \ 410 done;\ 411 done 412 413 ### 414 ### Documentation targets 415 ### 416 417 pkg/api/swagger.yaml: 418 make -C pkg/api 419 420 $(MANPAGES): %: %.md .install.md2man docdir 421 422 ### sed is used to filter http/s links as well as relative links 423 ### replaces "\" at the end of a line with two spaces 424 ### this ensures that manpages are renderd correctly 425 426 @sed -e 's/\((podman[^)]*\.md\(#.*\)\?)\)//g' \ 427 -e 's/\[\(podman[^]]*\)\]/\1/g' \ 428 -e 's/\[\([^]]*\)](http[^)]\+)/\1/g' \ 429 -e 's;<\(/\)\?\(a\|a\s\+[^>]*\|sup\)>;;g' \ 430 -e 's/\\$$/ /g' $< | \ 431 $(GOMD2MAN) -in /dev/stdin -out $(subst source/markdown,build/man,$@) 432 433 .PHONY: docdir 434 docdir: 435 mkdir -p docs/build/man 436 437 .PHONY: docs 438 docs: $(MANPAGES) ## Generate documentation 439 440 # docs/remote-docs.sh requires a locally executable 'podman-remote' binary 441 # in addition to the target-archetecture binary (if any). 442 podman-remote-%-docs: podman-remote-$(call err_if_empty,NATIVE_GOOS) 443 $(eval GOOS := $*) 444 $(MAKE) docs $(MANPAGES) 445 rm -rf docs/build/remote 446 mkdir -p docs/build/remote 447 ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ 448 docs/remote-docs.sh \ 449 $(GOOS) \ 450 docs/build/remote/$* \ 451 $(if $(findstring windows,$*),docs/source/markdown,docs/build/man) 452 453 .PHONY: man-page-check 454 man-page-check: bin/podman 455 hack/man-page-checker 456 hack/xref-helpmsgs-manpages 457 458 .PHONY: swagger-check 459 swagger-check: 460 hack/swagger-check 461 462 .PHONY: swagger 463 swagger: pkg/api/swagger.yaml 464 465 .PHONY: docker-docs 466 docker-docs: docs 467 (cd docs; ./dckrman.sh ./build/man/*.1) 468 469 # Workaround vim syntax highlighting bug: " 470 471 ### 472 ### Utility and Testing targets 473 ### 474 475 .PHONY: validate.completions 476 validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target 477 validate.completions: 478 # Check if the files can be loaded by the shell 479 . completions/bash/podman 480 if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi 481 if [ -x /bin/fish ]; then /bin/fish completions/fish/podman.fish; fi 482 483 # Note: Assumes test/python/requirements.txt is installed & available 484 .PHONY: run-docker-py-tests 485 run-docker-py-tests: 486 touch test/__init__.py 487 env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf pytest --disable-warnings test/python/docker/ 488 rm -f test/__init__.py 489 490 .PHONY: localunit 491 localunit: test/goecho/goecho test/version/version 492 rm -rf ${COVERAGE_PATH} && mkdir -p ${COVERAGE_PATH} 493 UNIT=1 ginkgo \ 494 -r \ 495 $(TESTFLAGS) \ 496 --skipPackage test/e2e,pkg/apparmor,pkg/bindings,hack,pkg/machine/e2e \ 497 --cover \ 498 --covermode atomic \ 499 --coverprofile coverprofile \ 500 --outputdir ${COVERAGE_PATH} \ 501 --tags "$(BUILDTAGS)" \ 502 --succinct 503 $(GO) tool cover -html=${COVERAGE_PATH}/coverprofile -o ${COVERAGE_PATH}/coverage.html 504 $(GO) tool cover -func=${COVERAGE_PATH}/coverprofile > ${COVERAGE_PATH}/functions 505 cat ${COVERAGE_PATH}/functions | sed -n 's/\(total:\).*\([0-9][0-9].[0-9]\)/\1 \2/p' 506 507 .PHONY: test 508 test: localunit localintegration remoteintegration localsystem remotesystem ## Run unit, integration, and system tests. 509 510 .PHONY: ginkgo-run 511 ginkgo-run: 512 ACK_GINKGO_RC=true ginkgo version 513 ACK_GINKGO_RC=true ginkgo -v $(TESTFLAGS) -tags "$(TAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 -debug test/e2e/. $(HACK) 514 515 .PHONY: ginkgo 516 ginkgo: 517 $(MAKE) ginkgo-run TAGS="$(BUILDTAGS)" HACK=hack/. 518 519 .PHONY: ginkgo-remote 520 ginkgo-remote: 521 $(MAKE) ginkgo-run TAGS="$(REMOTETAGS)" HACK= 522 523 .PHONY: localintegration 524 localintegration: test-binaries ginkgo 525 526 .PHONY: remoteintegration 527 remoteintegration: test-binaries ginkgo-remote 528 529 .PHONY: localbenchmarks 530 localbenchmarks: test-binaries 531 PATH=$(PATH):$(shell pwd)/hack ACK_GINKGO_RC=true ginkgo \ 532 -focus "Podman Benchmark Suite" \ 533 -tags "$(BUILDTAGS) benchmarks" -noColor \ 534 -noisySkippings=false -noisyPendings=false \ 535 test/e2e/. 536 537 .PHONY: localsystem 538 localsystem: 539 # Wipe existing config, database, and cache: start with clean slate. 540 $(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers 541 if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi 542 543 .PHONY: remotesystem 544 remotesystem: 545 # Wipe existing config, database, and cache: start with clean slate. 546 $(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers 547 # Start podman server using tmp socket; loop-wait for it; 548 # test podman-remote; kill server, clean up tmp socket file. 549 # podman server spews copious unhelpful output; ignore it. 550 rc=0;\ 551 if timeout -v 1 true; then \ 552 SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman_tmp_XXXX);\ 553 export PODMAN_SOCKET=unix:$$SOCK_FILE; \ 554 ./bin/podman system service --timeout=0 $$PODMAN_SOCKET > $(if $(PODMAN_SERVER_LOG),$(PODMAN_SERVER_LOG),/dev/null) 2>&1 & \ 555 retry=5;\ 556 while [ $$retry -ge 0 ]; do\ 557 echo Waiting for server...;\ 558 sleep 1;\ 559 ./bin/podman-remote --url $$PODMAN_SOCKET info >/dev/null 2>&1 && break;\ 560 retry=$$(expr $$retry - 1);\ 561 done;\ 562 if [ $$retry -lt 0 ]; then\ 563 echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\ 564 exit 1;\ 565 fi;\ 566 env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\ 567 rc=$$?;\ 568 kill %1;\ 569 rm -f $$SOCK_FILE;\ 570 else \ 571 echo "Skipping $@: 'timeout -v' unavailable'";\ 572 fi;\ 573 exit $$rc 574 575 .PHONY: localapiv2-bash 576 localapiv2-bash: 577 env PODMAN=./bin/podman stdbuf -o0 -e0 ./test/apiv2/test-apiv2 578 579 .PHONY: localapiv2-python 580 localapiv2-python: 581 env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \ 582 pytest --verbose --disable-warnings ./test/apiv2/python 583 touch test/__init__.py 584 env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \ 585 pytest --verbose --disable-warnings ./test/python/docker 586 rm -f test/__init__.py 587 588 # Order is important running python tests first causes the bash tests 589 # to fail, see 12-imagesMore. FIXME order of tests should not matter 590 .PHONY: localapiv2 591 localapiv2: localapiv2-bash localapiv2-python 592 593 .PHONY: remoteapiv2 594 remoteapiv2: 595 true 596 597 .PHONY: system.test-binary 598 system.test-binary: .install.ginkgo 599 $(GO) test -c ./test/system 600 601 .PHONY: test-binaries 602 test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho install.catatonit test/version/version 603 @echo "Canonical source version: $(call err_if_empty,RELEASE_VERSION)" 604 605 .PHONY: tests-included 606 tests-included: 607 contrib/cirrus/pr-should-include-tests 608 609 .PHONY: tests-expect-exit 610 tests-expect-exit: 611 @if egrep --line-number 'Expect.*ExitCode' test/e2e/*.go | egrep -v ', ".*"\)'; then \ 612 echo "^^^ Unhelpful use of Expect(ExitCode())"; \ 613 echo " Please use '.Should(Exit(...))' pattern instead."; \ 614 echo " If that's not possible, please add an annotation (description) to your assertion:"; \ 615 echo " Expect(...).To(..., \"Friendly explanation of this check\")"; \ 616 exit 1; \ 617 fi 618 619 ### 620 ### Release/Packaging targets 621 ### 622 623 .PHONY: podman-release 624 podman-release: podman-release-$(GOARCH).tar.gz # Build all Linux binaries for $GOARCH, docs., and installation tree, into a tarball. 625 626 # The following two targets are nuanced and complex: 627 # Cross-building the podman-remote documentation requires a functional 628 # native architecture executable. However `make` only deals with 629 # files/timestamps, it doesn't understand if an existing binary will 630 # function on the system or not. This makes building cross-platform 631 # releases incredibly accident-prone and fragile. The only practical 632 # way to deal with this, is via multiple conditional (nested) `make` 633 # calls along with careful manipulation of `$GOOS` and `$GOARCH`. 634 635 podman-release-%.tar.gz: test/version/version 636 $(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX)) 637 $(eval SUBDIR := podman-v$(call err_if_empty,RELEASE_NUMBER)) 638 $(eval _DSTARGS := "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr") 639 $(eval GOARCH := $*) 640 mkdir -p "$(call err_if_empty,TMPDIR)/$(SUBDIR)" 641 $(MAKE) GOOS=$(GOOS) GOARCH=$(NATIVE_GOARCH) \ 642 clean-binaries docs podman-remote-$(GOOS)-docs 643 if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then \ 644 $(MAKE) CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \ 645 BUILDTAGS="$(BUILDTAGS_CROSS)" clean-binaries binaries; \ 646 else \ 647 $(MAKE) GOOS=$(GOOS) GOARCH=$(GOARCH) binaries; \ 648 fi 649 $(MAKE) $(_DSTARGS) install.bin install.remote install.man install.systemd 650 tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)" 651 if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then $(MAKE) clean-binaries; fi 652 -rm -rf "$(TMPDIR)" 653 654 podman-remote-release-%.zip: test/version/version ## Build podman-remote for %=$GOOS_$GOARCH, and docs. into an installation zip. 655 $(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX)) 656 $(eval SUBDIR := podman-$(call err_if_empty,RELEASE_NUMBER)) 657 $(eval _DSTARGS := "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr") 658 $(eval GOOS := $(firstword $(subst _, ,$*))) 659 $(eval GOARCH := $(lastword $(subst _, ,$*))) 660 $(eval _GOPLAT := GOOS=$(call err_if_empty,GOOS) GOARCH=$(call err_if_empty,GOARCH)) 661 mkdir -p "$(call err_if_empty,TMPDIR)/$(SUBDIR)" 662 $(MAKE) GOOS=$(GOOS) GOARCH=$(NATIVE_GOARCH) \ 663 clean-binaries podman-remote-$(GOOS)-docs 664 if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then \ 665 $(MAKE) CGO_ENABLED=0 $(GOPLAT) BUILDTAGS="$(BUILDTAGS_CROSS)" \ 666 clean-binaries podman-remote-$(GOOS); \ 667 else \ 668 $(MAKE) $(GOPLAT) podman-remote-$(GOOS); \ 669 fi 670 cp -r ./docs/build/remote/$(GOOS) "$(TMPDIR)/$(SUBDIR)/docs/" 671 cp ./contrib/remote/containers.conf "$(TMPDIR)/$(SUBDIR)/" 672 $(MAKE) $(GOPLAT) $(_DSTARGS) SELINUXOPT="" install.remote 673 cd "$(TMPDIR)" && \ 674 zip --recurse-paths "$(CURDIR)/$@" "./" 675 if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then $(MAKE) clean-binaries; fi 676 -rm -rf "$(TMPDIR)" 677 678 .PHONY: podman.msi 679 podman.msi: test/version/version ## Build podman-remote, package for installation on Windows 680 $(MAKE) podman-v$(call err_if_empty,RELEASE_NUMBER).msi 681 podman-v%.msi: test/version/version podman-remote-windows podman-remote-windows-docs podman-winpath win-sshproxy 682 $(eval DOCFILE := docs/build/remote/windows) 683 find $(DOCFILE) -print | \ 684 wixl-heat --var var.ManSourceDir --component-group ManFiles \ 685 --directory-ref INSTALLDIR --prefix $(DOCFILE)/ > \ 686 $(DOCFILE)/pages.wsx 687 wixl -D VERSION=$(call err_if_empty,RELEASE_VERSION) -D ManSourceDir=$(DOCFILE) \ 688 -o $@ contrib/msi/podman.wxs $(DOCFILE)/pages.wsx --arch x64 689 690 # Checks out and builds win-sshproxy helper. See comment on GV_GITURL declaration 691 .PHONY: win-sshproxy 692 win-sshproxy: test/version/version 693 rm -rf tmp-gv; mkdir tmp-gv 694 (cd tmp-gv; \ 695 git init; \ 696 git remote add origin $(GV_GITURL); \ 697 git fetch --depth 1 origin $(GV_SHA); \ 698 git checkout FETCH_HEAD; make win-sshproxy) 699 mkdir -p bin/windows/ 700 cp tmp-gv/bin/win-sshproxy.exe bin/windows/ 701 rm -rf tmp-gv 702 703 .PHONY: package 704 package: ## Build rpm packages 705 rpkg local 706 707 ### 708 ### Installation targets 709 ### 710 711 # Remember that rpms install exec to /usr/bin/podman while a `make install` 712 # installs them to /usr/local/bin/podman which is likely before. Always use 713 # a full path to test installed podman or you risk to call another executable. 714 .PHONY: package-install 715 package-install: package ## Install rpm packages 716 sudo $(call err_if_empty,PKG_MANAGER) -y install ${HOME}/rpmbuild/RPMS/*/*.rpm 717 /usr/bin/podman version 718 /usr/bin/podman info # will catch a broken conmon 719 720 .PHONY: install 721 install: install.bin install.remote install.man install.systemd ## Install binaries to system locations 722 723 .PHONY: install.catatonit 724 install.catatonit: 725 ./hack/install_catatonit.sh 726 727 .PHONY: install.remote 728 install.remote: 729 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) 730 install ${SELINUXOPT} -m 755 $(SRCBINDIR)/podman$(BINSFX) \ 731 $(DESTDIR)$(BINDIR)/podman$(BINSFX) 732 test -z "${SELINUXOPT}" || \ 733 chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote \ 734 bin/podman-remote 735 736 .PHONY: install.bin 737 install.bin: 738 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) 739 install ${SELINUXOPT} -m 755 bin/podman $(DESTDIR)$(BINDIR)/podman 740 test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman 741 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(LIBEXECPODMAN) 742 install ${SELINUXOPT} -m 755 bin/rootlessport $(DESTDIR)$(LIBEXECPODMAN)/rootlessport 743 test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(LIBEXECPODMAN)/rootlessport bin/rootlessport 744 install ${SELINUXOPT} -m 755 -d ${DESTDIR}${TMPFILESDIR} 745 install ${SELINUXOPT} -m 644 contrib/tmpfile/podman.conf ${DESTDIR}${TMPFILESDIR}/podman.conf 746 747 .PHONY: install.modules-load 748 install.modules-load: # This should only be used by distros which might use iptables-legacy, this is not needed on RHEL 749 install ${SELINUXOPT} -m 755 -d ${DESTDIR}${MODULESLOADDIR} 750 install ${SELINUXOPT} -m 644 contrib/modules-load.d/podman-iptables.conf ${DESTDIR}${MODULESLOADDIR}/podman-iptables.conf 751 752 .PHONY: install.man 753 install.man: 754 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1 755 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man5 756 install ${SELINUXOPT} -m 644 $(filter %.1,$(MANPAGES_DEST)) -t $(DESTDIR)$(MANDIR)/man1 757 install ${SELINUXOPT} -m 644 $(filter %.5,$(MANPAGES_DEST)) -t $(DESTDIR)$(MANDIR)/man5 758 install ${SELINUXOPT} -m 644 docs/source/markdown/links/*1 -t $(DESTDIR)$(MANDIR)/man1 759 760 .PHONY: install.completions 761 install.completions: 762 install ${SELINUXOPT} -d -m 755 ${DESTDIR}${BASHINSTALLDIR} 763 install ${SELINUXOPT} -m 644 completions/bash/podman ${DESTDIR}${BASHINSTALLDIR} 764 install ${SELINUXOPT} -m 644 completions/bash/podman-remote ${DESTDIR}${BASHINSTALLDIR} 765 install ${SELINUXOPT} -d -m 755 ${DESTDIR}${ZSHINSTALLDIR} 766 install ${SELINUXOPT} -m 644 completions/zsh/_podman ${DESTDIR}${ZSHINSTALLDIR} 767 install ${SELINUXOPT} -m 644 completions/zsh/_podman-remote ${DESTDIR}${ZSHINSTALLDIR} 768 install ${SELINUXOPT} -d -m 755 ${DESTDIR}${FISHINSTALLDIR} 769 install ${SELINUXOPT} -m 644 completions/fish/podman.fish ${DESTDIR}${FISHINSTALLDIR} 770 install ${SELINUXOPT} -m 644 completions/fish/podman-remote.fish ${DESTDIR}${FISHINSTALLDIR} 771 # There is no common location for powershell files so do not install them. Users have to source the file from their powershell profile. 772 773 .PHONY: install.docker 774 install.docker: 775 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) 776 install ${SELINUXOPT} -m 755 docker $(DESTDIR)$(BINDIR)/docker 777 install ${SELINUXOPT} -m 755 -d ${DESTDIR}${SYSTEMDDIR} ${DESTDIR}${USERSYSTEMDDIR} ${DESTDIR}${TMPFILESDIR} 778 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-docker.conf -t ${DESTDIR}${TMPFILESDIR} 779 780 .PHONY: install.docker-docs 781 install.docker-docs: 782 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1 783 install ${SELINUXOPT} -m 644 docs/build/man/docker*.1 -t $(DESTDIR)$(MANDIR)/man1 784 install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man5 785 install ${SELINUXOPT} -m 644 docs/build/man/docker*.5 -t $(DESTDIR)$(MANDIR)/man5 786 787 .PHONY: install.docker-full 788 install.docker-full: install.docker install.docker-docs 789 790 .PHONY: install.systemd 791 ifneq (,$(findstring systemd,$(BUILDTAGS))) 792 PODMAN_UNIT_FILES = contrib/systemd/auto-update/podman-auto-update.service \ 793 contrib/systemd/system/podman.service \ 794 contrib/systemd/system/podman-restart.service \ 795 contrib/systemd/system/podman-play-kube@.service 796 797 %.service: %.service.in 798 sed -e 's;@@PODMAN@@;$(BINDIR)/podman;g' $< >$@.tmp.$$ \ 799 && mv -f $@.tmp.$$ $@ 800 801 install.systemd: $(PODMAN_UNIT_FILES) 802 install ${SELINUXOPT} -m 755 -d ${DESTDIR}${SYSTEMDDIR} ${DESTDIR}${USERSYSTEMDDIR} 803 # User services 804 install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service ${DESTDIR}${USERSYSTEMDDIR}/podman-auto-update.service 805 install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${USERSYSTEMDDIR}/podman-auto-update.timer 806 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket ${DESTDIR}${USERSYSTEMDDIR}/podman.socket 807 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${USERSYSTEMDDIR}/podman.service 808 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${USERSYSTEMDDIR}/podman-restart.service 809 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-play-kube@.service ${DESTDIR}${USERSYSTEMDDIR}/podman-play-kube@.service 810 # System services 811 install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.service 812 install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.timer 813 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket ${DESTDIR}${SYSTEMDDIR}/podman.socket 814 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${SYSTEMDDIR}/podman.service 815 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${SYSTEMDDIR}/podman-restart.service 816 install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-play-kube@.service ${DESTDIR}${SYSTEMDDIR}/podman-play-kube@.service 817 rm -f $(PODMAN_UNIT_FILES) 818 else 819 install.systemd: 820 endif 821 822 .PHONY: install.tools 823 install.tools: .install.ginkgo .install.golangci-lint .install.bats ## Install needed tools 824 make -C test/tools 825 826 .PHONY: .install.ginkgo 827 .install.ginkgo: 828 $(GO) install $(BUILDFLAGS) ./vendor/github.com/onsi/ginkgo/ginkgo 829 830 .PHONY: .install.golangci-lint 831 .install.golangci-lint: 832 VERSION=1.45.2 ./hack/install_golangci.sh 833 834 .PHONY: .install.md2man 835 .install.md2man: 836 if [ ! -x "$(GOMD2MAN)" ]; then \ 837 make -C test/tools build/go-md2man ; \ 838 fi 839 840 .PHONY: .install.bats 841 .install.bats: 842 VERSION=v1.1.0 ./hack/install_bats.sh 843 844 .PHONY: .install.pre-commit 845 .install.pre-commit: 846 if [ -z "$(PRE_COMMIT)" ]; then \ 847 python3 -m pip install --user pre-commit; \ 848 fi 849 850 .PHONY: uninstall 851 uninstall: 852 for i in $(filter %.1,$(MANPAGES_DEST)); do \ 853 rm -f $(DESTDIR)$(MANDIR)/man1/$$(basename $${i}); \ 854 done; \ 855 for i in $(filter %.5,$(MANPAGES_DEST)); do \ 856 rm -f $(DESTDIR)$(MANDIR)/man5/$$(basename $${i}); \ 857 done 858 # Remove podman and remote bin 859 rm -f $(DESTDIR)$(BINDIR)/podman 860 rm -f $(DESTDIR)$(BINDIR)/podman-remote 861 # Remove related config files 862 rm -f ${DESTDIR}${ETCDIR}/cni/net.d/87-podman-bridge.conflist 863 rm -f ${DESTDIR}${TMPFILESDIR}/podman.conf 864 rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.socket 865 rm -f ${DESTDIR}${USERSYSTEMDDIR}/io.podman.socket 866 rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.service 867 rm -f ${DESTDIR}${SYSTEMDDIR}/podman.service 868 rm -f ${DESTDIR}${SYSTEMDDIR}/podman.socket 869 rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.socket 870 rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service 871 872 .PHONY: clean-binaries 873 clean-binaries: ## Remove platform/architecture specific binary files 874 rm -rf \ 875 bin 876 877 .PHONY: clean 878 clean: clean-binaries ## Clean all make artifacts 879 rm -rf \ 880 _output \ 881 $(wildcard podman-*.msi) \ 882 $(wildcard podman-remote*.zip) \ 883 $(wildcard podman_tmp_*) \ 884 $(wildcard podman*.tar.gz) \ 885 build \ 886 test/checkseccomp/checkseccomp \ 887 test/goecho/goecho \ 888 test/version/version \ 889 test/__init__.py \ 890 test/testdata/redis-image \ 891 libpod/container_ffjson.go \ 892 libpod/pod_ffjson.go \ 893 libpod/container_easyjson.go \ 894 libpod/pod_easyjson.go \ 895 docs/build \ 896 .venv 897 make -C docs clean