#! /bin/sh

# $Id: mkdebmirror,v 1.18 2003/01/21 15:56:27 lange Exp $
# Thomas Lange, lange@informatik.uni-koeln.de, (c) 2001-2003

# create partitial debian mirror using debmirror new in unstable/sarge
# needs debmirror 20020427-1 or newer

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

    # get the boot disks
    rsync --delete -av $rsynchost::debian/dists/$1/main/disks-$arch $destdir/debian/dists/$1/main/
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
update_from() {

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

    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

arch=i386
dist=woody
debug="$@"
destdir=/files/scratch/debmirror

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

# since this mirror is not always up to date, sync now to 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 $dist/updates

rsynchost=ftp2.de.debian.org
rsync_disks $dist
