Introduce make release
So we can make all types of release binary with combination of following flags: seccomp selinux apparmor static All binary files are put in release/ dir, like: [root@zlosvm1 runc]# ls -l release total 53556 -rwxr-xr-x 1 root root 9517965 Aug 24 16:59 runc -rwxr-xr-x 1 root root 9673533 Aug 24 17:00 runc.seccomp -rwxr-xr-x 1 root root 9705839 Aug 24 17:00 runc.seccomp.selinux -rwxr-xr-x 1 root root 9546175 Aug 24 16:59 runc.selinux -rwxr-xr-x 1 root root 8205015 Aug 24 16:59 runc.selinux.static -rwxr-xr-x 1 root root 8181789 Aug 24 16:59 runc.static ... Closes #899 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
This commit is contained in:
parent
0636bdd45b
commit
54390f89a7
|
@ -2,3 +2,4 @@ vendor/pkg
|
|||
/runc
|
||||
Godeps/_workspace/src/github.com/opencontainers/runc
|
||||
man/man8
|
||||
release
|
||||
|
|
31
Makefile
31
Makefile
|
@ -20,14 +20,44 @@ MAN_PAGES = $(shell ls $(MAN_DIR)/*.8)
|
|||
MAN_PAGES_BASE = $(notdir $(MAN_PAGES))
|
||||
MAN_INSTALL_PATH := ${PREFIX}/share/man/man8/
|
||||
|
||||
RELEASE_DIR := $(CURDIR)/release
|
||||
|
||||
VERSION := ${shell cat ./VERSION}
|
||||
|
||||
SHELL ?= $(shell command -v bash 2>/dev/null)
|
||||
|
||||
all: $(RUNC_LINK)
|
||||
go build -i -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -tags "$(BUILDTAGS)" -o runc .
|
||||
|
||||
static: $(RUNC_LINK)
|
||||
CGO_ENABLED=1 go build -i -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o runc .
|
||||
|
||||
release: $(RUNC_LINK)
|
||||
@flag_list=(seccomp selinux apparmor static); \
|
||||
unset expression; \
|
||||
for flag in "$${flag_list[@]}"; do \
|
||||
expression+="' '{'',$${flag}}"; \
|
||||
done; \
|
||||
eval profile_list=("$$expression"); \
|
||||
for profile in "$${profile_list[@]}"; do \
|
||||
output=${RELEASE_DIR}/runc; \
|
||||
for flag in $$profile; do \
|
||||
output+=."$$flag"; \
|
||||
done; \
|
||||
tags="$$profile"; \
|
||||
ldflags="-X main.gitCommit=${COMMIT} -X main.version=${VERSION}"; \
|
||||
CGO_ENABLED=; \
|
||||
[[ "$$profile" =~ static ]] && { \
|
||||
tags="$${tags/static/static_build}"; \
|
||||
tags+=" cgo"; \
|
||||
ldflags+=" -w -extldflags -static"; \
|
||||
CGO_ENABLED=1; \
|
||||
}; \
|
||||
echo "Building target: $$output"; \
|
||||
rm -rf "${GOPATH}/pkg"; \
|
||||
go build -i -ldflags "$$ldflags" -tags "$$tags" -o "$$output" .; \
|
||||
done
|
||||
|
||||
$(RUNC_LINK):
|
||||
ln -sfn $(CURDIR) $(RUNC_LINK)
|
||||
|
||||
|
@ -88,6 +118,7 @@ clean:
|
|||
rm -f runc
|
||||
rm -f $(RUNC_LINK)
|
||||
rm -rf $(GOPATH)/pkg
|
||||
rm -rf $(RELEASE_DIR)
|
||||
|
||||
validate:
|
||||
script/validate-gofmt
|
||||
|
|
Loading…
Reference in New Issue