diff --git a/shim/Makefile b/shim/Makefile index 7e4640e1590811786e1551f33b0e49cab03d720b..0b8b36b6db1e6feec8f0ab91e0bd2047217ee56c 100644 --- a/shim/Makefile +++ b/shim/Makefile @@ -4,6 +4,11 @@ ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) # Base path used to install. DESTDIR ?= /usr/local +# Variables for building rpm +VERSION ?= 0.2.0 +RELEASE_TARBALL_URL ?= https://github.com/alibaba/inclavare-containers/archive/v$(VERSION).tar.gz +RPMBUILD_DIR ?= /tmp/inclavare-containers/shim/rpmbuild + ifneq "$(strip $(shell command -v go 2>/dev/null))" "" GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) @@ -39,7 +44,7 @@ SHIM_CGO_ENABLED ?= 0 BINARIES=$(addprefix bin/,$(COMMANDS)) -.PHONY: clean all build binaries help install uninstall +.PHONY: clean all binaries help install uninstall rpm .DEFAULT: default all: binaries @@ -49,11 +54,19 @@ bin/containerd-shim-rune-v2: @echo "bin/containerd-shim-rune-v2" @CGO_ENABLED=${SHIM_CGO_ENABLED} GOOS=${GOOS} go build ${GO_BUILD_FLAGS} -o bin/containerd-shim-rune-v2 ./cmd/containerd-shim-rune-v2 -binaries: $(BINARIES) ## build binaries +binaries: clean $(BINARIES) ## build binaries clean: ## clean up binaries @echo "$@" @rm -f $(BINARIES) + @rm -fr ${RPMBUILD_DIR} + +rpm: + @mkdir -p $(RPMBUILD_DIR) + @echo "%_topdir $(RPMBUILD_DIR)" >> ~/.rpmmacros + @mkdir -p $(RPMBUILD_DIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + @wget -P $(RPMBUILD_DIR)/SOURCES $(RELEASE_TARBALL_URL) + $(MAKE) -C dist/centos rpm RPMBUILD_DIR=$(RPMBUILD_DIR) install: ## install binaries @echo "$@ $(BINARIES)"