2016-10-21 12:19:40 +00:00
|
|
|
GO ?= go
|
2017-05-16 13:23:35 +00:00
|
|
|
EPOCH_TEST_COMMIT ?= 1cc5a27
|
2016-09-26 23:55:12 +00:00
|
|
|
PROJECT := github.com/kubernetes-incubator/cri-o
|
2016-09-20 10:23:34 +00:00
|
|
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
|
|
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
|
2017-05-15 22:05:58 +00:00
|
|
|
CRIO_IMAGE := crio_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
|
|
|
|
CRIO_INSTANCE := crio_dev
|
2017-01-05 05:39:22 +00:00
|
|
|
PREFIX ?= ${DESTDIR}/usr/local
|
2016-10-21 12:19:40 +00:00
|
|
|
BINDIR ?= ${PREFIX}/bin
|
|
|
|
LIBEXECDIR ?= ${PREFIX}/libexec
|
|
|
|
MANDIR ?= ${PREFIX}/share/man
|
2016-10-31 17:38:03 +00:00
|
|
|
ETCDIR ?= ${DESTDIR}/etc
|
2017-05-15 22:05:58 +00:00
|
|
|
ETCDIR_CRIO ?= ${ETCDIR}/crio
|
2018-01-19 19:39:27 +00:00
|
|
|
BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_installed.sh) $(shell hack/libdm_no_deferred_remove_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh)
|
2017-11-11 11:05:36 +00:00
|
|
|
CRICTL_CONFIG_DIR=${DESTDIR}/etc
|
2017-10-19 17:30:50 +00:00
|
|
|
|
2016-12-02 15:15:15 +00:00
|
|
|
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
2017-09-21 13:31:13 +00:00
|
|
|
OCIUMOUNTINSTALLDIR=$(PREFIX)/share/oci-umount/oci-umount.d
|
|
|
|
|
2017-09-12 10:17:44 +00:00
|
|
|
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
|
|
|
|
PACKAGES ?= $(shell go list -tags "${BUILDTAGS}" ./... | grep -v github.com/kubernetes-incubator/cri-o/vendor)
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2017-09-08 23:17:57 +00:00
|
|
|
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
|
|
|
|
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}")
|
2017-06-16 16:27:06 +00:00
|
|
|
BUILD_INFO := $(shell date +%s)
|
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
# If GOPATH not specified, use one in the local directory
|
|
|
|
ifeq ($(GOPATH),)
|
|
|
|
export GOPATH := $(CURDIR)/_output
|
|
|
|
unexport GOBIN
|
|
|
|
endif
|
|
|
|
GOPKGDIR := $(GOPATH)/src/$(PROJECT)
|
|
|
|
GOPKGBASEDIR := $(shell dirname "$(GOPKGDIR)")
|
|
|
|
|
|
|
|
# Update VPATH so make finds .gopathok
|
|
|
|
VPATH := $(VPATH):$(GOPATH)
|
2017-10-19 17:32:41 +00:00
|
|
|
SHRINKFLAGS := -s -w
|
2017-10-30 10:59:17 +00:00
|
|
|
BASE_LDFLAGS := ${SHRINKFLAGS} -X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO}
|
|
|
|
LDFLAGS := -ldflags '${BASE_LDFLAGS}'
|
2017-06-16 16:27:06 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
all: binaries crio.conf docs
|
2016-10-14 16:03:36 +00:00
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
default: help
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo "Usage: make <target>"
|
|
|
|
@echo
|
2017-01-17 19:57:35 +00:00
|
|
|
@echo " * 'install' - Install binaries to system locations"
|
2017-11-20 05:59:24 +00:00
|
|
|
@echo " * 'binaries' - Build crio, conmon and pause"
|
2016-09-20 10:23:34 +00:00
|
|
|
@echo " * 'integration' - Execute integration tests"
|
2016-09-19 06:28:34 +00:00
|
|
|
@echo " * 'clean' - Clean artifacts"
|
|
|
|
@echo " * 'lint' - Execute the source code linter"
|
2016-12-14 11:31:24 +00:00
|
|
|
@echo " * 'gofmt' - Verify the source code gofmt"
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
.gopathok:
|
|
|
|
ifeq ("$(wildcard $(GOPKGDIR))","")
|
|
|
|
mkdir -p "$(GOPKGBASEDIR)"
|
|
|
|
ln -s "$(CURDIR)" "$(GOPKGBASEDIR)"
|
2017-01-17 19:57:35 +00:00
|
|
|
endif
|
2017-03-27 20:53:33 +00:00
|
|
|
touch "$(GOPATH)/.gopathok"
|
2017-01-19 19:23:29 +00:00
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
lint: .gopathok
|
2016-09-19 06:28:34 +00:00
|
|
|
@echo "checking lint"
|
|
|
|
@./.tool/lint
|
2016-09-17 09:37:45 +00:00
|
|
|
|
2016-12-14 11:31:24 +00:00
|
|
|
gofmt:
|
|
|
|
@./hack/verify-gofmt.sh
|
|
|
|
|
2016-09-17 09:37:45 +00:00
|
|
|
conmon:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C $@
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-02 08:36:39 +00:00
|
|
|
pause:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C $@
|
2016-10-02 08:36:39 +00:00
|
|
|
|
2017-07-21 11:56:00 +00:00
|
|
|
test/bin2img/bin2img: .gopathok $(wildcard test/bin2img/*.go)
|
2018-01-04 15:52:33 +00:00
|
|
|
$(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o $@ $(PROJECT)/test/bin2img
|
2016-12-16 23:34:51 +00:00
|
|
|
|
2017-07-21 11:56:00 +00:00
|
|
|
test/copyimg/copyimg: .gopathok $(wildcard test/copyimg/*.go)
|
2018-01-04 15:52:33 +00:00
|
|
|
$(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o $@ $(PROJECT)/test/copyimg
|
2017-01-10 22:57:22 +00:00
|
|
|
|
2017-07-21 11:56:00 +00:00
|
|
|
test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
|
2018-01-04 15:52:33 +00:00
|
|
|
$(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o $@ $(PROJECT)/test/checkseccomp
|
2017-01-19 17:10:47 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
crio: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/crio $(PROJECT))
|
2018-01-04 15:52:33 +00:00
|
|
|
$(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o bin/$@ $(PROJECT)/cmd/crio
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
crio.conf: crio
|
2017-10-30 10:59:17 +00:00
|
|
|
./bin/crio --config="" config --default > crio.conf
|
2016-10-12 19:53:58 +00:00
|
|
|
|
2016-07-15 17:52:13 +00:00
|
|
|
clean:
|
2017-03-27 20:53:33 +00:00
|
|
|
ifneq ($(GOPATH),)
|
|
|
|
rm -f "$(GOPATH)/.gopathok"
|
|
|
|
endif
|
|
|
|
rm -rf _output
|
2017-11-08 15:10:58 +00:00
|
|
|
rm -f docs/*.5 docs/*.8
|
2017-01-10 22:57:22 +00:00
|
|
|
rm -fr test/testdata/redis-image
|
2016-09-28 18:33:53 +00:00
|
|
|
find . -name \*~ -delete
|
|
|
|
find . -name \#\* -delete
|
2017-11-20 05:59:24 +00:00
|
|
|
rm -f bin/crio
|
2016-10-14 16:03:36 +00:00
|
|
|
make -C conmon clean
|
|
|
|
make -C pause clean
|
2017-03-27 20:53:33 +00:00
|
|
|
rm -f test/bin2img/bin2img
|
|
|
|
rm -f test/copyimg/copyimg
|
|
|
|
rm -f test/checkseccomp/checkseccomp
|
2016-09-17 13:50:35 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
crioimage:
|
2017-05-15 22:05:58 +00:00
|
|
|
docker build -t ${CRIO_IMAGE} .
|
2016-09-20 10:23:34 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
dbuild: crioimage
|
2017-11-03 02:12:03 +00:00
|
|
|
docker run --name=${CRIO_INSTANCE} -e BUILDTAGS --privileged -v ${PWD}:/go/src/${PROJECT} --rm ${CRIO_IMAGE} make binaries
|
2016-09-20 10:23:34 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
integration: crioimage
|
2017-10-24 21:54:09 +00:00
|
|
|
docker run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${CRIO_IMAGE} make localintegration
|
2016-09-20 10:23:34 +00:00
|
|
|
|
2017-09-12 10:17:44 +00:00
|
|
|
testunit:
|
|
|
|
$(GO) test -tags "$(BUILDTAGS)" -cover $(PACKAGES)
|
|
|
|
|
2017-10-30 10:59:17 +00:00
|
|
|
localintegration: clean binaries test-binaries
|
2016-09-24 07:55:26 +00:00
|
|
|
./test/test_runner.sh ${TESTFLAGS}
|
2016-09-20 10:23:34 +00:00
|
|
|
|
2017-11-20 05:59:24 +00:00
|
|
|
binaries: crio conmon pause
|
2017-10-30 10:59:17 +00:00
|
|
|
test-binaries: test/bin2img/bin2img test/copyimg/copyimg test/checkseccomp/checkseccomp
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
MANPAGES_MD := $(wildcard docs/*.md)
|
|
|
|
MANPAGES := $(MANPAGES_MD:%.md=%)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
docs/%.5: docs/%.5.md .gopathok
|
2017-07-10 14:23:16 +00:00
|
|
|
(go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@) || ($(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
docs/%.8: docs/%.8.md .gopathok
|
2017-07-10 14:23:16 +00:00
|
|
|
(go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@) || ($(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@)
|
2016-12-02 15:15:15 +00:00
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
docs: $(MANPAGES)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-09-08 11:52:57 +00:00
|
|
|
install: .gopathok install.bin install.man
|
|
|
|
|
|
|
|
install.bin:
|
2017-10-30 10:59:17 +00:00
|
|
|
install ${SELINUXOPT} -D -m 755 bin/crio $(BINDIR)/crio
|
|
|
|
install ${SELINUXOPT} -D -m 755 bin/conmon $(LIBEXECDIR)/crio/conmon
|
|
|
|
install ${SELINUXOPT} -D -m 755 bin/pause $(LIBEXECDIR)/crio/pause
|
2017-09-08 11:52:57 +00:00
|
|
|
|
|
|
|
install.man:
|
2017-09-05 20:45:06 +00:00
|
|
|
install ${SELINUXOPT} -d -m 755 $(MANDIR)/man5
|
|
|
|
install ${SELINUXOPT} -d -m 755 $(MANDIR)/man8
|
|
|
|
install ${SELINUXOPT} -m 644 $(filter %.5,$(MANPAGES)) -t $(MANDIR)/man5
|
|
|
|
install ${SELINUXOPT} -m 644 $(filter %.8,$(MANPAGES)) -t $(MANDIR)/man8
|
2017-01-05 05:39:22 +00:00
|
|
|
|
2018-01-10 21:23:35 +00:00
|
|
|
install.config: crio.conf
|
2017-09-05 20:45:06 +00:00
|
|
|
install ${SELINUXOPT} -D -m 644 crio.conf $(ETCDIR_CRIO)/crio.conf
|
|
|
|
install ${SELINUXOPT} -D -m 644 seccomp.json $(ETCDIR_CRIO)/seccomp.json
|
2017-09-21 13:31:13 +00:00
|
|
|
install ${SELINUXOPT} -D -m 644 crio-umount.conf $(OCIUMOUNTINSTALLDIR)/crio-umount.conf
|
2017-11-11 11:05:36 +00:00
|
|
|
install ${SELINUXOPT} -D -m 644 crictl.yaml $(CRICTL_CONFIG_DIR)
|
2016-09-28 17:08:56 +00:00
|
|
|
|
2016-12-02 15:15:15 +00:00
|
|
|
install.completions:
|
2017-09-05 20:45:06 +00:00
|
|
|
install ${SELINUXOPT} -d -m 755 ${BASHINSTALLDIR}
|
2016-12-02 15:15:15 +00:00
|
|
|
|
2016-10-15 04:51:39 +00:00
|
|
|
install.systemd:
|
2017-09-05 20:45:06 +00:00
|
|
|
install ${SELINUXOPT} -D -m 644 contrib/systemd/crio.service $(PREFIX)/lib/systemd/system/crio.service
|
2017-08-28 12:59:35 +00:00
|
|
|
ln -sf crio.service $(PREFIX)/lib/systemd/system/cri-o.service
|
2017-09-05 20:45:06 +00:00
|
|
|
install ${SELINUXOPT} -D -m 644 contrib/systemd/crio-shutdown.service $(PREFIX)/lib/systemd/system/crio-shutdown.service
|
2016-10-15 04:51:39 +00:00
|
|
|
|
2016-09-28 17:08:56 +00:00
|
|
|
uninstall:
|
2017-05-12 13:36:15 +00:00
|
|
|
rm -f $(BINDIR)/crio
|
|
|
|
rm -f $(LIBEXECDIR)/crio/conmon
|
|
|
|
rm -f $(LIBEXECDIR)/crio/pause
|
2016-12-02 15:15:15 +00:00
|
|
|
for i in $(filter %.1,$(MANPAGES)); do \
|
2016-10-21 12:19:40 +00:00
|
|
|
rm -f $(MANDIR)/man8/$$(basename $${i}); \
|
2016-09-28 18:33:53 +00:00
|
|
|
done
|
2016-10-21 12:19:40 +00:00
|
|
|
for i in $(filter %.5,$(MANPAGES)); do \
|
|
|
|
rm -f $(MANDIR)/man5/$$(basename $${i}); \
|
2016-10-09 17:36:43 +00:00
|
|
|
done
|
2016-12-02 15:15:15 +00:00
|
|
|
for i in $(filter %.8,$(MANPAGES)); do \
|
|
|
|
rm -f $(MANDIR)/man8/$$(basename $${i}); \
|
|
|
|
done
|
2016-09-28 17:08:56 +00:00
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
.PHONY: .gitvalidation
|
|
|
|
# When this is running in travis, it will only check the travis commit range
|
2017-03-27 20:53:33 +00:00
|
|
|
.gitvalidation: .gopathok
|
2016-09-19 06:28:34 +00:00
|
|
|
ifeq ($(TRAVIS),true)
|
2017-05-25 09:02:59 +00:00
|
|
|
GIT_CHECK_EXCLUDE="./vendor" $(GOPATH)/bin/git-validation -q -run DCO,short-subject,dangling-whitespace
|
2016-09-19 06:28:34 +00:00
|
|
|
else
|
2017-05-25 09:02:59 +00:00
|
|
|
GIT_CHECK_EXCLUDE="./vendor" $(GOPATH)/bin/git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
|
2016-09-19 06:28:34 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: install.tools
|
|
|
|
|
2016-09-28 21:55:35 +00:00
|
|
|
install.tools: .install.gitvalidation .install.gometalinter .install.md2man
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2017-03-27 20:53:33 +00:00
|
|
|
.install.gitvalidation: .gopathok
|
|
|
|
if [ ! -x "$(GOPATH)/bin/git-validation" ]; then \
|
|
|
|
go get -u github.com/vbatts/git-validation; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
.install.gometalinter: .gopathok
|
|
|
|
if [ ! -x "$(GOPATH)/bin/gometalinter" ]; then \
|
|
|
|
go get -u github.com/alecthomas/gometalinter; \
|
2017-07-10 19:16:37 +00:00
|
|
|
cd $(GOPATH)/src/github.com/alecthomas/gometalinter; \
|
|
|
|
git checkout 23261fa046586808612c61da7a81d75a658e0814; \
|
|
|
|
go install github.com/alecthomas/gometalinter; \
|
2017-03-27 20:53:33 +00:00
|
|
|
$(GOPATH)/bin/gometalinter --install; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
.install.md2man: .gopathok
|
|
|
|
if [ ! -x "$(GOPATH)/bin/go-md2man" ]; then \
|
|
|
|
go get -u github.com/cpuguy83/go-md2man; \
|
|
|
|
fi
|
2016-09-28 21:55:35 +00:00
|
|
|
|
2017-07-13 17:13:36 +00:00
|
|
|
.install.ostree: .gopathok
|
|
|
|
if ! pkg-config ostree-1 2> /dev/null ; then \
|
|
|
|
git clone https://github.com/ostreedev/ostree $(GOPATH)/src/github.com/ostreedev/ostree ; \
|
|
|
|
cd $(GOPATH)/src/github.com/ostreedev/ostree ; \
|
|
|
|
./autogen.sh --prefix=/usr/local; \
|
|
|
|
make all install; \
|
|
|
|
fi
|
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
.PHONY: \
|
|
|
|
binaries \
|
2016-10-02 08:36:39 +00:00
|
|
|
clean \
|
2016-09-19 07:21:14 +00:00
|
|
|
conmon \
|
2016-09-28 18:33:53 +00:00
|
|
|
default \
|
|
|
|
docs \
|
2016-12-14 11:31:24 +00:00
|
|
|
gofmt \
|
2016-09-28 18:33:53 +00:00
|
|
|
help \
|
2016-09-28 17:08:56 +00:00
|
|
|
install \
|
2016-10-02 08:36:39 +00:00
|
|
|
lint \
|
|
|
|
pause \
|
2016-09-28 17:08:56 +00:00
|
|
|
uninstall
|