Re: Updated check-debian-cd
On Thu, 28 Sep 2000, Francesco Potorti` wrote:
> > 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.
>
> Right.
>
> I plan to add a way to read the MD5SUMS files, in addition to the
> internal database. This way, do you think that it would be reasonable
> to add it to the toolkit? I am not sure, really.
External MD5SUMs will be quite hard to use with the autodetection, and that's
one feature I like very much. I think an always-up-to-date program on some
website will be the easiest concept for most people to grasp ;-)
> > #! /bin/bash
>
> The Kit is often used on various *UXes;
>
> If that's the case, then okay, I'm going to remove bashisms.
>
> In the past, I worked with a true Bourne sh of the old days, and I am
> able to cope with it. But now I see that the minimum denominator is
> considered ash, which is much more powerful than that. It claims to
> strive to be Posix compliant.
>
> What is considered reasonable as of today? Be conservative, and go with
> the Bourne shell (whose exact characteristics are currently difficult to
> check, anyway), or is Posix enough?
AFAIK every self-respecting *UX is (or wants to be) POSIX certified today, so
I suppose we can assume that /bin/sh is POSIX-compliant. Well, the easiest way
would be to make it work with ash, and ask people to send you bug reports in
case it doesn't work with other shells. At least make-pseudo-image is known to
work "everywhere", so everything in there is allowed ;-)
> > 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.
>
> Hm. I need some info here. As a first try, I had used factor, as you
> suggest, and came up with a bs=98k. But that didn't spare kernel
> messages saying that I was going out of bounds. Then I went down to
I've never seen that kind of warning with any of the IDE drives I used, but
don't know about SCSI or old proprietary interfaces.
> bs=2k, which as far as I understand is the CD's sector lenght.
Correct.
> Questions (which I may all answer by trial myself, by the way):
> - what is the MCD of the lengths of all CDs (is it greater than 2k)?
2k guaranteed, if you're lucky 4k for a given set.
> - if I use factor(1), what else should I consider, given my bad
> experience with bs=98k (maybe only powers of 2)?
That's the problem ;-) Given a list of numbers and a range [A,B], finding
some product that lies in [A,B] is quite hard to do (especially in a shell
script). For the "powers of 2", you're the only one able to check at the
moment. If you get these factors working, maybe an option --force-2k-blocks
would be useful.
> > 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-`
>
> It works the way you suggest, but you end up repeatedly calling cut(1).
I don't mind much. As long as you don't do many external calls in long loops,
nobody will notice.
> The way I did it is AFAIK the *only* perfectly safe, perfectly portable
> way of parsing an output line without forking a process. It worked on
> old SysV Bourne shells, apart from the $(), but you used backquotes.
I'd also call it a perfectly obfuscated way -- it looks much like self-
modifying code and that's generally considered a Bad Thing[tm] ;-)
> > if ! type -t md5sum >/dev/null; then
>
> Bashism? Maybe this works:
>
> if ! md5sum --help >/dev/null ; then
>
> I did something similar (md5sum does not support --help...), but in fact
> `type' is a Posix builtin (without the -t option).
Indeed, it "even" works in ash.. I can use that in make-pseudo-image to check
if ncftp2 is available...
> > if [ "$(dd if=$iso bs=$bs count=$len 2>/dev/null | md5sum)" = $sum ]; then
>
> Ah that's your space problem ;-)
>
> Yes, correcting that would require "creative" quoting, and probably the
> use of `eval', and I am not sure I want to do that...
>
> 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"
>
> Double quotes inside backquotes inside double quotes? If that works,
> then I discovered a new trick :-) I'll try that out.
ash$ TEST='a b'
ash$ echo $TEST
a b
ash$ echo "$TEST"
a b
ash$ echo `echo $TEST`
a b
ash$ echo `echo "$TEST"`
a b
ash$ echo "`echo $TEST`"
a b
ash$ echo "`echo "$TEST"`"
a b
Regards,
Anne Bezemer
Reply to: