-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-theme-fs-lang.sh
executable file
·217 lines (169 loc) · 6.78 KB
/
build-theme-fs-lang.sh
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
# $1 export FONT_FAM_U="Sans Mono"
# $2 export FONT_FAM_F="SansMono"
# $3 export FONT_FAM_L=sansmono
# $4 export FONT_LANG_U=TC
# $5 export FONT_LANG_L=tc
# $6 export SRC_ZIP_FILE=$6
# $7 export SRC_BASE_URL=$7
export FONT_FAM_U="$1"
export FONT_FAM_F=$2
export FONT_FAM_L=$3
echo "FONT_FAM_U=\"$1\""
echo "FONT_FAM_F=$2"
echo "FONT_FAM_L=$3"
export FONT_LANG_U=$4
export FONT_LANG_L=$5
echo "FONT_LANG_U=$4"
echo "FONT_LANG_L=$5"
export SRC_ZIP_FILE=$6
echo "SRC_ZIP_FILE=$6"
export SRC_BASE_URL=$7
echo "SRC_BASE_URL=$7"
export TMP_DIR=$(mktemp -d -t asciidoctor-pdf-cjk-exts-$(date +%Y%m%d%H%M%S)-XXXX)
export SRC_FILE_URL=$SRC_BASE_URL/$SRC_ZIP_FILE
export LOCAL_CACHE_ZIP="$LOCAL_CACHE_DIR/$SRC_ZIP_FILE"
export FONT_NAME="Noto ${FONT_FAM_U} CJK ${FONT_LANG_U}"
export FONT_NAME_L=noto${FONT_FAM_L}-cjk-${FONT_LANG_L}
export FILE0=LICENSE
export FILE1=Noto${FONT_FAM_F}CJK${FONT_LANG_L}-Regular.ttf
export FILE2=Noto${FONT_FAM_F}CJK${FONT_LANG_L}-Bold.ttf
export FILE3=Noto${FONT_FAM_F}CJK${FONT_LANG_L}-Italic.ttf
export FILE4=Noto${FONT_FAM_F}CJK${FONT_LANG_L}-BoldItalic.ttf
export FILE1_N=${FONT_NAME_L}-normal.ttf
export FILE2_N=${FONT_NAME_L}-bold.ttf
export FILE3_N=${FONT_NAME_L}-italic.ttf
export FILE4_N=${FONT_NAME_L}-bold_italic.ttf
export THEME_TEMPLATE_FILE1=template_default-ext-theme.yml
export THEME_TEMPLATE_FILE2=template_default-theme.yml
export THEME_TEMPLATE_FILE3=template_theme.yml
export THEME_NAME=default-ext-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}
export THEME_FILE1=default-ext-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-theme.yml
export THEME_FILE2=default-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-theme.yml
export THEME_FILE3=noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-theme.yml
export THEME_PDF_1_TEMPLATE_FILE1=template_default-ext-pdf-1-theme.yml
export THEME_PDF_1_TEMPLATE_FILE2=template_default-pdf-1-theme.yml
export THEME_PDF_1_TEMPLATE_FILE3=template_pdf-1-theme.yml
export THEME_PDF_1_NAME=default-ext-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-pdf-1
export THEME_PDF_1_FILE1=default-ext-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-pdf-1-theme.yml
export THEME_PDF_1_FILE2=default-noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-pdf-1-theme.yml
export THEME_PDF_1_FILE3=noto${FONT_FAM_L}-cjk-${FONT_LANG_L}-pdf-1-theme.yml
echo "THEME_PDF_1_TEMPLATE_FILE1=$THEME_PDF_1_TEMPLATE_FILE1"
echo "THEME_PDF_1_TEMPLATE_FILE2=$THEME_PDF_1_TEMPLATE_FILE2"
echo "THEME_PDF_1_TEMPLATE_FILE3=$THEME_PDF_1_TEMPLATE_FILE3"
echo "THEME_PDF_1_NAME=$THEME_PDF_1_NAME"
echo "THEME_PDF_1_FILE1=$THEME_PDF_1_FILE1"
echo "THEME_PDF_1_FILE2=$THEME_PDF_1_FILE2"
echo "THEME_PDF_1_FILE3=$THEME_PDF_1_FILE3"
export LICENSE_FILE1=LICENSE
export LICENSE_FILE2=LICENSE-asciidoctor-pdf
export LICENSE_FILE3=LICENSE-asciidoctor-pdf-cjk-kai_gen_gothic
export LOCAL0=$LOCAL_CACHE_DIR/$FILE0
export LOCAL1=$LOCAL_CACHE_DIR/$FILE1
export LOCAL2=$LOCAL_CACHE_DIR/$FILE2
export LOCAL3=$LOCAL_CACHE_DIR/$FILE3
export LOCAL4=$LOCAL_CACHE_DIR/$FILE4
export JAR_FILE=pdf-ext-${FONT_NAME_L}.jar
export ZIP_FILE=${FONT_NAME_L}.zip
export TMP_DIR=$(mktemp -d -t ${THEME_NAME}-$(date +%Y%m%d%H%M%S)-XXXX)
echo "CREATE TMP_DIR=$TMP_DIR"
mkdir -p $TMP_DIR/data/fonts
mkdir -p $TMP_DIR/data/themes
cp $LICENSE_FILE1 $TMP_DIR/data/themes/
cp $LICENSE_FILE2 $TMP_DIR/data/themes/
cp $LICENSE_FILE3 $TMP_DIR/data/themes/
cp theme-templates/${THEME_TEMPLATE_FILE1} $TMP_DIR/data/themes/${THEME_FILE1}
cp theme-templates/${THEME_TEMPLATE_FILE2} $TMP_DIR/data/themes/${THEME_FILE2}
cp theme-templates/${THEME_TEMPLATE_FILE3} $TMP_DIR/data/themes/${THEME_FILE3}
cp theme-templates/${THEME_PDF_1_TEMPLATE_FILE1} $TMP_DIR/data/themes/${THEME_PDF_1_FILE1}
cp theme-templates/${THEME_PDF_1_TEMPLATE_FILE2} $TMP_DIR/data/themes/${THEME_PDF_1_FILE2}
cp theme-templates/${THEME_PDF_1_TEMPLATE_FILE3} $TMP_DIR/data/themes/${THEME_PDF_1_FILE3}
if [ ! -f "$LOCAL_CACHE_ZIP" ]; then
echo "$LOCAL_CACHE_ZIP does not exist."
echo "DOWNLOAD $SRC_FILE_URL TO $LOCAL_CACHE_DIR"
echo "wget -P \"$LOCAL_CACHE_DIR\" \"$SRC_FILE_URL\""
wget -P "$LOCAL_CACHE_DIR" "$SRC_FILE_URL"
sync
sleep 1
sync
fi
echo "COPY $LOCAL_CACHE_ZIP TO $TMP_DIR"
echo "cp \"$LOCAL_CACHE_ZIP\" \"$TMP_DIR/\" "
cp "$LOCAL_CACHE_ZIP" "$TMP_DIR/"
sync
sleep 1
sync
cd $TMP_DIR
echo ""
echo "UNZIP FILE $SRC_ZIP_FILE"
echo "unzip \"$SRC_ZIP_FILE\""
unzip "$SRC_ZIP_FILE"
echo ""
sync
sleep 1
sync
# RENAME
mv $FILE0 $TMP_DIR/data/fonts/$FILE0
mv $FILE1 $TMP_DIR/data/fonts/$FILE1_N
mv $FILE2 $TMP_DIR/data/fonts/$FILE2_N
mv $FILE3 $TMP_DIR/data/fonts/$FILE3_N
mv $FILE4 $TMP_DIR/data/fonts/$FILE4_N
# CREATE THEME FROM TEMPLATE FILE
cd $TMP_DIR/data/themes
echo "CREATE $THEME_FILE1"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_FILE1
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_FILE1
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_FILE1
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_FILE1
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_FILE1
echo "CREATE $THEME_FILE2"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_FILE2
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_FILE2
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_FILE2
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_FILE2
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_FILE2
echo "CREATE $THEME_FILE3"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_FILE3
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_FILE3
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_FILE3
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_FILE3
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_FILE3
echo "CREATE $THEME_PDF_1_FILE1"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_PDF_1_FILE1
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_PDF_1_FILE1
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_PDF_1_FILE1
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_PDF_1_FILE1
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_PDF_1_FILE1
echo "CREATE $THEME_PDF_1_FILE2"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_PDF_1_FILE2
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_PDF_1_FILE2
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_PDF_1_FILE2
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_PDF_1_FILE2
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_PDF_1_FILE2
echo "CREATE $THEME_PDF_1_FILE3"
sed -i "s/VAR_FONT_NAME_VAR/$FONT_NAME/gi" $THEME_PDF_1_FILE3
sed -i "s/VAR_FILE1_N_VAR/$FILE1_N/gi" $THEME_PDF_1_FILE3
sed -i "s/VAR_FILE2_N_VAR/$FILE2_N/gi" $THEME_PDF_1_FILE3
sed -i "s/VAR_FILE3_N_VAR/$FILE3_N/gi" $THEME_PDF_1_FILE3
sed -i "s/VAR_FILE4_N_VAR/$FILE4_N/gi" $THEME_PDF_1_FILE3
sleep 1
sync
# COPY RESULT TO WK
cd $TMP_DIR/
echo "cp -r data $RELEASES_DIR/$FONT_FAM_F/$FONT_LANG_U/"
cp -r data $RELEASES_DIR/$FONT_FAM_F/$FONT_LANG_U/
# CREATE jar
cd $TMP_DIR/
# use jdk 8 build can let jdk 8+ use
echo "CREATE JAR FILE $JAR_FILE"
jar cf $JAR_FILE data/*
sync
sleep 5
mv $JAR_FILE $RELEASES_DIR/
# CREATE zip
cd $TMP_DIR/data
echo "CREATE ZIP FILE $ZIP_FILE"
zip -r $ZIP_FILE *
sync
sleep 5
mv $ZIP_FILE $RELEASES_DIR
echo "DONE!"