\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-TeXDist}
\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 TeXDist package.
This is used in the DVD version of the Installer, and can also be used to add the TeXDist structure to distributions installed on older machines by the Unix installer using the legacy binaries.

\section{Updating for a New Year}

To update the  package for a new year, edit ``buildPackage.sh'' to
reflect the new package names, which contain the year.  

Also edit the License.rtf, ReadMe.rtf, and Welcome.rtf files both at the root level of the folder and inside the DVD folder.
 
Edit the two postflight scripts appropriately, mainly by changing the year.
For instance, to change from 2020 to 2021, use Search and Replace to change the many,
many occurrences of 2020 to 2021 in these files.

\section{Creating the  Package}

Issue the command

\begin{verbatim}
     sudo sh buildPackage.sh
 \end{verbatim}
to build the root folder, containing /Library/TeX.

\section{Signing, Timestamping, and Adopting Hardened Runtimes for Binaries}

This package has no binaries, so there is nothing to sign.


\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 TeXDist-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. Next create TeXDist-2021-Temp.pkg by running a second script
\begin{verbatim}
     sudo sh productbuildscript.sh
\end{verbatim}
Finally, created a signed package TeXDist-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 TeXDist-2021Start.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.texdist2021''. 
And it contains the restriction that the package can only be installed on machines running system 10.6 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}

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

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 TeXDist-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} 



