#!/bin/sh

### Debug
## date | mailx -s "$0 is running" tillea@rki.de

# Andreas Tille, tille@debian.org, (c) 2001

# create partitial debian mirror using debmirror from Joey and rsync
# http://cvs.kitenet.net/joey-cvs/bin/debmirror
# DIST=testing
# see #281844
# DIST=sarge
DIST=testing

CONF=$(dirname $0)/mirror.conf
# echo $CONF

if [ -f $CONF ] ; then
  . $CONF
fi

EXCLUDESTRING=""
INCLUDESTRING=""

for i in $EXCLUDE ; do
  EXCLUDESTRING="$EXCLUDESTRING|$i"
done

for i in $INCLUDE ; do
  INCLUDESTRING="$INCLUDESTRING|$i"
done

ARCHS="amd64"
arch="amd64"
debug="--debug"
debug="$*"
## defopt="$debug --arch=$arch --getcontents --host=$host --nosource"
## Schalte mal getcontents ab, weil's sowieso nicht immer funktioniert
## und hole dann per Hand an andere Stelle zum Platz sparen
# defopt="$debug --arch=$arch --host=$host --nosource"
defopt="$debug  --arch=$arch --host=$host --nosource --allow-dist-rename"
## Bei http worde manchmal nichts geholt

# echo "--getcontents wieder mit reinnehmen, sobald verfuegbar."
defopt="--method=http $defopt --getcontents"
# defopt="--method=http $defopt"

# damit es bei der langsamen Leitung keine Timing-Probleme gibt
defopt="--timeout=3000 --ignore-small-errors $defopt"

## --passive ... siehe #281844
# defopt="--passive $defopt"
defopt="--verbose $defopt"

$debmirrorprog $destdir/debian $defopt --dist=$DIST --exclude="non-US/|disks-i386/|disks-amd64|security/|/project/$EXCLUDESTRING"
## echo $debmirrorprog $destdir/debian $defopt --dist=$DIST --exclude="non-US/|disks-i386/|disks-amd64/|security/|/project/$EXCLUDESTRING" > /usr/local/sbin/zw

for dist in main contrib non-free ; do
    translationsdir=$destdir/dists/testing/$dist/i18n
    mkdir -p $translationsdir
    cd $translationsdir
    wget -q $host/debian/dists/testing/$dist/i18n/Translation-en.bz2
    wget -q $host/debian/dists/testing/$dist/i18n/Translation-de.bz2
    wget -q $host/debian/dists/testing/$dist/i18n/Translation-de_DE.bz2
done
