forked from sylabs/singularity-cri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (70 loc) · 2.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# silent build
V := @
BIN_DIR := ./bin
SY_CRI := $(BIN_DIR)/sycri
SY_CRI_TEST := $(BIN_DIR)/sycri.test
INSTALL_DIR := /usr/local/bin
SY_CRI_INSTALL := $(INSTALL_DIR)/sycri
CRI_CONFIG := ./config/sycri.yaml
CRI_CONFIG_INSTALL := /usr/local/etc/sycri/sycri.yaml
SECCOMP = "$(shell printf "\#include <seccomp.h>\nint main() { seccomp_syscall_resolve_name(\"read\"); }" | gcc -x c -o /dev/null - -lseccomp >/dev/null 2>&1; echo $$?)"
all: $(SY_CRI)
$(SY_CRI):
@echo " GO" $@
@if [ $(SECCOMP) -eq "0" ] ; then \
_=$(eval BUILD_TAGS = seccomp) ; \
else \
echo " WARNING: seccomp is not found, ignoring" ; \
fi
$(V)GOOS=linux go build -mod vendor -tags "sylog selinux $(BUILD_TAGS)" \
-ldflags "-X main.version=`(git describe --tags --dirty --always 2>/dev/null || echo "unknown") \
| sed -e "s/^v//;s/-/_/g;s/_/-/;s/_/./g"`" \
-o $(SY_CRI) ./cmd/server
install: $(SY_CRI_INSTALL) $(CRI_CONFIG_INSTALL)
$(SY_CRI_INSTALL):
@echo " INSTALL" $@
$(V)install -d $(@D)
$(V)install -m 0755 $(SY_CRI) $(SY_CRI_INSTALL)
$(CRI_CONFIG_INSTALL):
@echo " INSTALL" $@
$(V)install -d $(@D)
$(V)install -m 0644 $(CRI_CONFIG) $(CRI_CONFIG_INSTALL)
.PHONY: clean
clean:
@echo " CLEAN"
$(V)go clean -mod vendor
$(V)rm -rf $(BIN_DIR)
.PHONY: uninstall
uninstall:
@echo " UNINSTALL"
$(V)rm -rf $(SY_CRI_INSTALL) $(CRI_CONFIG_INSTALL)
.PHONY: test
test:
$(V)GOOS=linux go test -mod vendor -v -coverprofile=cover.out -race ./...
$(SY_CRI_TEST):
@echo " GO" $@
@if [ $(SECCOMP) -eq "0" ] ; then \
_=$(eval BUILD_TAGS = seccomp) ; \
else \
echo " WARNING: seccomp is not found, ignoring" ; \
fi
$(V)GOOS=linux go test -mod vendor -c -o $(SY_CRI_TEST) -tags "selinux $(BUILD_TAGS) testrunmain" \
-coverpkg=./... ./cmd/server
GOBIN = $(shell go env GOPATH)/bin
LINTER = $(GOBIN)/golangci-lint
LINTER_VERSION := v1.19.1
.PHONY: linter-install
linter-install:
@echo " INSTALL" $(LINTER) $(LINTER_VERSION)
$(V)curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOBIN) $(LINTER_VERSION)
.PHONY: lint
lint:
$(V) [ ! -x $(LINTER) ] && \
echo 'Linter is not installed, run `make linter-install`' && \
exit 1 || true
@echo " RUNNING LINTER"
$(V)$(LINTER) run --config .golangci.local.yml
.PHONY: dep
dep:
$(V)go mod tidy
$(V)go mod vendor