The CD repository and software repository are two distinct components (they even have separate Launchpad pages: cdmirrors and archivemirrors). Therefore, mirroring them are two distinct tasks. Further, while the various flavours have different folders on the CD repository, they share a software repository. So you can selectively mirror the images per flavour, but not the software. For the software repository, you can selectively mirror based on:
- release (
trusty
, precise
, etc.)
- architecture (
amd64
, i386
, etc.)
- package type (binary [
deb
] vs source [deb-src
])
- channels (
trusty
, trusty-updates
, trusty-backports
, etc.)
- sections (
main
, multiverse
, etc.)
To mirror the software repository, use apt-mirror
.
apt-mirror
is configured using /etc/apt/mirror.list
. It has a format very similar to sources.list
. The configuration file installed by the package has a few commented out options which list their defaults. If you wish, you can uncomment and change them.
To mirror a repository, you need to add a line to mirror.list
like you would for sources.list
:
deb http://us.archive.ubuntu.com/ubuntu trusty main multiverse restricted universe
The default is to mirror only the host's architecture, so if you're on a 64-bit Ubuntu, only amd64
will be mirrored. You need to add another line of the form:
deb-i386 http://us.archive.ubuntu.com/ubuntu trusty main multiverse restricted universe
And for source packages:
deb-src http://us.archive.ubuntu.com/ubuntu trusty main multiverse restricted universe
If you're looking for a reasonably complete mirror, these lines would be the minimum (I would also recommend -updates
channel):
deb http://us.archive.ubuntu.com/ubuntu trusty main multiverse restricted universe
deb http://us.archive.ubuntu.com/ubuntu trusty-security main multiverse restricted universe
deb-i386 http://us.archive.ubuntu.com/ubuntu trusty main multiverse restricted universe
deb-i386 http://us.archive.ubuntu.com/ubuntu trusty-security main multiverse restricted universe
Finally, you need to add a clean
line so that packages no longer available in the repository are filtered for removal:
clean http://us.archive.ubuntu.com/ubuntu
Say your variables are thus (the defaults):
set base_path /var/spool/apt-mirror
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var
set cleanscript $var_path/clean.sh
Then:
- The repository will be mirrored to
$mirror_path/parent-hostname/directory
(so /var/spool/apt-mirror/mirror/us.archive.ubuntu.com/ubuntu
)
- The
clean.sh
(which will be a set of rm
commands to delete obsolete packages and directories) will be /var/spool/apt-mirror/var/clean.sh
.
- The logs will go to
/var/spool/apt-mirror/var
.
The apt-mirror
package installs a cron job (/etc/cron.d/apt-mirror
), which you should edit to enable (by uncommenting the line containing /usr/bin/apt-mirror
). You should also add a cron job for running clean.sh
(I run it weekly).
Of course, you should replace http://us.archive.ubuntu.com./ubuntu
with whichever mirror you prefer.