-
Notifications
You must be signed in to change notification settings - Fork 76
/
Makefile
175 lines (149 loc) · 6.5 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
GIT = git
MAKE = make
DOCKERREGISTRY := drbd.io
ARCH ?= amd64
ifneq ($(strip $(ARCH)),)
DOCKERREGISTRY := $(DOCKERREGISTRY)/$(ARCH)
endif
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/\(.*\)-g/\1-/')
GITHASH := $(shell git rev-parse HEAD)
DEBVERSION = $(shell echo $(VERSION) | sed -e 's/-/~/g')
.PHONY: .filelist
.filelist:
@set -e ; submodules=`$(GIT) submodule foreach --quiet 'echo $$path'`; \
$(GIT) ls-files | \
grep -v "^\.gitlab" | \
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 jclcrypto/jar.deps >> .filelist
@echo server/libs >> .filelist
@echo controller/libs >> .filelist
@echo satellite/libs >> .filelist
@echo jclcrypto/libs >> .filelist
@echo gradlew >> .filelist
@echo gradle/wrapper/gradle-wrapper.jar >> .filelist
@echo gradle/wrapper/gradle-wrapper.properties >> .filelist
@echo .filelist >> .filelist
@echo "./.filelist updated."
tgz:
test -s .filelist
@if [ ! -e .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 ($(DEBVERSION)" 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:
@./gradlew getprotoc
.PHONY: gen-java
gen-java: getprotc
@./gradlew generateJava
@echo "generated java sources"
.PHONY: copytolibs
copytolibs:
./gradlew --console plain copytolibs
server/jar.deps: build.gradle
./gradlew -q showServerRuntimeLibs > $@
ifneq ("$(wildcard libs/server-st.jar)","")
echo "/usr/share/linstor-server/lib/server-st.jar" >> $@
endif
controller/jar.deps satellite/jar.deps jclcrypto/jar.deps: build.gradle copytolibs
./scripts/diffcopy.py -n ./controller/libs/runtimeClasspath ./server/libs/runtimeClasspath /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/runtimeClasspath ./server/libs/runtimeClasspath /usr/share/linstor-server/lib > satellite/jar.deps
sed -i '/^|usr|share|linstor-server|lib|server-/d' satellite/jar.deps
./scripts/diffcopy.py -n ./jclcrypto/libs/runtimeClasspath ./server/libs/runtimeClasspath /usr/share/linstor-server/lib > jclcrypto/jar.deps
sed -i '/^|usr|share|linstor-server|lib|server-/d' jclcrypto/jar.deps
ifneq ("$(wildcard libs/controller-st.jar)","")
echo "/usr/share/linstor-server/lib/controller-st.jar" >> controller/jar.deps
endif
ifneq ("$(wildcard libs/satellite-st.jar)","")
echo "/usr/share/linstor-server/lib/satellite-st.jar" >> satellite/jar.deps
endif
ifneq ("$(wildcard libs/jclcrypto-st.jar)","")
echo "/usr/share/linstor-server/lib/jclcrypto-st.jar" >> jclcrypto/jar.deps
endif
tarball: check-all-committed check-submods versioninfo gen-java server/jar.deps controller/jar.deps satellite/jar.deps jclcrypto/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 --build-arg=ARCH=$(ARCH) -f $(DOCKERFILE_CONTROLLER) -t $(DOCKERREGPATH_CONTROLLER):$(DOCKER_TAG) $(EXTRA_DOCKER_BUILDARGS) .
docker tag $(DOCKERREGPATH_CONTROLLER):$(DOCKER_TAG) $(DOCKERREGPATH_CONTROLLER):latest
dockerimage.satellite:
docker build --build-arg=ARCH=$(ARCH) -f $(DOCKERFILE_SATELLITE) -t $(DOCKERREGPATH_SATELLITE):$(DOCKER_TAG) $(EXTRA_DOCKER_BUILDARGS) .
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
generate-db-constants:
./gradlew controller:distTar -PversionOverride=
rm -Rf ./controller/build/distributions/controller
tar -xf ./controller/build/distributions/controller.tar -C ./controller/build/distributions
java -cp "controller/build/distributions/controller/lib/*" com/linbit/linstor/dbcp/GenerateSql
.PHONY: check-openapi
check-openapi: docs/rest_v1_openapi.yaml
cd docs && docker run -it --rm -v `pwd`:/data jamescooke/openapi-validator:0.51.3 -e rest_v1_openapi.yaml