OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: lib/sde-download/cksum.sh
  5. # Copyright (C) 2006 - 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. BUNZIP2=bunzip2
  15. GUNZIP=gunzip
  16. UNCOMPRESS=uncompress
  17. # gunzip may be an alternative for uncompress
  18. if ! type -p $UNCOMPRESS 2>&1 > /dev/null; then
  19. UNCOMPRESS=gunzip
  20. fi
  21. get_cksum() {
  22. local extractor=cat
  23. case "${x##*.}" in
  24. bz2|tbz2|tbz) extractor=$BUNZIP2 ;;
  25. gz|tgz) extractor=$GUNZIP ;;
  26. Z) extractor=$UNCOMPRESS ;;
  27. esac
  28. $extractor < "$x" | cksum | cut -f1 -d' '
  29. }
  30. if [ $# -eq 0 ]; then
  31. cat >&2 <<-EOT
  32. Usage: $0 <file> ...
  33. Returns the checksums of a given list of files
  34. EOT
  35. false
  36. else
  37. for x; do
  38. if [ -f "$x" ]; then
  39. echo -n "$x: "
  40. get_cksum "$x"
  41. else
  42. echo "$x: No such file." >&2
  43. fi
  44. done
  45. fi