forked from Mirantis/cri-dockerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (92 loc) · 4.69 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
APP_DIR:=$(CURDIR)
PACKAGING_DIR:=$(CURDIR)/packaging
RELEASE_DIR:=$(CURDIR)/build/release
DATE_FMT=+%Y%m%d.%H%M%S
SOURCE_DATE_EPOCH?=$(shell git log -1 --pretty=%ct)
ifdef SOURCE_DATE_EPOCH
BUILD_DATE?=$(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
BUILD_DATE?=$(shell date "$(DATE_FMT)")
endif
SHELL=/bin/bash
export VERSION?=$(shell (git describe --abbrev=0 --tags | sed -e 's/v//') || echo $(cat VERSION)-$(git log -1 --pretty='%h'))
PRERELEASE=`grep -q dev <<< "${VERSION}" && echo "pre" || echo ""`
REVISION?=`git log -1 --pretty='%h'`
export CRI_DOCKERD_LDFLAGS:=-ldflags "${CRI_DOCKERD_LDFLAGS} -s -w -buildid=${REVISION} \
-X github.com/Mirantis/cri-dockerd/cmd/version.Version=${VERSION} \
-X github.com/Mirantis/cri-dockerd/cmd/version.PreRelease=${PRERELEASE} \
-X github.com/Mirantis/cri-dockerd/cmd/version.GitCommit=${REVISION}"
.PHONY: help
help: ## show make targets
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: cri-dockerd
cri-dockerd: ## build cri-dockerd
GOARCH=$(ARCH) go build -trimpath $(CRI_DOCKERD_LDFLAGS) -o $@
.PHONY: deb
deb: ## build deb packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) deb
.PHONY: rpm
rpm: ## build rpm packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) rpm
.PHONY: static
static: ## build static packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) static
.PHONY: static-linux
static-linux: ## build static packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) static-linux
.PHONY: cross-mac
cross-mac: ## build static packages
echo ${SOURCE_DATE_EPOCH}
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) cross-mac
.PHONY: cross-win
cross-win: ## build static packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) cross-win
.PHONY: cross-arm
cross-arm: ## build static packages
$(MAKE) APP_DIR=$(APP_DIR) -C $(PACKAGING_DIR) cross-arm
.PHONY: clean
clean: ## clean the build artifacts
$(RM) cri-dockerd
$(RM) -r build
-$(MAKE) -C $(PACKAGING_DIR) clean
.PHONY: release
release: static deb rpm cross-arm cross-mac cross-win ## build the release binaries
mkdir -p $(RELEASE_DIR)
# Copy the release files
# Debian
cp $(PACKAGING_DIR)/deb/debbuild/debian-bullseye/cri-dockerd_$(VERSION)~3-0~debian-bullseye_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/debian-buster/cri-dockerd_$(VERSION)~3-0~debian-buster_amd64.deb $(RELEASE_DIR)
# Ubuntu
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-bionic/cri-dockerd_$(VERSION)~3-0~ubuntu-bionic_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-focal/cri-dockerd_$(VERSION)~3-0~ubuntu-focal_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-jammy/cri-dockerd_$(VERSION)~3-0~ubuntu-jammy_amd64.deb $(RELEASE_DIR)
# CentOS
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el7.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el8.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el7.src.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el8.src.rpm $(RELEASE_DIR)
# Fedora
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc35.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc36.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc35.src.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc36.src.rpm $(RELEASE_DIR)
# arm
cp $(PACKAGING_DIR)/static/build/arm/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).arm64.tgz
# win
cp $(PACKAGING_DIR)/static/build/win/cri-dockerd-$(VERSION).zip $(RELEASE_DIR)/cri-dockerd-$(VERSION).win.amd64.zip
# mac
cp $(PACKAGING_DIR)/static/build/mac/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).darwin.amd64.tgz
# linux
cp $(PACKAGING_DIR)/static/build/linux/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).amd64.tgz
.PHONY: run
run: cri-dockerd ## Run cri-docker in a running minikube
sudo ./cri-dockerd --log-level debug --network-plugin=""
.PHONY: dev
dev: cri-dockerd ## Run cri-docker in a running minikube
./scripts/replace-in-minikube
.PHONY: docs
docs:
hugo server --source docs/
.PHONY: integration
integration:
sudo critest -runtime-endpoint=unix:///var/run/cri-dockerd.sock -ginkgo.skip="runtime should support apparmor|runtime should support reopening container log|runtime should support execSync with timeout|runtime should support selinux|.*should support propagation.*"