-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
119 lines (94 loc) · 5.2 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
SMIV := 5.2.0
RDMPV := 7.0.12
JARS := ctpanonymiser-1.0.0/CTPAnonymiser-portable-1.0.0.jar smi-nerd-v$(SMIV).jar
BINS := smiinit
CXXFLAGS := -Wall -Wextra -O2 --std=c++11 -Iyaml-cpp/include
UNAME := $(shell uname)
.PHONY: list clean distclean
all: $(BINS)
minidocker: smi/smiinit smi/smiinit.sh smi/CTPAnonymiser-portable-1.0.0.jar smi/smi-nerd-v$(SMIV).jar smi/ctp-whitelist.script smi/eng.traineddata.gz
mkdir -p smi
touch smi/dummy.sh
(cd smi-services-v4.0.0-linux-x64;tar cf - .) | (cd smi ; tar xf -)
$(eval ctr1:=$(shell buildah from --name smidocker docker://docker.io/adoptopenjdk/openjdk11:debian-jre))
tar c -f - smi/ | buildah run "$(ctr1)" sh -c "tar xof - && apt-get update && apt-get install libicu63"
buildah config --cmd "/smi/smiinit.sh" "$(ctr1)"
buildah commit "$(ctr1)" "smidocker"
smi/smiinit.sh: smi-services-v$(SMIV)-linux-x64/default.yaml
mkdir -p smi
cp smiinit.sh $@
sed -e 's/c:\\temp/\/tmp/gi' $< | tail -n +2 >> $@
sed -i -e 's/TEST.//g' $@
sed -i -e 's/RabbitMqUserName: '\''guest'\''/RabbitMqUserName: '\''\$$(<\/run\/secrets\/rabbituser)'\''/g' $@
sed -i -e 's/RabbitMqHostName: '\''localhost'\''/RabbitMqHostName: '\''\$$(<\/run\/secrets\/rabbithost)'\''/g' $@
sed -i -e 's/RabbitMqHostPort: 5672/RabbitMqHostPort: \$$(<\/run\/secrets\/rabbitport)/g' $@
sed -i -e 's/RabbitMqPassword: '\''guest'\''/RabbitMqPassword: '\''\$$(<\/run\/secrets\/rabbitpass)'\''/g' $@
sed -i -e 's/HostName: '\''localhost'\''/HostName: '\''\$$(<\/run\/secrets\/mongohost)'\''/g' $@
sed -i -e 's/UserName: '\'''\''/UserName: '\''\$$(<\/run\/secrets\/mongouser)'\''/g' $@
sed -i -e 's/Password: '\'''\''/Password: '\''\$$(<\/run\/secrets\/mongopass)'\''/g' $@
sed -i -e 's/Port: 27017/Port: \$$(<\/run\/secrets\/mongoport)/g' $@
sed -i -e 's/CatalogueConnectionString: '\''[^'\'']*'\''/CatalogueConnectionString: '\''\$$(<\/run\/secrets\/cscatalogue)'\''/g' $@
sed -i -e 's/DataExportConnectionString: '\''[^'\'']*'\''/DataExportConnectionString: '\''\$$(<\/run\/secrets\/csexport)'\''/g' $@
sed -i -e 's/MappingConnectionString: '\''[^'\'']*'\''/MappingConnectionString: '\''\$$(<\/run\/secrets\/csmapping)'\''/g' $@
sed -i -e 's/LogsRoot: '\'\''/LogsRoot: '\''\/logs'\''/g' $@
sed -i -e 's/Root: '\''\/tmp'\''/Root: '\''\/data'\''/g' $@
sed -i -e 's/DataDirectory: '\'\''/DataDirectory: '\''\/data\/identifiablerules'\''/g' $@
echo EOS >> $@
echo exec /smi/smiinit -c /smi -f /smi/smi.yaml >> $@
chmod +x $@
smi/smiinit: smiinit
mkdir -p smi
cp $< $@
smi/CTPAnonymiser-portable-1.0.0.jar: ctpanonymiser-1.0.0/CTPAnonymiser-portable-1.0.0.jar
mkdir -p smi
ln -f $< $@
smi/smi-nerd-v$(SMIV).jar: smi-nerd-v$(SMIV).jar
mkdir -p smi
ln -f $< $@
smi/ctp-whitelist.script: ctp-whitelist.script
mkdir -p smi
ln -f $< $@
smi/eng.traineddata.gz:
curl -sL https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata | gzip -9 > $@
smi-services-v$(SMIV)-linux-x64/default.yaml:
curl -L https://github.com/SMI/SmiServices/releases/download/v$(SMIV)/smi-services-v$(SMIV)-linux-x64.tgz | tar xzf -
sed -i -e 's:MappingTable'"'"':smi.MappingTable'"'"':' smi-services-v$(SMIV)-linux-x64/default.yaml
sed -i -e 's/CTPAnonymiserOptions:/CTPAnonymiserOptions:\n SRAnonTool: '\''\/smi\/dummy.sh'\''/' smi-services-v$(SMIV)-linux-x64/default.yaml
docker: smiinit $(JARS) $(HOME)/rdmp-cli/rdmp ctp-whitelist.script smi-services-v$(SMIV)-linux-x64/default.yaml
touch smi-services-v$(SMIV)-linux-x64/dummy.sh
$(eval ctr1:=$(shell buildah from docker://docker.io/debian:latest))
buildah copy "$(ctr1)" smiinit /bin/
buildah copy "$(ctr1)" $(HOME)/rdmp-cli /rdmp-cli
buildah copy "$(ctr1)" $(JARS) ctp-whitelist.script smi-services-v$(SMIV)-linux-x64/ /smi
./eqnames.pl < smi-services-v3.0.2-linux-x64/default.yaml | buildah run "$(ctr1)" -- bash 2>&1 | tee dockerbuild.log
buildah config --cmd "/bin/smiinit -c /smi -f /smi.yaml" "$(ctr1)"
buildah commit "$(ctr1)" "smifull"
$(HOME)/rdmp-cli/rdmp: rdmp-cli-linux-x64.zip
[ -e $@ ] || unzip -DD -d $(HOME)/rdmp-cli rdmp-cli-linux-x64.zip -x "Curation*" "zh-*" "*\\Terminal.Gui.resources.dll"
chmod +x $(HOME)/rdmp-cli/rdmp
rdmp-cli-linux-x64.zip:
wget https://github.com/HicServices/RDMP/releases/download/v$(RDMPV)/rdmp-cli-linux-x64.zip
ctpanonymiser-v$(SMIV).zip:
wget https://github.com/SMI/SmiServices/releases/download/v$(SMIV)/ctpanonymiser-v$(SMIV).zip
ctpanonymiser-1.0.0/CTPAnonymiser-portable-1.0.0.jar: ctpanonymiser-v$(SMIV).zip
[ -e $@ ] || unzip -DD $<
smi-nerd-v$(SMIV).jar:
wget https://github.com/SMI/SmiServices/releases/download/v$(SMIV)/smi-nerd-v$(SMIV).jar
ctp-whitelist.script:
wget https://raw.githubusercontent.com/SMI/SmiServices/v$(SMIV)/data/ctp/ctp-whitelist.script
smiinit: smiinit.cpp yaml-cpp/build/libyaml-cpp.a
ifeq ($(UNAME), Darwin)
$(CXX) $(CXXFLAGS) -o $@ $^
else
$(CXX) -static -s $(CXXFLAGS) -o $@ $^
endif
yaml-cpp/build/libyaml-cpp.a:
mkdir -p yaml-cpp/build
cd yaml-cpp/build && cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. && $(MAKE)
clean:
$(RM) $(BINS) ctp-whitelist.script
distclean: clean
$(RM) -r yaml-cpp/build
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'