Setting Up A CTAN Mirror

Having a personal CTAN mirror will change your life. --M Doob

You can automatically keep on your local machine an up-to-date collection of material from the Comprehensive TeX Archive Network.

The CTAN tree structure differs from the TeX Directory Standard tree used by teTeX, or MiKTeX, or fpTeX from TeXLive, or TeXShop, etc. This means that you can't automatically mirror what's here into your texmf tree and always have what's perfectly up to date. (Do you really want that anyway? What if the newly uploaded version has a bug, so that your document fails to run?) Instead, set up a separate CTAN directory, perhaps /usr/share/CTAN, or /usr/local/share/CTAN/. Test things before you move them over.

Please note: CTAN is very big. It is 7.5 gig and growing. If you are setting up a personal mirror then you do not want all of this. It will take up your space and bandwidth and it will slow down other people's connections to CTAN. In particular, you probably do not want a new TeXLive portion every time one comes out; they are shockingly large. You are very welcome to whatever you can use, however, while the simplest thing is to just mirror it all, that is not usually the Right Thing.

In fact, probably what you want is only the material that is in the `macros' directory, and also that on `nonfree/macros'. These are used for illustration below.

Note also that one way to reduce the large number of transfers needed for initialization of a mirror is to use a CD-ROM of CTAN to start. Many TeX users groups distribute such CD's to members, and you can also order a recent CTAN CD (of the Dante site); see the home page of the TeX Users Group. Then your mirroring program only needs to begin with the changes since the CD-ROM was printed.

Remark. I am a Linux person so my advice may not apply to you. Probably any Unix-like system would work the same way but if you have a win32 or a Mac then I'd be glad to have a version of this document for your platforms.


Syncronicity

Mirror

See the Mirror home page (isn't that the nicest graphic?). This is a very flexible and powerful package, and is in fact what the CTAN maintainers use. However, flexibility and power typically trade off on ease of use and this package is no exception.

Nonetheless, with the mirror.defaults and the ctan.org configuration files, we've done most of the setting-up for you. Once you've gotten mirror from its home site, installed it and patched it, and installed these two files from here, then you only have to edit them to set a few things. Follow the comments inside of the two files; it is straightforward.

Rsync

This program uses diff's and compression to do the transfers efficently. It is also very easy to use for a partial mirror. It has two disadvantages: it is relatively CPU intensive, and the site that you are mirroring has to be running an rsync server (for mirror, the site need only be running a more usual ftp service).

Get it from the rsync home page. After you install it, run it.
   rsync -an rsync://www.ctan.org
You will see a list of options for parts of the CTAN holdings.

Probably all that you want is the MACROS holdings so you can keep up on LaTeX style files.
   rsync -av --delete rsync://www.ctan.org/MACROS /usr/share/CTAN/macros
The options have these effects.

If you intend to mirror all of CTAN, for instance to be an official mirror, then this will work.
   rsync -av --delete rsync://www.ctan.org/CTAN /var/ftp/pub/tex-archive

Wget

The wget program is like rsync in some ways. It is easy to use, and a single command gets an entire tree. You can get it from the wget home page. This command (it is all one line, but has been broken for readability)
   wget --mirror --no-host-directories --cut-dirs=2
     --directory-prefix=/usr/local/share/CTAN
     --wait=15 --background
     ftp://tug.ctan.org/pub/tex-archive/macros

will copy the files in the `macros' subdirectory on the CTAN site to a `macros' subdirectory of your local directory `/usr/local/share/CTAN/'. You may want to also get `nonfree/macros' by reissuing this command, with a small change to the last part.

Here is what the options do.


Periodicity

Running any of the above once a week should suffice. At the command line ask for
   crontab -e
and enter a line like
   31 2 * * 0 rsync -a --delete rsync://www.ctan.org/MACROS /usr/share/CTAN/macros
(this is the rsync mirroring, obviously; for the other programs make the natural changes). The explanation of that line is: run the rsync command

Please change these numbers when you set yours up, so not everyone in the world hits CTAN at the same instant. Pick something in the middle of the night.

WARNING! As described above, you almost certainly do not want either SYSTEMS or CTAN. Either of these will bring you a TeXLive version every time one comes out and these files are *very* big.


Responsibility

This document is based on a presentation by M Doob at the 2001 meeting of the TeX Users Group. Last updated 2001-Sep-11 by Jim Hefferon.