forked from reutenauer/polyglossia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakectanzip
executable file
·150 lines (132 loc) · 4.05 KB
/
makectanzip
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
#!/bin/bash
if [ z"$1" = z ]; then
branch=master
else
branch="$1"
fi
# TODO Check branch
warn_and_exit=false
line=`git status | fgrep 'Your branch is ahead' | wc -l`
if [ "$line" = 1 ]; then
warn_and_exit=true
elif [ `git status -s | cut -c -2 | egrep -c 'M|A'` -gt 0 ]; then
warn_and_exit=true
fi
if $warn_and_exit; then
echo "Please commit and push your changes to GitHub!"
exit -1
fi
# TODO Test zip and DTX file thus produced!
pgroot=`dirname $0`
first_char=`echo $pgroot | sed -e 's/^\(.\).*$/\1/'`
if [ "$first_char" != '/' ]; then
pgroot="`pwd`/$pgroot"
fi
origdir=`pwd`
tmpdir=`mktemp -d`
root=$tmpdir/polyglossia
cd $tmpdir
git clone --branch $branch https://github.com/reutenauer/polyglossia
builddir="$root/build"
mkdir -p $builddir
pdf="$root/doc/polyglossia.pdf"
pdfsrc="$root/doc/polyglossia.tex"
pdfbasename=${pdf%.pdf}
cd $root
source ./env
# Overrides the default 79. This makes for overly long lines in TeX’s
# output, but at least it’s easy to see what’s on the same line and
# what’s not (within the first 2048, of course).
# The default is set by kpathsea, but it’s just easier to make it an
# environment variable).
max_print_line=2048
export max_print_line
# check if pdf is older than polyglossia.tex
if [[ ! -f $pdf || $pdf -ot $pdfsrc ]] ; then
echo "Updating PDF documentation ..."
cd $root/doc
xelatex $pdfsrc || exit 1
xelatex $pdfsrc
cp -f $pdf $pgroot/generated
rm -f $pdfbasename.{aux,toc,lof,lot,lop,log,out,nav,bbl,blg,ind,idx,glo,ilg,dvi}
for doc in example-arabic example-thai example-korean examples; do
echo "COMPILING doc '$doc'"
cd $root/doc
# The line below generates an error even if things don’t go wrong,
# and quite frankly I don’t know what it’s good for.
# First of all, the last bit should be echo "Failed to compile ..."
# but I won’t bother
# xelatex $doc.tex || exit 1 && "Failed to compile $doc.tex"
xelatex $doc.tex || exit 1
xelatex $doc.tex
rm -f $doc.{log,aux,toc}
cp -f $doc.pdf $pgroot/generated
cd $root
done
fi
cd $root
echo "Making polyglossia.{dtx,ins}"
test -d $builddir || mkdir $builddir
# echo $builddir # TODO Finish the job
perl makepolyglossiadtx.pl || exit 1
mv polyglossia.dtx $builddir || exit 1
cd $builddir
(
cat <<'EOF'
\begingroup
\input docstrip.tex
\keepsilent
\nopreamble\nopostamble
\generate{\file{polyglossia.ins}{\from{polyglossia.dtx}{batchfile}}}
\endgroup
\bye
EOF
) > makeins.tex
# xetex makeins.tex 2&> /dev/nul
rm -f polyglossia.ins # Otherwise docstrip expects interactive input
xetex makeins.tex
# rm makeins.*
#rm *.{sty,def,ldf,map,txt,tex,glo,log,out,idx,aux,toc} 2&> /dev/null
echo "Create TDS tree ..."
TDS_src="$builddir/source/latex/polyglossia"
TDS_tex="$builddir/tex/latex/polyglossia"
TDS_doc="$builddir/doc/latex/polyglossia"
TDS_map="$builddir/fonts/misc/xetex/fontmapping/polyglossia"
mkdir -p $TDS_src
mkdir -p $TDS_tex
mkdir -p $TDS_doc
mkdir -p $TDS_map
cp polyglossia.dtx $TDS_src/ || exit 1
cp $root/tex/* $TDS_tex/ || exit 1
cp $root/doc/* $TDS_doc/ || exit 1
cp $root/README $TDS_doc/ || exit 1
cp $root/fontmapping/* $TDS_map/ || exit 1
echo "Update TECkit mappings ..."
cd $TDS_map
for map in *.map; do
teckit_compile $map || exit 1
done
echo "Make TDS tarball ..."
cd $builddir
tarball="polyglossia.tds.zip"
zip $tarball tex/latex/polyglossia/*.{ldf,def,sty,lua} || exit 1
zip $tarball fonts/misc/xetex/fontmapping/polyglossia/* || exit 1
zip $tarball source/latex/polyglossia/polyglossia.dtx || exit 1
zip $tarball doc/latex/polyglossia/*.{tex,pdf} || exit 1
zip $tarball doc/latex/polyglossia/README || exit 1
echo "Make CTAN zip ..."
ctanzip="polyglossia.zip"
mkdir -p $builddir/tmp/polyglossia
cd $builddir/tmp
mv $builddir/$tarball . || exit 1
mv $builddir/polyglossia.{dtx,ins} polyglossia/ || exit 1
cp $root/{doc/polyglossia.pdf,README} polyglossia/ || exit 1
zip -9 $ctanzip polyglossia/* polyglossia.tds.zip || exit 1
mv $ctanzip $root/ || exit 1
cd $root
mv -f $root/doc/*.pdf $root/generated || exit 1
rm -rf $builddir
echo "$ctanzip is ready to upload"
mv -f $ctanzip $pgroot/
cd $origdir
exit 0