2018-10-27 03:35:04 +08:00
|
|
|
SELINUXTAG := $(shell ./selinux_tag.sh)
|
|
|
|
|
STORAGETAGS := $(shell ./btrfs_tag.sh) $(shell ./btrfs_installed_tag.sh) $(shell ./libdm_tag.sh) $(shell ./ostree_tag.sh)
|
|
|
|
|
SECURITYTAGS ?= seccomp $(SELINUXTAG)
|
2018-11-29 03:08:47 +08:00
|
|
|
TAGS ?= $(SECURITYTAGS) $(STORAGETAGS)
|
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
|
|
|
|
|
BUILDFLAGS := -tags "$(TAGS)"
|
2018-10-27 03:35:04 +08:00
|
|
|
BUILDAH := buildah
|
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))
|
2018-04-24 21:00:13 +08:00
|
|
|
GIT_COMMIT := $(if $(shell git rev-parse --short HEAD),$(shell git rev-parse --short HEAD),$(error "git failed"))
|
|
|
|
|
BUILD_INFO := $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
|
2018-04-14 06:20:25 +08:00
|
|
|
CNI_COMMIT := $(if $(shell sed -e '\,github.com/containernetworking/cni, !d' -e 's,.* ,,g' vendor.conf),$(shell sed -e '\,github.com/containernetworking/cni, !d' -e 's,.* ,,g' vendor.conf),$(error "sed failed"))
|
2018-11-29 03:08:47 +08:00
|
|
|
STATIC_STORAGETAGS = "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper $(STORAGE_TAGS)"
|
2017-06-22 23:47:20 +08:00
|
|
|
|
2018-07-20 02:41:02 +08:00
|
|
|
RUNC_COMMIT := 2c632d1a2de0192c3f18a2542ccb6f30a8719b1f
|
2017-07-22 05:42:10 +08:00
|
|
|
LIBSECCOMP_COMMIT := release-2.3
|
2017-07-21 01:41:51 +08:00
|
|
|
|
2018-10-27 03:35:04 +08:00
|
|
|
EXTRALDFLAGS :=
|
2018-11-29 03:08:47 +08:00
|
|
|
LDFLAGS := -ldflags '-X main.GitCommit=$(GIT_COMMIT) -X main.buildInfo=$(BUILD_INFO) -X main.cniVersion=$(CNI_COMMIT)' $(EXTRALDFLAGS)
|
2018-10-18 06:06:16 +08:00
|
|
|
SOURCES=*.go imagebuildah/*.go bind/*.go chroot/*.go cmd/buildah/*.go docker/*.go pkg/blobcache/*.go pkg/cli/*.go pkg/parse/*.go unshare/*.c unshare/*.go util/*.go
|
2017-06-22 23:47:20 +08:00
|
|
|
|
2017-06-29 02:34:41 +08:00
|
|
|
all: buildah imgtype docs
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2018-10-27 03:35:04 +08:00
|
|
|
.PHONY: static
|
|
|
|
|
static: $(SOURCES)
|
|
|
|
|
$(MAKE) SECURITYTAGS="$(SECURITYTAGS)" STORAGETAGS=$(STATIC_STORAGETAGS) EXTRALDFLAGS='-ldflags "-extldflags '-static'"' BUILDAH=buildah.static binary
|
|
|
|
|
|
|
|
|
|
.PHONY: binary
|
|
|
|
|
binary: $(SOURCES)
|
2018-11-29 03:08:47 +08:00
|
|
|
$(GO) build $(LDFLAGS) -o $(BUILDAH) $(BUILDFLAGS) ./cmd/buildah
|
2018-10-27 03:35:04 +08:00
|
|
|
|
|
|
|
|
buildah: binary
|
2018-06-29 22:00:38 +08:00
|
|
|
|
|
|
|
|
darwin:
|
|
|
|
|
GOOS=darwin $(GO) build $(LDFLAGS) -o buildah.darwin -tags "containers_image_openpgp" ./cmd/buildah
|
2017-01-27 23:55:04 +08:00
|
|
|
|
2018-04-19 16:52:24 +08:00
|
|
|
imgtype: *.go docker/*.go util/*.go tests/imgtype/imgtype.go
|
|
|
|
|
$(GO) build $(LDFLAGS) -o imgtype $(BUILDFLAGS) ./tests/imgtype/imgtype.go
|
2017-06-29 02:34:41 +08:00
|
|
|
|
2017-01-27 23:55:04 +08:00
|
|
|
.PHONY: clean
|
|
|
|
|
clean:
|
2018-10-27 03:35:04 +08:00
|
|
|
$(RM) -r buildah imgtype build buildah.static
|
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
|
|
|
|
|
docs: ## 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
|
|
|
|
2017-01-28 12:59:37 +08:00
|
|
|
# We use https://github.com/lk4d4/vndr to manage dependencies.
|
2017-01-27 23:55:04 +08:00
|
|
|
.PHONY: deps
|
|
|
|
|
deps: gopath
|
|
|
|
|
env GOPATH=$(shell cd ../../../.. ; pwd) vndr
|
2017-03-29 03:20:37 +08:00
|
|
|
|
2017-04-04 05:43:57 +08:00
|
|
|
.PHONY: validate
|
|
|
|
|
validate:
|
2018-10-17 07:57:59 +08:00
|
|
|
# Run gofmt on version 1.11 and higher
|
2018-10-18 22:47:37 +08:00
|
|
|
ifneq ($(GO110),$(GOVERSION))
|
2017-04-04 05:43:57 +08:00
|
|
|
@./tests/validate/gofmt.sh
|
2018-10-18 07:20:37 +08:00
|
|
|
endif
|
2018-09-19 05:07:10 +08:00
|
|
|
@./tests/validate/whitespace.sh
|
2017-05-04 02:50:55 +08:00
|
|
|
@./tests/validate/govet.sh
|
2017-04-04 05:43:57 +08:00
|
|
|
@./tests/validate/git-validation.sh
|
|
|
|
|
@./tests/validate/gometalinter.sh . cmd/buildah
|
|
|
|
|
|
|
|
|
|
.PHONY: install.tools
|
|
|
|
|
install.tools:
|
2018-02-10 02:42:07 +08:00
|
|
|
$(GO) get -u $(BUILDFLAGS) github.com/cpuguy83/go-md2man
|
2017-10-03 02:49:22 +08:00
|
|
|
$(GO) get -u $(BUILDFLAGS) github.com/vbatts/git-validation
|
2018-02-12 23:45:12 +08:00
|
|
|
$(GO) get -u $(BUILDFLAGS) github.com/onsi/ginkgo/ginkgo
|
2017-10-03 02:49:22 +08:00
|
|
|
$(GO) get -u $(BUILDFLAGS) gopkg.in/alecthomas/gometalinter.v1
|
2018-05-15 21:09:31 +08:00
|
|
|
$(GOPATH)/bin/gometalinter.v1 -i
|
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
|
|
|
|
|
cd ../../containernetworking/plugins && ./build.sh && mkdir -p /opt/cni/bin && sudo install -v -m755 bin/* /opt/cni/bin/
|
|
|
|
|
|
2017-04-12 03:34:36 +08:00
|
|
|
.PHONY: install
|
2017-03-29 03:20:37 +08:00
|
|
|
install:
|
2017-04-14 20:48:53 +08:00
|
|
|
install -D -m0755 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)/
|
|
|
|
|
|
2017-10-06 01:48:22 +08:00
|
|
|
.PHONY: test-integration
|
|
|
|
|
test-integration:
|
2018-02-12 23:45:12 +08:00
|
|
|
ginkgo -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
|
2018-10-27 03:35:04 +08:00
|
|
|
$(GO) build -ldflags "-linkmode external -extldflags -static" -tags "$(STORAGETAGS) $(SECURITYTAGS)" -o tests/testreport/testreport ./tests/testreport
|
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
|
2018-10-27 03:35:04 +08:00
|
|
|
$(GO) test -v -tags "$(STOAGETAGS) $(SECURITYTAGS)" -race $(shell $(GO) list ./... | grep -v vendor | grep -v tests | grep -v cmd)
|
2017-10-06 01:48:22 +08:00
|
|
|
tmp=$(shell mktemp -d) ; \
|
|
|
|
|
mkdir -p $$tmp/root $$tmp/runroot; \
|
2018-10-27 03:35:04 +08:00
|
|
|
$(GO) test -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" ./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
|