#! /bin/sh

# $Id: mkdebmirror 3027 2005-11-10 22:37:16Z lange $
# 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 --ignore-missing-release --ignore-release-gpg --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,sarge-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

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