It's a little bit strange to build an apt mirror right in home... but I do need it.

I referenced How to build a local apt-get mirror and found that apt-mirror is a very handy utility to do apt mirror. Before this time, I established another apt mirror with rsync and shell script, but that old mirror have failed when the main archive of apt broke down last year.

Now I have this Perl-written, well-behaved and easy-configurable apt-mirror, and it took me only less than 2 days to get the testing and unstable i386 binary as well as source packages from a taiwan mirror, via my 2M/512 ADSL line. The total size of downloaded local apt archive is around 25GB.

apt-mirror is easy to use, but still not in official archive. So you need to add

deb http://apt-mirror.sourceforge.net/ apt-mirror/

this line to your sources.list, then

apt-get install apt-mirror

to install the package. After successfully install, apt-mirror will create its config file to /etc/apt/mirror.list, and the syntax is very similar to sources.list. My mirror.list is like:

# apt-mirror configuration file

##
## The default configuration options (uncomment and change to override)
##
#
# 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 defaultarch  <running host architecture>
# set nthreads     20
#

set base_path /var/lib/aptmirror
set mirror_path       $base_path/mirror
set skel_path $base_path/skel
set var_path  $base_path/var

set defaultarch i386

# testing @nchc
deb http://opensource.nchc.org.tw/debian/ testing main non-free contrib
deb-src http://opensource.nchc.org.tw/debian/ testing main non-free contrib

# unstable @nchc
deb http://opensource.nchc.org.tw/debian/ unstable main non-free contrib
deb-src http://opensource.nchc.org.tw/debian/ unstable main non-free contrib

# irssi precompiled package
deb http://irssi.qvr.info/debian/ sarge/

# apt-mirror itself
deb http://apt-mirror.sourceforge.net/ apt-mirror/

##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#

# What shold we clean up
clean http://security.debian.org/
clean http://opensource.nchc.org.tw/

# But exclude this directories
skip-clean http://opensource.nchc.org.tw/doc/
skip-clean http://opensource.nchc.org.tw/tools/
skip-clean http://opensource.nchc.org.tw/debian-cd/
skip-clean http://opensource.nchc.org.tw/debian-minicd/
skip-clean http://opensource.nchc.org.tw/debian/dists/potato/main/disks-i386/
skip-clean http://opensource.nchc.org.tw/debian/dists/woody/main/disks-i386/
skip-clean http://opensource.nchc.org.tw/debian/doc/
skip-clean http://opensource.nchc.org.tw/debian/tools/
skip-clean http://opensource.nchc.org.tw/debian/project/
skip-clean http://opensource.nchc.org.tw/debian-non-US/project/

You may see that in the config file, base_path is set to /var/lib/aptmirror, where the mirror_path, skel_path and var_path reside in. These related subdirectory must be first created, because apt-mirror will write data into them.

The mirrored apt archive will be collected in mirror_path, and is organized by host name.

apt-mirror should be executed once it's configured. Initially it takes time, but as its first execution succeeds, subsequent execution won't use too much time.

apt-mirror places a cron job in /etc/cron.d/apt-mirror, off by default. It can be opened by removing the heading comment mark (#). Further more, it can be modified like

0 4     * * *   apt-mirror /usr/bin/apt-mirror >> /var/lib/aptmirror/log/apt-mirror.log

to have everyday update tracked and logged.

Posted by yungyuc at 22:00, 0 comment, 0 trackback.
Navigate
Add a trackback
Add a comment

Your name. (required)

Your personal website. (optional)

Your email address. Will not show in page. (suggested, but optional)

Text format is "Plain Text".

Enter "WWXvS"
© hover year to navigate month: powered by django