summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-hyph-test
blob: 8d34dae4745967682f1f39376dfb71425cf0c58d (plain)
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
#!/bin/sh
# $Id$
# Public domain. Karl Berry, 2021; Arthur Rosendahl, 2021--2022.
# 
# Method for testing hyph-utf8 before committing to TL.
# The idea is to make a new TL tree, unzip the hyph-utf8.tds.zip there,
# build TL from the modified (not committed) tree,
# install from that TL into another temp dir.
# Thus checking all the steps that will happen after commit.
# It's complicated.

# Usage:
## Initial setup for first time:
##tmpdir=/home/texlive/hyphtest # used in TLhyphtest.pro (used below).
##                              # but otherwise could be anything
##mkdir $tmpdir # e.g., , could be anywhere
##cd $tmpdir
## 
## Get svn checkout of Master tree; need real checkout for the build below.
##svn -q co svn://tug.org/texlive/trunk/Master # takes an hour
## If on tug, slightly faster:
##time nice -19 svn -q co file:///home/svn/texlive/trunk/Master
#
# 
# After the first time, when the checkout already exists:
#cd $tmpdir
#rm -rf inst catdump.pl # clean up from last time
#svn update -q Master   # get updates made in the meantime (30-60min)
#svn status Master      # make sure it's completely clean
# 
# Unzip the new hyph-utf tree in our temp checkout.
#pushd Master/texmf-dist
#ls -l $CTAN/install/language/hyph-utf8.tds.zip # ensure new file on ctan
#unzip !$                                       # overwrite All
# In that unzip command, overwrite All symlinks with the regular files.
# (Can't use -q since we have to do this overwrite.)
#   On tug.org, CTAN=/home/ftp/tex-archive.
#   (This unzip won't remove any no-longer-distributed files, but that
#    seems like too much trouble to deal with here. The final commit
#    will take care of it.)
# 
# Unzip new tlpsrc files (without leading directory):
#cd ../tlpkg/tlpsrc
#unzip -j ../../texmf-dist/source/generic/hyph-utf8/tlpsrc.zip  # overwrite All
#
# No tlpsrc should have any non-ASCII characters. If so, change them.
#
# Back to top level of $tmpdir (the one with the ./Master subdir).
#popd
#
# See what we've got.
#svn status Master # if new package/file has been added, set newpkg/file below
#svn diff Master >/tmp/sdh # review changes
#
# When ready, run this script:
#./Master/tlpkg/bin/tl-hyph-test
#
# Once it all works, can install hyph-utf8 with ctan2tl as usual;
#   don't just commit here, so additions and removals will be correct.
# Also, good to run a test build right after committing since there is a
#   good chance of failure, despite all the testing:
#force_rebuild=true cron.trunk # or cron.pretest, if during pretest
# 
# To clean up here:
#rm -rf inst tmp catdump.pl
#svn revert --depth infinity Master >/tmp/svri
#rm `svn status Master | sed -n 's/\?//p'` # remove "?" files (new ones)
#svn status Master  # ensure clean

# 
: ${do_mktexlsr=true}
: ${do_tlpdb=true}
: ${do_lang_files=true}
: ${do_install=true}
: ${do_pkgs=true}
: ${newfile=hyph-he.tex}  # some new file in the new release
: ${newpkg=hyphen-hebrew} # and the package it's in

real0=`realpath $0`
mydir=`cd \`dirname "$real0"\` && pwd`  # tlpkg/bin

Master=`cd $mydir/../.. && pwd`
test -d "$Master" || { echo "$0: no Master dir: $Master" >&2; exit 1; }

top=`cd $Master/.. && pwd`

# /usr/local/bin for updated perl on tug.
PATH=$Master/bin/x86_64-linux:/usr/local/bin:/usr/bin
TMPDIR=$top/tmp; export TMPDIR
test -d $TMPDIR || mkdir $TMPDIR
test -d $TMPDIR || { echo "$0: no tmpdir?: $TMPDIR" >&2; exit 1; }

unset TEXMFSYSVAR; unset TEXMFSYSCONFIG
unset TEXMFVAR; unset TEXMFCONFIG
MKTEXFMT=0; export MKTEXFMT
MKTEXTFM=0; export MKTEXTFM

if $do_mktexlsr; then
  printf "\n\f `date`\n"
  set -x
  mktexlsr --verbose || exit 1; set +x
fi
#
if kpsewhich $newfile >/dev/null; then :; else
  echo "$0: kpsewhich could not find new file, ls-R problem?: $newfile" >&2
  exit 1
fi

if $do_tlpdb; then
  printf "\n\f `date`\n"
  # It takes a long time to read the Catalogue info; it can be turned
  # off as shown, but then the resulting texlive.tlpdb will be hugely
  # different from the canonical one, which makes it hard to check.
  nocat="--catalogue /nonesuch"; nocat=
  
  # If running this multiple times, can use --catalogue-dump
  # to avoid rereading the XML every time; just don't forget
  # to remove the dump file when done, or it will never get updated.
  # If you want to sit around waiting for the Catalogue reading every time,
  # can just disable as shown.
  catdump="--catalogue-dump $top/catdump.pl" #; catdump=
  
  # -v for progress; -vv for extremely voluminous debugging.
  # --save-anyway because there will probably be revision decreases.
  # --from-files because we don't want to commit the new files,
  #   so the script has to read the filesystem, not svn.
  opts="-v --save-anyway --from-files $nocat $catdump"
  set -x
  $Master/tlpkg/bin/tl-update-tlpdb $opts || exit 1; set +x
fi
#
# we intentionally use tlmgr instead of grepping tlpdb directly
# to make sure it's working normally.

if tlmgr info --list $newpkg | grep /$newfile'$' >/dev/null; then :; else
  echo "$0: tlmgr could not find new file, tlpdb problem?: $newfile" >&2
  exit 1
fi

# 
# Remake the language.* files. Irritatingly different for different
# formats and engines.

# return 0 if files $1 and $2 are the same except for the first lines.
# (we need to ignore the timestamps in the generation lines.)
same_except_for_line1 ()
{
  rm -f $TMPDIR/sef1 $TMPDIR/sef2
  sed 1d <"$1" >$TMPDIR/sef1
  sed 1d <"$2" >$TMPDIR/sef2
  cmp -s $TMPDIR/sef1 $TMPDIR/sef2
}

if $do_lang_files; then
  printf "\n\f `date`\n"
  echo "$0: updating language.* files ..."

  cd $Master/texmf-dist/tex/generic/config || exit 1
  for utype in language.dat language.def language.dat.lua; do
    ufile=$utype
    cmd="tlmgr -q generate --dest=$ufile.new $utype"
    # -q to avoid the "helpful" message about running fmtutil.
    printf "$ufile update with: $cmd\n"
    $cmd || { echo "$0: $ufile generation failed: $cmd" >&2; exit 1; }
    if same_except_for_line1 $ufile $ufile.new; then
      printf "  same: "; ls -l `pwd`/$ufile
      rm $ufile.new 
    else
      mv -v $ufile.new $ufile || exit 1
      printf "  updated: "; ls -l `pwd`/$ufile
      svn diff $ufile >$TMPDIR/$ufile.diff
      echo "  (diff in $TMPDIR/$ufile.diff)"
    fi
  done
fi

# 
printf "\n\f `date`\n"
cmd="tlmgr check files runfiles"
echo "$0: checking file consistency: $cmd"
$cmd || exit $?

# 
# Install minimal, then install the packages with AddHyphen directives
# (in practice: hyphen-* and dehyph-exptl), to avoid installing all the
# non-language stuff, which is a ton.

instdir=$top/inst
if $do_install; then
  printf "\n\f `date`\n"
  echo "$0: installing minimal TL into: $instdir"

  rm -rf $instdir
  date
  set -x
  $Master/tlpkg/bin/tl-try-install \
    -o $instdir \
    --profile $Master/tlpkg/dev/profiles/TLhyphtest.pro \
    --quiet \
    --repo $Master \
  || { echo "$0: tl-try-install failed." >&2; exit 1; }
  set +x
fi

if $do_pkgs; then
  printf "\n\f `date`\n"
  echo "$0: installing hyph packages with tlmgr into: $instdir"

  tlpsrc=$Master/tlpkg/tlpsrc
  hyphen_pkgs=`cd $tlpsrc && grep -l AddHyphen * | sed s/.tlpsrc//`
  if test -z "$hyphen_pkgs"; then
    echo "$0: no packages with AddHyphen found in: $tlpsrc" >&2
    exit 1
  fi

  engine_pkgs="pdftex etex xetex luatex uptex "

  echo "$0: installing hyphen packages: " $hyphen_pkgs
  echo "$0:        and engine packages: " $engine_pkgs
  
  # reset PATH to run using our just-installed tree.
  PATH=$instdir/bin/x86_64-linux:/usr/local/bin:/usr/bin
  date
  set -x
  tlmgr install $hyphen_pkgs $engine_pkgs || exit $?
fi

# also written into inst/ since we just changed PATH.
printf "\n\f `date`\n"
echo "$0: running fmtutil-sys separately from install for reproducibility:"
set -x
fmtutil-sys --all
# and that's our exit status.