
\documentclass[11pt, oneside]{amsart}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\usepackage{url}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\title{DOC-TeXLive-2021}
\author{Richard Koch}
%\date{}                                           % Activate to display a given date or no date

\begin{document}
\maketitle
\section{TeXLive-2021}
This is the portion of the TUG documentation which deals with making the TeXLive-2021 package.
This is the key component of the build directory.

Create a directory named texlive2021pretest in your home directory. To get or update the pretest, issue the following command; everything should be on one line:
\begin{verbatim}
rsync -a --delete --exclude="mactex*"  ftp.math.utah.edu::tlpretest
   /Users/koch/texlive2021pretest
\end{verbatim}



\section{Creating the  Package}

 
The compile system must contain X11. Get it at X11Quartz if it isn't there.

 On the compile system, issue the commands
 \begin{verbatim}
      cd /usr/local
      sudo mv texlive texlive-old
 \end{verbatim}
 
 Then make sure local configuration files for TeX Live are disabled, perhaps by writing
  \begin{verbatim}
     cd 
     cd Library
     mv texmf texmfold
     rm -R texlive
 \end{verbatim}
 
 
 Then create a folder containing the tlpretest, which will later be updated with the same command. To do that, make a directory named
 texlive2021pretest and then
 \begin{verbatim}
      cd
      cd texlive2021pretest
      rsync -a --delete --exclude="mactex*" ftp.math.utah.edu::tlpretest .
\end{verbatim}

The last line here obtains a copy from the utah mirror site for pretest releases. If time is of the essence, but not otherwise, download directly
from the tug home site:

\newpage
 \begin{verbatim}
      cd
      cd texlive2021pretest
      rsync -a --delete --exclude="mactex*" ftp.tug.org::tlpretext .
\end{verbatim}

 
When first building binaries, it is necessary to submit them to Karl, wait for him to install them in the pretest and wait overnight
for the pretest to make its way to mirror sites.

 
 Then install TeX Live from the svn directory by
 \begin{verbatim}
 TEXLIVE_INSTALL_NO_CONTEXT_CACHE=1
 export TEXLIVE_INSTALL_NO_CONTEXT_CACHE
 cd
 cd texlive2021pretest
 sudo env  TEXLIVE_INSTALL_NO_CONTEXT_CACHE=$TEXLIVE_INSTALL_NO_CONTEXT_CACHE ./install-tl
 \end{verbatim}
 
 This will run the graphic Unix install script. If not, change ``./install-tl'' to ``./install-tl --gui tcl''. The default values will be correctly chosen for the Macintosh. Change the paper size option to ``letter''.
 Then start installation.

When installation is complete, switch the default tlmgr repository to the final value using
the command 
\begin{verbatim}
     sudo /usr/local/texlive/2021/bin/x86_64-darwin/tlmgr option repository \
          http://mirror.ctan.org/systems/texlive/tlnet
\end{verbatim} 


After these steps, the final TeXLive directory ``root''  can be built, using the command:
\begin{verbatim}
     sudo sh buildPackage.sh
\end{verbatim}


Finally repair /usr/local  by
\begin{verbatim}
      cd
      cd /usr/local
      sudo rm -R texlive
      sudo mv texlive-temp texlive
\end{verbatim}

This root file is  all  that is needed to make MacTeX. 

Most binaries will be signed, but some will not, so sign and adopt a hardened runtime for everything using
\begin{verbatim}
     sudo sh liposcriptsignallapps
\end{verbatim}

This script signs lz4, wget, and xz in tlpkg/installer, and over 100 apps in the app directory. Note that mf and xdvi and dvisvgm require third party library exceptions because they link with X11; dvisvgm also links with libgs. The four luatex binaries require two exceptions.

We also remove four pieces of documentation which causes notarize problems in April and May of 2021. It would be good to discuss this with Apple and eventually remove these fixes.


\section{Building the Final Install Package}

The install package is constructed using scripts in the folder ``CreateInstallPackage.'' This folder also contains Resources and Scripts which will become part of the package. We first build TeXLive-2021Start.pkg by
\begin{verbatim}
     sudo sh pkgbuildscript.sh
\end{verbatim}
This script reaches up a level to find the root folder containing the package material. 

This is the only package required to make MacTeX, and since the remaining packages are quite large, most builders will stop here. In particular, it is silly to notarize the package because notarization will require a very large upload to Apple, and will never be used.

However, for the record it is possible to  create TeXLive-2019-Temp.pkg by running a second script
\begin{verbatim}
     sudo sh productbuildscript.sh
\end{verbatim}
Finally, it is possible to create a signed package TeXLive-2021.pkg by running the script
\begin{verbatim}
     sh signPackage.sh
\end{verbatim}
This script contains my Apple signing identity; future builders will first have to join Apple's Developer Support and get their own signing identity.

The CreateInstallPackage folder contains two other files and one other script. The files are requirement.xml and distribution.xml, and the script is create\_distribution.sh. In future years, it may be enough to edit distribution.xml by hand. This file contains the TeXLive-2021-Start.pkg name, and references to the background image, Welcome dialog, ReadMe dialog, and License dialog. It contains the identifier of the package, currently ``org.tug.mactex.texlive2021''. And it contains the restriction that the package can only be installed on machines running system 10.14 or higher.

But if necessary, the file can be recreated as follows. The system requirement is contained in requirement.xml. Edit this first. Then run the script create\_distribution.sh. This script provides some information in distribution.xml, and outputs a sample distribution.xml file. But other items must be added by directly editing the file.

\section{Notarizing the Final Install Package}

It takes a very long time to upload TeXLive-2021.pkg to Apple to be notarized, and that step is completely unnecessary, so most builders will not do it. Notice that the final MacTeX-2021 only uses TeXLive-2021-Start.pkg, but only the final TeXLive-2021.pkg is notarized below.

Scripts to notarize TeXLive-2021.pkg are in the folder ``NotarizePackage'' inside ``CreateInstallPackage.'' The actual TeXLive-2021.pkg created above can be left where it is; it need not be moved to the new folder.

\newpage
To notarize,
\begin{verbatim}
     sh sendnotarizerequest.sh
\end{verbatim}
There will be a delay when nothing is printed in Terminal as the package is uploaded to Apple. When the upload is complete, a message of the form
\begin{verbatim}
    RequestUUID = 96f0932f-b50f-4d73-ad65-1220fd9c8efe
\end{verbatim}
will be printed. This magic number can be used to discover what went wrong if notarization fails, so I recommend copying it to the file requestUUID.tex. There will be a pause of about ten minutes and then a notification from Apple and an email from Apple will arrive. If all is well, this message says that notarization succeeded. To add the certificate to the install package
 \begin{verbatim}
    sh stapleresult.sh
\end{verbatim}
The package TeXLive-2021.pkg is then ready for uploading and release.

In case of failure, open the script detailedinfo.sh and notice that the magic UUID number is part of this script. Copy and paste the new number from requestUUID.tex to this script. Then run it.
 \begin{verbatim}
    sh detailedinfo.sh
\end{verbatim}
This command will return a web url. Use Safari to go to that url, where a very detailed error report will clearly state what went wrong.

The detailedinfo script runs a command named xcrun which communicates with developer support. Apple has adopted two-factor authentication security for such communication, but this security is not very convenient when running shell scripts. So developers can log into their Apple developer account and assign a password to xcrun and a few similar commands. Then when the script runs, typing this password is enough to run the command.
Note that the detailedinfo script contains my account name and password. When someone else makes these packages, they will replace this information with their own personal information.










\end{document}