-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
387 lines (335 loc) · 15.8 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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# ====================================================================
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation. For more
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
MVN=mvn
EXTRA_BUILD_FLAGS=
BUILD_FLAGS=-P gwt-admin,gwt-user
PACKAGE_NAME=ovirt-engine
ENGINE_NAME=$(PACKAGE_NAME)
PREFIX=/usr/local
BIN_DIR=$(PREFIX)/bin
SYSCONF_DIR=$(PREFIX)/etc
DATAROOT_DIR=$(PREFIX)/share
DATA_DIR=$(DATAROOT_DIR)/$(ENGINE_NAME)
MAVENPOM_DIR=$(DATAROOT_DIR)/maven-poms
JAVA_DIR=$(DATAROOT_DIR)/java
PKG_JAVA_DIR=$(JAVA_DIR)/$(ENGINE_NAME)
PKG_SYSCONF_DIR=$(SYSCONF_DIR)/$(ENGINE_NAME)
PKG_PKI_DIR=$(SYSCONF_DIR)/pki/$(ENGINE_NAME)
PKG_EAR_DIR=$(DATA_DIR)/engine.ear
PKG_JBOSS_MODULES=$(DATA_DIR)/modules
RPMBUILD=rpmbuild
PYTHON=python
PYTHON_DIR:=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib as f;print f()")
# RPM version
APP_VERSION:=$(shell cat pom.xml | grep '<engine.version>' | awk -F\> '{print $$2}' | awk -F\< '{print $$1}')
RPM_VERSION:=$(shell echo $(APP_VERSION) | sed "s/-/_/")
# Release Version; used to create y in <x.x.x-y> numbering.
# Should be used to create releases.
RPM_RELEASE_VERSION=3
SPEC_FILE_IN=packaging/fedora/spec/ovirt-engine.spec.in
SPEC_FILE=$(PACKAGE_NAME).spec
OUTPUT_RPMBUILD=$(shell pwd -P)/tmp.rpmbuild
OUTPUT_DIR=output
TARBALL=$(PACKAGE_NAME)-$(RPM_VERSION).tar.gz
SRPM=$(OUTPUT_DIR)/$(PACKAGE_NAME)-$(RPM_VERSION)*.src.rpm
ARCH=noarch
BUILD_FILE=tmp.built
MAVEN_OUTPUT_DIR_DEFAULT=$(shell pwd -P)/tmp.repos
MAVEN_OUTPUT_DIR=$(MAVEN_OUTPUT_DIR_DEFAULT)
ARTIFACTS = \
backend bll \
common \
compat \
dal \
engine-config \
engine-notifier \
engine-notifier-resources \
engine-notifier-service \
engine-tools-common \
engineencryptutils \
genericapi \
interface-common-jaxrs \
manager \
manager-modules \
manager-tools \
restapi-definition \
restapi-jaxrs \
restapi-parent \
restapi-types \
root \
scheduler \
searchbackend \
utils \
vdsbroker
# avoid duplicate jars, remove 1st component
# link to 2nd component
# no convention yet...
OWN_JAR_FIXUPS = \
$(PKG_EAR_DIR)/engine-bll,bll \
$(PKG_EAR_DIR)/engine-genericapi,genericapi \
$(PKG_EAR_DIR)/engine-scheduler,scheduler \
$(PKG_EAR_DIR)/lib/engine-common,common \
$(PKG_EAR_DIR)/lib/engine-compat,compat \
$(PKG_EAR_DIR)/lib/engine-dal,dal \
$(PKG_EAR_DIR)/lib/engine-encryptutils,engineencryptutils \
$(PKG_EAR_DIR)/lib/engine-tools-common,engine-tools-common \
$(PKG_EAR_DIR)/lib/engine-utils,utils \
$(PKG_EAR_DIR)/lib/engine-vdsbroker,vdsbroker \
$(PKG_EAR_DIR)/lib/searchbackend,searchbackend
all: $(BUILD_FILE)
$(BUILD_FILE):
export MAVEN_OPTS="${MAVEN_OPTS} -XX:MaxPermSize=512m"
$(MVN) \
$(BUILD_FLAGS) \
$(EXTRA_BUILD_FLAGS) \
dependency:resolve-plugins
$(MVN) \
$(BUILD_FLAGS) \
$(EXTRA_BUILD_FLAGS) \
-D skipTests \
-D altDeploymentRepository=install::default::file://$(MAVEN_OUTPUT_DIR) \
deploy
touch $(BUILD_FILE)
clean:
$(MVN) clean $(EXTRA_BUILD_FLAGS)
rm -rf $(OUTPUT_RPMBUILD) $(SPEC_FILE) $(OUTPUT_DIR) $(BUILD_FILE)
[ "$(MAVEN_OUTPUT_DIR_DEFAULT)" = "$(MAVEN_OUTPUT_DIR)" ] && rm -fr "$(MAVEN_OUTPUT_DIR)"
test:
$(MVN) install $(BUILD_FLAGS) $(EXTRA_BUILD_FLAGS)
install: \
all \
install_without_maven
install_without_maven: \
create_dirs \
install_artifacts \
install_config \
install_sysprep \
install_notification_service \
install_db_scripts \
install_setup \
install_misc \
install_sec \
install_aio_plugin \
install_jboss_modules \
install_service
tarball:
sed -e 's/^Version:.*/Version: $(RPM_VERSION)/' \
-e 's/^Release:.*/Release: $(RPM_RELEASE_VERSION)%{?dist}/' $(SPEC_FILE_IN) > $(SPEC_FILE)
tar zcf $(TARBALL) `git ls-files` $(SPEC_FILE)
rm -f $(SPEC_FILE)
@echo
@echo You can use $(RPMBUILD) -tb $(TARBALL) to produce rpms
@echo
srpm: tarball
rm -rf $(OUTPUT_RPMBUILD)
mkdir -p $(OUTPUT_RPMBUILD)/{SPECS,RPMS,SRPMS,SOURCES,BUILD,BUILDROOT}
mkdir -p $(OUTPUT_DIR)
$(RPMBUILD) -ts --define="_topdir $(OUTPUT_RPMBUILD)" $(TARBALL)
mv $(OUTPUT_RPMBUILD)/SRPMS/*.rpm $(OUTPUT_DIR)
rm -rf $(OUTPUT_RPMBUILD)
@echo
@echo srpm is ready at $(OUTPUT_DIR)
@echo
rpm: srpm
rm -rf $(OUTPUT_RPMBUILD)
mkdir -p $(OUTPUT_RPMBUILD)/{SPECS,RPMS,SRPMS,SOURCES,BUILD,BUILDROOT}
mkdir -p $(OUTPUT_DIR)
$(RPMBUILD) --define="_topdir $(OUTPUT_RPMBUILD)" $(RPMBUILD_EXTRA_ARGS) --rebuild $(SRPM)
mv $(OUTPUT_RPMBUILD)/RPMS/$(ARCH)/*.rpm $(OUTPUT_DIR)
rm -rf $(OUTPUT_RPMBUILD)
@echo
@echo rpms are ready at $(OUTPUT_DIR)
@echo
# This is intended to quickly build a set of RPMs that don't
# contain working copies of the GWT applications, mostly useful
# for testing the RPM build process itself or for testing only the
# backend and the RESTAPI
rpm-quick:
$(MAKE) \
rpm \
RPMBUILD_EXTRA_ARGS='--define="__jar_repack 0" \
--define="BUILD_FLAGS -D dummy" \
--define="EXTRA_BUILD_FLAGS -D maven.test.skip=true -D gwt.userAgent=gecko1_8"'
@echo
@echo WARNING:
@echo rpms produces from quick are partial!
@echo *DO NOT* use them for any other use but debug.
@echo
create_dirs:
@echo "*** Creating Directories"
@install -dm 755 $(DESTDIR)$(BIN_DIR)
@install -dm 755 $(DESTDIR)$(DATA_DIR)/conf
@install -dm 755 $(DESTDIR)$(DATA_DIR)/db-backups
@install -dm 755 $(DESTDIR)$(DATA_DIR)/engine-config
@install -dm 755 $(DESTDIR)$(DATA_DIR)/engine-manage-domains
@install -dm 755 $(DESTDIR)$(DATA_DIR)/kerberos
@install -dm 755 $(DESTDIR)$(DATA_DIR)/ovirt-isos
@install -dm 755 $(DESTDIR)$(DATA_DIR)/scripts/plugins
@install -dm 755 $(DESTDIR)$(PYTHON_DIR)/sos/plugins
@install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-config
@install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-manage-domains
@install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/sysconfig
@install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/cron.daily
@install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/security/limits.d
@install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/rc.d/init.d
@install -dm 755 $(DESTDIR)$(DATA_DIR)/resources/jboss/modules/org
@install -dm 755 $(DESTDIR)/usr/lib/systemd/system
@install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/tmpfiles.d
install_artifacts:
@echo "*** Deploying EAR to $(DESTDIR)"
install -dm 755 $(DESTDIR)$(PKG_EAR_DIR)
install -dm 755 $(DESTDIR)$(PKG_JAVA_DIR)
install -dm 755 $(DESTDIR)$(MAVENPOM_DIR)
X=`find "$(MAVEN_OUTPUT_DIR)" -name engine-server-ear-$(APP_VERSION).ear` && unzip "$$X" -d "$(DESTDIR)$(PKG_EAR_DIR)"
for artifact_id in $(ARTIFACTS); do \
POM=`find "$(MAVEN_OUTPUT_DIR)" -name "$${artifact_id}-$(APP_VERSION).pom"`; \
if ! [ -f "$${POM}" ]; then \
echo "ERROR: Cannot find artifact $${artifact_id}"; \
exit 1; \
fi; \
JAR=`echo "$${POM}" | sed 's/\.pom/.jar/'`; \
install -p -m 644 "$${POM}" "$(DESTDIR)$(MAVENPOM_DIR)/$(PACKAGE_NAME)-$${artifact_id}.pom"; \
[ -f "$${JAR}" ] && install -p -m 644 "$${JAR}" "$(DESTDIR)$(PKG_JAVA_DIR)/$${artifact_id}.jar"; \
done
# Replace jar files in the ear with links to their actuals
# locations
for jar_line in $(OWN_JAR_FIXUPS); do \
path=`echo $${jar_line} | sed 's/,.*//'`; \
jar=`echo $${jar_line} | sed 's/.*,//'`; \
rm -rf "$(DESTDIR)$${path}"*.jar; \
ln -s "$(PKG_JAVA_DIR)/$${jar}.jar" "$(DESTDIR)$${path}.jar"; \
done
install_setup:
@echo "*** Deploying setup executables"
# Configuration files:
install -m 644 packaging/fedora/setup/engine-config-install.properties $(DESTDIR)$(DATA_DIR)/conf
install -m 644 packaging/fedora/setup/iptables.default $(DESTDIR)$(DATA_DIR)/conf
install -m 644 packaging/fedora/setup/nfs.sysconfig $(DESTDIR)$(DATA_DIR)/conf
# Shared python modules:
install -m 644 packaging/fedora/setup/nfsutils.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/basedefs.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/engine_validators.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/setup_params.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/setup_sequences.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/setup_controller.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/common_utils.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/output_messages.py $(DESTDIR)$(DATA_DIR)/scripts
install -m 644 packaging/fedora/setup/post_upgrade.py $(DESTDIR)$(DATA_DIR)/scripts
# Example Plugin:
install -m 644 packaging/fedora/setup/plugins/example_plugin_000.py $(DESTDIR)$(DATA_DIR)/scripts/plugins
# Main programs and links:
install -m 755 packaging/fedora/setup/engine-setup.py $(DESTDIR)$(DATA_DIR)/scripts
ln -s $(DATA_DIR)/scripts/engine-setup.py $(DESTDIR)$(BIN_DIR)/engine-setup
install -m 755 packaging/fedora/setup/engine-cleanup.py $(DESTDIR)$(DATA_DIR)/scripts
ln -s $(DATA_DIR)/scripts/engine-cleanup.py $(DESTDIR)$(BIN_DIR)/engine-cleanup
install -m 755 packaging/fedora/setup/engine-upgrade.py $(DESTDIR)$(DATA_DIR)/scripts
ln -s $(DATA_DIR)/scripts/engine-upgrade.py $(DESTDIR)$(BIN_DIR)/engine-upgrade
install -m 755 packaging/fedora/setup/engine-check-update $(DESTDIR)$(BIN_DIR)/
# Configuration file for the index page:
install -m 644 packaging/fedora/setup/resources/jboss/web-conf.js $(DESTDIR)$(PKG_SYSCONF_DIR)
sed -i "s/MYVERSION/$(RPM_VERSION)-$(RPM_RELEASE_VERSION)/" $(DESTDIR)$(PKG_EAR_DIR)/root.war/engineVersion.js
install_aio_plugin:
install -m 755 packaging/fedora/setup/plugins/all_in_one_100.py $(DESTDIR)$(DATA_DIR)/scripts/plugins
install_sec:
install -dm 755 $(DESTDIR)$(PKG_PKI_DIR)/certs
install -dm 755 $(DESTDIR)$(PKG_PKI_DIR)/keys
install -dm 755 $(DESTDIR)$(PKG_PKI_DIR)/private
install -dm 755 $(DESTDIR)$(PKG_PKI_DIR)/requests
# Configuration files:
install -m 644 backend/manager/conf/ca/openssl.conf $(DESTDIR)$(PKG_PKI_DIR)
install -m 644 backend/manager/conf/ca/cacert.template $(DESTDIR)$(PKG_PKI_DIR)
install -m 644 backend/manager/conf/ca/cert.template $(DESTDIR)$(PKG_PKI_DIR)
# Certificate database:
install -m 644 backend/manager/conf/ca/database.txt $(DESTDIR)$(PKG_PKI_DIR)
install -m 644 backend/manager/conf/ca/serial.txt $(DESTDIR)$(PKG_PKI_DIR)
# Scripts:
install -m 755 backend/manager/conf/ca/*.sh $(DESTDIR)$(PKG_PKI_DIR)
install -m 755 backend/manager/conf/ca/generate-ssh-keys $(DESTDIR)$(PKG_PKI_DIR)
install_config:
@echo "*** Deploying engine-config & engine-manage-domains"
# Configuration files for the configuration tool:
install -m 644 backend/manager/tools/engine-config/src/main/resources/engine-config.conf $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-config/
install -m 644 backend/manager/tools/engine-config/src/main/resources/engine-config.*properties $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-config/
install -m 644 backend/manager/tools/engine-config/src/main/resources/log4j.xml $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-config/
# Main program for the configuration tool:
install -m 750 backend/manager/tools/engine-config/src/main/resources/engine-config $(DESTDIR)$(DATA_DIR)/engine-config/
ln -s $(DATA_DIR)/engine-config/engine-config $(DESTDIR)$(BIN_DIR)/engine-config
# Configuration files for the domain management tool:
install -m 644 backend/manager/modules/utils/src/main/resources/engine-manage-domains.conf $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-manage-domains/
install -m 644 backend/manager/modules/utils/src/main/resources/engine-manage-domains/log4j.xml $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-manage-domains/
# Main program for the domain management tool:
install -m 750 backend/manager/conf/kerberos/engine-manage-domains $(DESTDIR)$(DATA_DIR)/engine-manage-domains/
ln -s $(DATA_DIR)/engine-manage-domains/engine-manage-domains $(DESTDIR)$(BIN_DIR)/engine-manage-domains
install_sysprep:
@echo "*** Deploying sysperp"
@install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/sysprep
install -m 644 backend/manager/conf/sysprep/* $(DESTDIR)$(PKG_SYSCONF_DIR)/sysprep
install_notification_service:
@echo "*** Deploying notification service"
install -dm 755 $(DESTDIR)$(DATA_DIR)/notifier
install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/notifier
# Configuration files:
install -m 644 backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/log4j.xml $(DESTDIR)$(PKG_SYSCONF_DIR)/notifier/
install -m 640 backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf $(DESTDIR)$(PKG_SYSCONF_DIR)/notifier/
# Main program:
install -m 755 backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh $(DESTDIR)$(DATA_DIR)/notifier/
install -m 755 backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/engine-notifierd $(DESTDIR)$(SYSCONF_DIR)/rc.d/init.d/
install_db_scripts:
@echo "*** Deploying Database scripts"
install -dm 755 $(DESTDIR)$(DATA_DIR)/dbscripts
cp -r backend/manager/dbscripts/* $(DESTDIR)$(DATA_DIR)/dbscripts
find $(DESTDIR)$(DATA_DIR)/dbscripts -type d -exec chmod 755 {} \;
find $(DESTDIR)$(DATA_DIR)/dbscripts -type f -name '*.sql' -exec chmod 644 {} \;
find $(DESTDIR)$(DATA_DIR)/dbscripts -type f -name '*.sh' -exec chmod 755 {} \;
install_misc:
@echo "*** Copying additional files"
install -m 644 backend/manager/conf/jaas.conf $(DESTDIR)$(DATA_DIR)/conf
install -m 640 backend/manager/conf/engine.conf $(DESTDIR)$(PKG_SYSCONF_DIR)/
install -m 644 backend/manager/conf/jboss-log4j.xml $(DESTDIR)$(DATA_DIR)/conf
install -m 644 backend/manager/conf/kerberos/* $(DESTDIR)$(DATA_DIR)/kerberos
# XXX: Does this script need execution permission? It
# needs when copied to the host, but I am not sure it
# should it have it in the manager machine.
install -m 755 backend/manager/conf/vds_installer.py $(DESTDIR)$(DATA_DIR)/scripts/
install -m 644 backend/manager/conf/jboss-log4j.xml $(DESTDIR)$(DATA_DIR)/conf
install -m 755 packaging/resources/ovirtlogrot.sh ${DESTDIR}$(DATA_DIR)/scripts/
install -m 755 packaging/resources/ovirt-cron ${DESTDIR}$(SYSCONF_DIR)/cron.daily/
install -m 644 packaging/resources/ovirt-tmpfilesd ${DESTDIR}$(SYSCONF_DIR)/tmpfiles.d/$(ENGINE_NAME).conf
install_jboss_modules:
@echo "*** Deploying JBoss modules"
# PostgreSQL driver:
install -dm 755 $(DESTDIR)$(PKG_JBOSS_MODULES)/org/postgresql/main
install -m 644 deployment/modules/org/postgresql/main/module.xml $(DESTDIR)$(PKG_JBOSS_MODULES)/org/postgresql/main/.
ln -s $(JAVA_DIR)/postgresql-jdbc.jar $(DESTDIR)$(PKG_JBOSS_MODULES)/org/postgresql/main/.
install_service:
@echo "*** Deploying service"
# Install the files:
install -dm 755 $(DESTDIR)$(DATA_DIR)/service
install -m 644 packaging/fedora/engine-service.xml.in $(DESTDIR)$(DATA_DIR)/service
install -m 644 packaging/fedora/engine-service-logging.properties $(DESTDIR)$(DATA_DIR)/service
install -m 755 packaging/fedora/engine-service.py $(DESTDIR)$(DATA_DIR)/service
install -m 644 packaging/fedora/engine-service.sysconfig $(DESTDIR)$(SYSCONF_DIR)/sysconfig/ovirt-engine
install -m 644 packaging/fedora/engine-service.limits $(DESTDIR)$(SYSCONF_DIR)/security/limits.d/10-$(ENGINE_NAME).conf
install -m 644 packaging/fedora/engine-service.systemd $(DESTDIR)/usr/lib/systemd/system/ovirt-engine.service
# Install the links:
ln -s $(DATA_DIR)/service/engine-service.py $(DESTDIR)$(BIN_DIR)/engine-service