forked from LINBIT/linstor-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (116 loc) · 4.76 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
GIT = git
MAKE = make
DOCKERREGISTRY = drbd.io
DOCKERREGPATH_CONTROLLER = $(DOCKERREGISTRY)/linstor-controller
DOCKERREGPATH_SATELLITE = $(DOCKERREGISTRY)/linstor-satellite
DOCKERFILE_CONTROLLER = Dockerfile.controller
DOCKERFILE_SATELLITE = Dockerfile.satellite
DOCKER_TAG ?= latest
GENRES=./server/generated-resources
GENSRC=./server/generated-src
VERSINFO=$(GENRES)/version-info.properties
# echo v0.1 to get it started
VERSION := $(shell echo $(shell git describe --tags || echo "v0.1") | sed -e 's/^v//;s/^[^0-9]*//;s/-/./;s/\(.*\)-g/\1-/')
GITHASH := $(shell git rev-parse HEAD)
.PHONY: .filelist
.filelist:
@set -e ; submodules=`$(GIT) submodule foreach --quiet 'echo $$path'`; \
$(GIT) ls-files | \
grep -vxF -e "$$submodules" | \
sed '$(if $(PRESERVE_DEBIAN),,/^debian/d)' | \
grep -v "gitignore\|gitmodules" > .filelist
@$(GIT) submodule foreach --quiet 'git ls-files | sed -e "s,^,$$path/,"' | \
grep -v "gitignore\|gitmodules" >> .filelist
@[ -s .filelist ] # assert there is something in .filelist now
@echo $(VERSINFO) >> .filelist
@find $(GENSRC) -name '*.java' >> .filelist
@echo libs >> .filelist
@echo server/jar.deps >> .filelist
@echo controller/jar.deps >> .filelist
@echo satellite/jar.deps >> .filelist
@echo server/libs >> .filelist
@echo controller/libs >> .filelist
@echo satellite/libs >> .filelist
@echo .filelist >> .filelist
@echo "./.filelist updated."
tgz:
test -s .filelist
@if [ ! -d .git ]; then \
echo >&2 "Not a git directory!"; exit 1; \
fi; \
tar --transform="s,^,linstor-server-$(VERSION)/,S" \
--owner=0 --group=0 -czf - -T .filelist > linstor-server-$(VERSION).tar.gz
# we cannot use 'git submodule foreach':
# foreach only works if submodule already checked out
.PHONY: check-submods
check-submods:
@if test -d .git && test -s .gitmodules; then \
for d in `grep "^\[submodule" .gitmodules | cut -f2 -d'"'`; do \
if [ ! "`ls -A $$d`" ]; then \
git submodule init; \
git submodule update; \
break; \
fi; \
done; \
fi
prepare_release: tarball
release: prepare_release
debrelease:
make tarball PRESERVE_DEBIAN=1 KEEPNAME=1
.PHONY: check-all-committed
check-all-committed:
ifneq ($(FORCE),1)
if ! tmp=$$(git diff --name-status HEAD 2>&1) || test -n "$$tmp" ; then \
echo >&2 "$$tmp"; echo >&2 "Uncommitted changes"; exit 1; \
fi
if ! grep -q "^linstor-server ($(VERSION)" debian/changelog ; then \
echo >&2 "debian/changelog needs update"; exit 1; \
fi
for df in "$(DOCKERFILE_CONTROLLER)" "$(DOCKERFILE_SATELLITE)"; do \
if test "$$(grep -c "ENV LINSTOR_VERSION $(VERSION)" "$$df")" -ne 2 ; then \
echo >&2 "LINSTOR_VERSION in $$df needs update"; exit 1; \
fi; \
done
endif
.PHONY: getprotc
getprotc:
@gradle getprotoc
.PHONY: gen-java
gen-java: getprotc
@gradle generateJava
@echo "generated java sources"
.PHONY: copytolibs
copytolibs:
gradle --console plain copytolibs
server/jar.deps: build.gradle
gradle -q showServerRuntimeLibs > $@
controller/jar.deps satellite/jar.deps: build.gradle copytolibs
./scripts/diffcopy.py -n ./controller/libs/runtime ./server/libs/runtime /usr/share/linstor-server/lib > controller/jar.deps
sed -i '/^|usr|share|linstor-server|lib|server-/d' controller/jar.deps
./scripts/diffcopy.py -n ./satellite/libs/runtime ./server/libs/runtime /usr/share/linstor-server/lib > satellite/jar.deps
sed -i '/^|usr|share|linstor-server|lib|server-/d' satellite/jar.deps
tarball: check-all-committed check-submods versioninfo gen-java server/jar.deps controller/jar.deps satellite/jar.deps .filelist
$(MAKE) tgz
versioninfo:
mkdir $(GENRES) || true
echo "version=$(VERSION)" > $(VERSINFO)
echo "git.commit.id=$(GITHASH)" >> $(VERSINFO)
echo "build.time=$$(date -u --iso-8601=second)" >> $(VERSINFO)
.PHONY: dockerimage dockerimage.controller dockerimage.satellite dockerpatch update-rest-props resttypes
dockerimage.controller:
docker build -f $(DOCKERFILE_CONTROLLER) -t $(DOCKERREGPATH_CONTROLLER):$(DOCKER_TAG) .
docker tag $(DOCKERREGPATH_CONTROLLER):$(DOCKER_TAG) $(DOCKERREGPATH_CONTROLLER):latest
dockerimage.satellite:
docker build -f $(DOCKERFILE_SATELLITE) -t $(DOCKERREGPATH_SATELLITE):$(DOCKER_TAG) .
docker tag $(DOCKERREGPATH_SATELLITE):$(DOCKER_TAG) $(DOCKERREGPATH_SATELLITE):latest
ifneq ($(FORCE),1)
dockerimage: debrelease dockerimage.controller dockerimage.satellite
else
dockerimage: dockerimage.controller dockerimage.satellite
endif
dockerpath:
@echo $(DOCKERREGPATH_CONTROLLER):latest $(DOCKERREGPATH_CONTROLLER):$(DOCKER_TAG) $(DOCKERREGPATH_SATELLITE):latest $(DOCKERREGPATH_SATELLITE):$(DOCKER_TAG)
update-rest-props:
PYTHONPATH=../linstor-api-py ./scripts/rest-docu-props.py -i docs/rest_v1_openapi.yaml
resttypes:
python3 ./scripts/rest-gen.py ./docs/rest_v1_openapi.yaml > controller/src/main/java/com/linbit/linstor/api/rest/v1/serializer/JsonGenTypes.java