# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: lib/sde-download/cksum.sh
|
|
# Copyright (C) 2006 - 2007 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
BUNZIP2=bunzip2
|
|
GUNZIP=gunzip
|
|
UNCOMPRESS=uncompress
|
|
# gunzip may be an alternative for uncompress
|
|
if ! type -p $UNCOMPRESS 2>&1 > /dev/null; then
|
|
UNCOMPRESS=gunzip
|
|
fi
|
|
|
|
get_cksum() {
|
|
local extractor=cat
|
|
case "${x##*.}" in
|
|
bz2|tbz2|tbz) extractor=$BUNZIP2 ;;
|
|
gz|tgz) extractor=$GUNZIP ;;
|
|
Z) extractor=$UNCOMPRESS ;;
|
|
esac
|
|
$extractor < "$x" | cksum | cut -f1 -d' '
|
|
}
|
|
|
|
if [ $# -eq 0 ]; then
|
|
cat >&2 <<-EOT
|
|
Usage: $0 <file> ...
|
|
Returns the checksums of a given list of files
|
|
EOT
|
|
false
|
|
else
|
|
for x; do
|
|
if [ -f "$x" ]; then
|
|
echo -n "$x: "
|
|
get_cksum "$x"
|
|
else
|
|
echo "$x: No such file." >&2
|
|
fi
|
|
done
|
|
fi
|