#! /bin/sh

# $Id: mkdebmirror,v 1.19 2004/07/08 11:35:44 lange Exp $
# Thomas Lange, lange@informatik.uni-koeln.de, (c) 2001-2004

# create partitial debian mirror using command debmirror(1) and rsync

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rsync_disks() {

    # get the boot disks
    rsync --delete -av $2::debian/dists/$1/main/disks-$arch $destdir/debian/dists/$1/main/
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
update_from() {

    # update local mirror from a host
    host=$1
    allopt="$debug --passive --getcontents --nosource --arch=$arch --ignore=disks-$arch/"
    defopt="$allopt --host=$host --dist=$dist"

    echo "------------------ create mirror for debian ------------------"
    debmirror $destdir/debian $defopt

    echo "------------------ create mirror for debian-non-US ------------------"
    debmirror $destdir/debian-non-US $defopt -r /debian-non-US -s non-US/main,non-US/contrib,non-US/non-free
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program
#
# here you have to adjust the hostnames of the mirror and the names of the distributions


debug="$@"
arch=i386
dist=sarge,woody,sarge-proposed-updates,woody-proposed-updates

destdir=/files/scratch/debmirror

# first sync from a mirror near to you
update_from ftp.uni-koeln.de

# since this mirror is not always up to date, sync the rest from an official mirror
update_from ftp.de.debian.org

# even one should not mirror the security site, but I will do it.
echo "------------------ create mirror for debian-security ------------------"
debmirror $destdir/debian-security $allopt --host=security.debian.org -r debian-security -d sarge/updates,woody/updates

# get installation disk images via rsync
rsync_disks woody ftp2.de.debian.org
