-
Notifications
You must be signed in to change notification settings - Fork 9
/
acro.build
executable file
·357 lines (340 loc) · 10.2 KB
/
acro.build
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
# --------------------------------------------------------------------------
# the ACRO package
#
# Typeset Acronyms
#
# --------------------------------------------------------------------------
# Clemens Niederberger
# Web: https://github.com/cgnieder/acro/
# E-Mail: contact@mychemistry.eu
# --------------------------------------------------------------------------
# Copyright 2011--2020 Clemens Niederberger
#
# --------------------------------------------------------------------------
# this is a personal bash script to build the acro package
# and very likely not of use for anybody else
#
# !! USE WITH CAUTION !!
#
# --------------------------------------------------------------------------
#!/bin/bash
pkgname="acro"
moduleext="code.tex"
styname="$pkgname.sty"
styoldname="${pkgname}2.sty"
styexplname="${pkgname}-examples.sty"
program="arara --verbose"
manualfile="$pkgname-manual"
zipname="$pkgname"
build=true
cleancode=false
cleandoc=false
cleanexamples=false
cleanup=false
createzip=false
manual=false
runmktexlsr=false
update=false
silent=false
usage="script for buiding the $pkgname package
./$(basename "$0") [option(s) [value]]
where valid options are:
-b build sty file from modules (default: $build)
-d deletes auxiliary files from a latex compilation
allowed values: 'none', 'all', 'code', 'doc', 'examples' (default: 'none')
-f name of manual file (without .tex) (default: '$manualfile')
-h show this help
-l run latex to (re-) create manual (default: $manual)
-m run mktexlsr, only when used together with -u (default: $runmktexlsr)
-n do nothing and exit
-o output file for creating the style file (default: '$styname')
-p program for building the manual (default: '$program')
-s silent, avoid messages (default: $silent)
-u update local tex repository (default: $update)
-z create zip file for CTAN upload (default: $createzip)"
# options:
while [ -n "$1" ]; do
case "$1" in
-b|--build)
case "$2" in
true)
shift ;;
false)
build=false
shift ;;
*) ;;
esac ;;
-d|--delete)
case "$2" in
none)
cleanup=false ;;
all)
cleanup=true
cleancode=true
cleandoc=true
cleanexamples=true ;;
code)
cleanup=true
cleancode=true ;;
doc)
cleanup=true
cleandoc=true ;;
examples)
cleanup=true
cleanexamples=true ;;
*)
echo "invalid value '$2'"
exit 1 ;;
esac
shift ;;
-f|--file)
manualfile="$2"
shift ;;
-h|--help)
echo "$usage"
exit 0 ;;
-l|--latex)
case "$2" in
true)
manual=true
shift ;;
false)
manual=false
shift ;;
*)
manual=true ;;
esac ;;
-m|--mktexlsr)
case "$2" in
true)
runmktexlsr=true
shift ;;
false)
runmktexlsr=false
shift ;;
*)
runmktexlsr=true ;;
esac ;;
-n|--nothing)
exit 0 ;;
-o|--output)
styname="$2"
shift ;;
-p|--program)
program="$2"
shift ;;
-s|--silent)
case "$2" in
true)
slient=true
shift ;;
false)
silent=false
shift ;;
*)
silent=true ;;
esac ;;
-u|--update)
case "$2" in
true)
update=true
shift ;;
false)
update=false
shift ;;
*)
update=true ;;
esac ;;
-v|--version)
zipname="${zipname}_v$2"
shift ;;
-z|--zip)
case "$2" in
true)
createzip=true
shift ;;
false)
createzip=false
shift ;;
*)
createzip=true ;;
esac ;;
*) echo "unknown option '$1'"
exit 1 ;;
esac
shift
done
if [ "$silent" == true ] ; then
verbose=false
else
verbose=true
fi
START_DIR="${PWD}"
DEV_DIR=~/LaTeX/dev
SNAPSHOT_DIR=~/LaTeX/snapshots
ACRO_DEV_DIR=${DEV_DIR}/$pkgname
CODE_DIR=${ACRO_DEV_DIR}/code
DOC_DIR=${ACRO_DEV_DIR}/doc
EXAMPLES_DIR=${DOC_DIR}/examples
TEXMFLOCAL_DIR=/usr/local/texlive/texmf-local
LATEXLOCAL_DIR=${TEXMFLOCAL_DIR}/tex/latex/local
BIBLOCAL_DIR=${TEXMFLOCAL_DIR}/bibtex/bib/local
# files to be "cleaned":
AUX_FILES=""
if [ "$cleanup" == true ] ; then
if [ "$cleancode" == true ] ; then
AUX_FILES="${AUX_FILES}
${CODE_DIR}/*~"
fi
if [ "$cleandoc" == true ] ; then
AUX_FILES="${AUX_FILES}
${DOC_DIR}/*~
${DOC_DIR}/*synctex*
${DOC_DIR}/*.run.xml
${DOC_DIR}/*.aux
${DOC_DIR}/*.acr
${DOC_DIR}/*.xsim
${DOC_DIR}/*.log
${DOC_DIR}/*.out
${DOC_DIR}/*.bbl
${DOC_DIR}/*.bcf
${DOC_DIR}/*.bib
${DOC_DIR}/*.blg
${DOC_DIR}/*.idx
${DOC_DIR}/*.ilg
${DOC_DIR}/*.ind
${DOC_DIR}/*.tmp
${DOC_DIR}/*.toc
${DOC_DIR}/*.lof
${DOC_DIR}/*.lot"
fi
if [ "$cleanexamples" == true ] ; then
AUX_FILES="${AUX_FILES}
${EXAMPLES_DIR}/*~
${EXAMPLES_DIR}/*synctex*
${EXAMPLES_DIR}/*.run.xml
${EXAMPLES_DIR}/*.aux
${EXAMPLES_DIR}/*.acr
${EXAMPLES_DIR}/*.xsim
${EXAMPLES_DIR}/*.log
${EXAMPLES_DIR}/*.out
${EXAMPLES_DIR}/*.bbl
${EXAMPLES_DIR}/*.bcf
${EXAMPLES_DIR}/*.bib
${EXAMPLES_DIR}/*.blg
${EXAMPLES_DIR}/*.idx
${EXAMPLES_DIR}/*.ilg
${EXAMPLES_DIR}/*.ind
${EXAMPLES_DIR}/*.tmp
${EXAMPLES_DIR}/*.toc
${EXAMPLES_DIR}/*.lof
${EXAMPLES_DIR}/*.lot"
fi
fi
if [ "$build" == true ] ; then
if [ "$verbose" == true ] ; then
echo "writing style file $styname ..."
fi
# change to the code directory
cd ${CODE_DIR}
# build sty file from modules:
cat \
$pkgname.start.$moduleext \
$pkgname.base.$moduleext \
$pkgname.interface.$moduleext \
$pkgname.aux.$moduleext \
$pkgname.properties.$moduleext \
$pkgname.acronyms.$moduleext \
$pkgname.formatting.$moduleext \
$pkgname.ppfixes.$moduleext \
$pkgname.tools.$moduleext \
$pkgname.commands.$moduleext \
$pkgname.templates.$moduleext \
$pkgname.list.$moduleext \
$pkgname.pages.$moduleext \
$pkgname.locale.$moduleext \
$pkgname.pdfsupport.$moduleext \
$pkgname.patch.$moduleext \
$pkgname.definitions.$moduleext \
$pkgname.upgrade.$moduleext \
> $styname
# append necessary end:
echo -e "% finish package:\n\
\\hook_gput_code:nnn {enddocument} {acro} { \\\\acro_do_rerun: }\n\
%----------------------------------------------------------------------------\n\
\\\\file_input_stop:"\
>> $styname
fi
# build manual
if [ "$manual" == true ] ; then
cd ${DOC_DIR}
if [ "$verbose" == true ] ; then
echo "running '$program' on '$manualfile'..."
fi
$program $manualfile
fi
# remove temporary and auxiliary files
if [ "$cleanup" == true ] ; then
if [ "$verbose" == true ] ; then
echo "deleting auxiliary files..."
fi
for file in ${AUX_FILES}
do
if [ ! -e "${file}" ]; then continue
else
if [ "$verbose" == true ] ; then
echo "deleting file '${file}' ..."
fi
rm "${file}"
fi
done
fi
# move new sty file to local repo
if [ "$update" == true ] ; then
if [ "$verbose" == true ] ; then
echo "updating texmf-local..."
fi
if [ ! -d "${LATEXLOCAL_DIR}/$pkgname" ]; then
if [ "$verbose" == true ] ; then
echo "creating directory '${LATEXLOCAL_DIR}/$pkgname' ..."
fi
mkdir ${LATEXLOCAL_DIR}/$pkgname
fi
cd ${CODE_DIR}
cp $styname ${LATEXLOCAL_DIR}/$pkgname
cp $styoldname ${LATEXLOCAL_DIR}/$pkgname
cp $styexplname ${LATEXLOCAL_DIR}/$pkgname
if [ "$runmktexlsr" == true ] ; then
if [ "$verbose" == true ] ; then
echo "running mktexlsr ..."
fi
mktexlsr
fi
fi
if [ "$createzip" == true ] ; then
if [ -f "${SNAPSHOT_DIR}/$pkgname/$zipname.zip" ] ; then
rm ${SNAPSHOT_DIR}/$pkgname/$zipname.zip
fi
if [ "$verbose" == true ] ; then
echo "creating zip archive $zipname.zip ..."
fi
cd ${ACRO_DEV_DIR}
mkdir $pkgname/
mkdir $pkgname/examples
cp ${CODE_DIR}/$styname $pkgname/
cp ${CODE_DIR}/$styoldname $pkgname/
cp ${CODE_DIR}/$styexplname $pkgname/
cp ${DOC_DIR}/$manualfile.tex $pkgname/
cp ${DOC_DIR}/$manualfile.pdf $pkgname/
cp ${DOC_DIR}/examples/$pkgname.example.*.tex $pkgname/examples/
cp ${DOC_DIR}/examples/$pkgname.example.*.pdf $pkgname/examples/
cp README $pkgname/
zip -r $zipname.zip $pkgname/
rm -r $pkgname/
if [ "$verbose" == true ] ; then
echo "moving zip archive $zipname.zip ..."
fi
mv $zipname.zip ${SNAPSHOT_DIR}/$pkgname/$zipname.zip
fi
cd ${START_DIR}
exit 0