Debian Codegraph @

Makefile

raw symbols SCIP
1 # Copyright The containerd Authors.
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 # Go command to use for build
17 GO ?= go
18 INSTALL ?= install
19
20 # Root directory of the project (absolute path).
21 ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
22
23 # Base path used to install.
24 # The files will be installed under `$(DESTDIR)/$(PREFIX)`.
25 # The convention of `DESTDIR` was changed in containerd v1.6.
26 PREFIX ?= /usr/local
27 BINDIR ?= $(PREFIX)/bin
28 DATADIR ?= $(PREFIX)/share
29 DOCDIR ?= $(DATADIR)/doc
30 MANDIR ?= $(DATADIR)/man
31
32 TEST_IMAGE_LIST ?=
33
34 # Used to populate variables in version package.
35 VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
36 REVISION ?= $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
37 PACKAGE=github.com/containerd/containerd/v2
38 SHIM_CGO_ENABLED ?= 0
39
40 ifneq "$(strip $(shell command -v $(GO) 2>/dev/null))" ""
41 GOOS ?= $(shell $(GO) env GOOS)
42 GOARCH ?= $(shell $(GO) env GOARCH)
43 else
44 ifeq ($(GOOS),)
45 # approximate GOOS for the platform if we don't have Go and GOOS isn't
46 # set. We leave GOARCH unset, so that may need to be fixed.
47 ifeq ($(OS),Windows_NT)
48 GOOS = windows
49 else
50 UNAME_S := $(shell uname -s)
51 ifeq ($(UNAME_S),Linux)
52 GOOS = linux
53 endif
54 ifeq ($(UNAME_S),Darwin)
55 GOOS = darwin
56 endif
57 ifeq ($(UNAME_S),FreeBSD)
58 GOOS = freebsd
59 endif
60 endif
61 else
62 GOOS ?= $$GOOS
63 GOARCH ?= $$GOARCH
64 endif
65 endif
66
67 ifndef GODEBUG
68 EXTRA_LDFLAGS += -s -w
69 DEBUG_GO_GCFLAGS :=
70 DEBUG_TAGS :=
71 else
72 DEBUG_GO_GCFLAGS := -gcflags=all="-N -l"
73 DEBUG_TAGS := static_build
74 endif
75
76 WHALE = "🇩"
77 ONI = "👹"
78
79 RELEASE=containerd-$(VERSION:v%=%)-${GOOS}-${GOARCH}
80 STATICRELEASE=containerd-static-$(VERSION:v%=%)-${GOOS}-${GOARCH}
81 CRIRELEASE=cri-containerd-$(VERSION:v%=%)-${GOOS}-${GOARCH}
82 CRICNIRELEASE=cri-containerd-cni-$(VERSION:v%=%)-${GOOS}-${GOARCH}
83
84 PKG=github.com/containerd/containerd/v2
85
86 # Project binaries.
87 COMMANDS=ctr containerd containerd-stress
88 MANPAGES=ctr.8 containerd.8 containerd-config.8 containerd-config.toml.5
89
90 ifdef BUILDTAGS
91 GO_BUILDTAGS = ${BUILDTAGS}
92 endif
93 GO_BUILDTAGS ?=
94 GO_BUILDTAGS += urfave_cli_no_docs
95 GO_BUILDTAGS += ${DEBUG_TAGS}
96 ifneq ($(STATIC),)
97 GO_BUILDTAGS += osusergo netgo static_build
98 endif
99
100 SHIM_GO_BUILDTAGS := $(GO_BUILDTAGS) no_grpc
101
102 GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",)
103 SHIM_GO_TAGS=$(if $(SHIM_GO_BUILDTAGS),-tags "$(strip $(SHIM_GO_BUILDTAGS))",)
104
105 GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS)
106 ifneq ($(STATIC),)
107 GO_LDFLAGS += -extldflags "-static"
108 endif
109 GO_LDFLAGS+='
110
111 SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)'
112
113 # Project packages.
114 PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration)
115 API_PACKAGES=$(shell (cd api && $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration))
116 TEST_REQUIRES_ROOT_PACKAGES=$(filter \
117 ${PACKAGES}, \
118 $(shell \
119 for f in $$(git grep -l testutil.RequiresRoot | grep -v Makefile); do \
120 d="$$(dirname $$f)"; \
121 [ "$$d" = "." ] && echo "${PKG}" && continue; \
122 echo "${PKG}/$$d"; \
123 done | sort -u) \
124 )
125
126 ifdef SKIPTESTS
127 PACKAGES:=$(filter-out ${SKIPTESTS},${PACKAGES})
128 TEST_REQUIRES_ROOT_PACKAGES:=$(filter-out ${SKIPTESTS},${TEST_REQUIRES_ROOT_PACKAGES})
129 endif
130
131 #Replaces ":" (*nix), ";" (windows) with newline for easy parsing
132 GOPATHS=$(shell $(GO) env GOPATH | tr ":" "\n" | tr ";" "\n")
133
134 TESTFLAGS_RACE=
135 GO_BUILD_FLAGS ?=
136 # See Golang issue re: '-trimpath': https://github.com/golang/go/issues/13809
137 GO_GCFLAGS=$(shell \
138 set -- ${GOPATHS}; \
139 echo "-gcflags=-trimpath=$${1}/src"; \
140 )
141
142 BINARIES=$(addprefix bin/,$(COMMANDS))
143
144 #include platform specific makefile
145 -include Makefile.$(GOOS)
146
147 # Flags passed to `go test`
148 TESTFLAGS ?= $(TESTFLAGS_RACE) $(EXTRA_TESTFLAGS)
149 TESTFLAGS_PARALLEL ?= 8
150
151 # Use this to replace `go test` with, for instance, `gotestsum`
152 GOTEST ?= $(GO) test
153
154 OUTPUTDIR = $(join $(ROOTDIR), _output)
155 CRIDIR=$(OUTPUTDIR)/cri
156
157
158 .PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release static-release mandir install-man install-doc genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test remove-replace clean-vendor
159 .DEFAULT: default
160
161 # Forcibly set the default goal to all, in case an include above brought in a rule definition.
162 .DEFAULT_GOAL := all
163
164 all: binaries
165
166 check: proto-fmt ## run all linters
167 @echo "$(WHALE) $@"
168 GOGC=75 golangci-lint run
169
170 ci: check binaries check-protos coverage coverage-integration ## to be used by the CI
171
172 AUTHORS: .mailmap .git/HEAD
173 git log --format='%aN <%aE>' | sort -fu > $@
174
175 generate: protos
176 @echo "$(WHALE) $@"
177 @PATH="${ROOTDIR}/bin:${PATH}" $(GO) generate -x ${PACKAGES}
178
179 protos: bin/protoc-gen-go-fieldpath bin/go-buildtag
180 @echo "$(WHALE) $@"
181 @find . -path ./vendor -prune -false -o -name '*.pb.go' | xargs rm
182 $(eval TMPDIR := $(shell mktemp -d))
183 @mv ${ROOTDIR}/vendor ${TMPDIR}
184 @(cd ${ROOTDIR}/api && PATH="${ROOTDIR}/bin:${PATH}" protobuild --quiet ${API_PACKAGES})
185 @mv ${TMPDIR}/vendor ${ROOTDIR}
186 @rm -rf ${TMPDIR} v2
187 go-fix-acronym -w -a '^Os' $(shell find api/ -name '*.pb.go')
188 go-fix-acronym -w -a '(Id|Io|Uuid|Os)$$' $(shell find api/ -name '*.pb.go')
189 bin/go-buildtag -w --tags '!no_grpc' $(shell find api/ -name '*_grpc.pb.go')
190 @test -z "$$(git status --short | grep "api/next.pb.txt" | tee /dev/stderr)" || \
191 $(GO) mod edit -replace=github.com/containerd/containerd/api=./api
192
193 check-protos: protos ## check if protobufs needs to be generated again
194 @echo "$(WHALE) $@"
195 @test -z "$$(git status --short | grep ".pb.go" | tee /dev/stderr)" || \
196 ((git diff | cat) && \
197 (echo "$(ONI) please run 'make protos' when making changes to proto files" && false))
198
199 check-api-descriptors: protos ## check that protobuf changes aren't present.
200 @echo "$(WHALE) $@"
201 @test -z "$$(git status --short | grep ".pb.txt" | tee /dev/stderr)" || \
202 ((git diff $$(find . -name '*.pb.txt') | cat) && \
203 (echo "$(ONI) please run 'make protos' when making changes to proto files and check-in the generated descriptor file changes" && false))
204
205 proto-fmt: ## check format of proto files
206 @echo "$(WHALE) $@"
207 @test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
208 (echo "$(ONI) please indent proto files with tabs only" && false)
209
210 build: ## build the go packages
211 @echo "$(WHALE) $@"
212 @$(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${EXTRA_FLAGS} ${GO_LDFLAGS} ${PACKAGES}
213
214 test: ## run tests, except integration tests and tests that require root
215 @echo "$(WHALE) $@"
216 @$(GOTEST) ${TESTFLAGS} ${PACKAGES}
217
218 root-test: ## run tests, except integration tests
219 @echo "$(WHALE) $@"
220 @$(GOTEST) ${TESTFLAGS} ${TEST_REQUIRES_ROOT_PACKAGES} -test.root
221
222 integration: ## run integration tests
223 @echo "$(WHALE) $@"
224 @cd "${ROOTDIR}/integration/client" && $(GO) mod download && $(GOTEST) -v ${TESTFLAGS} -test.root -parallel ${TESTFLAGS_PARALLEL} .
225
226 # TODO integrate cri integration bucket with coverage
227 bin/cri-integration.test:
228 @echo "$(WHALE) $@"
229 @$(GO) test -c ./integration -o bin/cri-integration.test
230
231 cri-integration: binaries bin/cri-integration.test ## run cri integration tests (example: FOCUS=TestContainerListStats make cri-integration)
232 @echo "$(WHALE) $@"
233 @bash ./script/test/cri-integration.sh
234 @rm -rf bin/cri-integration.test
235
236 # build runc shimv2 with failpoint control, only used by integration test
237 bin/containerd-shim-runc-fp-v1: integration/failpoint/cmd/containerd-shim-runc-fp-v1 FORCE
238 @echo "$(WHALE) $@"
239 @CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ${SHIM_GO_TAGS} ./integration/failpoint/cmd/containerd-shim-runc-fp-v1
240
241 # build CNI bridge plugin wrapper with failpoint support, only used by integration test
242 bin/cni-bridge-fp: integration/failpoint/cmd/cni-bridge-fp FORCE
243 @echo "$(WHALE) $@"
244 @$(GO) build ${GO_BUILD_FLAGS} -o $@ ./integration/failpoint/cmd/cni-bridge-fp
245
246 # build runc-fp as runc wrapper to support failpoint, only used by integration test
247 bin/runc-fp: integration/failpoint/cmd/runc-fp FORCE
248 @echo "$(WHALE) $@"
249 @$(GO) build ${GO_BUILD_FLAGS} -o $@ ./integration/failpoint/cmd/runc-fp
250
251 # build loopback-v2 with failpoint support, only used by integration test
252 bin/loopback-v2: integration/failpoint/cmd/loopback-v2 FORCE
253 @echo "$(WHALE) $@"
254 @CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ./integration/failpoint/cmd/loopback-v2
255
256 benchmark: ## run benchmarks tests
257 @echo "$(WHALE) $@"
258 @$(GO) test ${TESTFLAGS} -bench . -run Benchmark -test.root
259
260 FORCE:
261
262 define BUILD_BINARY
263 @echo "$(WHALE) $@"
264 $(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} ${GO_TAGS} ./$<
265 endef
266
267 # Build a binary from a cmd.
268 bin/%: cmd/% FORCE
269 $(call BUILD_BINARY)
270
271 # gen-manpages must not have the urfave_cli_no_docs build-tag set
272 bin/gen-manpages: cmd/gen-manpages FORCE
273 @echo "$(WHALE) $@"
274 $(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} $(subst urfave_cli_no_docs,,${GO_TAGS}) ./cmd/gen-manpages
275
276 bin/containerd-shim-runc-v2: cmd/containerd-shim-runc-v2 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
277 @echo "$(WHALE) $@"
278 CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${SHIM_GO_TAGS} ./cmd/containerd-shim-runc-v2
279
280 binaries: $(BINARIES) ## build binaries
281 @echo "$(WHALE) $@"
282
283 man: $(addprefix man/,$(MANPAGES))
284 @echo "$(WHALE) $@"
285
286 mandir:
287 @mkdir -p man
288
289 # Kept for backwards compatibility
290 genman: man/containerd.8 man/ctr.8
291
292 man/containerd.8: bin/gen-manpages FORCE | mandir
293 @echo "$(WHALE) $@"
294 $< $(@F) $(@D)
295
296 man/ctr.8: bin/gen-manpages FORCE | mandir
297 @echo "$(WHALE) $@"
298 $< $(@F) $(@D)
299
300 man/%: docs/man/%.md FORCE | mandir
301 @echo "$(WHALE) $@"
302 go-md2man -in "$<" -out "$@"
303
304 define installmanpage
305 $(INSTALL) -d $(DESTDIR)$(MANDIR)/man$(2);
306 gzip -c $(1) >$(DESTDIR)$(MANDIR)/man$(2)/$(3).gz;
307 endef
308
309 install-man: man
310 @echo "$(WHALE) $@"
311 $(foreach manpage,$(addprefix man/,$(MANPAGES)), $(call installmanpage,$(manpage),$(subst .,,$(suffix $(manpage))),$(notdir $(manpage))))
312
313 install-doc:
314 @echo "$(WHALE) $@"
315 @mkdir -p $(DESTDIR)/$(DOCDIR)/containerd
316 @cp -R docs/* $(DESTDIR)/$(DOCDIR)/containerd
317
318 define pack_release
319 @rm -rf releases/$(1) releases/$(1).tar.gz
320 @$(INSTALL) -d releases/$(1)/bin
321 @$(INSTALL) $(BINARIES) releases/$(1)/bin
322 @tar -czf releases/$(1).tar.gz -C releases/$(1) bin
323 @rm -rf releases/$(1)
324 endef
325
326
327 releases/$(RELEASE).tar.gz: $(BINARIES)
328 @echo "$(WHALE) $@"
329 $(call pack_release,$(RELEASE))
330
331 release: releases/$(RELEASE).tar.gz
332 @echo "$(WHALE) $@"
333 @cd releases && sha256sum $(RELEASE).tar.gz >$(RELEASE).tar.gz.sha256sum
334
335 releases/$(STATICRELEASE).tar.gz:
336 ifeq ($(GOOS),linux)
337 @make STATIC=1 $(BINARIES)
338 @echo "$(WHALE) $@"
339 $(call pack_release,$(STATICRELEASE))
340 else
341 @echo "Skipping $(STATICRELEASE) for $(GOOS)"
342 endif
343
344 static-release: releases/$(STATICRELEASE).tar.gz
345 ifeq ($(GOOS),linux)
346 @echo "$(WHALE) $@"
347 @cd releases && sha256sum $(STATICRELEASE).tar.gz >$(STATICRELEASE).tar.gz.sha256sum
348 else
349 @echo "Skipping releasing $(STATICRELEASE) for $(GOOS)"
350 endif
351
352 # install of cri deps into release output directory
353 ifeq ($(GOOS),windows)
354 install-cri-deps: $(BINARIES)
355 $(INSTALL) -d $(CRIDIR)
356 DESTDIR=$(CRIDIR) script/setup/install-cni-windows
357 cp bin/* $(CRIDIR)
358 else
359 install-cri-deps: $(BINARIES)
360 @rm -rf ${CRIDIR}
361 @$(INSTALL) -d ${CRIDIR}/usr/local/bin
362 @$(INSTALL) -D -m 755 bin/* ${CRIDIR}/usr/local/bin
363 @$(INSTALL) -d ${CRIDIR}/opt/containerd/cluster
364 @cp -r contrib/gce ${CRIDIR}/opt/containerd/cluster/
365 @$(INSTALL) -d ${CRIDIR}/etc/systemd/system
366 @$(INSTALL) -m 644 containerd.service ${CRIDIR}/etc/systemd/system
367 echo "CONTAINERD_VERSION: '$(VERSION:v%=%)'" | tee ${CRIDIR}/opt/containerd/cluster/version
368
369 DESTDIR=$(CRIDIR) script/setup/install-runc
370 DESTDIR=$(CRIDIR) script/setup/install-cni
371 DESTDIR=$(CRIDIR) script/setup/install-critools
372 DESTDIR=$(CRIDIR) script/setup/install-imgcrypt
373
374 @$(INSTALL) -d $(CRIDIR)/bin
375 @$(INSTALL) $(BINARIES) $(CRIDIR)/bin
376 endif
377
378 $(CRIDIR)/cri-containerd.DEPRECATED.txt:
379 @mkdir -p $(CRIDIR)
380 @$(INSTALL) -m 644 releases/cri-containerd.DEPRECATED.txt $@
381
382 ifeq ($(GOOS),windows)
383 releases/$(CRIRELEASE).tar.gz: install-cri-deps $(CRIDIR)/cri-containerd.DEPRECATED.txt
384 @echo "$(WHALE) $@"
385 @cd $(CRIDIR) && tar -czf ../../releases/$(CRIRELEASE).tar.gz *
386
387 releases/$(CRICNIRELEASE).tar.gz: install-cri-deps $(CRIDIR)/cri-containerd.DEPRECATED.txt
388 @echo "$(WHALE) $@"
389 @cd $(CRIDIR) && tar -czf ../../releases/$(CRICNIRELEASE).tar.gz *
390 else
391 releases/$(CRIRELEASE).tar.gz: install-cri-deps $(CRIDIR)/cri-containerd.DEPRECATED.txt
392 @echo "$(WHALE) $@"
393 @tar -czf releases/$(CRIRELEASE).tar.gz -C $(CRIDIR) cri-containerd.DEPRECATED.txt etc/crictl.yaml etc/systemd usr opt/containerd
394
395 releases/$(CRICNIRELEASE).tar.gz: install-cri-deps $(CRIDIR)/cri-containerd.DEPRECATED.txt
396 @echo "$(WHALE) $@"
397 @tar -czf releases/$(CRICNIRELEASE).tar.gz -C $(CRIDIR) cri-containerd.DEPRECATED.txt etc usr opt
398 endif
399
400 cri-release: releases/$(CRIRELEASE).tar.gz ## Deprecated (only kept for external CI)
401 @echo "$(WHALE) $@"
402 @cd releases && sha256sum $(CRIRELEASE).tar.gz >$(CRIRELEASE).tar.gz.sha256sum && ln -sf $(CRIRELEASE).tar.gz cri-containerd.tar.gz
403
404 cri-cni-release: releases/$(CRICNIRELEASE).tar.gz ## Deprecated (only kept for external CI)
405 @echo "$(WHALE) $@"
406 @cd releases && sha256sum $(CRICNIRELEASE).tar.gz >$(CRICNIRELEASE).tar.gz.sha256sum && ln -sf $(CRICNIRELEASE).tar.gz cri-cni-containerd.tar.gz
407
408 clean: ## clean up binaries
409 @echo "$(WHALE) $@"
410 @rm -f $(BINARIES)
411 @rm -f releases/*.tar.gz*
412 @rm -rf $(OUTPUTDIR)
413 @rm -rf bin/cri-integration.test
414
415 clean-test: ## clean up debris from previously failed tests
416 @echo "$(WHALE) $@"
417 $(eval containers=$(shell find /run/containerd/runc -mindepth 2 -maxdepth 3 -type d -exec basename {} \;))
418 $(shell pidof containerd runc | xargs -r -n 1 kill -9)
419 @( for container in $(containers); do \
420 grep $$container /proc/self/mountinfo | while read -r mountpoint; do \
421 umount $$(echo $$mountpoint | awk '{print $$5}'); \
422 done; \
423 find /sys/fs/cgroup -name $$container -print0 | xargs -r -0 rmdir; \
424 done )
425 @rm -rf /run/containerd/runc/*
426 @rm -rf /run/containerd/fifo/*
427 @rm -rf /run/containerd-test/*
428 @rm -rf bin/cri-integration.test
429 @rm -rf bin/cni-bridge-fp
430 @rm -rf bin/containerd-shim-runc-fp-v1
431
432 install: ## install binaries
433 @echo "$(WHALE) $@ $(BINARIES)"
434 @$(INSTALL) -d $(DESTDIR)$(BINDIR)
435 @$(INSTALL) $(BINARIES) $(DESTDIR)$(BINDIR)
436
437 uninstall:
438 @echo "$(WHALE) $@"
439 @rm -f $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(BINARIES)))
440
441 ifeq ($(GOOS),windows)
442 install-deps:
443 script/setup/install-critools
444 script/setup/install-cni-windows
445 else
446 install-deps: ## install cri dependencies
447 script/setup/install-seccomp
448 script/setup/install-runc
449 script/setup/install-critools
450 script/setup/install-cni
451 endif
452
453 coverage: ## generate coverprofiles from the unit tests, except tests that require root
454 @echo "$(WHALE) $@"
455 @rm -f coverage.txt
456 @$(GO) test -i ${TESTFLAGS} ${PACKAGES} 2> /dev/null
457 @( for pkg in ${PACKAGES}; do \
458 $(GO) test ${TESTFLAGS} \
459 -cover \
460 -coverprofile=profile.out \
461 -covermode=atomic $$pkg || exit; \
462 if [ -f profile.out ]; then \
463 cat profile.out >> coverage.txt; \
464 rm profile.out; \
465 fi; \
466 done )
467
468 root-coverage: ## generate coverage profiles for unit tests that require root
469 @echo "$(WHALE) $@"
470 @$(GO) test -i ${TESTFLAGS} ${TEST_REQUIRES_ROOT_PACKAGES} 2> /dev/null
471 @( for pkg in ${TEST_REQUIRES_ROOT_PACKAGES}; do \
472 $(GO) test ${TESTFLAGS} \
473 -cover \
474 -coverprofile=profile.out \
475 -covermode=atomic $$pkg -test.root || exit; \
476 if [ -f profile.out ]; then \
477 cat profile.out >> coverage.txt; \
478 rm profile.out; \
479 fi; \
480 done )
481
482 remove-replace:
483 @echo "$(WHALE) $@"
484 @$(GO) mod edit -dropreplace=github.com/containerd/containerd/api
485
486 vendor: ## ensure all the go.mod/go.sum files are up-to-date including vendor/ directory
487 @echo "$(WHALE) $@"
488 @$(GO) mod tidy
489 @$(GO) mod vendor
490 @$(GO) mod verify
491 @(cd ${ROOTDIR}/api && ${GO} mod tidy)
492
493 verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date
494 @echo "$(WHALE) $@"
495 $(eval TMPDIR := $(shell mktemp -d))
496 @cp -R ${ROOTDIR} ${TMPDIR}
497 @(cd ${TMPDIR}/containerd && ${GO} mod tidy)
498 @(cd ${TMPDIR}/containerd && ${GO} mod vendor)
499 @(cd ${TMPDIR}/containerd && ${GO} mod verify)
500 @(cd ${TMPDIR}/containerd/api && ${GO} mod tidy)
501 @diff -r -u -q ${ROOTDIR} ${TMPDIR}/containerd
502 @rm -rf ${TMPDIR}
503
504 clean-vendor: remove-replace vendor
505
506
507 help: ## this help
508 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort