-
Notifications
You must be signed in to change notification settings - Fork 49
/
cll_build
executable file
·242 lines (191 loc) · 6.33 KB
/
cll_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
#!/bin/bash
export LANG=en_US.UTF-8
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE=C
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="en_US.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="en_US.UTF-8"
export LC_MEASUREMENT="en_US.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"
export LC_ALL=
# Find and go to where the script lives
sdir="$(dirname "$(readlink -f $0)")"
cd "$sdir"
usage() {
echo "
Usage: $0 [-j] [-c] [-a <archivedir>] [-A <coverage archivedir>] [-s/-t] [-n/-d] [-V] [-S] [-T target] [chapters]
Commonly used options:
-T target: Specifies the make target. Defaults to 'all'. Most of them are obvious. Complete list:
$(grep '^[a-z][a-z_]*:' scripts/Makefile | sed 's/:.*//' | sed 's/^/ /' | uniq)
[chapters]: defaults to all chapters; if you specify less than all chapters, you must use -s or -t
Build faster for testing:
-s: Replaces external xrefs in each chapter, so each chapter works standalone. Normally you want -t instead.
-t: Does what -s does, but also prevents most glossary processing so the glossary building goes much faster. Normally you want this intead of -s.
Regenerate jbovlaste:
-j: Pulls down a new version of xml/jbovlaste.xml from jbovlaste. Note that if you do this you should later check in the new version, so we can have consistent builds.
Copy output to your web directory:
-a <archivedir>: Copy the resulting output into the specified directory after building it in $(pwd)/build/ ; typically this is something under ~/public_html/ so it can be viewed on the web.
Diff-related options:
By default, we offer to diff the new output to the latest official/ version. The unpacked diffables are left in /tmp/cll_diffs/ for your use.
-n: Skip the diff
-d: Run the diff without asking
-V: run vimdiff on each file
Special and Unusual options:
-c: Coverage mode. Instead of using the normal chapter data, runs a special small file that is designed to do everything we ever do, but runs very quickly. In this case, the 'chapters' argument is one or more coverage types to run. Possible coverage types:
$(ls $(pwd)/coverage/*.xml | xargs -n 1 basename | sed 's/^coverage_//' | sed 's/\.xml$//')
In coverage mode, -a is ignored; use -A instead.
In coverage mode, -T is ignored; it always produces a no-chunk XHTML and a PDF.
-A <coverage archivedir>: Same as -a but only used in coverage mode; this is to stop your coverage runs from overwriting your normal runs.
-S: Provide a shell when done (useful inside a container (i.e. docker/podman))
"
exit 1
}
shell="no"
optlist=""
run_chapters=""
coverage=""
update_jbovlaste=""
builddir="build"
target="all"
diff='maybe'
vimdiff=""
while getopts "jndcC:a:A:sSthVT:" opt
do
case "$opt" in
c) coverage="true"
run_chapters="true"
;;
s) optlist="$optlist -s"
run_chapters="true"
;;
t) optlist="$optlist -t"
run_chapters="true"
;;
T) target="$OPTARG";;
a) archivedir="$OPTARG";;
A) covarchivedir="$OPTARG";;
n) diff='no';;
d) diff='yes';;
S) shell='yes';;
V) vimdiff='-V';;
j) update_jbovlaste='yes';;
[?h]) usage;;
esac
done
if [ $OPTIND -gt 1 ]
then
shift $(expr $OPTIND - 1)
fi
chapters="$*"
if [ "$target" = "coverage" -a "$optlist" ]
then
echo "
Coverage is special; give no other options.
"
usage
fi
if [ "$chapters" -a ! "$run_chapters" ]
then
echo "
Since you specified chapters, you need to specify -s or -t. -t is faster.
"
usage
fi
# Set up defaults
if [ ! "$chapters" ]
then
chapters="$(ls chapters/* | tr '\012' ' ')"
fi
if [ "$coverage" ]
then
target="coverage"
test=""
new_chapters=""
for chapter in $chapters
do
chap="coverage/coverage_$chapter.xml"
if [ -f "$chap" ]
then
new_chapters="$new_chapters $chap"
else
echo "$chapter is not a valid coverage type"
exit 1
fi
done
chapters=$new_chapters
builddir="coverage/build"
archivedir=""
fi
#**********
# Get the correct xsl version, which we'll need pretty much no
# matter what.
#**********
if [ -f xml/docbook-xsl-1.78.1.zip \
-a "$(md5sum xml/docbook-xsl-1.78.1.zip 2>&1)" = '51ed42fe67ed513763c5bd9f1abd680b xml/docbook-xsl-1.78.1.zip' ]
then
echo "xsl already downloaded; if you think this is in error, delete xml/docbook-xsl-1.78.1.zip"
else
rm -rf xml/docbook-xsl-1.78.1*
# it would be best not to go to a specific mirror like this, but
# it's not obivous how to fix that
wget https://astuteinternet.dl.sourceforge.net/project/docbook/docbook-xsl/1.78.1/docbook-xsl-1.78.1.zip -O xml/docbook-xsl-1.78.1.zip
fi
if [ -d xml/docbook-xsl-1.78.1 -a "$(find xml/docbook-xsl-1.78.1 | sort | wc -l 2>&1)" = '1945' ]
then
echo "xsl already unpacked; if you think this is in error, delete xml/docbook-xsl-1.78.1/ and/or xml/docbook-xsl-1.78.1.zip"
else
rm -rf xml/docbook-xsl-1.78.1/
bash -c "cd xml/ ; unzip docbook-xsl-1.78.1.zip"
fi
if [ "$(find xml/docbook-xsl-1.78.1 | sort | wc -l 2>&1)" != '1945' ]
then
echo -e "\n\nI don't see valid unpacked xsl in xml/docbook-xsl-1.78.1; bailing.\n\n"
exit 1
fi
echo "chapters: $chapters"
echo "optlist: $optlist"
echo "target: $target"
# See if we need to delete the cll.xml before we run make
mkdir -p $builddir
echo "$optlist $chapters" >$builddir/chapter-list.new
if [ ! -f $builddir/chapter-list ]
then
touch $builddir/chapter-list
fi
if [ "$(diff -q $builddir/chapter-list $builddir/chapter-list.new)" ]
then
cp $builddir/chapter-list.new $builddir/chapter-list
echo -e "\nChapter list differences found; forcing a re-merge.\n"
rm -f $builddir/cll.xml
fi
# If regeneration of xml/jbovlaste.xml was requestiod, remove
# that file and it will get regenerated downstream.
if [ "$update_jbovlaste" ]
then
rm xml/jbovlaste.xml
fi
make -f scripts/Makefile builddir="$builddir" test="$optlist" chapters="$chapters" covcopydir="$covarchivedir" copydir="$archivedir" $target
if [ $diff = 'yes' ]
then
./scripts/diff_official -c "$vimdiff"
fi
if [ $diff = 'maybe' ]
then
echo
echo
echo "Would you like to diff the new output against the last official/ build? Ctrl-C or 'no' for no, anything else for yes."
read answer
if [ "$answer" != 'no' ]
then
./scripts/diff_official -c "$vimdiff"
fi
fi
if [ "$shell" = 'yes' ]
then
/bin/bash
fi