Re: Updated check-debian-cd
Ohps. I forgot the code. Here it is:
===File /var/mirrors/potato/check-debian-cd=================
#! /bin/sh
## Made September, 2000 by Francesco Potortì <pot@gnu.org>
## current version is 1.6
## This program is released under the GNU GPL, whichever version
##
## This script requires a Posix compliant sh.
## BUGS:
## - Short options cannot be coalesced, and long ones cannot be followed by
## '=' before their argument. To do that, one should use either use the
## new getopt(1), which I don't know how much widespread is, or doing
## that parsing in the script, which probably is not worth the effort.
## - $bs should be optimised.
basename=$(basename "$0")
cdversion=2.2.0
version='1.6'
isodefault=/dev/cdrom
sumsfile=MD5SUMS
quiet= # flag
database="'$0'" # MD5 checksum files
while expr "$1" : "-*" >/dev/null; do
option="$1"
shift
case $option in
--) # end of options
break ;;
-m|--md5sums) # MD5 checksum file
database="$database '$1'"; shift ;;
-q|--quiet) # be quiet
quiet=yes ;;
-v|--cdversion) # last Debian version in database
echo $cdversion; exit 0 ;;
-V|--version) # this script's version number
cat <<EOFversion
$basename $version
Copyright (C) 2000 Francesco Potortì
This program is distributed under the GNU General Public License
The internal CD image database is current up to Debian $cdversion
EOFversion
exit 0 ;;
-h|--help)
cat <<EOFusage
A program for checking Debian CDs and image files.
$basename reads one or more image (ISO) files. If none is given on
the command line, it reads from $isodefault. It then compares their MD5
hashes with those contained in its internal database of Debian CDs and
possibly in an $sumsfile file in the current or in the parent directory, and
in the one specified with the --md5sums option.
usage: $basename [options] [files...]
Options:
-m file, --md5sums file
Add \`file' to the database of known CD images.
-q, --quiet
Run quietly, do not print informative messages.
-v, --cdversion
Print last version of Debian CD images (currently $cdversion) in the
internal database.
-V, --version
Print the version of this script.
-h, --help
Print this help message.
EOFusage
exit 0
;;
*)
cat >&2 <<EOFwrong
$basename: unrecognized option \`$option'
Try \`$basename --help' for a complete list of options.
EOFwrong
exit 10
esac
done
if ! md5sum </dev/null >/dev/null 2>&1; then
echo "$basename: cannot find the md5sum program; exiting" >&2
exit 11
fi
case $# in
0) # no arguments
iso=$isodefault ;;
1) # the image file or device
iso="$1" ;;
*) # more than one file: recursive call
options=
test $quiet && options="$options -q"
exitcode=0
for arg; do
"$0" $options "$arg"
ec=$?
test $ec -gt $exitcode && exitcode=$ec && test $quiet && break
done
exit $exitcode
esac
## Let's start doing some real work now
if [ ! -r "$iso" ]; then
echo "Cannot read file \`$iso'" >&2
exit 1
fi
# Look for databases. Could even use locate to get them.
test -r $sumsfile && database="$database $sumsfile"
test -r ../$sumsfile && database="$database ../$sumsfile"
id=$(dd if="$iso" bs=1 skip=32808 count=32 2>/dev/null)
set - $(eval cat $database | grep "^#Id-.*<$id>")
comment=$1
len=$2
sum=$3
#id=$(expr "$id" : "<\\(.*[^ ]\\) *>") # instead of forking a new process, do:
test $# -gt 3 && shift 3
id="$*" # tokenized disc Id string
id="${id% >}" # remove trailing " >"
id="${id#<}" # remove leading "<"
if [ "$comment" = "#Id-" ]; then
test $quiet || echo "This is \"$id\""
else
test $quiet || echo "I do not have this disc in my database"
exit 2
fi
bs=2048
test $quiet || echo -n "Checking MD5 hash..."
set - "$(dd if="$iso" bs=$bs count=$len 2>/dev/null | md5sum)"
if [ "$1" = $sum ]; then
test $quiet || echo " success"
exit 0
else
test $quiet || echo " FAILED!"
exit 3
fi
## List of known Debian cd image discs: length in $bs, md5sum, id string
## the list is complete as of September, 2000, apart from the slink sources
#
#Id- 312412 c2c046ed739d78d56b1c5b34202268d1 <Debian-i386 2.1 Disc 1 >
#Id- 265072 f126f97fb20f3e1dd4868ae1d3309d24 <Debian-i386 2.1 Disc 2 >
#Id- 315877 b0d41dc89753ed4af3927d2446e8c7fe <Debian 2.2 r0 Src-1 >
#Id- 326892 3e6272d23a5f6a2f3c8ce92841eca119 <Debian 2.2 r0 Src-1_NONUS >
#Id- 323574 c04d100965361437e0f970d781153274 <Debian 2.2 r0 Src-2 >
#Id- 321204 a8142b47bce78bc9678ba2dcf52984ba <Debian 2.2 r0 Src-3 >
#Id- 316351 b5951d4325de81eeaa8514ec78ecab9d <Debian 2.2 0a alpha Bin-1 >
#Id- 322398 c83fe57ba0f4dc615efcaed19dc166cc <Debian 2.2 0a alpha Bin-1_NONUS >
#Id- 327489 3b24410ea4fb25e455f2855407d9cb0f <Debian 2.2 0a alpha Bin-2 >
#Id- 258784 fde444ae21f8ea4f18909d4a7a5acd91 <Debian 2.2 0a alpha Bin-3 >
#Id- 304639 9e757c6cd952efb030383fd6dd327a0f <Debian 2.2 r0 arm Bin-1 >
#Id- 304977 35bc41583a999c43f33021e0ae4c5716 <Debian 2.2 r0 arm Bin-1_NONUS >
#Id- 317057 fff543d36e1e313944c463a24dfb4307 <Debian 2.2 r0 arm Bin-2 >
#Id- 50704 4a4f07b7c7130c39f74340e05260a2be <Debian 2.2 r0 arm Bin-3 >
#Id- 321743 c4435b6a6b8dd91ea51bd69bfb8642df <Debian 2.2 r0 i386 Bin-1 >
#Id- 327271 aa81c0848d199e9317735a1af0a2e4cc <Debian 2.2 r0 i386 Bin-1_NONUS >
#Id- 328594 be04cd6d17159d66978ad227b26ed17d <Debian 2.2 r0 i386 Bin-2 >
#Id- 257243 13a1509ea29e4891004ca1c397b316a6 <Debian 2.2 r0 i386 Bin-3 >
#Id- 322735 83b0c5b40ca5b31db973d2a28bcc50af <Debian 2.2 r0 m68k Bin-1 >
#Id- 329160 6ccad6848468e7eccb9a8550215cddc9 <Debian 2.2 r0 m68k Bin-1_NONUS >
#Id- 330903 a73b2ea406e0c493361236ebffb5ebdb <Debian 2.2 r0 m68k Bin-2 >
#Id- 111328 5a8c7778d4e18ddd622df8c8f5d4f3e9 <Debian 2.2 r0 m68k Bin-3 >
#Id- 319500 c4435b6a6b8dd91ea51bd69bfb8642df <Debian 2.2 r0 ppc Bin-1 >
#Id- 324505 aa81c0848d199e9317735a1af0a2e4cc <Debian 2.2 r0 ppc Bin-1_NONUS >
#Id- 329991 be04cd6d17159d66978ad227b26ed17d <Debian 2.2 r0 ppc Bin-2 >
#Id- 141048 13a1509ea29e4891004ca1c397b316a6 <Debian 2.2 r0 ppc Bin-3 >
#Id- 326020 b8eca28f7eb4c96ce7a6f74efbe2f9bf <Debian 2.2 0a sparc Bin-1 >
#Id- 331717 e5065a6bd3bdaf44bd2f00951c119fb3 <Debian 2.2 0a sparc Bin-1_NONUS >
#Id- 326370 acce0bffbd85edf52f9a446da3c2cb56 <Debian 2.2 0a sparc Bin-2 >
#Id- 153459 25e78e58aac0f229a6d7d60bdc9849ae <Debian 2.2 0a sparc Bin-3 >
============================================================
Reply to: