#!/bin/bash
set -e
set -x
METHOD=rsync
HOST=mirror.xxx.com
REPOPATH="ftp/mirror/ubuntu"
DIST=gutsy
REPOS="main/debian-installer main/installer-i386 main restricted"
ARCHS="i386"
WORKDIR="."
if test ! -d ftp;then
mkdir ftp
fi
for REPO in $REPOS;do
for ARCH in "$ARCHS";do
REPOFILE=`echo "$REPO" | sed -e 's/\//-/g'`
if test $METHOD = "rsync";then
rsync rsync://$HOST/$REPOPATH/dists/$DIST/$REPO/binary-$ARCH/Packages.gz /tmp/repo.$REPOFILE.$ARCH.gz && echo ""
if test -f "/tmp/repo.$REPOFILE.$ARCH.gz";then
echo "dists/$DIST/$REPO/binary-$ARCH/Packages.gz" > /tmp/list.$REPOFILE.$ARCH.txt
gunzip -c /tmp/repo.$REPOFILE.$ARCH.gz |grep ^Filename:|sed -e "s/Filename: //" >> /tmp/list.$REPOFILE.$ARCH.txt
else
if test "$REPOFILE" = "main-installer-i386";then
echo "dists/$DIST/$REPO" > /tmp/list.$REPOFILE.$ARCH.txt
fi
fi
rsync --recursive --links --hard-links --times --verbose --stats --files-from=/tmp/list.$REPOFILE.$ARCH.txt rsync://$HOST/$REPOPATH ftp
fi
done
done