link-checksums 845 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. # Written by Marc Espie, 2000
  3. # Public domain
  4. # Sets up hard links under a distfiles mirror, so that
  5. # files will be preserved against checksum changes as a last
  6. # ditch attempt.
  7. # Also see REFETCH in bsd.port.mk, and mirroring-ports (7)
  8. DISTDIR=${DISTDIR:-/usr/ports/distfiles}
  9. cd ${DISTDIR}
  10. CIPHERS=${CIPHERS:-sha1 md5 rmd160 sha256}
  11. bdir=by_cipher
  12. # Build the find so that existing cipher dirs are avoided
  13. exclude="-type d -name $bdir -prune"
  14. for ci in ${CIPHERS}
  15. do
  16. exclude="${exclude} -o -type d -name $ci -prune"
  17. done
  18. echo "find . \( $exclude \) -o -type f -print"
  19. find . \( $exclude \) -o -type f -print | while read i
  20. do
  21. file=`basename $i`
  22. for ci in ${CIPHERS}
  23. do
  24. result=`cksum -a $ci -b <$i`
  25. res=`echo $result|sed -e 's,\(..\).*,\1,'`
  26. dir=$bdir/$ci/$res/$result
  27. mkdir -p $dir
  28. ln -f $i $dir/$file
  29. done
  30. done