MD5SUMS File and script to read

Ag. D. Hatzimanikas a.hatzim at gmail.com
Sat Jun 9 09:36:26 PDT 2007


On Sat, Jun 09, at 10:31 Wit wrote:
> Chris Staub wrote:
> > John Gnew wrote:
> >   
> >> Does anyone have a script that would read the MD5SUMS files and then 
> >> verify the MD5s against each source file?
> >
> > Isn't this what "md5sum -c" does?
> >   
> You can build a file containg the names of the files and results of 
> md5sum (either locally generated or paste in the values from the book) 
> and run md5sum with the correct parameter. It will tell you the results. 
> "Man md5sum" will get you going.
> 

Here is a 5 lines script, which it will do something like this.
It needs a HTML version of the Lfs Book, and compares the local md5sums with
those in the Book. I tested with a recent book from the development
branch.
Adjust the patterns if it is necessary. Adjust also the format at your desire.

########### CUT HERE ##################

PACKAGES_page=/path/to/HTML/LFS/BOOK/chapter03/packages.html

sed -n 's/^.*"[fh]t\+p.*\/\(.*tar\.[bg]z2\?\).*$/\1/p' $PACKAGES_page >book_list

while read line;do 

BOOK_md5sum=$(sed -n "/$line/,/literal/p" $PACKAGES_page | \
sed -e '$!d' -e "s/^.*>\(.*\)<.*$/\1/")

LOCAL_md5sum=$(md5sum $line |cut -d" " -f1)

[[ $BOOK_md5sum = $LOCAL_md5sum ]] && echo "local md5sum for $line is identical"|| \
echo "$line has a wrong md5sum or you are missing the package"
done < book_list

########### CUT HERE ##################



More information about the lfs-support mailing list