-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.el7
286 lines (262 loc) · 11.5 KB
/
Makefile.el7
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
## Conditional variables.
DOCKER ?= docker
DOCKER_COMPOSE ?= docker-compose
EL_VERSION ?= el7
CI ?= false
COMPOSE_FILE ?= docker-compose.$(EL_VERSION).yml
COMPOSE_PROJECT_NAME ?= geoint-deps-$(RPMBUILD_CHANNEL)-$(EL_VERSION)
IMAGE_PREFIX ?= $(COMPOSE_PROJECT_NAME)_
## Macro functions.
build_unless_image_exists = $(shell $(DOCKER) image inspect $(IMAGE_PREFIX)$(1) >/dev/null 2>&1 || COMPOSE_FILE=$(COMPOSE_FILE) DOCKER_BUILDKIT=1 $(DOCKER_COMPOSE) build $(1))
pull_if_ci = $(shell bash -c '[ "$(CI)" == "false" ] || COMPOSE_FILE=$(COMPOSE_FILE) $(DOCKER_COMPOSE) pull --quiet $(1)')
# The `rpmbuild_util.py` utility script is used to pull out configured versions,
# Docker build images, and other build variables.
rpmbuild_util = $(shell ./scripts/rpmbuild_util.py $(1) --config-file $(COMPOSE_FILE) $(2))
config_release = $(call rpmbuild_util,$(1),--release)
config_version = $(call rpmbuild_util,$(1),--version)
# Variants for getting RPM file names.
RPMBUILD_DIST := $(call rpmbuild_util,dist,--variable)
rpm_file = $(call rpmbuild_util,$(1),--filename)
# Gets the RPM package name from the filename.
rpm_package = $(shell ./scripts/rpm_package.py $(1))
rpmbuild_image = $(call rpmbuild_util,$(call rpm_package,$(1)),--image)
rpmbuild_image_parent = $(call rpmbuild_util,$(call rpmbuild_image,$(1)).build.args.rpmbuild_image,--variable --config-key services)
rpmbuild_release = $(call config_release,$(call rpm_package,$(1)))
rpmbuild_version = $(call config_version,$(call rpm_package,$(1)))
## Variables
DOCKER_VERSION := $(shell $(DOCKER) --version 2>/dev/null)
DOCKER_COMPOSE_VERSION := $(shell $(DOCKER_COMPOSE) version 2>/dev/null)
POSTGRES_VERSION := $(call rpmbuild_util,postgres_version,--variable)
RPMBUILD_CHANNEL := $(call rpmbuild_util,channel_name,--variable)
RPMBUILD_UID := $(shell id -u)
RPMBUILD_GID := $(shell id -g)
# RPM files at desired versions.
CADDY_RPM := $(call rpm_file,caddy)
CGAL_RPM := $(call rpm_file,CGAL)
DUMB_INIT_RPM := $(call rpm_file,dumb-init)
FILEGDBAPI_RPM := $(call rpm_file,FileGDBAPI)
GDAL_RPM := $(call rpm_file,gdal)
GEOS_RPM := $(call rpm_file,geos)
GOOGLE_NOTO_RPM := $(call rpm_file,google-noto-fonts-extra)
GPSBABEL_RPM := $(call rpm_file,gpsbabel)
HANAZONO_RPM := $(call rpm_file,hanazono-fonts)
JOURNALD_CLOUDWATCH_LOGS_RPM := $(call rpm_file,journald-cloudwatch-logs)
LIBGEOTIFF_RPM := $(call rpm_file,libgeotiff)
LIBKML_RPM := $(call rpm_file,libkml)
LIBOSMIUM_RPM := $(call rpm_file,libosmium)
LIBOSMPBF_RPM := $(call rpm_file,libosmpbf)
MAPNIK_RPM := $(call rpm_file,mapnik)
OGDI_RPM := $(call rpm_file,ogdi)
OPENSTREETMAP_CARTO_RPM := $(call rpm_file,openstreetmap-carto)
OSM2PGSQL_RPM := $(call rpm_file,osm2pgsql)
OSMCTOOLS_RPM := $(call rpm_file,osmctools)
OSMDBT_RPM := $(call rpm_file,osmdbt)
OSMIUM_TOOL_RPM := $(call rpm_file,osmium-tool)
OSMOSIS_RPM := $(call rpm_file,osmosis)
PASSENGER_RPM := $(call rpm_file,passenger)
PLANET_DUMP_NG_RPM := $(call rpm_file,planet-dump-ng)
POSTGIS_RPM := $(call rpm_file,postgis)
PROJ_RPM := $(call rpm_file,proj)
PROTOBUF_C_RPM := $(call rpm_file,protobuf-c)
PROTOBUF_RPM := $(call rpm_file,protobuf)
PROTOZERO_RPM := $(call rpm_file,protozero)
PYOSMIUM_RPM := $(call rpm_file,python3-osmium)
RACK_RPM := $(call rpm_file,rubygem-rack)
RUBY_RPM := $(call rpm_file,ruby)
RUBYGEM_LIBXML_RUBY_RPM := $(call rpm_file,rubygem-libxml-ruby)
RUBYGEM_PG_RPM := $(call rpm_file,rubygem-pg)
SBT_RPM := $(call rpm_file,sbt,noarch)
SFCGAL_RPM := $(call rpm_file,SFCGAL)
SQLITE_RPM := $(call rpm_file,sqlite)
SQLITE_PCRE_RPM := $(call rpm_file,sqlite-pcre)
STEP_CA_RPM := $(call rpm_file,step-ca)
STEP_CLI_RPM := $(call rpm_file,step-cli)
TBB_RPM := $(call rpm_file,tbb)
WALG_RPM := $(call rpm_file,wal-g)
# Build images and RPMs.
RPMBUILD_BASE_IMAGES := \
rpmbuild \
rpmbuild-fonts \
rpmbuild-generic \
rpmbuild-pgdg
RPMBUILD_RPMS := \
CGAL \
caddy \
dumb-init \
FileGDBAPI \
gdal \
geos \
google-noto-fonts-extra \
gpsbabel \
hanazono-fonts \
journald-cloudwatch-logs \
libgeotiff \
libkml \
libosmium \
libosmpbf \
mapnik \
ogdi \
openstreetmap-carto \
osm2pgsql \
osmctools \
osmdbt \
osmium-tool \
osmosis \
passenger \
planet-dump-ng \
postgis \
proj \
protobuf \
protobuf-c \
protozero \
pyosmium \
rack \
ruby \
rubygem-libxml-ruby \
rubygem-pg \
sbt \
SFCGAL \
sqlite \
sqlite-pcre \
step-ca \
step-cli \
tbb \
wal-g
## General targets
.PHONY: \
all \
all-rpms \
distclean \
$(RPMBUILD_BASE_IMAGES) \
$(RPMBUILD_RPMS)
all:
ifndef DOCKER_VERSION
$(error "command docker is not available, please install Docker")
endif
ifndef DOCKER_COMPOSE_VERSION
$(error "command docker-compose is not available, please install docker-compose")
endif
all-rpms: $(RPMBUILD_RPMS)
distclean: .env
COMPOSE_FILE=$(COMPOSE_FILE) $(DOCKER_COMPOSE) down --volumes --rmi all
rm -fr .env RPMS/noarch RPMS/x86_64 \
SOURCES/$(EL_VERSION)/*.asc SOURCES/$(EL_VERSION)/*.sha256 SOURCES/$(EL_VERSION)/*.tgz \
SOURCES/$(EL_VERSION)/*.tar.gz SOURCES/$(EL_VERSION)/*.tar.xz SOURCES/$(EL_VERSION)/*.zip
# Environment file for docker-compose; required packages for build containers
# are provided here.
.env: SPECS/$(EL_VERSION)/*.spec
echo COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) > .env
echo IMAGE_PREFIX=$(IMAGE_PREFIX) >> .env
echo RPMBUILD_GID=$(RPMBUILD_GID) >> .env
echo RPMBUILD_UID=$(RPMBUILD_UID) >> .env
echo RPMBUILD_CGAL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/CGAL.spec) >> .env
echo RPMBUILD_GDAL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/gdal.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
echo RPMBUILD_GPSBABEL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/gpsbabel.spec) >> .env
echo RPMBUILD_JOURNALD_CLOUDWATCH_LOGS_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/journald-cloudwatch-logs.spec) >> .env
echo RPMBUILD_LIBGEOTIFF_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/libgeotiff.spec) >> .env
echo RPMBUILD_LIBKML_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/libkml.spec) >> .env
echo RPMBUILD_LIBOSMIUM_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/libosmium.spec) >> .env
echo RPMBUILD_LIBOSMPBF_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/libosmpbf.spec) >> .env
echo RPMBUILD_MAPNIK_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/mapnik.spec) >> .env
echo RPMBUILD_OGDI_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/ogdi.spec) >> .env
echo RPMBUILD_OPENSTREETMAP_CARTO_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/openstreetmap-carto.spec) >> .env
echo RPMBUILD_OSM2PGSQL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/osm2pgsql.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
echo RPMBUILD_OSMCTOOLS_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/osmctools.spec) >> .env
echo RPMBUILD_OSMDBT_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/osmdbt.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
echo RPMBUILD_OSMIUM_TOOL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/osmium-tool.spec) >> .env
echo RPMBUILD_PASSENGER_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/passenger.spec) >> .env
echo RPMBUILD_PLANET_DUMP_NG_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/planet-dump-ng.spec) >> .env
echo RPMBUILD_POSTGIS_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/postgis.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
echo RPMBUILD_PROJ_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/proj.spec) >> .env
echo RPMBUILD_PROTOBUF_C_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/protobuf-c.spec) >> .env
echo RPMBUILD_PROTOBUF_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/protobuf.spec) >> .env
echo RPMBUILD_PROTOZERO_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/protozero.spec) >> .env
echo RPMBUILD_PYOSMIUM_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/python3-osmium.spec) >> .env
echo RPMBUILD_RACK_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/rubygem-rack.spec) >> .env
echo RPMBUILD_RUBY_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/ruby.spec) >> .env
echo RPMBUILD_RUBYGEM_LIBXML_RUBY_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/rubygem-libxml-ruby.spec) >> .env
echo RPMBUILD_RUBYGEM_PG_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/rubygem-pg.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
echo RPMBUILD_SFCGAL_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/SFCGAL.spec) >> .env
echo RPMBUILD_SQLITE_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/sqlite.spec) >> .env
echo RPMBUILD_SQLITE_PCRE_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/sqlite-pcre.spec) >> .env
echo RPMBUILD_STEP_CA_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/step-ca.spec) >> .env
echo RPMBUILD_TBB_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/tbb.spec) >> .env
echo RPMBUILD_WALG_PACKAGES=$(shell ./scripts/buildrequires.py SPECS/$(EL_VERSION)/wal-g.spec --define postgres_version=$(POSTGRES_VERSION)) >> .env
## Image targets
rpmbuild: .env
$(call pull_if_ci,$@)
$(call build_unless_image_exists,$@)
rpmbuild-fonts: rpmbuild
$(call pull_if_ci,$?)
$(call pull_if_ci,$@)
$(call build_unless_image_exists,$@)
rpmbuild-generic: rpmbuild
$(call pull_if_ci,$?)
$(call pull_if_ci,$@)
$(call build_unless_image_exists,$@)
rpmbuild-pgdg: rpmbuild
$(call pull_if_ci,$?)
$(call pull_if_ci,$@)
$(call build_unless_image_exists,$@)
## RPM targets
CGAL: $(CGAL_RPM)
caddy: $(CADDY_RPM)
dumb-init: $(DUMB_INIT_RPM)
FileGDBAPI: $(FILEGDBAPI_RPM)
gdal: $(CGAL_RPM) $(FILEGDBAPI_RPM) $(GEOS_RPM) $(GPSBABEL_RPM) $(LIBKML_RPM) $(OGDI_RPM) $(SQLITE_RPM) \
$(PROJ_RPM) $(SFCGAL_RPM) \
$(LIBGEOTIFF_RPM) \
$(GDAL_RPM)
geos: $(GEOS_RPM)
google-noto-fonts-extra: rpmbuild-fonts $(GOOGLE_NOTO_RPM)
gpsbabel: $(GPSBABEL_RPM)
hanazono-fonts: rpmbuild-fonts $(HANAZONO_RPM)
journald-cloudwatch-logs: $(JOURNALD_CLOUDWATCH_LOGS_RPM)
libgeotiff: $(SQLITE_RPM) \
$(PROJ_RPM) \
$(LIBGEOTIFF_RPM)
libkml: $(LIBKML_RPM)
libosmium: $(PROTOBUF_RPM) \
$(PROTOZERO_RPM) \
$(LIBOSMIUM_RPM)
libosmpbf: $(LIBOSMPBF_RPM)
mapnik: $(MAPNIK_RPM)
ogdi: $(OGDI_RPM)
openstreetmap-carto: $(OPENSTREETMAP_CARTO_RPM)
osm2pgsql: $(OSM2PGSQL_RPM)
osmctools: $(OSMCTOOLS_RPM)
osmdbt: $(OSMDBT_RPM)
osmium-tool: $(OSMIUM_TOOL_RPM)
osmosis: $(OSMOSIS_RPM)
passenger: $(PASSENGER_RPM)
planet-dump-ng: $(PLANET_DUMP_NG_RPM)
postgis: $(POSTGIS_RPM)
proj: $(SQLITE_RPM) \
$(PROJ_RPM)
protobuf-c: $(PROTOBUF_RPM) \
$(PROTOBUF_C_RPM)
protobuf: $(PROTOBUF_RPM)
protozero: $(PROTOBUF_RPM) \
$(PROTOZERO_RPM)
pyosmium: $(PYOSMIUM_RPM)
rack: $(RACK_RPM)
ruby: $(RUBY_RPM)
rubygem-libxml-ruby: $(RUBYGEM_LIBXML_RUBY_RPM)
rubygem-pg: $(RUBYGEM_PG_RPM)
sbt: $(SBT_RPM)
SFCGAL: $(CGAL_RPM) \
$(SFCGAL_RPM)
sqlite-pcre: $(SQLITE_RPM) \
$(SQLITE_PCRE_RPM)
sqlite: $(SQLITE_RPM)
step-ca: $(STEP_CA_RPM)
step-cli: $(STEP_CLI_RPM)
tbb: $(TBB_RPM)
wal-g: $(WALG_RPM)
## Build patterns
RPMS/x86_64/%.rpm RPMS/noarch/%.rpm: | .env
$(MAKE) --makefile=Makefile.$(EL_VERSION) $(call rpmbuild_image_parent,$*)
$(call pull_if_ci,$(call rpmbuild_image,$*))
$(call build_unless_image_exists,$(call rpmbuild_image,$*))
COMPOSE_FILE=$(COMPOSE_FILE) $(DOCKER_COMPOSE) run --rm -T $(call rpmbuild_image,$*) \
$(shell ./scripts/rpmbuild_util.py $(call rpm_package,$*) --config-file $(COMPOSE_FILE))