2019-08-30 18:03:41 +08:00
|
|
|
export GOPROXY=https://proxy.golang.org
|
|
|
|
|
2018-10-27 03:35:04 +08:00
|
|
|
SELINUXTAG := $(shell ./selinux_tag.sh)
|
2019-08-05 19:55:56 +08:00
|
|
|
APPARMORTAG := $(shell hack/apparmor_tag.sh)
|
2019-10-30 17:48:28 +08:00
|
|
|
STORAGETAGS := $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./libdm_tag.sh)
|
2019-08-05 19:55:56 +08:00
|
|
|
SECURITYTAGS ?= seccomp $(SELINUXTAG) $(APPARMORTAG)
|
2018-11-29 03:08:47 +08:00
|
|
|
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS)
|
2018-12-07 22:55:55 +08:00
|
|
|
BUILDTAGS += $(TAGS)
|
2017-04-14 20:48:53 +08:00
|
|
|
PREFIX := /usr/local
|
2017-03-30 03:06:36 +08:00
|
|
|
BINDIR := $(PREFIX)/bin
|
2018-11-29 03:08:47 +08:00
|
|
|
BASHINSTALLDIR = $(PREFIX)/share/bash-completion/completions
|
2018-12-07 22:55:55 +08:00
|
|
|
BUILDFLAGS := -tags "$(BUILDTAGS)"
|
2018-10-27 03:35:04 +08:00
|
|
|
BUILDAH := buildah
|
2019-08-01 19:13:37 +08:00
|
|
|
|
2017-10-03 02:49:22 +08:00
|
|
|
GO := go
|
2018-10-18 22:47:37 +08:00
|
|
|
GO110 := 1.10
|
|
|
|
GOVERSION := $(findstring $(GO110),$(shell go version))
|
2019-08-01 19:13:37 +08:00
|
|
|
# test for go module support
|
|
|
|
ifeq ($(shell go help mod >/dev/null 2>&1 && echo true), true)
|
|
|
|
export GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor
|
2020-01-17 23:44:47 +08:00
|
|
|
export GO_TEST=GO111MODULE=on $(GO) test -mod=vendor
|
2019-08-01 19:13:37 +08:00
|
|
|
else
|
|
|
|
export GO_BUILD=$(GO) build
|
2020-01-17 23:44:47 +08:00
|
|
|
export GO_TEST=$(GO) test
|
2019-08-01 19:13:37 +08:00
|
|
|
endif
|
|
|
|
|
2018-12-07 23:13:01 +08:00
|
|
|
GIT_COMMIT ?= $(if $(shell git rev-parse --short HEAD),$(shell git rev-parse --short HEAD),$(error "git failed"))
|
2019-08-20 21:45:48 +08:00
|
|
|
SOURCE_DATE_EPOCH ?= $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
|
2019-10-30 17:48:28 +08:00
|
|
|
STATIC_STORAGETAGS = "containers_image_openpgp exclude_graphdriver_devicemapper $(STORAGE_TAGS)"
|
2017-06-22 23:47:20 +08:00
|
|
|
|
2019-07-18 16:30:42 +08:00
|
|
|
CNI_COMMIT := $(shell sed -n 's;\tgithub.com/containernetworking/cni \([^ \n]*\).*$\;\1;p' go.mod)
|
2019-09-07 03:07:18 +08:00
|
|
|
#RUNC_COMMIT := $(shell sed -n 's;\tgithub.com/opencontainers/runc \([^ \n]*\).*$\;\1;p' go.mod)
|
|
|
|
RUNC_COMMIT := v1.0.0-rc8
|
2017-07-22 05:42:10 +08:00
|
|
|
LIBSECCOMP_COMMIT := release-2.3
|
2017-07-21 01:41:51 +08:00
|
|
|
|
2020-05-28 12:10:04 +08:00
|
|
|
EXTRA_LDFLAGS ?=
|
2020-11-06 17:51:20 +08:00
|
|
|
BUILDAH_LDFLAGS := -ldflags '-X main.GitCommit=$(GIT_COMMIT) -X main.buildInfo=$(SOURCE_DATE_EPOCH) -X main.cniVersion=$(CNI_COMMIT) $(EXTRA_LDFLAGS)'
|
2020-07-15 04:34:07 +08:00
|
|
|
SOURCES=*.go imagebuildah/*.go bind/*.go chroot/*.go cmd/buildah/*.go copier/*.go docker/*.go pkg/blobcache/*.go pkg/cli/*.go pkg/parse/*.go util/*.go
|
2017-06-22 23:47:20 +08:00
|
|
|
|
2020-01-17 00:41:51 +08:00
|
|
|
LINTFLAGS ?=
|
|
|
|
|
2020-05-28 12:10:04 +08:00
|
|
|
all: bin/buildah bin/imgtype docs
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2020-06-29 10:40:58 +08:00
|
|
|
# Update nix/nixpkgs.json its latest stable commit
|
|
|
|
.PHONY: nixpkgs
|
2020-05-28 12:10:04 +08:00
|
|
|
nixpkgs:
|
2020-06-29 10:40:58 +08:00
|
|
|
@nix run -f channel:nixos-20.03 nix-prefetch-git -c nix-prefetch-git \
|
2020-05-28 12:10:04 +08:00
|
|
|
--no-deepClone https://github.com/nixos/nixpkgs > nix/nixpkgs.json
|
2018-10-27 03:35:04 +08:00
|
|
|
|
2020-06-29 10:40:58 +08:00
|
|
|
# Build statically linked binary
|
|
|
|
.PHONY: static
|
|
|
|
static:
|
|
|
|
@nix build -f nix/
|
|
|
|
mkdir -p ./bin
|
|
|
|
cp -rfp ./result/bin/* ./bin/
|
|
|
|
|
2020-05-28 12:10:04 +08:00
|
|
|
.PHONY: bin/buildah
|
|
|
|
bin/buildah: $(SOURCES)
|
2020-11-06 17:51:20 +08:00
|
|
|
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./cmd/buildah
|
2018-10-27 03:35:04 +08:00
|
|
|
|
2020-05-28 12:10:04 +08:00
|
|
|
.PHONY: buildah
|
|
|
|
buildah: bin/buildah
|
2018-06-29 22:00:38 +08:00
|
|
|
|
2020-09-04 01:44:26 +08:00
|
|
|
.PHONY: cross
|
2020-10-21 03:16:31 +08:00
|
|
|
cross: bin/buildah.darwin.amd64 bin/buildah.linux.386 bin/buildah.linux.amd64 bin/buildah.linux.arm64 bin/buildah.linux.arm bin/buildah.linux.mips64 bin/buildah.linux.mips64le bin/buildah.linux.mips bin/buildah.linux.mipsle bin/buildah.linux.ppc64 bin/buildah.linux.ppc64le bin/buildah.linux.riscv64 bin/buildah.linux.s390x bin/buildah.windows.amd64.exe
|
2020-09-04 01:44:26 +08:00
|
|
|
|
|
|
|
.PHONY: bin/buildah.%
|
|
|
|
bin/buildah.%:
|
|
|
|
mkdir -p ./bin
|
2020-11-06 17:51:20 +08:00
|
|
|
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ -tags "containers_image_openpgp" ./cmd/buildah
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2020-05-28 12:10:04 +08:00
|
|
|
.PHONY: bin/imgtype
|
|
|
|
bin/imgtype: *.go docker/*.go util/*.go tests/imgtype/imgtype.go
|
2020-11-06 17:51:20 +08:00
|
|
|
$(GO_BUILD) $(BUILDAH_LDFLAGS) -o $@ $(BUILDFLAGS) ./tests/imgtype/imgtype.go
|
2017-06-29 02:34:41 +08:00
|
|
|
|
2017-01-27 23:55:04 +08:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2020-05-28 12:10:04 +08:00
|
|
|
$(RM) -r bin tests/testreport/testreport
|
2018-11-29 03:08:47 +08:00
|
|
|
$(MAKE) -C docs clean
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2017-03-29 03:37:24 +08:00
|
|
|
.PHONY: docs
|
2019-06-21 23:07:34 +08:00
|
|
|
docs: install.tools ## build the docs on the host
|
2017-04-12 03:34:36 +08:00
|
|
|
$(MAKE) -C docs
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
# For vendoring to work right, the checkout directory must be such that our top
|
2018-09-18 03:20:16 +08:00
|
|
|
# level is at $GOPATH/src/github.com/containers/buildah.
|
2017-01-27 23:55:04 +08:00
|
|
|
.PHONY: gopath
|
|
|
|
gopath:
|
2018-09-18 03:20:16 +08:00
|
|
|
test $(shell pwd) = $(shell cd ../../../../src/github.com/containers/buildah ; pwd)
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2020-01-08 22:48:59 +08:00
|
|
|
codespell:
|
2020-09-11 22:06:31 +08:00
|
|
|
codespell -S Makefile,build,buildah,buildah.spec,imgtype,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L uint,iff,od
|
2020-01-08 22:48:59 +08:00
|
|
|
|
2017-04-04 05:43:57 +08:00
|
|
|
.PHONY: validate
|
2019-06-21 23:07:34 +08:00
|
|
|
validate: install.tools
|
2018-09-19 05:07:10 +08:00
|
|
|
@./tests/validate/whitespace.sh
|
2017-04-04 05:43:57 +08:00
|
|
|
@./tests/validate/git-validation.sh
|
New CI check: xref --help vs man pages
Run 'buildah --help', recursively against all subcommands,
then cross-reference the results against docs/buildah*.md.
Report differences in subcommands and/or flags.
The majority of the changes in this PR are trivial (see
below) but a handful may be controversial and require
careful review:
* Making 'bud' the default output of 'buildah help',
with 'build-using-dockerfile' as an alias. This is
the inverse of the situation until now: buildah
would list build-using-dockerfile as the primary
name. The man page, OTOH, lists 'bud'. The source
file name is 'bud'. I suspect that most people
type 'bud'. So, for consistency, I choose to make
'bud' the default visible command.
* add --encryption-key and --encrypt-layer documentation
to buildah-commit.md, and --encrypt-layer to -push.md.
Please double-check the wording here.
* remove --notruncate from buildah-images.md. The option
does not exist (although there is a TODO comment in
the code). If it should exist, it is left to the
reader to implement. I would humbly suggest that this
is a good idea, for consistency with buildah containers.
* remove --shm-size from buildah-pull.md. The option
does not exist, and I suspect this was a copy-paste error.
* remove --security-opt from run.go. It was unimplemented
and undocumented.
* remove --userns-[gu]id-map from buildah-bud.md. These
are global options, not bud options, and are documented
well enough in buildah.bud.
Trivial (IMO) changes:
* split options in man pages, from '**--foo, -f**'
to '**--foo**, **-f**'. This conforms with the style
used in podman man pages.
* add missing one-letter aliases (usually "-q", "-a")
* add missing man page entries for some easy options
* sort out-of-order subcommand listings in man pages
Finally, do note that this is a copy-and-alter duplicate of the
original script in podman, and that is horrible. In an ideal
world I would've been able to refactor the podman version into
something usable on both repos (and then more). It turns out the
differences in man page format and in special-case handling are
too broad to let me do a clean refactor.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
|
|
|
@./hack/xref-helpmsgs-manpages
|
2017-04-04 05:43:57 +08:00
|
|
|
|
|
|
|
.PHONY: install.tools
|
|
|
|
install.tools:
|
2019-07-08 17:24:22 +08:00
|
|
|
make -C tests/tools
|
2017-04-04 05:43:57 +08:00
|
|
|
|
2017-07-21 01:41:51 +08:00
|
|
|
.PHONY: runc
|
|
|
|
runc: gopath
|
|
|
|
rm -rf ../../opencontainers/runc
|
|
|
|
git clone https://github.com/opencontainers/runc ../../opencontainers/runc
|
2018-10-27 03:35:04 +08:00
|
|
|
cd ../../opencontainers/runc && git checkout $(RUNC_COMMIT) && $(GO) build -tags "$(STORAGETAGS) $(SECURITYTAGS)"
|
2017-07-21 01:41:51 +08:00
|
|
|
ln -sf ../../opencontainers/runc/runc
|
|
|
|
|
2017-07-22 05:42:10 +08:00
|
|
|
.PHONY: install.libseccomp.sudo
|
|
|
|
install.libseccomp.sudo: gopath
|
|
|
|
rm -rf ../../seccomp/libseccomp
|
|
|
|
git clone https://github.com/seccomp/libseccomp ../../seccomp/libseccomp
|
|
|
|
cd ../../seccomp/libseccomp && git checkout $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && sudo make install
|
|
|
|
|
2018-05-23 01:48:15 +08:00
|
|
|
.PHONY: install.cni.sudo
|
|
|
|
install.cni.sudo: gopath
|
|
|
|
rm -rf ../../containernetworking/plugins
|
|
|
|
git clone https://github.com/containernetworking/plugins ../../containernetworking/plugins
|
2020-02-11 01:36:06 +08:00
|
|
|
cd ../../containernetworking/plugins && ./build_linux.sh && sudo install -D -v -m755 -t /opt/cni/bin/ bin/*
|
2018-05-23 01:48:15 +08:00
|
|
|
|
2017-04-12 03:34:36 +08:00
|
|
|
.PHONY: install
|
2017-03-29 03:20:37 +08:00
|
|
|
install:
|
2020-05-28 12:10:04 +08:00
|
|
|
install -D -m0755 bin/buildah $(DESTDIR)/$(BINDIR)/buildah
|
2017-03-29 03:37:24 +08:00
|
|
|
$(MAKE) -C docs install
|
|
|
|
|
2018-06-19 14:08:55 +08:00
|
|
|
.PHONY: uninstall
|
|
|
|
uninstall:
|
|
|
|
rm -f $(DESTDIR)/$(BINDIR)/buildah
|
|
|
|
rm -f $(PREFIX)/share/man/man1/buildah*.1
|
2018-11-29 03:08:47 +08:00
|
|
|
rm -f $(DESTDIR)/$(BASHINSTALLDIR)/buildah
|
2018-06-19 14:08:55 +08:00
|
|
|
|
2017-03-29 03:20:37 +08:00
|
|
|
.PHONY: install.completions
|
|
|
|
install.completions:
|
2018-11-29 03:08:47 +08:00
|
|
|
install -m 644 -D contrib/completions/bash/buildah $(DESTDIR)/$(BASHINSTALLDIR)/buildah
|
2017-10-06 01:48:22 +08:00
|
|
|
|
2017-12-12 02:25:42 +08:00
|
|
|
.PHONY: install.runc
|
|
|
|
install.runc:
|
|
|
|
install -m 755 ../../opencontainers/runc/runc $(DESTDIR)/$(BINDIR)/
|
|
|
|
|
2020-06-19 06:03:43 +08:00
|
|
|
.PHONY: test-conformance
|
|
|
|
test-conformance:
|
|
|
|
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 15m ./tests/conformance
|
|
|
|
|
2017-10-06 01:48:22 +08:00
|
|
|
.PHONY: test-integration
|
2019-06-21 23:07:34 +08:00
|
|
|
test-integration: install.tools
|
2019-08-15 03:23:36 +08:00
|
|
|
./tests/tools/build/ginkgo $(BUILDFLAGS) -v tests/e2e/.
|
2017-10-06 01:48:22 +08:00
|
|
|
cd tests; ./test_runner.sh
|
|
|
|
|
2018-05-12 01:08:18 +08:00
|
|
|
tests/testreport/testreport: tests/testreport/testreport.go
|
2020-07-21 05:54:25 +08:00
|
|
|
$(GO_BUILD) -ldflags "-linkmode external -extldflags -static" -tags "$(STORAGETAGS) $(SECURITYTAGS)" -o tests/testreport/testreport ./tests/testreport/testreport.go
|
2018-05-12 01:08:18 +08:00
|
|
|
|
2017-10-06 01:48:22 +08:00
|
|
|
.PHONY: test-unit
|
2018-05-12 01:08:18 +08:00
|
|
|
test-unit: tests/testreport/testreport
|
2020-06-19 06:03:43 +08:00
|
|
|
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -race $(shell $(GO) list ./... | grep -v vendor | grep -v tests | grep -v cmd) -timeout 40m
|
2017-10-06 01:48:22 +08:00
|
|
|
tmp=$(shell mktemp -d) ; \
|
|
|
|
mkdir -p $$tmp/root $$tmp/runroot; \
|
2020-06-19 06:03:43 +08:00
|
|
|
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -race ./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
|
2019-01-31 01:14:47 +08:00
|
|
|
|
2019-10-29 04:56:48 +08:00
|
|
|
vendor-in-container:
|
|
|
|
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.13 make vendor
|
|
|
|
|
2019-01-31 01:14:47 +08:00
|
|
|
.PHONY: vendor
|
2019-06-21 23:23:28 +08:00
|
|
|
vendor:
|
2020-04-09 02:24:18 +08:00
|
|
|
GO111MODULE=on $(GO) mod tidy
|
2020-04-09 02:25:37 +08:00
|
|
|
GO111MODULE=on $(GO) mod vendor
|
2020-04-09 02:24:18 +08:00
|
|
|
GO111MODULE=on $(GO) mod verify
|
2019-07-04 20:36:46 +08:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: install.tools
|
2020-01-17 00:41:51 +08:00
|
|
|
./tests/tools/build/golangci-lint run $(LINTFLAGS)
|