/[scripts]/trunk/small-deb-mirror.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/small-deb-mirror.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 11 by dpavlin, Mon Jan 10 14:49:47 2005 UTC revision 14 by dpavlin, Thu Oct 6 09:07:47 2005 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
3  from="rem.pliva.hr:/mirrors/debian/pub/debian"  from="rem.pliva.hr:/mirrors/debian/pub/debian"
4  to="/mnt/mirrors/debian"  mount | grep " /usb_drive " && to="/usb_drive/mirrors/debian"
5  dist="sid"  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    
9    echo "$from -> $to"
10    
11  OPT="  OPT="
12  --exclude "*-alpha" \  --exclude "*-alpha" \
# Line 16  OPT=" Line 20  OPT="
20  --exclude "*-s390" \  --exclude "*-s390" \
21  --exclude "*-sparc" \  --exclude "*-sparc" \
22  "  "
 rsync -rav --delete $OPT "$from/dists/$dist/" "$to/dists/$dist/"  
 rsync -rav --delete $OPT "$from-non-US/dists/$dist/" "$to-non-US/dists/$dist/"  
23    
24  grep ^Filename: $to/dists/$dist/*/binary-i386/Packages | sed 's#^.*Filename: *##' > /tmp/pool  echo > /tmp/pool
25  grep ^Filename: $to-non-US/dists/$dist/non-US/*/binary-i386/Packages | sed 's#^.*Filename: *##' > /tmp/pool-non-US  echo > /tmp/pool-non-US
26    
27    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    xargs rm < $e.delete
61    
62  rsync -av --delete --files-from=/tmp/pool "$from/" "$to/"  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/"  rsync -av --delete --files-from=/tmp/pool-non-US "$from-non-US/" "$to-non-US/"

Legend:
Removed from v.11  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26