Debian MD5 Digests

Cousin Stanley CousinStanley at HotMail.Com
Tue Jul 27 04:03:08 CEST 2004

After 4 failed attempts at installing Debian Linux from CDs
that were burned from downloaded  .iso  files, I've finally come to
the conclusion that my CD Burner is not working properly .... 

The md5 digests of all downloaded  .iso  files has checked out OK 
in each case  PRIOR  to burning them to CD and in each case
the burned CDs always boot and begin the Debian install proc
which ultimately fails due to md5 errors ..... 

The Debian installer doesn't present the user
with the opportunity to check CD-ROM integrity
until  AFTER  the above failures have occurred,
which seems a bit late ....  

I wrote a small script to check md5s of the burned CD files
against those in the supplied  md5sum.txt  file, 
but since the burned CD I have is corrupted, 
testing the script  is somewhat tedious and fails 
at different points in processing with the following error 
attributed to permissions .... 

Traceback (most recent call last):
  File "K:\Python\py_Work\file\", line 76, in ?
    that_md5 = md5_digest( this_path )
  File "K:\Python\py_Work\file\", line 53, in md5_digest
    xFile = file( xPath , 'rb' ).read()
IOError: [Errno 13] Permission denied

I'm not particularly interested in getting rid of that particular error
as I  think/hope  it will go away when I get a good CD burn .... 

However, I would like to hear from someone 
who has a Debian CD with the  md5sum.txt  file
on it that would test the script and see if it 
actually runs all the way to completion .... 

Are all the files that are listed in the  md5sum.txt  file
always included on the CD ???? 

I added a check for this after seeing  file not found  errors 
in the script .... 

# ------------------------------------------------------------------------------------------

import md5 , os ,  sys

if len( sys.argv ) < 2 : 
    print '    Usage .......... python base_path_to_CD'
    sys.exit( -1 )

base_path = sys.argv[ 1 ]

if not os.path.exists( base_path ) : 
    print '    ****  Base Path NOT Found  ****'
    sys.exit( -2 )

os.chdir( base_path )                        

file_in  = file( 'md5sum.txt' , 'r' )

def md5_digest( xPath ) : 
    xFile = file( xPath , 'rb' ).read()
    m =
    m.update( xFile )
    return m.hexdigest()     

rec_num = 0

for this_line in file_in : 

    this_list = this_line.split()

    this_md5 = this_list[ 0 ]
    this_path = this_list[ 1 ]

    rec_num += 1

    if os.path.exists( this_path ) :

        that_md5 = md5_digest( this_path )

        if this_md5 != that_md5 : 
            print '%4d * MD5 Error * %s ' % ( rec_num , this_path )

        else : 
            print '%4d %s' % ( rec_num , this_path )

    else : 
        print '%4d * Not Found * %s' % ( rec_num , this_path )


Cousin Stanley
Human Being
Phoenix, Arizona

More information about the Python-list mailing list