| 1 |
11 |
dpavlin |
#!/bin/sh |
| 2 |
|
|
|
| 3 |
|
|
from="rem.pliva.hr:/mirrors/debian/pub/debian" |
| 4 |
14 |
dpavlin |
mount | grep " /usb_drive " && to="/usb_drive/mirrors/debian" |
| 5 |
|
|
test -z "$to" && mount | grep " /mnt " && to="/mnt/mirrors/debian" |
| 6 |
|
|
test -z "$to" && echo "can't find destination directory!" && exit |
| 7 |
|
|
dists="sid sarge" |
| 8 |
11 |
dpavlin |
|
| 9 |
14 |
dpavlin |
echo "$from -> $to" |
| 10 |
|
|
|
| 11 |
11 |
dpavlin |
OPT=" |
| 12 |
|
|
--exclude "*-alpha" \ |
| 13 |
|
|
--exclude "*-arm" \ |
| 14 |
|
|
--exclude "*-hppa" \ |
| 15 |
|
|
--exclude "*-ia64" \ |
| 16 |
|
|
--exclude "*-m68k" \ |
| 17 |
|
|
--exclude "*-mips" \ |
| 18 |
|
|
--exclude "*-mipsel" \ |
| 19 |
|
|
--exclude "*-powerpc" \ |
| 20 |
|
|
--exclude "*-s390" \ |
| 21 |
|
|
--exclude "*-sparc" \ |
| 22 |
|
|
" |
| 23 |
|
|
|
| 24 |
14 |
dpavlin |
echo > /tmp/pool |
| 25 |
|
|
echo > /tmp/pool-non-US |
| 26 |
11 |
dpavlin |
|
| 27 |
14 |
dpavlin |
for dist in $dists ; do |
| 28 |
|
|
|
| 29 |
|
|
echo "working on $dist" |
| 30 |
|
|
|
| 31 |
|
|
test -d "$to/dists/$dist/" || mkdir -p "$to/dists/$dist/" |
| 32 |
|
|
test -d "$to-non-US/dists/$dist/" || mkdir -p "$to-non-US/dists/$dist/" |
| 33 |
|
|
|
| 34 |
|
|
rsync -raq --delete $OPT "$from/dists/$dist/" "$to/dists/$dist/" |
| 35 |
|
|
rsync -raq --delete $OPT "$from-non-US/dists/$dist/" "$to-non-US/dists/$dist/" |
| 36 |
|
|
|
| 37 |
|
|
grep ^Filename: $to/dists/$dist/*/binary-i386/Packages | sed 's#^.*Filename: *##' > /tmp/pool_$dist |
| 38 |
|
|
grep ^Filename: $to-non-US/dists/$dist/non-US/*/binary-i386/Packages | sed 's#^.*Filename: *##' > /tmp/pool-non-US_$dist |
| 39 |
|
|
|
| 40 |
|
|
done |
| 41 |
|
|
|
| 42 |
|
|
cat /tmp/pool_* | sort -u > /tmp/pool |
| 43 |
|
|
cat /tmp/pool-non-US_* | sort -u > /tmp/pool-non-US |
| 44 |
|
|
|
| 45 |
|
|
echo `wc -l /tmp/pool` " files in pool" |
| 46 |
|
|
echo `wc -l /tmp/pool-non-US` " files in non-US pool" |
| 47 |
|
|
|
| 48 |
|
|
cd $to || exit |
| 49 |
|
|
|
| 50 |
|
|
echo -n "remove expired files " |
| 51 |
|
|
|
| 52 |
|
|
e=/tmp/pool.existing |
| 53 |
|
|
|
| 54 |
|
|
find pool -type f | sort -u > $e.old |
| 55 |
|
|
cat /tmp/pool /tmp/pool-non-US | sort -u > $e.new |
| 56 |
|
|
diff $e.old $e.new | grep '^<' | cut -c3- > $e.delete |
| 57 |
|
|
|
| 58 |
|
|
wc -l $e.delete | cut -d" " -f1 |
| 59 |
|
|
|
| 60 |
15 |
dpavlin |
test -s $e.delete && xargs rm < $e.delete |
| 61 |
14 |
dpavlin |
|
| 62 |
11 |
dpavlin |
rsync -av --delete --files-from=/tmp/pool "$from/" "$to/" |
| 63 |
|
|
rsync -av --delete --files-from=/tmp/pool-non-US "$from-non-US/" "$to-non-US/" |