summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-update-images
blob: c30068d5147821e31dee8892a381c307a478cdab (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
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
#!/bin/sh
# $Id$
# Create the .iso image(s) for TeX Live.
# 
# Copyright 2007-2024 Karl Berry.
# Copyright 2003, 2004, 2005 Sebastian Rahtz.
#
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
# Send bug reports or suggestions to tex-live@tug.org.
# Historical notes at the end of the script.

renice 20 $$ >/dev/null 2>&1
LANG=C; export LANG
LC_ALL=C; export LC_ALL
unset CDPATH  # avoid output from cd
umask 022

NAME=texlive
V=2024
D=`date +%Y%m%d`
target=/home/ftp/texlive/Images/test

XZ_OPT=-6e; export XZ_OPT # compression level, -9 for slowest-but-most,
                          # which is not worth the (excessive) time.
                          # The -e is also for better compression.

mydir=`cd \`dirname $0\` && /bin/pwd`
cd $mydir || exit 1  # the Master/tlpkg/bin directory
master=`cd ../.. && /bin/pwd`
test -z "$master" && exit 1

lockfile=/dev/shm/cron.tlimg.lock  # so it'll go away on reboot
lockfile -r 0 $lockfile || exit 1  # from procmail
#
release_savefile=/tmp/tluirt.txt
release_livefile=$master/release-texlive.txt
#
# On exit, remove the lockfile and undo the release-texlive.txt without
# using svn.
#
trap "set -x; rm -f $lockfile; \
  test -s $release_savefile && cp $release_savefile $release_livefile; \
  rm -f $release_savefile
exit 0;" 0 1 2 15

debug=${OVERRIDE_DEBUG-false}
mkisofs="xorriso -read_mkisofsrc -as mkisofs"   # mkisofs
makeinst=true
maketar=true
tar_all=true
tar_bin_only=false
tar_devsource_only=false
tar_extra_only=false
tar_source_only=false
tlnet=/home/ftp/texlive/tlpretest
quiet=  # for passing to mkisofs

while test $# -gt 0; do
  case $1 in
  --debug)     debug=true; quiet=;;
  --help)      echo "$0: Helpless, use the source, sorry."; exit 0;;
  --mkisofs=*) mkisofs=`echo $1 | sed 's/.*=//'`;;
  --noinst)    makeinst=false;;
  --notar)     maketar=false;;
  --quiet)     quiet=-quiet;;
  --target=*)  target=`echo $1 | sed 's/.*=//'`;;
  --tar-bin-only)       tar_all=false; makeinst=false; tar_bin_only=true;;
  --tar-devsource-only) tar_all=false; makeinst=false;tar_devsource_only=true;;
  --tar-extra-only)     tar_all=false; makeinst=false; tar_extra_only=true;;
  --tar-source-only)    tar_all=false; makeinst=false; tar_source_only=true;;
  --tlnet=*)   tlnet=`echo $1 | sed 's/.*=//'`;;
  --version)   echo "$0 for $NAME-$V ($D)"; exit 0;;  # who cares ...
  *) echo "$0: unknown option $1; try --help if you need it." >&2; exit 1;;
  esac
  shift
done

if $debug; then
  echo "master = $master"
  echo "target = $target"
fi
mkdir -p $target

# From the days when we made multiple images.  Keep it factored out in
# case they come back.
common_mkisofs_options="$quiet -pad -J -dir-mode 0755 -r -x .svn"

# 
MAKEINST ()
{
  origdir=`pwd`
  prefix=$target/$NAME$V # directory and prefix for our files within
  iso=$prefix-$D.iso
  echo "-- `date` writing iso to $iso"

  # remove old images, checksums, signatures, versioned and generic.
  rm -f $iso* $prefix*.iso*

  # the image consists of a tlnet tree and the top-level files
  # from master, more or less.
  imgdir=${prefix}imgtmp
  rm -rf $imgdir
  mkdir $imgdir
  
  # files and a few dirs from master.
  cp -p $master/.mkisofsrc $imgdir || exit 1    # mkisofs control
  cp -p $master/* $imgdir 2>/dev/null           # intentionally skip dirs
  cp -pr $master/readme* $master/source $imgdir # but do these few dirs
  
  # included preformatted doc in new dir for the DVD.
  mkdir $imgdir/texlive-doc
  (cd $master/texmf-dist/doc/texlive && tar cf - \
     index.html */*.html */*.pdf */*.png \
   | (cd $imgdir/texlive-doc && tar xf -))
  
  # files from network dist.
  cd $tlnet || exit 1
  if $debug; then
    echo "source = `pwd`"
  fi
  if test ! -r install-tl; then
    echo "$0: no install-tl in `pwd`, goodbye." >&2
    exit 1
  fi
  cp -pr install-tl *.bat tlpkg $imgdir || exit 1

  # we also don't want the symlinks since we don't actually need them
  # and since we want to make Joliet images (though that format may not
  # be needed anymore). Every symlink provokes a warning from xorrisofs
  # under Joliet. But copy all the regular files, they are the basic thing.
  archivedir=$imgdir/archive
  mkdir $archivedir || exit 1
  find archive -type l -prune -o -type f -print \
  | xargs cp --target-directory=$archivedir || exit 1

  # Save all tlpdb files before pruning platforms; these will be posted
  # to historic later; see releng.txt.
  preprune=$target/preprune-tlpdb
  rm -rf $preprune && mkdir $preprune
  cp -p tlpkg/texlive.tlpdb* $preprune || exit 1
  
  # remove platforms to save space on the dvd.
  # do this here so that they can be kept in the tree,
  # and thus installed normally over the net.
  # keep in sync with info on http://tug.org/texlive/doc.html.
  prune="aarch64-linux amd64-netbsd armhf-linux \
         i386-freebsd i386-linux i386-netbsd i386-solaris \
         x86_64-linuxmusl x86_64-solaris"
  echo "-- pruning platforms: $prune..."
  mkdir $imgdir/tlpkg/bin
  cp $mydir/tl-prune-platforms $imgdir/tlpkg/bin
  $imgdir/tlpkg/bin/tl-prune-platforms $prune >/tmp/pruneimg.out || exit 1

  # due to the pruning, must re-checksum and re-sign the tlpdb in the image.
  md5sum $imgdir/tlpkg/texlive.tlpdb >$imgdir/tlpkg/texlive.tlpdb.md5 \
    || exit 1
  sha512sum $imgdir/tlpkg/texlive.tlpdb >$imgdir/tlpkg/texlive.tlpdb.sha512 \
    || exit 1
  $master/tlpkg/bin/tl-sign-file $imgdir/tlpkg/texlive.tlpdb.sha512 \
    || exit 1

  # some files we don't want in the image after all.
  rm -rf $imgdir/tlpkg/texlive.tlpdb.xz $imgdir/tlpkg/bin
  
  # the actual iso creation.
  cd $imgdir || exit 1
  cmd="$mkisofs $common_mkisofs_options -o $iso ."
  echo "-- `date` with: $cmd"
  $cmd
  if test $? -ne 0; then
    echo "$0: $mkisofs failed (status $?), goodbye." >&2
    exit $?
  fi
  
  cd $target || exit 1
  rm -rf $imgdir

  # since prune-platforms changes the tlpdb file, must remake checksums.
  # (before making the iso). redundantly remove files being created.
  rm -f $prefix.iso.md5; md5sum `basename $iso` >$iso.md5 || exit 1
  rm -f $prefix.iso.sha512; sha512sum `basename $iso` >$iso.sha512 || exit 1

  # for md5 and sha512, adjust the embedded filename for generic files.
  rm -f $prefix.iso.md5; sed "s,-$D,," $iso.md5 >$prefix.iso.md5
  rm -f $prefix.iso.sha512; sed "s,-$D,," $iso.sha512 >$prefix.iso.sha512

  # sign both the versioned and generic checksums, separately.
  rm -f $iso.sha512.asc
  $master/tlpkg/bin/tl-sign-file $iso.sha512 || exit 1
  #
  rm -f $prefix.iso.sha512.asc
  $master/tlpkg/bin/tl-sign-file $prefix.iso.sha512 || exit 1

  # symlinks with short name (potentially used in /etc/fstab).
  rm -f $prefix.iso; ln -s `basename $iso` $prefix.iso             # with year
  rm -f $target/$NAME.iso; ln -s `basename $iso` $target/$NAME.iso # no year

  # at the end, all the files should be non-empty.
  all_ok=true
  for f in *.md5 *.sha512 *.asc *.iso; do
    if test ! -s $f; then
      echo "$0: MAKEINST: unexpected empty file: $f" >&2
      all_ok=false
    fi
  done
  $all_ok || exit 1  # give up now if empty files
  
  cd $origdir || exit 1
  echo "-- `date` iso files:"
  ls -l $iso $iso.sha512 $iso.sha512.asc 
}


# 
# Make the tar files: the sources, the texmf trees, the binaries, the
# minor "extra" files.  Each should unpack into its directory name.  We
# use the GNU tar --transform option to avoid copying the whole
# hierarchy to a temp directory.  The do_tar function takes that
# temp directory name as its first argument, and the files to archive as
# the rest.
# 
do_tar ()
{
  name=$1; shift
  #
  if false; then # ddebug
    verbose="-v --show-transformed-names"
  else
    verbose=
  fi
  #
  compress=--xz
  #
  excludes="--exclude-vcs"
  if echo "$name" | grep 'source$' >/dev/null; then
    # more excludes for source tarball.
    excludes="$excludes --exclude=Work --exclude=inst"
    excludes="$excludes --exclude=autom4te.cache"
    excludes="$excludes --exclude=asymptote/binaries" # also distclean asy
  fi
  #
  tar_common_opt="$verbose $compress $excludes"
  #
  tarfile=$target/$name.tar.xz
  tar -cf $tarfile --owner=0 --group=0 \
      --transform="s,^,$name/," $tar_common_opt \
      "$@"
  if test $? -ne 0; then
    echo "$0: tar failed, goodbye." >&2
  fi
  
  origdir=`pwd`
  cd $target || exit 1
  #
  rm -f $tarfile.sha512
  sha512sum `basename $tarfile` >$tarfile.sha512 || exit 1
  #
  rm -f $tarfile.sha512.asc
  $master/tlpkg/bin/tl-sign-file $tarfile.sha512 || exit 1
  #
  cd $origdir || exit 1

  echo
  ls -l $tarfile $tarfile.sha512 $tarfile.sha512.asc
}

MAKETAR ()
{
  echo; echo "-- `date` writing tars to $target" # ~2 hours

  # remove old tarballs and checksums.
  rm -f $target/$NAME-*.tar.*

  # make tar files using the contents of the tree we are running out of.
  if $tar_extra_only || $tar_all; then
    cd $master || exit 1
    do_tar $NAME-$D-extra \
         LICENSE* README* autorun.inf *.html install* re* tl-* \
         tlpkg/TeXLive tlpkg/texlive.tlpdb tlpkg/tlpostcode tlpkg/translations
    $tar_extra_only && return  # for debugging
  fi
  
  # compiled binaries.
  if $tar_bin_only || $tar_all; then
    cd $master/bin || exit 1
    do_tar $NAME-$D-bin *
    $tar_bin_only && return
  fi
  
  # compilable sources.
  if $tar_source_only || $tar_all; then
    cd $master/../Build/source || exit 1
    do_tar $NAME-$D-source *
    $tar_source_only && return
  fi
  
  # development sources, which we record in the
  # 00texlive.image (fake) package; see its .tlpsrc.
  if $tar_devsource_only || $tar_all; then
    cd $master || exit 1
    do_tar $NAME-$D-devsource `$mydir/tlpfiles 00texlive.image`
    $tar_devsource_only && return
  fi

  # the big tree; must have $tar_all if we get here.
  cd $master || exit 1
  do_tar $NAME-$D-texmf texmf*
}


#  main program.

# Add our exact version to the release file.  Ensure a line of its own,
# although a blank line should already be there.
rm -f $release_savefile
cp $release_livefile $release_savefile
printf "\ntexlive-$D\n" >>$release_livefile

$makeinst && MAKEINST
$maketar && MAKETAR

exit 0

# Until 2010, we also produced:
# live: full live distribution which can be run as is (CD/DVD)
# but this was dropped in 2010.  TeX Live is no longer live.  Oh well.
#
# From 2004-2007, we produced:
# inst: compressed zip files and installer only (CD)
# but this was dropped in 2008, and restored in a different form in 2010
# for DVD.
# 
# In 2003, we produced:
# demo: live subset which can be run as is (CD)
# but this was dropped in 2004.