podman

Форк
0
232 строки · 9.4 Кб
1
export GOPROXY=https://proxy.golang.org
2

3
APPARMORTAG := $(shell hack/apparmor_tag.sh)
4
STORAGETAGS := exclude_graphdriver_devicemapper $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./hack/libsubid_tag.sh)
5
SECURITYTAGS ?= seccomp $(APPARMORTAG)
6
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS) $(shell ./hack/systemd_tag.sh)
7
ifeq ($(shell uname -s),FreeBSD)
8
# FreeBSD needs CNI until netavark is supported
9
TAGS += cni
10
endif
11
BUILDTAGS += $(TAGS)
12
PREFIX := /usr/local
13
BINDIR := $(PREFIX)/bin
14
BASHINSTALLDIR = $(PREFIX)/share/bash-completion/completions
15
BUILDFLAGS := -tags "$(BUILDTAGS)"
16
BUILDAH := buildah
17
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
18
SELINUXTYPE=container_runtime_exec_t
19
AS ?= as
20
STRIP ?= strip
21

22
GO := go
23
GO_LDFLAGS := $(shell if $(GO) version|grep -q gccgo; then echo "-gccgoflags"; else echo "-ldflags"; fi)
24
GO_GCFLAGS := $(shell if $(GO) version|grep -q gccgo; then echo "-gccgoflags"; else echo "-gcflags"; fi)
25
# test for go module support
26
ifeq ($(shell $(GO) help mod >/dev/null 2>&1 && echo true), true)
27
export GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor
28
export GO_TEST=GO111MODULE=on $(GO) test -mod=vendor
29
else
30
export GO_BUILD=$(GO) build
31
export GO_TEST=$(GO) test
32
endif
33
RACEFLAGS := $(shell $(GO_TEST) -race ./pkg/dummy > /dev/null 2>&1 && echo -race)
34

35
COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
36
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
37
SOURCE_DATE_EPOCH ?= $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
38
STATIC_STORAGETAGS = "containers_image_openpgp $(STORAGE_TAGS)"
39

40
# we get GNU make 3.x in MacOS build envs, which wants # to be escaped in
41
# strings, while the 4.x we have on Linux doesn't. this is the documented
42
# workaround
43
COMMENT := \#
44
CNI_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/containernetworking/cni \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
45
RUNC_COMMIT := $(shell sed -n 's;^$(COMMENT) github.com/opencontainers/runc \([^ \n]*\).*$$;\1;p' vendor/modules.txt)
46
LIBSECCOMP_COMMIT := release-2.3
47

48
EXTRA_LDFLAGS ?=
49
BUILDAH_LDFLAGS := $(GO_LDFLAGS) '-X main.GitCommit=$(GIT_COMMIT) -X main.buildInfo=$(SOURCE_DATE_EPOCH) -X main.cniVersion=$(CNI_COMMIT) $(EXTRA_LDFLAGS)'
50
SOURCES=*.go imagebuildah/*.go bind/*.go chroot/*.go copier/*.go define/*.go docker/*.go internal/config/*.go internal/mkcw/*.go internal/mkcw/types/*.go internal/parse/*.go internal/sbom/*.go internal/source/*.go internal/tmpdir/*.go internal/util/*.go internal/volumes/*.go manifests/*.go pkg/chrootuser/*.go pkg/cli/*.go pkg/completion/*.go pkg/formats/*.go pkg/overlay/*.go pkg/parse/*.go pkg/rusage/*.go pkg/sshagent/*.go pkg/umask/*.go pkg/util/*.go util/*.go
51

52
LINTFLAGS ?=
53

54
ifeq ($(BUILDDEBUG), 1)
55
  override GOGCFLAGS += -N -l
56
endif
57

58
#   make all BUILDDEBUG=1
59
#     Note: Uses the -N -l go compiler options to disable compiler optimizations
60
#           and inlining. Using these build options allows you to subsequently
61
#           use source debugging tools like delve.
62
all: bin/buildah bin/imgtype bin/copy bin/tutorial docs
63

64
# Update nix/nixpkgs.json its latest stable commit
65
.PHONY: nixpkgs
66
nixpkgs:
67
	@nix run \
68
		-f channel:nixos-20.09 nix-prefetch-git \
69
		-c nix-prefetch-git \
70
		--no-deepClone \
71
		https://github.com/nixos/nixpkgs refs/heads/nixos-20.09 > nix/nixpkgs.json
72

73
# Build statically linked binary
74
.PHONY: static
75
static:
76
	@nix build -f nix/
77
	mkdir -p ./bin
78
	cp -rfp ./result/bin/* ./bin/
79

80
bin/buildah: $(SOURCES) cmd/buildah/*.go internal/mkcw/embed/entrypoint_amd64.gz
81
	$(GO_BUILD) $(BUILDAH_LDFLAGS) $(GO_GCFLAGS) "$(GOGCFLAGS)" -o $@ $(BUILDFLAGS) ./cmd/buildah
82
	test -z "${SELINUXOPT}" || chcon --verbose -t $(SELINUXTYPE) $@
83

84
ifneq ($(shell $(AS) --version | grep x86_64),)
85
internal/mkcw/embed/entrypoint_amd64.gz: internal/mkcw/embed/entrypoint_amd64
86
	gzip -k9nf $^
87

88
internal/mkcw/embed/entrypoint_amd64: internal/mkcw/embed/entrypoint_amd64.s
89
	$(AS) -o $(patsubst %.s,%.o,$^) $^
90
	$(LD) -o $@ $(patsubst %.s,%.o,$^)
91
	$(STRIP) $@
92
endif
93

94

95
.PHONY: buildah
96
buildah: bin/buildah
97

98
ALL_CROSS_TARGETS := $(addprefix bin/buildah.,$(subst /,.,$(shell $(GO) tool dist list)))
99
LINUX_CROSS_TARGETS := $(filter-out %.loong64,$(filter bin/buildah.linux.%,$(ALL_CROSS_TARGETS)))
100
DARWIN_CROSS_TARGETS := $(filter bin/buildah.darwin.%,$(ALL_CROSS_TARGETS))
101
WINDOWS_CROSS_TARGETS := $(addsuffix .exe,$(filter bin/buildah.windows.%,$(ALL_CROSS_TARGETS)))
102
FREEBSD_CROSS_TARGETS := $(filter bin/buildah.freebsd.%,$(ALL_CROSS_TARGETS))
103
.PHONY: cross
104
cross: $(LINUX_CROSS_TARGETS) $(DARWIN_CROSS_TARGETS) $(WINDOWS_CROSS_TARGETS) $(FREEBSD_CROSS_TARGETS)
105

106
bin/buildah.%:
107
	mkdir -p ./bin
108
	GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ -tags "containers_image_openpgp" ./cmd/buildah
109

110
bin/imgtype: $(SOURCES) tests/imgtype/imgtype.go
111
	$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/imgtype/imgtype.go
112

113
bin/copy: $(SOURCES) tests/copy/copy.go
114
	$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/copy/copy.go
115

116
bin/tutorial: $(SOURCES) tests/tutorial/tutorial.go
117
	$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/tutorial/tutorial.go
118

119
.PHONY: clean
120
clean:
121
	$(RM) -r bin tests/testreport/testreport
122
	$(MAKE) -C docs clean
123

124
.PHONY: docs
125
docs: install.tools ## build the docs on the host
126
	$(MAKE) -C docs
127

128
# For vendoring to work right, the checkout directory must be such that our top
129
# level is at $GOPATH/src/github.com/containers/buildah.
130
.PHONY: gopath
131
gopath:
132
	test $(shell pwd) = $(shell cd ../../../../src/github.com/containers/buildah ; pwd)
133

134
codespell:
135
	codespell -S Makefile,buildah.spec.rpkg,AUTHORS,bin,vendor,.git,go.mod,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L secon,passt,bu,uint,iff,od,erro -w
136

137
.PHONY: validate
138
validate: install.tools
139
	./tests/validate/whitespace.sh
140
	./hack/xref-helpmsgs-manpages
141
	./tests/validate/pr-should-include-tests
142

143
.PHONY: install.tools
144
install.tools:
145
	$(MAKE) -C tests/tools
146

147
.PHONY: runc
148
runc: gopath
149
	rm -rf ../../opencontainers/runc
150
	git clone https://github.com/opencontainers/runc ../../opencontainers/runc
151
	cd ../../opencontainers/runc && git checkout $(RUNC_COMMIT) && $(GO) build -tags "$(STORAGETAGS) $(SECURITYTAGS)"
152
	ln -sf ../../opencontainers/runc/runc
153

154
.PHONY: install.libseccomp.sudo
155
install.libseccomp.sudo: gopath
156
	rm -rf ../../seccomp/libseccomp
157
	git clone https://github.com/seccomp/libseccomp ../../seccomp/libseccomp
158
	cd ../../seccomp/libseccomp && git checkout $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && sudo make install
159

160
.PHONY: install.cni.sudo
161
install.cni.sudo: gopath
162
	rm -rf ../../containernetworking/plugins
163
	git clone https://github.com/containernetworking/plugins ../../containernetworking/plugins
164
	cd ../../containernetworking/plugins && ./build_linux.sh && sudo install -D -v -m755 -t /opt/cni/bin/ bin/*
165

166
.PHONY: install
167
install:
168
	install -d -m 755 $(DESTDIR)/$(BINDIR)
169
	install -m 755 bin/buildah $(DESTDIR)/$(BINDIR)/buildah
170
	$(MAKE) -C docs install
171

172
.PHONY: uninstall
173
uninstall:
174
	rm -f $(DESTDIR)/$(BINDIR)/buildah
175
	rm -f $(PREFIX)/share/man/man1/buildah*.1
176
	rm -f $(DESTDIR)/$(BASHINSTALLDIR)/buildah
177

178
.PHONY: install.completions
179
install.completions:
180
	install -m 755 -d $(DESTDIR)/$(BASHINSTALLDIR)
181
	install -m 644 contrib/completions/bash/buildah $(DESTDIR)/$(BASHINSTALLDIR)/buildah
182

183
.PHONY: install.runc
184
install.runc:
185
	install -m 755 ../../opencontainers/runc/runc $(DESTDIR)/$(BINDIR)/
186

187
.PHONY: test-conformance
188
test-conformance:
189
	$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 60m ./tests/conformance
190

191
.PHONY: test-integration
192
test-integration: install.tools
193
	./tests/tools/build/ginkgo $(BUILDFLAGS) -v tests/e2e/.
194
	cd tests; ./test_runner.sh
195

196
tests/testreport/testreport: tests/testreport/testreport.go
197
	$(GO_BUILD) $(GO_LDFLAGS) "-linkmode external -extldflags -static" -tags "$(STORAGETAGS) $(SECURITYTAGS)" -o tests/testreport/testreport ./tests/testreport/testreport.go
198

199
.PHONY: test-unit
200
test-unit: tests/testreport/testreport
201
	$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) $(shell $(GO) list ./... | grep -v vendor | grep -v tests | grep -v cmd | grep -v chroot | grep -v copier) -timeout 45m
202
	$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)"        $(RACEFLAGS) ./chroot ./copier -timeout 60m
203
	tmp=$(shell mktemp -d) ; \
204
	mkdir -p $$tmp/root $$tmp/runroot; \
205
	$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) ./cmd/buildah -args --root $$tmp/root --runroot $$tmp/runroot --storage-driver vfs --signature-policy $(shell pwd)/tests/policy.json --registries-conf $(shell pwd)/tests/registries.conf
206

207
vendor-in-container:
208
	podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.21 make vendor
209

210
.PHONY: vendor
211
vendor:
212
	GO111MODULE=on $(GO) mod tidy
213
	GO111MODULE=on $(GO) mod vendor
214
	GO111MODULE=on $(GO) mod verify
215

216
.PHONY: lint
217
lint: install.tools
218
	./tests/tools/build/golangci-lint run $(LINTFLAGS)
219

220
# CAUTION: This is not a replacement for RPMs provided by your distro.
221
# Only intended to build and test the latest unreleased changes.
222
.PHONY: rpm
223
rpm:  ## Build rpm packages
224
	$(MAKE) -C rpm
225

226
# Remember that rpms install exec to /usr/bin/buildah while a `make install`
227
# installs them to /usr/local/bin/buildah which is likely before. Always use
228
# a full path to test installed buildah or you risk to call another executable.
229
.PHONY: rpm-install
230
rpm-install: package  ## Install rpm packages
231
	$(call err_if_empty,PKG_MANAGER) -y install rpm/RPMS/*/*.rpm
232
	/usr/bin/buildah version
233

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

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

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

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