-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
232 lines (195 loc) · 6.27 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
MAKEFLAGS:= --warn-undefined-variables --no-print-directory $(MAKEFLAGS)
VERBOSE?= 0
CONTAINER_NAMESPACE := test
# Commands
MAKE := make
MKDIR := mkdir
TAR := tar
GIT := git
RM := rm
TEST := test
CP := cp
CD := cd
FALSE := false
TRUE := true
CAT := cat
PASTE := paste
NPM := npm
DOCKER := docker
SED := sed
ifneq ($(VERBOSE),0)
WGET := wget
else
WGET := wget -q
endif
# Configuration
USE_JDBC_CONFIG_GENERATOR := 1
# Downloads
# Mysql
DOWNLOAD_URL_MYSQL_CONNECTOR ?= https://files.dietrich-hosting.de/public/mysql/mysql-connector-java-8.0.16.tar.gz
PACKAGE_PATH_MYSQL_CONNECTOR ?= $(DOWNLOAD_DIR)/mysql-connector.tar.gz
# Mongo
DOWNLOAD_URL_MONGO_DRIVER ?= https://files.dietrich-hosting.de/public/mongo/mongodb-driver-3.10.1.jar
PACKAGE_PATH_MONGO_DRIVER ?= $(DOWNLOAD_DIR)/mongo-java-driver.jar
# Kettle
ETL_KETTLE_PACKAGE_FILE ?= $(DOWNLOAD_DIR)/pentaho-kettle.download.tar.gz
# Directories
LIB_DIR := library
LIB_ETL_DIR := $(LIB_DIR)/etl
CONFIG_DIR := config
CONFIG_JDBC_FILE := $(CONFIG_DIR)/database/jdbc/jdbc.properties
DOWNLOAD_DIR := download
TEMP_DIR := temp
LOG_DIR := log
PATH_NODE_MODULES := $(LIB_DIR)/javascript/node_modules
# Files
JS_JAR_FILE = $(LIB_DIR)/javascript/node_modules/nodeschnaps/deps/rhino/lib/rhino-1.7.11.jar
CONFIG_APPLICATION_GENERATED = $(CONFIG_DIR)/application.generated.conf
# TOOLS
TOOL_REPLACER := $(LIB_ETL_DIR)/tool/replacer
TOOL_JDBC_FILE_GENERATOR := $(LIB_ETL_DIR)/tool/jdbcFileGenerator
# Defaults
APPLICATION_ENV ?= development
# Macros
IS_INSTALLED = $(shell $(TEST) -d $(LIB_ETL_DIR)/application/pentaho-kettle && printf '1')
IS_LIBGTK_3_INSTALLED = $(shell dpkg-query -s libgtk-3-0 > /dev/null && echo 1)
.PHONY: \
.install-folders \
.download-mysql-connector \
.download-mongo-driver \
.patch-kettle \
all \
install \
uninstall \
configure \
clean
.install-folders:
# Create temp directory.
@$(TEST) -d $(TEMP_DIR) || $(MKDIR) $(TEMP_DIR)
# Create download directory.
@$(TEST) -d $(DOWNLOAD_DIR) || $(MKDIR) $(DOWNLOAD_DIR)
# Create log directory.
@$(TEST) -d $(LOG_DIR) || $(MKDIR) $(LOG_DIR)
.download-mysql-connector:
# Download Mysql-Connector from: $(DOWNLOAD_URL_MYSQL_CONNECTOR)
@$(WGET) -O $(PACKAGE_PATH_MYSQL_CONNECTOR) $(DOWNLOAD_URL_MYSQL_CONNECTOR) 2>&1
.download-mongo-driver:
# Download Mongo driver from: $(DOWNLOAD_URL_MONGO_DRIVER)
@$(WGET) -O $(PACKAGE_PATH_MONGO_DRIVER) $(DOWNLOAD_URL_MONGO_DRIVER) 2>&1
.patch-kettle: install-node-modules install-library-etl .download-mysql-connector .download-mongo-driver
##### Patch Kettle #####
# Install mysql connector.
@$(TAR) -xa --to-stdout --wildcards \
-f $(PACKAGE_PATH_MYSQL_CONNECTOR) \
'mysql-connector-java-*.jar' \
> $(LIB_ETL_DIR)/application/pentaho-kettle/lib/mysql-connector-java-bin.jar
# Install mongo driver.
@$(CP) $(PACKAGE_PATH_MONGO_DRIVER) \
$(LIB_ETL_DIR)/application/pentaho-kettle/lib/mongo-java-driver.jar
# Install rhino.
@$(RM) $(LIB_ETL_DIR)/application/pentaho-kettle/lib/js-*.jar
@$(CP) $(JS_JAR_FILE) \
$(LIB_ETL_DIR)/application/pentaho-kettle/lib/
ifeq ($(IS_LIBGTK_3_INSTALLED),1)
# Fix SWT_GTK3
@${SED} -i 's/export SWT_GTK3=0$$/export SWT_GTK3=1/' $(LIB_ETL_DIR)/application/pentaho-kettle/spoon.sh
endif
# External targets
all:
##### Overview #####
# install: Downlaod and install the application.
# uninstall: uninstall the application.
# configure: Write the config files.
# clean: Cleanup the temporary files.
install: .install-header
ifeq ($(IS_INSTALLED),1)
# Already installed
else
# Install dependencies.
@$(MAKE) install-dependencies .patch-kettle
@$(MAKE) configure
endif
.install-header:
##### Install #####
install-dependencies: install-library-etl
install-library-etl: .install-folders
# Install etl library
@$(MAKE) -C $(LIB_ETL_DIR) install
install-node-modules:
@# Install node modules
@# @cd $(PATH_NODE_MODULES)/.. && $(NPM) install >/dev/null
uninstall: uninstall-header uninstall-node-modules uninstall-dependencies
uninstall-header:
##### Uninstall #####
uninstall-dependencies: uninstall-library-etl
uninstall-library-etl:
@$(TEST) ! -d $(LIB_ETL_DIR) || $(MAKE) -C $(LIB_ETL_DIR) uninstall
uninstall-node-modules:
@# # Uninstall node modules
@# @rm -rf $(PATH_NODE_MODULES)
configure: .configure-head .configure-generate-main .configure-kettle .configure-database
.configure-head:
##### Configure #####
.configure-generate-main:
# Copy default dist application.conf if not exists.
@$(TEST) -f $(CONFIG_DIR)/application.conf \
|| $(CP) \
$(CONFIG_DIR)/application.conf.dist \
$(CONFIG_DIR)/application.conf
# Combine config files.
@$(PASTE) --serial --delimiters='\n' \
$(CONFIG_DIR)/application.default.conf \
$(CONFIG_DIR)/application.conf \
> $(CONFIG_APPLICATION_GENERATED)
# Generate environment.generated.config.sh
@$(TOOL_REPLACER) \
$(CONFIG_DIR)/environment.config.sh \
$(CONFIG_APPLICATION_GENERATED) \
> $(CONFIG_DIR)/environment.generated.config.sh
.configure-kettle: .configure-generate-main
# Copy default .spoonrc if not exists.
@$(TEST) -f $(CONFIG_DIR)/kettle/.kettle/.spoonrc \
|| $(CP) \
$(CONFIG_DIR)/kettle/.kettle/.spoonrc.default \
$(CONFIG_DIR)/kettle/.kettle/.spoonrc
# Generate kettle.properties.
@$(PASTE) --serial --delimiters='\n' \
$(CONFIG_DIR)/kettle/.kettle/kettle.properties.template \
$(CONFIG_APPLICATION_GENERATED) \
> $(CONFIG_DIR)/kettle/.kettle/kettle.properties
.configure-database: .configure-generate-main
# Generate jdbc database config:
ifeq ($(USE_JDBC_CONFIG_GENERATOR),1)
# With jdbc file generator.
@$(TOOL_JDBC_FILE_GENERATOR) \
< $(CONFIG_APPLICATION_GENERATED) \
> $(CONFIG_JDBC_FILE)
else
# With config replacer.
@$(TOOL_REPLACER) \
$(CONFIG_DIR)/database/jdbc.properties.template \
$(CONFIG_DIR)/application.conf \
> $(CONFIG_JDBC_FILE)
endif
clean: clean-dependencies
##### Cleanup #####
# Remove temp directory.
@$(RM) -rf $(TEMP_DIR)
# Remove download directory.
@$(RM) -rf $(DOWNLOAD_DIR)
# Remove log directory.
@$(RM) -rf $(LOG_DIR)
@$(MAKE) .install-folders
clean-dependencies:
@$(MAKE) -C $(LIB_ETL_DIR) clean
start-gui: configure
ifeq ($(IS_INSTALLED),1)
##### Start GUI #####
@./bin/gui
else
# !!! NOT INSTALLED !!!
# Please run make install first.
endif
docker-image: configure
$(DOCKER) build -t $(CONTAINER_NAMESPACE) .
# now docker run $(CONTAINER_NAMESPACE) /home/etl/bin/transformation Project/Test/simpleTest