podman

Форк
0
/
Makefile 
1054 строки · 40.2 Кб
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
# Default shell `/bin/sh` has different meanings depending on the platform.
24
SHELL := $(shell command -v bash;)
25
GO ?= go
26
GO_LDFLAGS:= $(shell if $(GO) version|grep -q gccgo ; then echo "-gccgoflags"; else echo "-ldflags"; fi)
27
GOCMD = CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)
28
COVERAGE_PATH ?= .coverage
29
DESTDIR ?=
30
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
31
HEAD ?= HEAD
32
PROJECT := github.com/containers/podman
33
GIT_BASE_BRANCH ?= origin/main
34
LIBPOD_INSTANCE := libpod_dev
35
PREFIX ?= /usr/local
36
RELEASE_PREFIX = /usr
37
BINDIR ?= ${PREFIX}/bin
38
LIBEXECDIR ?= ${PREFIX}/libexec
39
LIBEXECPODMAN ?= ${LIBEXECDIR}/podman
40
MANDIR ?= ${PREFIX}/share/man
41
SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
42
ETCDIR ?= /etc
43
LIBDIR ?= ${PREFIX}/lib
44
TMPFILESDIR ?= ${LIBDIR}/tmpfiles.d
45
USERTMPFILESDIR ?= ${PREFIX}/share/user-tmpfiles.d
46
MODULESLOADDIR ?= ${LIBDIR}/modules-load.d
47
SYSTEMDDIR ?= ${LIBDIR}/systemd/system
48
USERSYSTEMDDIR ?= ${LIBDIR}/systemd/user
49
SYSTEMDGENERATORSDIR ?= ${LIBDIR}/systemd/system-generators
50
USERSYSTEMDGENERATORSDIR ?= ${LIBDIR}/systemd/user-generators
51
REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp
52
BUILDTAGS ?= \
53
	$(shell hack/apparmor_tag.sh) \
54
	$(shell hack/btrfs_installed_tag.sh) \
55
	$(shell hack/btrfs_tag.sh) \
56
	$(shell hack/systemd_tag.sh) \
57
	$(shell hack/libsubid_tag.sh) \
58
	exclude_graphdriver_devicemapper \
59
	seccomp
60
# allow downstreams to easily add build tags while keeping our defaults
61
BUILDTAGS += ${EXTRA_BUILDTAGS}
62
# N/B: This value is managed by Renovate, manual changes are
63
# possible, as long as they don't disturb the formatting
64
# (i.e. DO NOT ADD A 'v' prefix!)
65
GOLANGCI_LINT_VERSION := 1.57.2
66
PYTHON ?= $(shell command -v python3 python|head -n1)
67
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
68
# ~/.local/bin is not in PATH on all systems
69
PRE_COMMIT = $(shell command -v bin/venv/bin/pre-commit ~/.local/bin/pre-commit pre-commit | head -n1)
70
ifeq ($(shell uname -s),FreeBSD)
71
SED=gsed
72
GREP=ggrep
73
MAN_L=	mandoc
74
# FreeBSD needs CNI until netavark is supported
75
BUILDTAGS += cni
76
else
77
SED=sed
78
GREP=grep
79
MAN_L=	man -l
80
endif
81

82
# This isn't what we actually build; it's a superset, used for target
83
# dependencies. Basically: all *.go and *.c files, except *_test.go,
84
# and except anything in a dot subdirectory. If any of these files is
85
# newer than our target (bin/podman{,-remote}), a rebuild is
86
# triggered.
87
SOURCES = $(shell find . -path './.*' -prune -o \( \( -name '*.go' -o -name '*.c' \) -a ! -name '*_test.go' \) -print)
88

89
BUILDTAGS_CROSS ?= containers_image_openpgp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_overlay
90
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
91
OCI_RUNTIME ?= ""
92

93
# The 'sort' below is crucial: without it, 'make docs' behaves differently
94
# on the first run than on subsequent ones, because the generated .md
95
MANPAGES_SOURCE_DIR = docs/source/markdown
96
MANPAGES_MD_IN ?= $(wildcard $(MANPAGES_SOURCE_DIR)/*.md.in)
97
MANPAGES_MD_GENERATED ?= $(MANPAGES_MD_IN:%.md.in=%.md)
98
MANPAGES_MD ?= $(sort $(wildcard $(MANPAGES_SOURCE_DIR)/*.md) $(MANPAGES_MD_GENERATED))
99
MANPAGES ?= $(MANPAGES_MD:%.md=%)
100
MANPAGES_DEST ?= $(subst markdown,man, $(subst source,build,$(MANPAGES)))
101

102
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
103
ZSHINSTALLDIR=${PREFIX}/share/zsh/site-functions
104
FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d
105

106
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
107

108

109
COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
110
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),$(call err_if_empty,COMMIT_NO)-dirty,$(COMMIT_NO))
111
DATE_FMT = %s
112
ifdef SOURCE_DATE_EPOCH
113
	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)")
114
else
115
	BUILD_INFO ?= $(shell date "+$(DATE_FMT)")
116
endif
117
LIBPOD := ${PROJECT}/v5/libpod
118
GOFLAGS ?= -trimpath
119
LDFLAGS_PODMAN ?= \
120
	$(if $(GIT_COMMIT),-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT),) \
121
	$(if $(BUILD_INFO),-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO),) \
122
	-X $(LIBPOD)/config._installPrefix=$(PREFIX) \
123
	-X $(LIBPOD)/config._etcDir=$(ETCDIR) \
124
	-X $(PROJECT)/v5/pkg/systemd/quadlet._binDir=$(BINDIR) \
125
	-X github.com/containers/common/pkg/config.additionalHelperBinariesDir=$(HELPER_BINARIES_DIR)\
126
	$(EXTRA_LDFLAGS)
127
LDFLAGS_PODMAN_STATIC ?= \
128
	$(LDFLAGS_PODMAN) \
129
	-extldflags=-static
130
#Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too.
131
LIBSECCOMP_COMMIT := v2.3.3
132
# Rarely if ever should integration tests take more than 50min,
133
# caller may override in special circumstances if needed.
134
GINKGOTIMEOUT ?= -timeout=90m
135
# By default, run test/e2e
136
GINKGOWHAT ?= test/e2e/.
137
GINKGO_PARALLEL=y
138
GINKGO ?= ./test/tools/build/ginkgo
139
# ginkgo json output is only useful in CI, not on developer runs
140
GINKGO_JSON ?= $(if $(CI),--json-report ginkgo-e2e.json,)
141

142
# Allow control over some Ginkgo parameters
143
GINKGO_FLAKE_ATTEMPTS ?= 3
144
GINKGO_NO_COLOR ?= y
145

146
# Conditional required to produce empty-output if binary not built yet.
147
RELEASE_VERSION = $(shell if test -x test/version/version; then test/version/version; fi)
148
RELEASE_NUMBER = $(shell echo "$(call err_if_empty,RELEASE_VERSION)" | sed -e 's/^v\(.*\)/\1/')
149

150
# If non-empty, logs all output from server during remote system testing
151
PODMAN_SERVER_LOG ?=
152

153
# Ensure GOBIN is not set so the default (`go env GOPATH`/bin) is used.
154
override undefine GOBIN
155
# This must never include the 'hack' directory
156
export PATH := $(shell $(GO) env GOPATH)/bin:$(PATH)
157

158
GOMD2MAN ?= ./test/tools/build/go-md2man
159

160
# There are many possibly unexpected places where podman is used.  For example
161
# by OpenWRT for routers and other similar small "edge" devices.  Testing builds
162
# for otherwise non-mainstream architectures ensures we catch platform-specific
163
# toolchain shenanigans early, for example:
164
# https://github.com/containers/podman/issues/8782
165
CROSS_BUILD_TARGETS := \
166
	bin/podman.cross.linux.amd64 \
167
	bin/podman.cross.linux.ppc64le \
168
	bin/podman.cross.linux.arm \
169
	bin/podman.cross.linux.arm64 \
170
	bin/podman.cross.linux.386 \
171
	bin/podman.cross.linux.s390x \
172
	bin/podman.cross.linux.loong64 \
173
	bin/podman.cross.linux.mips \
174
	bin/podman.cross.linux.mipsle \
175
	bin/podman.cross.linux.mips64 \
176
	bin/podman.cross.linux.mips64le \
177
	bin/podman.cross.linux.riscv64 \
178
	bin/podman.cross.freebsd.amd64 \
179
	bin/podman.cross.freebsd.arm64
180

181
# Dereference variable $(1), return value if non-empty, otherwise raise an error.
182
err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty))
183

184
# Podman does not work w/o CGO_ENABLED, except in some very specific cases.
185
# Windows and Mac (both podman-remote client only) require CGO_ENABLED=0.
186
CGO_ENABLED ?= 1
187
# Default to the native OS type and architecture unless otherwise specified
188
NATIVE_GOOS := $(shell env -u GOOS $(GO) env GOOS)
189
GOOS ?= $(call err_if_empty,NATIVE_GOOS)
190
# Default to the native architecture type
191
NATIVE_GOARCH := $(shell env -u GOARCH $(GO) env GOARCH)
192
GOARCH ?= $(NATIVE_GOARCH)
193
ifeq ($(call err_if_empty,GOOS),windows)
194
BINSFX := .exe
195
SRCBINDIR := bin/windows
196
CGO_ENABLED := 0
197
else ifeq ($(GOOS),darwin)
198
BINSFX :=
199
SRCBINDIR := bin/darwin
200
CGO_ENABLED := 0
201
else ifeq ($(GOOS),freebsd)
202
BINSFX := -remote
203
SRCBINDIR := bin
204
RELEASE_PREFIX = /usr/local
205
else
206
BINSFX := -remote
207
SRCBINDIR := bin
208
endif
209
# Necessary for nested-$(MAKE) calls and docs/remote-docs.sh
210
export GOOS GOARCH CGO_ENABLED BINSFX SRCBINDIR
211

212
# Need to use CGO for mDNS resolution, but cross builds need CGO disabled
213
# See https://github.com/golang/go/issues/12524 for details
214
DARWIN_GCO := 0
215
ifeq ($(call err_if_empty,NATIVE_GOOS),darwin)
216
ifdef HOMEBREW_PREFIX
217
	DARWIN_GCO := 1
218
endif
219
endif
220

221
# gvisor-tap-vsock version for gvproxy.exe and win-sshproxy.exe downloads
222
# the upstream project ships pre-built binaries since version 0.7.1
223
GV_VERSION=v0.7.3
224

225
###
226
### Primary entry-point targets
227
###
228

229
.PHONY: default
230
default: all
231

232
.PHONY: all
233
all: binaries docs
234

235
.PHONY: binaries
236
ifeq ($(shell uname -s),FreeBSD)
237
binaries: podman podman-remote ## Build podman and podman-remote binaries
238
else ifneq (, $(findstring $(GOOS),darwin windows))
239
binaries: podman-remote ## Build podman-remote (client) only binaries
240
else
241
binaries: podman podman-remote podmansh rootlessport quadlet ## Build podman, podman-remote and rootlessport binaries quadlet
242
endif
243

244
# Extract text following double-# for targets, as their description for
245
# the `help` target.  Otherwise these simple-substitutions are resolved
246
# at reference-time (due to `=` and not `=:`).
247
_HLP_TGTS_RX = '^[[:print:]]+:.*?\#\# .*$$'
248
_HLP_TGTS_CMD = $(GREP) -E $(_HLP_TGTS_RX) $(MAKEFILE_LIST)
249
_HLP_TGTS_LEN = $(shell $(call err_if_empty,_HLP_TGTS_CMD) | cut -d : -f 1 | wc -L 2>/dev/null || echo "PARSING_ERROR")
250
# Separated condition for Darwin
251
ifeq ($(shell uname -s)$(_HLP_TGTS_LEN),DarwinPARSING_ERROR)
252
ifneq (,$(wildcard /usr/local/bin/gwc))
253
_HLP_TGTS_LEN = $(shell $(call err_if_empty,_HLP_TGTS_CMD) | cut -d : -f 1 | gwc -L)
254
else
255
$(warning On Darwin (MacOS) installed coreutils is necessary)
256
$(warning Use 'brew install coreutils' command to install coreutils on your system)
257
endif
258
endif
259
_HLPFMT = "%-$(call err_if_empty,_HLP_TGTS_LEN)s %s\n"
260
.PHONY: help
261
help: ## (Default) Print listing of key targets with their descriptions
262
	@printf $(_HLPFMT) "Target:" "Description:"
263
	@printf $(_HLPFMT) "--------------" "--------------------"
264
	@$(_HLP_TGTS_CMD) | sort | \
265
		awk 'BEGIN {FS = ":(.*)?## "}; \
266
			{printf $(_HLPFMT), $$1, $$2}'
267

268
###
269
### Linting/Formatting/Code Validation targets
270
###
271

272
.PHONY: .gitvalidation
273
.gitvalidation: .install.gitvalidation
274
	@echo "Validating vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'"
275
	GIT_CHECK_EXCLUDE="./vendor:./test/tools/vendor:docs/make.bat:test/buildah-bud/buildah-tests.diff:test/e2e/quadlet/remap-keep-id2.container" ./test/tools/build/git-validation -run short-subject -range $(EPOCH_TEST_COMMIT)..$(HEAD)
276

277
.PHONY: lint
278
lint: golangci-lint
279
	@echo "Linting vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'"
280
ifeq ($(PRE_COMMIT),)
281
	@echo "FATAL: pre-commit was not found, make .install.pre-commit to installing it." >&2
282
	@exit 2
283
endif
284
	$(PRE_COMMIT) run -a
285

286
.PHONY: golangci-lint
287
golangci-lint: .install.golangci-lint
288
	hack/golangci-lint.sh run
289

290
.PHONY: test/checkseccomp/checkseccomp
291
test/checkseccomp/checkseccomp: $(wildcard test/checkseccomp/*.go)
292
	$(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ ./test/checkseccomp
293

294
.PHONY: test/testvol/testvol
295
test/testvol/testvol: $(wildcard test/testvol/*.go)
296
	$(GOCMD) build -o $@ ./test/testvol
297

298
.PHONY: volume-plugin-test-img
299
volume-plugin-test-img:
300
	./bin/podman build --network none -t quay.io/libpod/volume-plugin-test-img:$$(date +%Y%m%d) -f ./test/testvol/Containerfile .
301

302
.PHONY: test/goecho/goecho
303
test/goecho/goecho: $(wildcard test/goecho/*.go)
304
	$(GOCMD) build $(BUILDFLAGS) $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho
305

306
# The ./test/version/version binary is executed in other make steps
307
# so we have to make sure the version binary is built for NATIVE_GOARCH.
308
test/version/version: version/version.go
309
	GOARCH=$(NATIVE_GOARCH) $(GO) build -o $@ ./test/version/
310

311
.PHONY: codespell
312
codespell:
313
	codespell -S bin,vendor,.git,go.sum,.cirrus.yml,"*.fish,RELEASE_NOTES.md,*.xz,*.gz,*.ps1,*.tar,swagger.yaml,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L secon,passt,bu,hastable,te,clos,ans,pullrequest,uint,iff,od,seeked,splitted,marge,erro,hist,ether,specif -w
314

315
.PHONY: validate
316
validate: lint .gitvalidation validate.completions man-page-check swagger-check tests-expect-exit pr-removes-fixed-skips
317

318
.PHONY: validatepr
319
validatepr:
320
	$(PODMANCMD) run --rm --env HOME=/root \
321
		-v $(CURDIR):/var/tmp/go/src/github.com/containers/podman \
322
		--security-opt label=disable \
323
		quay.io/libpod/fedora_podman:latest  \
324
		make .validatepr
325

326
.PHONY: .validatepr
327
.validatepr:
328
	env BUILDTAGS="$(BUILDTAGS)" REMOTETAGS="$(REMOTETAGS)" contrib/validatepr/validatepr.sh
329

330
.PHONY: build-all-new-commits
331
build-all-new-commits:
332
	# Validate that all the commits build on top of $(GIT_BASE_BRANCH)
333
	git rebase $(call err_if_empty,GIT_BASE_BRANCH) -x "$(MAKE)"
334

335
.PHONY: vendor
336
vendor:
337
	$(GO) mod tidy
338
	$(GO) mod vendor
339
	$(GO) mod verify
340

341

342
# We define *-in-container targets for the following make targets. This allow the targets to be run in a container.
343
# Note that the PODMANCMD can also be overridden to allow a different container CLI to be used on systems where podman is not already available.
344
IN_CONTAINER_TARGETS = vendor validate
345
PODMANCMD ?= podman
346
IN_CONTAINER = $(patsubst %,%-in-container,$(IN_CONTAINER_TARGETS))
347

348
.PHONY: $(IN_CONTAINER)
349
$(IN_CONTAINER): %-in-container:
350
	$(PODMANCMD) run --rm --env HOME=/root \
351
		-v $(CURDIR):/src -w /src \
352
		--security-opt label=disable \
353
		docker.io/library/golang:1.20 \
354
		make $(*)
355

356

357
###
358
### Primary binary-build targets
359
###
360

361
# Make sure to warn in case we're building without the systemd buildtag.
362
bin/podman: $(SOURCES) go.mod go.sum
363
ifeq (,$(findstring systemd,$(BUILDTAGS)))
364
	@echo "Podman is being compiled without the systemd build tag. \
365
		Install libsystemd on Ubuntu or systemd-devel on rpm based \
366
		distro for journald support."
367
endif
368
	$(GOCMD) build \
369
		$(BUILDFLAGS) \
370
		$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
371
		-tags "$(BUILDTAGS)" \
372
		-o $@ ./cmd/podman
373
	test -z "${SELINUXOPT}" || chcon -t container_runtime_exec_t $@
374

375
# Disambiguate Linux vs Darwin/Windows platform binaries under distinct "bin" dirs
376
$(SRCBINDIR):
377
	mkdir -p $(SRCBINDIR)
378

379
# '|' is to ignore SRCBINDIR mtime; see: info make 'Types of Prerequisites'
380
$(SRCBINDIR)/podman$(BINSFX): $(SOURCES) go.mod go.sum | $(SRCBINDIR)
381
	$(GOCMD) build \
382
		$(BUILDFLAGS) \
383
		$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
384
		-tags "${REMOTETAGS}" \
385
		-o $@ ./cmd/podman
386

387
$(SRCBINDIR)/podman-remote-static-linux_%: GOARCH = $(patsubst $(SRCBINDIR)/podman-remote-static-linux_%,%,$@)
388
$(SRCBINDIR)/podman-remote-static $(SRCBINDIR)/podman-remote-static-linux_amd64 $(SRCBINDIR)/podman-remote-static-linux_arm64: $(SRCBINDIR) $(SOURCES) go.mod go.sum
389
	CGO_ENABLED=0 \
390
	GOOS=linux \
391
	$(GO) build \
392
		$(BUILDFLAGS) \
393
		$(GO_LDFLAGS) '$(LDFLAGS_PODMAN_STATIC)' \
394
		-tags "${REMOTETAGS}" \
395
		-o $@ ./cmd/podman
396

397
.PHONY: podman
398
podman: bin/podman
399

400
# This will map to the right thing on Linux, Windows, and Mac.
401
.PHONY: podman-remote
402
podman-remote: $(SRCBINDIR)/podman$(BINSFX)
403

404
$(SRCBINDIR)/quadlet: $(SOURCES) go.mod go.sum
405
	$(GOCMD) build \
406
		$(BUILDFLAGS) \
407
		$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
408
		-tags "${BUILDTAGS}" \
409
		-o $@ ./cmd/quadlet
410

411
.PHONY: quadlet
412
quadlet: bin/quadlet
413

414
.PHONY: podman-remote-static podman-remote-static-linux_amd64 podman-remote-static-linux_arm64
415
podman-remote-static: $(SRCBINDIR)/podman-remote-static
416
podman-remote-static-linux_amd64: $(SRCBINDIR)/podman-remote-static-linux_amd64
417
podman-remote-static-linux_arm64: $(SRCBINDIR)/podman-remote-static-linux_arm64
418

419
.PHONY: podman-winpath
420
podman-winpath: $(SOURCES) go.mod go.sum
421
	CGO_ENABLED=0 \
422
		GOOS=windows \
423
		$(GO) build \
424
		$(BUILDFLAGS) \
425
		-ldflags -H=windowsgui \
426
		-o bin/windows/winpath.exe \
427
		./cmd/winpath
428

429
.PHONY: podman-mac-helper
430
podman-mac-helper: ## Build podman-mac-helper for macOS
431
	CGO_ENABLED=0 \
432
		GOOS=darwin \
433
		GOARCH=$(GOARCH) \
434
		$(GO) build \
435
		$(BUILDFLAGS) \
436
		-o bin/darwin/podman-mac-helper \
437
		./cmd/podman-mac-helper
438

439
bin/rootlessport: $(SOURCES) go.mod go.sum
440
	CGO_ENABLED=$(CGO_ENABLED) \
441
		$(GO) build \
442
		$(BUILDFLAGS) \
443
		-o $@ ./cmd/rootlessport
444

445
.PHONY: rootlessport
446
rootlessport: bin/rootlessport
447

448
# podmansh calls `podman exec` into the `podmansh` container when used as
449
# os.Args[0] and is intended to be set as a login shell for users.
450
# Run: `man 1 podmansh` for details.
451
podmansh: bin/podman
452
	if [ ! -f bin/podmansh ]; then ln -s podman bin/podmansh; fi
453

454
###
455
### Secondary binary-build targets
456
###
457

458
.PHONY: generate-bindings
459
generate-bindings:
460
ifneq ($(GOOS),darwin)
461
	$(GOCMD) generate ./pkg/bindings/... ;
462
endif
463

464
# DO NOT USE: use local-cross instead
465
bin/podman.cross.%:
466
	TARGET="$*"; \
467
	GOOS="$${TARGET%%.*}"; \
468
	GOARCH="$${TARGET##*.}"; \
469
	CGO_ENABLED=0 \
470
		$(GO) build \
471
		$(BUILDFLAGS) \
472
		$(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
473
		-tags '$(BUILDTAGS_CROSS)' \
474
		-o "$@" ./cmd/podman
475

476
.PHONY: local-cross
477
local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures
478

479
.PHONY: cross
480
cross: local-cross
481

482
.PHONY: completions
483
completions: podman podman-remote
484
	# key = shell, value = completion filename
485
	declare -A outfiles=([bash]=%s [zsh]=_%s [fish]=%s.fish [powershell]=%s.ps1);\
486
	for shell in $${!outfiles[*]}; do \
487
	    for remote in "" "-remote"; do \
488
		podman="podman$$remote"; \
489
		outfile=$$(printf "completions/$$shell/$${outfiles[$$shell]}" $$podman); \
490
		./bin/$$podman completion $$shell >| $$outfile; \
491
	    done;\
492
	done
493

494
###
495
### Documentation targets
496
###
497

498
pkg/api/swagger.yaml: .install.swagger
499
	make -C pkg/api
500

501
$(MANPAGES_MD_GENERATED): %.md: %.md.in $(MANPAGES_SOURCE_DIR)/options/*.md
502
	hack/markdown-preprocess
503

504
$(MANPAGES): OUTFILE=$(subst source/markdown,build/man,$@)
505
$(MANPAGES): %: %.md .install.md2man docdir
506

507
# This does a bunch of filtering needed for man pages:
508
#  1. Strip markdown link targets like '[podman(1)](podman.1.md)'
509
#     to just '[podman(1)]', because man pages have no link mechanism;
510
#  2. Then remove the brackets: '[podman(1)]' -> 'podman(1)';
511
#  3. Then do the same for all other markdown links,
512
#     like '[cgroups(7)](https://.....)'  -> just 'cgroups(7)';
513
#  4. Remove HTML-ish stuff like '<sup>..</sup>' and '<a>..</a>'
514
#  5. Replace "\" (backslash) at EOL with two spaces (no idea why)
515
# Then two sanity checks:
516
#  1. test for "included file options/blahblah"; this indicates a failure
517
#     in the markdown-preprocess tool; and
518
#  2. run 'man -l' against the generated man page, and check for tables
519
#     with an empty right-hand column followed by an empty left-hand
520
#     column on the next line. (Technically, on the next-next line,
521
#     because the next line must be table borders). This is a horrible
522
#     unmaintainable rats-nest of duplication, obscure grep options, and
523
#     ASCII art. I (esm) believe the cost of releasing corrupt man pages
524
#     is higher than the cost of carrying this kludge.
525
#
526
	@$(SED) -e 's/\((podman[^)]*\.md\(#.*\)\?)\)//g'    \
527
	       -e 's/\[\(podman[^]]*\)\]/\1/g'              \
528
	       -e 's/\[\([^]]*\)](http[^)]\+)/\1/g'         \
529
	       -e 's;<\(/\)\?\(a\|a\s\+[^>]*\|sup\)>;;g'    \
530
	       -e 's/\\$$/  /g' $<                         |\
531
	$(GOMD2MAN) -out $(OUTFILE)
532
	@if grep 'included file options/' $(OUTFILE); then \
533
		echo "FATAL: man pages must not contain ^^^^ in $(OUTFILE)"; exit 1; \
534
	fi
535
	@if $(MAN_L) $(OUTFILE)| $(GREP) -Pazoq '│\s+│\n\s+├─+┼─+┤\n\s+│\s+│'; then  \
536
		echo "FATAL: $< has a too-long table column; use 'man -l $(OUTFILE)' and look for empty table cells."; exit 1; \
537
	fi
538

539
.PHONY: docdir
540
docdir:
541
	mkdir -p docs/build/man
542

543
.PHONY: docs
544
docs: $(MANPAGES) ## Generate documentation
545
	@ln -sf $(CURDIR)/docs/source/markdown/links/* docs/build/man/
546

547
# docs/remote-docs.sh requires a locally executable 'podman-remote' binary
548
# in addition to the target-architecture binary (if different). That's
549
# what the NATIVE_GOOS make does in the first line.
550
podman-remote-%-docs: podman-remote
551
	$(MAKE) clean-binaries
552
	$(MAKE) podman-remote GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH)
553
	$(eval GOOS := $*)
554
	$(MAKE) docs $(MANPAGES)
555
	rm -rf docs/build/remote
556
	mkdir -p docs/build/remote
557
	ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/
558
	docs/remote-docs.sh \
559
		$(GOOS) \
560
		docs/build/remote/$* \
561
		$(if $(findstring windows,$*),docs/source/markdown,docs/build/man)
562

563
.PHONY: man-page-check
564
man-page-check: bin/podman docs
565
	hack/man-page-checker
566
	hack/xref-helpmsgs-manpages
567
	hack/man-page-table-check
568
	hack/xref-quadlet-docs
569

570
.PHONY: swagger-check
571
swagger-check:
572
	hack/swagger-check
573

574
.PHONY: swagger
575
swagger: pkg/api/swagger.yaml
576

577
.PHONY: docker-docs
578
docker-docs: docs
579
	(cd docs; ./dckrman.sh ./build/man/*.1)
580

581
# Workaround vim syntax highlighting bug: "
582

583
###
584
### Utility and Testing targets
585
###
586

587
.PHONY: validate.completions
588
validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target
589
validate.completions:
590
	# Check if the files can be loaded by the shell
591
	. completions/bash/podman
592
	if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi
593
	if [ -x /bin/fish ]; then /bin/fish completions/fish/podman.fish; fi
594

595
# Note: Assumes test/python/requirements.txt is installed & available
596
.PHONY: run-docker-py-tests
597
run-docker-py-tests:
598
	touch test/__init__.py
599
	env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf pytest --disable-warnings test/python/docker/
600
	rm -f test/__init__.py
601

602
.PHONY: localunit
603
localunit: test/goecho/goecho test/version/version
604
	rm -rf ${COVERAGE_PATH} && mkdir -p ${COVERAGE_PATH}
605
	UNIT=1 $(GINKGO) \
606
		-r \
607
		$(TESTFLAGS) \
608
		--skip-package test/e2e,pkg/bindings,hack,pkg/machine/e2e \
609
		--cover \
610
		--covermode atomic \
611
		--coverprofile coverprofile \
612
		--output-dir ${COVERAGE_PATH} \
613
		--tags "$(BUILDTAGS)" \
614
		--succinct
615
	$(GO) tool cover -html=${COVERAGE_PATH}/coverprofile -o ${COVERAGE_PATH}/coverage.html
616
	$(GO) tool cover -func=${COVERAGE_PATH}/coverprofile > ${COVERAGE_PATH}/functions
617
	cat ${COVERAGE_PATH}/functions | sed -n 's/\(total:\).*\([0-9][0-9].[0-9]\)/\1 \2/p'
618

619
.PHONY: test
620
test: localunit localintegration remoteintegration localsystem remotesystem  ## Run unit, integration, and system tests.
621

622
.PHONY: ginkgo-run
623
ginkgo-run: .install.ginkgo
624
	$(GINKGO) version
625
	$(GINKGO) -vv $(TESTFLAGS) --tags "$(TAGS) remote" $(GINKGOTIMEOUT) --flake-attempts $(GINKGO_FLAKE_ATTEMPTS) \
626
		--trace $(if $(findstring y,$(GINKGO_NO_COLOR)),--no-color,) \
627
		$(GINKGO_JSON) $(if $(findstring y,$(GINKGO_PARALLEL)),-p,) $(if $(FOCUS),--focus "$(FOCUS)",) \
628
		$(if $(FOCUS_FILE),--focus-file "$(FOCUS_FILE)",) $(GINKGOWHAT) $(HACK)
629

630
.PHONY: ginkgo
631
ginkgo:
632
	$(MAKE) ginkgo-run TAGS="$(BUILDTAGS)" HACK=hack/.
633

634
.PHONY: ginkgo-remote
635
ginkgo-remote:
636
	$(MAKE) ginkgo-run TAGS="$(REMOTETAGS) remote_testing" HACK=
637

638
.PHONY: testbindings
639
testbindings: .install.ginkgo
640
	$(GINKGO) -v $(TESTFLAGS) --tags "$(TAGS) remote" $(GINKGOTIMEOUT) --trace --no-color --timeout 30m  -v -r ./pkg/bindings/test
641

642
.PHONY: localintegration
643
localintegration: test-binaries ginkgo
644

645
.PHONY: remoteintegration
646
remoteintegration: test-binaries ginkgo-remote
647

648
.PHONY: localmachine
649
localmachine:
650
	# gitCommit needed by logformatter, to link to sources
651
	@echo /define.gitCommit=$(GIT_COMMIT)
652
	$(MAKE) ginkgo-run GINKGO_PARALLEL=n TAGS="$(REMOTETAGS)" GINKGO_FLAKE_ATTEMPTS=0 FOCUS_FILE=$(FOCUS_FILE) GINKGOWHAT=pkg/machine/e2e/. HACK=
653

654
.PHONY: localsystem
655
localsystem:
656
	# Wipe existing config, database, and cache: start with clean slate.
657
	$(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers
658
	if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman QUADLET=$(CURDIR)/bin/quadlet bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi
659

660
.PHONY: remotesystem
661
remotesystem:
662
	# Wipe existing config, database, and cache: start with clean slate.
663
	$(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers
664
	# Start podman server using tmp socket; loop-wait for it;
665
	# test podman-remote; kill server, clean up tmp socket file.
666
	# podman server spews copious unhelpful output; ignore it.
667
	rc=0;\
668
	if timeout -v 1 true; then \
669
		SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman_tmp_XXXX);\
670
		export PODMAN_SOCKET=unix://$$SOCK_FILE; \
671
		./bin/podman system service --timeout=0 $$PODMAN_SOCKET > $(if $(PODMAN_SERVER_LOG),$(PODMAN_SERVER_LOG),/dev/null) 2>&1 & \
672
		retry=5;\
673
		while [ $$retry -ge 0 ]; do\
674
			echo Waiting for server...;\
675
			sleep 1;\
676
			./bin/podman-remote --url $$PODMAN_SOCKET info >/dev/null 2>&1 && break;\
677
			retry=$$(expr $$retry - 1);\
678
		done;\
679
		if [ $$retry -lt 0 ]; then\
680
			echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\
681
			exit 1;\
682
		fi;\
683
		env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\
684
		rc=$$?;\
685
		kill %1;\
686
		rm -f $$SOCK_FILE;\
687
	else \
688
		echo "Skipping $@: 'timeout -v' unavailable'";\
689
	fi;\
690
	exit $$rc
691

692
.PHONY: localapiv2-bash
693
localapiv2-bash:
694
	env PODMAN=./bin/podman stdbuf -o0 -e0 ./test/apiv2/test-apiv2
695

696
.PHONY: localapiv2-python
697
localapiv2-python:
698
	env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
699
		pytest --verbose --disable-warnings ./test/apiv2/python
700
	touch test/__init__.py
701
	env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
702
		pytest --verbose --disable-warnings ./test/python/docker
703
	rm -f test/__init__.py
704

705
# Order is important running python tests first causes the bash tests
706
# to fail, see 12-imagesMore.  FIXME order of tests should not matter
707
.PHONY: localapiv2
708
localapiv2: localapiv2-bash localapiv2-python
709

710
.PHONY: remoteapiv2
711
remoteapiv2:
712
	true
713

714
.PHONY: system.test-binary
715
system.test-binary: .install.ginkgo
716
	$(GO) test -c ./test/system
717

718
.PHONY: test-binaries
719
test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho install.catatonit test/version/version
720
	@echo "Canonical source version: $(call err_if_empty,RELEASE_VERSION)"
721

722
.PHONY: tests-included
723
tests-included:
724
	contrib/cirrus/pr-should-include-tests
725

726
.PHONY: tests-expect-exit
727
tests-expect-exit:
728
	@if grep -E --line-number 'Expect.*ExitCode' test/e2e/*.go | grep -E -v ', ".*"\)'; then \
729
		echo "^^^ Unhelpful use of Expect(ExitCode())"; \
730
		echo "   Please use '.Should(Exit(...))' pattern instead."; \
731
		echo "   If that's not possible, please add an annotation (description) to your assertion:"; \
732
		echo "        Expect(...).To(..., \"Friendly explanation of this check\")"; \
733
		exit 1; \
734
	fi
735

736
.PHONY: pr-removes-fixed-skips
737
pr-removes-fixed-skips:
738
	contrib/cirrus/pr-removes-fixed-skips
739

740
###
741
### Release/Packaging targets
742
###
743

744
.PHONY: podman-release
745
podman-release: podman-release-$(GOARCH).tar.gz  # Build all Linux binaries for $GOARCH, docs., and installation tree, into a tarball.
746

747
# The following two targets are nuanced and complex:
748
# Cross-building the podman-remote documentation requires a functional
749
# native architecture executable.  However `make` only deals with
750
# files/timestamps, it doesn't understand if an existing binary will
751
# function on the system or not.  This makes building cross-platform
752
# releases incredibly accident-prone and fragile.  The only practical
753
# way to deal with this, is via multiple conditional (nested) `make`
754
# calls along with careful manipulation of `$GOOS` and `$GOARCH`.
755

756
podman-release-%.tar.gz: test/version/version
757
	$(eval tmpsubdir := $(shell mktemp -d podman_tmp_XXXX))
758
	$(eval releasedir := podman-v$(call err_if_empty,RELEASE_NUMBER))
759
	$(eval _dstargs := "DESTDIR=$(tmpsubdir)/$(releasedir)" "PREFIX=$(RELEASE_PREFIX)")
760
	$(eval GOARCH := $*)
761
	mkdir -p "$(call err_if_empty,tmpsubdir)/$(releasedir)"
762
	$(MAKE) GOOS=$(GOOS) GOARCH=$(NATIVE_GOARCH) \
763
		clean-binaries docs podman-remote-$(GOOS)-docs
764
	if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then \
765
		$(MAKE) CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \
766
			BUILDTAGS="$(BUILDTAGS_CROSS)" clean-binaries binaries; \
767
	else \
768
		$(MAKE) GOOS=$(GOOS) GOARCH=$(GOARCH) binaries; \
769
	fi
770
	$(MAKE) $(_dstargs) install.bin install.remote install.man install.systemd
771
	tar -czvf $@ --xattrs -C "$(tmpsubdir)" "./$(releasedir)"
772
	if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then $(MAKE) clean-binaries; fi
773
	-rm -rf "$(tmpsubdir)"
774

775
podman-remote-release-%.zip: test/version/version ## Build podman-remote for %=$GOOS_$GOARCH, and docs. into an installation zip.
776
	$(eval tmpsubdir := $(shell mktemp -d podman_tmp_XXXX))
777
	$(eval releasedir := podman-$(call err_if_empty,RELEASE_NUMBER))
778
	$(eval _dstargs := "DESTDIR=$(tmpsubdir)/$(releasedir)" "PREFIX=$(RELEASE_PREFIX)")
779
	$(eval GOOS := $(firstword $(subst _, ,$*)))
780
	$(eval GOARCH := $(lastword $(subst _, ,$*)))
781
	$(eval _GOPLAT := GOOS=$(call err_if_empty,GOOS) GOARCH=$(call err_if_empty,GOARCH))
782
	mkdir -p "$(call err_if_empty,tmpsubdir)/$(releasedir)"
783
	$(MAKE) GOOS=$(GOOS) GOARCH=$(GOARCH) \
784
		clean-binaries podman-remote-$(GOOS)-docs
785
	if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then \
786
		$(MAKE) CGO_ENABLED=0 $(GOPLAT) BUILDTAGS="$(BUILDTAGS_CROSS)" \
787
			clean-binaries podman-remote; \
788
	else \
789
		$(MAKE) $(GOPLAT) podman-remote; \
790
	fi
791
	if [[ "$(GOOS)" == "windows" ]]; then \
792
		$(MAKE) $(GOPLAT) TMPDIR="" win-gvproxy; \
793
	fi
794
	if [[ "$(GOOS)" == "darwin" ]]; then \
795
		$(MAKE) $(GOPLAT) podman-mac-helper;\
796
	fi
797
	cp -r ./docs/build/remote/$(GOOS) "$(tmpsubdir)/$(releasedir)/docs/"
798
	cp ./contrib/remote/containers.conf "$(tmpsubdir)/$(releasedir)/"
799
	$(MAKE) $(GOPLAT) $(_dstargs) SELINUXOPT="" install.remote
800
	cd "$(tmpsubdir)" && \
801
		zip --recurse-paths "$(CURDIR)/$@" "./$(releasedir)"
802
	if [[ "$(GOARCH)" != "$(NATIVE_GOARCH)" ]]; then $(MAKE) clean-binaries; fi
803
	-rm -rf "$(tmpsubdir)"
804

805
# Checks out and builds win-sshproxy helper. See comment on GV_GITURL declaration
806
.PHONY: win-gvproxy
807
win-gvproxy: test/version/version
808
	mkdir -p bin/windows/
809
	curl -sSL -o bin/windows/gvproxy.exe --retry 5 https://github.com/containers/gvisor-tap-vsock/releases/download/$(GV_VERSION)/gvproxy-windowsgui.exe
810
	curl -sSL -o bin/windows/win-sshproxy.exe --retry 5 https://github.com/containers/gvisor-tap-vsock/releases/download/$(GV_VERSION)/win-sshproxy.exe
811

812
.PHONY: rpm
813
rpm:  ## Build rpm packages
814
	$(MAKE) -C rpm
815

816
###
817
### Installation targets
818
###
819

820
# Remember that rpms install exec to /usr/bin/podman while a `make install`
821
# installs them to /usr/local/bin/podman which is likely before. Always use
822
# a full path to test installed podman or you risk to call another executable.
823
.PHONY: rpm-install
824
rpm-install: package  ## Install rpm packages
825
	$(call err_if_empty,PKG_MANAGER) -y install rpm/RPMS/*/*.rpm
826
	/usr/bin/podman version
827
	/usr/bin/podman info  # will catch a broken conmon
828

829
.PHONY: install
830
install: install.bin install.remote install.man install.systemd  ## Install binaries to system locations
831

832
.PHONY: install.catatonit
833
install.catatonit:
834
	./hack/install_catatonit.sh
835

836
.PHONY: install.remote
837
install.remote:
838
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
839
	install ${SELINUXOPT} -m 755 $(SRCBINDIR)/podman$(BINSFX) \
840
		$(DESTDIR)$(BINDIR)/podman$(BINSFX)
841
	test "${GOOS}" != "windows" || \
842
		install -m 755 $(SRCBINDIR)/win-sshproxy.exe $(DESTDIR)$(BINDIR)
843
	test "${GOOS}" != "windows" || \
844
		install -m 755 $(SRCBINDIR)/gvproxy.exe $(DESTDIR)$(BINDIR)
845
	test "${GOOS}" != "darwin" || \
846
		install -m 755 $(SRCBINDIR)/podman-mac-helper $(DESTDIR)$(BINDIR)
847
	test -z "${SELINUXOPT}" || \
848
		chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote \
849
		bin/podman-remote
850

851
.PHONY: install.bin
852
install.bin:
853
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
854
	install ${SELINUXOPT} -m 755 bin/podman $(DESTDIR)$(BINDIR)/podman
855
	ln -sf podman $(DESTDIR)$(BINDIR)/podmansh
856
	test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman bin/podman
857
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(LIBEXECPODMAN)
858
ifneq ($(shell uname -s),FreeBSD)
859
	install ${SELINUXOPT} -m 755 bin/rootlessport $(DESTDIR)$(LIBEXECPODMAN)/rootlessport
860
	test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(LIBEXECPODMAN)/rootlessport bin/rootlessport
861
	install ${SELINUXOPT} -m 755 bin/quadlet $(DESTDIR)$(LIBEXECPODMAN)/quadlet
862
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(SYSTEMDGENERATORSDIR)
863
	ln -sfr $(DESTDIR)$(LIBEXECPODMAN)/quadlet $(DESTDIR)$(SYSTEMDGENERATORSDIR)/podman-system-generator
864
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(USERSYSTEMDGENERATORSDIR)
865
	ln -sfr $(DESTDIR)$(LIBEXECPODMAN)/quadlet $(DESTDIR)$(USERSYSTEMDGENERATORSDIR)/podman-user-generator
866
	install ${SELINUXOPT} -m 755 -d $(DESTDIR)${TMPFILESDIR}
867
	install ${SELINUXOPT} -m 644 contrib/tmpfile/podman.conf $(DESTDIR)${TMPFILESDIR}/podman.conf
868
endif
869

870
.PHONY: install.modules-load
871
install.modules-load: # This should only be used by distros which might use iptables-legacy, this is not needed on RHEL
872
	install ${SELINUXOPT} -m 755 -d $(DESTDIR)${MODULESLOADDIR}
873
	install ${SELINUXOPT} -m 644 contrib/modules-load.d/podman-iptables.conf $(DESTDIR)${MODULESLOADDIR}/podman-iptables.conf
874

875
.PHONY: install.man
876
install.man:
877
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1
878
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man5
879
	install ${SELINUXOPT} -m 644 $(filter %.1,$(MANPAGES_DEST)) $(DESTDIR)$(MANDIR)/man1
880
	install ${SELINUXOPT} -m 644 docs/source/markdown/links/*1 $(DESTDIR)$(MANDIR)/man1
881
	install ${SELINUXOPT} -m 644 $(filter %.5,$(MANPAGES_DEST)) $(DESTDIR)$(MANDIR)/man5
882
	install ${SELINUXOPT} -m 644 docs/source/markdown/links/*5 $(DESTDIR)$(MANDIR)/man5
883

884
.PHONY: install.completions
885
install.completions:
886
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)${BASHINSTALLDIR}
887
	install ${SELINUXOPT} -m 644 completions/bash/podman $(DESTDIR)${BASHINSTALLDIR}
888
	install ${SELINUXOPT} -m 644 completions/bash/podman-remote $(DESTDIR)${BASHINSTALLDIR}
889
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)${ZSHINSTALLDIR}
890
	install ${SELINUXOPT} -m 644 completions/zsh/_podman $(DESTDIR)${ZSHINSTALLDIR}
891
	install ${SELINUXOPT} -m 644 completions/zsh/_podman-remote $(DESTDIR)${ZSHINSTALLDIR}
892
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)${FISHINSTALLDIR}
893
	install ${SELINUXOPT} -m 644 completions/fish/podman.fish $(DESTDIR)${FISHINSTALLDIR}
894
	install ${SELINUXOPT} -m 644 completions/fish/podman-remote.fish $(DESTDIR)${FISHINSTALLDIR}
895
	# There is no common location for powershell files so do not install them. Users have to source the file from their powershell profile.
896

897
.PHONY: install.docker
898
install.docker:
899
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
900
	$(eval INTERPOLATED_DOCKER_SCRIPT := $(shell mktemp))
901
	env BINDIR=${BINDIR} ETCDIR=${ETCDIR} envsubst < docker/docker.in > ${INTERPOLATED_DOCKER_SCRIPT}
902
	install ${SELINUXOPT} -m 755 ${INTERPOLATED_DOCKER_SCRIPT} $(DESTDIR)$(BINDIR)/docker
903
	rm ${INTERPOLATED_DOCKER_SCRIPT}
904
	install ${SELINUXOPT} -m 755 -d $(DESTDIR)${SYSTEMDDIR}  $(DESTDIR)${USERSYSTEMDDIR} $(DESTDIR)${TMPFILESDIR} $(DESTDIR)${USERTMPFILESDIR}
905
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)${ETCDIR}/profile.d
906
	install ${SELINUXOPT} -m 644 docker/podman-docker.sh $(DESTDIR)${ETCDIR}/profile.d/podman-docker.sh
907
	install ${SELINUXOPT} -m 644 docker/podman-docker.csh $(DESTDIR)${ETCDIR}/profile.d/podman-docker.csh
908
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-docker.conf -t $(DESTDIR)${TMPFILESDIR}
909
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-docker.conf -t $(DESTDIR)${USERTMPFILESDIR}
910

911
.PHONY: install.docker-docs
912
install.docker-docs:
913
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man1
914
	install ${SELINUXOPT} -m 644 docs/build/man/docker*.1 -t $(DESTDIR)$(MANDIR)/man1
915
	install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(MANDIR)/man5
916
	install ${SELINUXOPT} -m 644 docs/build/man/docker*.5 -t $(DESTDIR)$(MANDIR)/man5
917

918
.PHONY: install.docker-full
919
install.docker-full: install.docker install.docker-docs
920

921
.PHONY: install.systemd
922
ifneq (,$(findstring systemd,$(BUILDTAGS)))
923
PODMAN_UNIT_FILES = contrib/systemd/auto-update/podman-auto-update.service \
924
		    contrib/systemd/system/podman.service \
925
		    contrib/systemd/system/podman-restart.service \
926
		    contrib/systemd/system/podman-kube@.service \
927
		    contrib/systemd/system/podman-clean-transient.service
928

929
%.service: %.service.in
930
	sed -e 's;@@PODMAN@@;$(BINDIR)/podman;g' $< >$@.tmp.$$ \
931
		&& mv -f $@.tmp.$$ $@
932

933
install.systemd: $(PODMAN_UNIT_FILES)
934
	install ${SELINUXOPT} -m 755 -d $(DESTDIR)${SYSTEMDDIR}  $(DESTDIR)${USERSYSTEMDDIR}
935
	# User services
936
	install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service $(DESTDIR)${USERSYSTEMDDIR}/podman-auto-update.service
937
	install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer $(DESTDIR)${USERSYSTEMDDIR}/podman-auto-update.timer
938
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket $(DESTDIR)${USERSYSTEMDDIR}/podman.socket
939
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service $(DESTDIR)${USERSYSTEMDDIR}/podman.service
940
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service $(DESTDIR)${USERSYSTEMDDIR}/podman-restart.service
941
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-kube@.service $(DESTDIR)${USERSYSTEMDDIR}/podman-kube@.service
942
	# System services
943
	install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service $(DESTDIR)${SYSTEMDDIR}/podman-auto-update.service
944
	install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer $(DESTDIR)${SYSTEMDDIR}/podman-auto-update.timer
945
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket $(DESTDIR)${SYSTEMDDIR}/podman.socket
946
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service $(DESTDIR)${SYSTEMDDIR}/podman.service
947
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service $(DESTDIR)${SYSTEMDDIR}/podman-restart.service
948
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-kube@.service $(DESTDIR)${SYSTEMDDIR}/podman-kube@.service
949
	install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-clean-transient.service $(DESTDIR)${SYSTEMDDIR}/podman-clean-transient.service
950
	rm -f $(PODMAN_UNIT_FILES)
951
else
952
install.systemd:
953
endif
954

955
.PHONY: install.tools
956
install.tools: .install.golangci-lint ## Install needed tools
957
	$(MAKE) -C test/tools
958

959
.PHONY: .install.goimports
960
.install.goimports:
961
	$(MAKE) -C test/tools build/goimports
962

963
.PHONY: .install.ginkgo
964
.install.ginkgo:
965
	$(MAKE) -C test/tools build/ginkgo
966

967
.PHONY: .install.gitvalidation
968
.install.gitvalidation:
969
	$(MAKE) -C test/tools build/git-validation
970

971
.PHONY: .install.golangci-lint
972
.install.golangci-lint:
973
	VERSION=$(GOLANGCI_LINT_VERSION) ./hack/install_golangci.sh
974

975
.PHONY: .install.swagger
976
.install.swagger:
977
	$(MAKE) -C test/tools build/swagger
978

979
.PHONY: .install.md2man
980
.install.md2man:
981
	if [ ! -x "$(GOMD2MAN)" ]; then \
982
		$(MAKE) -C test/tools build/go-md2man GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH); \
983
	fi
984

985
.PHONY: .install.pre-commit
986
.install.pre-commit:
987
	if [ -z "$(PRE_COMMIT)" ]; then \
988
		$(PYTHON) -m pip install --user pre-commit; \
989
	fi
990

991
.PHONY: release-artifacts
992
release-artifacts: clean-binaries
993
	mkdir -p release/
994
	$(MAKE) podman-remote-release-darwin_amd64.zip
995
	mv podman-remote-release-darwin_amd64.zip release/
996
	$(MAKE) podman-remote-release-darwin_arm64.zip
997
	mv podman-remote-release-darwin_arm64.zip release/
998
	$(MAKE) podman-remote-release-windows_amd64.zip
999
	mv podman-remote-release-windows_amd64.zip release/
1000
	$(MAKE) podman-remote-static-linux_amd64
1001
	tar -cvzf podman-remote-static-linux_amd64.tar.gz bin/podman-remote-static-linux_amd64
1002
	$(MAKE) podman-remote-static-linux_arm64
1003
	tar -cvzf podman-remote-static-linux_arm64.tar.gz bin/podman-remote-static-linux_arm64
1004
	mv podman-remote-static-linux*.tar.gz release/
1005
	cd release/; sha256sum *.zip *.tar.gz > shasums
1006

1007
.PHONY: uninstall
1008
uninstall:
1009
	for i in $(filter %.1,$(MANPAGES_DEST)); do \
1010
		rm -f $(DESTDIR)$(MANDIR)/man1/$$(basename $${i}); \
1011
	done; \
1012
	for i in $(filter %.5,$(MANPAGES_DEST)); do \
1013
		rm -f $(DESTDIR)$(MANDIR)/man5/$$(basename $${i}); \
1014
	done
1015
	# Remove podman and remote bin
1016
	rm -f $(DESTDIR)$(BINDIR)/podman
1017
	rm -f $(DESTDIR)$(BINDIR)/podman-remote
1018
	# Remove related config files
1019
	rm -f $(DESTDIR)${ETCDIR}/cni/net.d/87-podman-bridge.conflist
1020
	rm -f $(DESTDIR)${TMPFILESDIR}/podman.conf
1021
	rm -f $(DESTDIR)${SYSTEMDDIR}/io.podman.socket
1022
	rm -f $(DESTDIR)${USERSYSTEMDDIR}/io.podman.socket
1023
	rm -f $(DESTDIR)${SYSTEMDDIR}/io.podman.service
1024
	rm -f $(DESTDIR)${SYSTEMDDIR}/podman.service
1025
	rm -f $(DESTDIR)${SYSTEMDDIR}/podman.socket
1026
	rm -f $(DESTDIR)${USERSYSTEMDDIR}/podman.socket
1027
	rm -f $(DESTDIR)${USERSYSTEMDDIR}/podman.service
1028

1029
.PHONY: clean-binaries
1030
clean-binaries: ## Remove platform/architecture specific binary files
1031
	rm -rf \
1032
		bin
1033

1034
.PHONY: clean
1035
clean: clean-binaries ## Clean all make artifacts
1036
	rm -rf \
1037
		_output \
1038
		$(wildcard podman-*.msi) \
1039
		$(wildcard podman-remote*.zip) \
1040
		$(wildcard podman_tmp_*) \
1041
		$(wildcard podman*.tar.gz) \
1042
		build \
1043
		test/checkseccomp/checkseccomp \
1044
		test/goecho/goecho \
1045
		test/version/version \
1046
		test/__init__.py \
1047
		test/testdata/redis-image \
1048
		libpod/container_ffjson.go \
1049
		libpod/pod_ffjson.go \
1050
		libpod/container_easyjson.go \
1051
		libpod/pod_easyjson.go \
1052
		docs/build \
1053
		.venv
1054
	make -C docs clean
1055

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.