apt-setup is used to generate an /etc/apt/sources.list for the installed
system. It does this by creating a new sources.list file (commenting out
the previous contents) and then running each program in
/usr/lib/apt-setup/generators/ in turn (run-parts ordering). Each generator
is passed the name of a temporary file that it can write sources.list lines
(and comments) to.
After the generator finishes writing the file, apt-setup-verify will be run
on it to verify that each line of the sources sources works, and it will be
added to the sources.list. Generators can also run apt-setup-verify
themselves and do their own error recovery if it fails. apt-setup-verify
tests each line of the file and comments out lines that do not work, and
exits nonzero if all deb and deb-src lines in the file failed.
Generators should add both "deb" lines and corresponding
deb-src lines to the sources.list. apt-setup-verify will handle commenting
out any deb-src lines for unavailable sources.
Generators can ask configuration questions using debconf. To support
backing up, generators should exit with the special return code of 10 if
the user backs up from their first question. Each generator should provide
a progress bar text template named apt-setup/progress/<generator>, where
<generator> is the script's name with leading numbers removed. Anything
after the first dot (if any) will also be removed when constructing the
progress template name, so that different scripts that share the same
purpose can easily be written.
Note that apt-setup and its generators may be run against some other system
in a chroot. (i.e., when installing Debian.) If apt-setup is running this
way, then ROOT will be set to the root of the chroot that it is acting on
and all sources.list validation will occur inside the chroot.
apt-setup is split into several udebs that contain different generators.
These udebs are installed depending on the type of install; for a install
from CD, cdrom-detect queues apt-cdrom-setup for install, for an install
from the network, choose-mirror queues apt-mirror-setup, etc.