[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Updated check-debian-cd



[I'll skip your earlier private mail, since this seems to override it ;-]

On Wed, 27 Sep 2000, Francesco Potorti` wrote:

> I made an update to my check-debian-cd script.  Now it knows about every

Very nice script, but I do have some comments (see below).

> I  suggest  it to  be  added  to the  pseudo-image  toolkit,  and to  be
> mentioned in the FAQ as an easy way of checking a CD after having burned
> it.

The Pseudo-Image Kit is meant to be release-independent, so I don't really
like the idea of adding this script -- if only because then a new version of
the Kit must be released with every CD revision, and that's something I don't
have the time for.

But if you can put it up on some website, I'll gladly link to it from the FAQ.
(And if you don't have webspace yourself, I can put it somewhere myself, but
then you'd have to send each new version to me which is just a hassle ;-)

> Please note that I do not subscribe to either debian-cd or debian-user.
> 
> ===File /var/mirrors/potato/check-debian-cd=================
> #! /bin/bash

The Kit is often used on various *UXes; I suggest you work around bashisms (if
any) and use /bin/sh instead. (Test with /bin/ash on Linux to get a nice
impression ;-)

> ## Made September, 2000 by Francesco Potortì <pot@gnu.org>
> ## current version is 1.3
> ## This program is released under the GNU public license, whichever version
> ##
> ## BUGS:
> ## Does not work when file names given as arguments contain spaces
> 
> isodefault=/dev/cdrom
> quiet=
> cdversion=2.2.0
> 
> while getopts :qv option; do
>     case $option in
> 	q)
> 	    quiet=yes ;;
> 	v)
> 	    echo $cdversion; exit 0 ;;

echo Program version: $programversion
echo CD version: $cdversion

> 	*)  
> 	    cat <<-EOF

check-debian-cd version $programversion, released under GNU GPL

> 		A program for checking Debian CDs and image files.
> 		It reads /dev/cdrom or the given files and compares their MD5 hash with
> 		those contained in an internal database of Debian CDs.
> 		
> 		usage: $(basename $0) [options] [files...]
> 		   Options:
> 		   -q: run quietly, do not print informative messages
> 		   -v: print last known version of CD images (currently $cdversion)
> 		EOF
> 	    exit 10
>     esac
> done
> 
> bs=2048

In my own experience, a bs of 50k to 100k is much much faster than 2048 (on
IDE drives at least). I use factor(1) to determine "optimal" bs's, but (still)
didn't write some automatic tool for that purpose.

> ## List of known Debian cd image disks: 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       '
> 
> shift $((OPTIND-1))
> 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
> 
> if [ ! -r "$iso" ]; then
>     echo "Cannot read file $iso" >&2
>     exit 1
> fi
> 
> set - $(grep "^#Id-.*'$(dd if=$iso bs=1 skip=32808 count=32 2>/dev/null)'" "$0")
> comment=$1
> len=$2
> sum=$3

Bashism? I'd do something like

infoline=`grep ... "$0"`
comment=`echo "$infoline" | cut -d ' ' -f 1`
len=`echo "$infoline" | cut -d ' ' -f 2`
sum=`echo "$infoline" | cut -d ' ' -f 3`
id=`echo "$infoline" | cut -d ' ' -f 4-`

> shift 3
> id="$*"					# disk Id string
> id="${id//\'}"				# remove simple quotes
> id="${id//% }"				# remove trailing blank
> 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
> 
> if ! type -t md5sum >/dev/null; then

Bashism? Maybe this works:

if ! md5sum --help >/dev/null ; then

>     echo "Cannot find the md5sum program; exiting" >&2
>     exit 11
> fi
> 
> test $quiet || echo -n "Checking MD5 hash..."
> if [ "$(dd if=$iso bs=$bs count=$len 2>/dev/null | md5sum)" = $sum ]; then

Ah that's your space problem ;-)  Be inventive with qoutes, and don't use that
$(), like

"`dd if="$iso" bs="$bs" count="$len" 2>/dev/null | md5sum | cut -d ' ' -f 1`"
= "$sum"

and the last cut is needed because some md5sum's put a '-' after the checksum
as filename when reading from stdin.

>     test $quiet || echo " success"
>     exit 0
> else
>     test $quiet || echo " FAILED!"
>     exit 3
> fi
> ============================================================


Regards,

  Anne Bezemer



Reply to: