#! /bin/sh -
### ====================================================================
### This script updates the TeX Live installation with the latest
### versions of all packages.
###
### The TeX Live manager program, tlmgr, can download updates to any TeX
### Live installation from a number of international and national
### mirrors.
###
### The default master site at ctan.tug.org is in Berlin, Germany, but
### that machine has limited resources, so TeX Live updating work is
### farmed out to mirror sites around the world, with an attempt to
### assign you a `nearby' mirror.
###
### The North American master mirror in Salt Lake City, Utah, USA, named
### equivalently tug.ctan.org, ctan.math.utah.edu, ftp.math.utah.edu,
### and www.math.utah.edu, is updated hourly from Germany.
###
### A list of mirrors around the world can be found at
###
###     http://tug.ctan.org/tex-archive/README.mirrors
###
### Check the status of TeX Live mirrors at
###
###     https://ctan.org/mirrors/mirmon
###
### Check the path to the current repository like this:
###
###     tlmgr repository list
###
### During the pretest interval, change the default repository to Utah
### like this:
###
###     tlmgr option repository http://www.math.utah.edu/pub/texlive/tlpretest
###
### After official release, change the repository to Utah like this:
###
###     tlmgr option repository http://ctan.math.utah.edu/tex-archive/systems/texlive/tlnet
###
### To install from a mirror assigned by the master in Germany for this
### one time only, run
###
###     tlmgr --repository http://mirror.ctan.org/systems/texlive/tlnet
###
### or more simply, just
###
###	tlmgr --repository ctan
###
### To change the default back to the Germany mirror master for all
### future updates, run
###
###     tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet
###
### or more simply, just
###
###	tlmgr option repository ctan
###
### Once a suitable (usually nearby) repository has been chosen, updates
### are normally done in two steps:
###
### (1) Update the management software itself:
###         tlmgr update --self
###
### (2) Update the TeX Live tree:
###         tlmgr update --all
###
### To list all installed packages (here with "collections" in their name):
###
###         tlmgr info --only-installed collections
###
### To find which packages belong to a particular collection (here, the
### argument "collection-games"):
###
###         tlmgr info --data=depends collection-games
###
### To add the SIAM styles to your TeX Live tree, run
###
###         tlmgr repository add https://mirror.ctan.org/systems/texlive/tlcontrib tlcontrib
###         tlmgr pinning add tlcontrib "*"
###         tlmgr install siam
###
### To prepare for a new annual TeX Live tree:
###
###	* update the current release of TeX Live (e.g. with update-texlive-2024.sh)
###	* create a new TeX Live year tree
###		mkdir /usr/uumath/texlive/2025
###		rsync -a --exclude=backups --exclude=bin --exclude=logs \
###			/usr/uumath/texlive/2024/. /usr/uumath/texlive/2025/ ; date
###	* after the first successful build and installation
###	  of TeX Live, and BEFORE the asymtote build, run
###	  "fmtutil-sys --all" and then propagate all of the
###	  new *.fmt files to all other build systems
###	* run "build-asymptote.sh texlive-YYYYMMDD" to
###	  complete the build process.
###
### [04-Feb-2025] -- adapt from TeX Live 2024 to TeX Live 2025
### [05-Mar-2024] -- adapt from TeX Live 2023 to TeX Live 2024
### [24-Aug-2023] -- change Paris, France to Berlin, Germany
### [18-Feb-2023] -- adapt from TeX Live 2022 to TeX Live 2023
### [01-Nov-2022] -- add note about SIAM additions
### [05-Jan-2022] -- adapt from TeX Live 2021 to TeX Live 2022
### [06-Jan-2021] -- adapt from TeX Live 2020 to TeX Live 2021
### [17-Jul-2020] -- add final notes about tlmgr use
### [05-Mar-2020] -- adapt from TeX Live 2019 to TeX Live 2020
### [30-Apr-2019] -- correct and improve comment header
### [08-Mar-2019] -- adapt from TeX Live 2018 to TeX Live 2019
### [06-Mar-2018] -- adapt from TeX Live 2017 to TeX Live 2018
### [04-Feb-2017] -- adapt from TeX Live 2016 to TeX Live 2017
### [25-Nov-2016] -- change Aarhus, Denmark to Paris, France
### [23-Apr-2016] -- generate from update-texlive-2015.sh
### [28-Apr-2015] -- generate from update-texlive-2014.sh
### [07-Jul-2014] -- generate from update-texlive-2013.sh
### [03-Apr-2013] -- update comments about repository locations
### [23-Nov-2013] -- update for TeX Live June 2013 DVD installation
### [13-May-2011]
### ====================================================================

prefix=${prefix-/usr/uumath}
test -d $prefix/bin || prefix=/usr/local

PATH=$prefix/bin:/bin:/usr/bin:/usr/sfw/bin
test -d /usr/local/bin -a "$prefix" != /usr/local && PATH=$PATH:/usr/local/bin
test -d /usr/pkg/bin   -a "$prefix" != /usr/pkg   && PATH=$PATH:/usr/pkg/bin
export PATH

## This is the ONLY place where the TeX Live year appears in this script
TLYEAR=${TLYEAR-2025}

TLDIR=$prefix/texlive/$TLYEAR

## Temporary during $TLYEAR setup
## TLDIR=${TLDIR-/var/tmp/texlive/$TLYEAR}

echo
echo ========================================================================
echo TeX Live $TLYEAR tree under $TLDIR
echo ========================================================================
echo

unset AFMPATH BIBINPUTS D DVIPSHEADERS LTX MFINPUTS STEX TEX TEXCONFIG		\
      TEXFONTS TEXFORMATS TEXINPUTS TEXMFCNF TEXMFDBS TEXPKS TEXPSHEADERS	\
      VFFONTS

## Override Utah default TeX installation (not needed on standalone TeX Live-only systems)
test -f $prefix/skel/SYS.texlive-$TLYEAR.sh && . $prefix/skel/SYS.texlive-$TLYEAR.sh

echo
echo ========================================================================
echo TeX Live $TLYEAR update environment:
env | sort | awk '{print "\t" $0}'
echo ========================================================================
echo

## This is the default installation location for TeX Live
cd $TLDIR

echo
echo ========================================================================
echo Current TeX Live $TLYEAR repository:
echo `tlmgr repository list`
echo ========================================================================
echo

## Update tlmgr itself first, then the whole installation tree
date ; nice time tlmgr update --self ; date
date ; nice time tlmgr update --all ; date
## [16-Oct-2018] I found an unwanted reversion to A4 paper, so
## reset it to US letter (A) after every update.
date ; nice time tlmgr paper letter ; date

echo Updating FILES\* and DIRECTORIES\* ...

/u/sy/beebe/bin/FILESDIRECTORIES $TLDIR

chmod 664 $TLDIR/FILES.*  $TLDIR/DIRECTORIES.*
