Ticket #51: haikuporter.checksum.patch
| File haikuporter.checksum.patch, 2.5 KB (added by thorn, 6 years ago) |
|---|
-
haikuporter
20 20 import tarfile 21 21 import zipfile 22 22 import types 23 import hashlib 23 24 from optparse import OptionParser 24 25 25 26 # -- HaikuPorts options ------------------------------------------------------- … … 44 45 45 46 # allowed types of the BepFile values 46 47 bepTypes = {} 47 bepTypes['DESCRIPTION'] = [types.StringType, types.ListType] 48 bepTypes['HOMEPAGE'] = [types.StringType] 49 bepTypes['SRC_URI'] = [types.StringType, types.ListType] 50 bepTypes['REVISION'] = [types.IntType] 51 bepTypes['STATUS_HAIKU']= [StatusType] 52 bepTypes['DEPEND'] = [types.StringType, types.ListType, types.NoneType] 53 bepTypes['BUILD'] = [ShellType] 54 bepTypes['INSTALL'] = [ShellType] 48 bepTypes['DESCRIPTION'] = [types.StringType, types.ListType] 49 bepTypes['HOMEPAGE'] = [types.StringType] 50 bepTypes['SRC_URI'] = [types.StringType, types.ListType] 51 bepTypes['CHECKSUM_MD5'] = [types.StringType] 52 bepTypes['REVISION'] = [types.IntType] 53 bepTypes['STATUS_HAIKU'] = [StatusType] 54 bepTypes['DEPEND'] = [types.StringType, types.ListType, types.NoneType] 55 bepTypes['BUILD'] = [ShellType] 56 bepTypes['INSTALL'] = [ShellType] 55 57 56 58 # is field # default 57 59 bepDefaults = {} # required? # value 58 60 bepDefaults['DESCRIPTION'] = [True, None ] 59 61 bepDefaults['HOMEPAGE'] = [True, None ] 60 62 bepDefaults['SRC_URI'] = [True, None ] 63 bepDefaults['CHECKSUM_MD5'] = [False, None ] 61 64 bepDefaults['REVISION'] = [True, None ] 62 65 bepDefaults['WORKING'] = [False, True ] 63 66 bepDefaults['STATUS_HAIKU'] = [False, 'untested' ] … … 233 236 234 237 self.checkDeps() # check dependencies 235 238 self.fetch() # fetch sources 239 self.checksum() # calculate checksum 236 240 self.unpack() # unpack source archive 237 241 if options.patch: 238 242 self.patch() # apply patches … … 520 524 sys.stdout.write('\r' + progressInfo) 521 525 sys.stdout.flush() 522 526 527 def checksum(self): 528 if self.bepKeys['CHECKSUM_MD5']: 529 sys.stdout.write('Calculating checksum -') 530 sys.stdout.flush() 531 h = hashlib.md5() 532 f = open(self.src_local, 'rb') 533 while True: 534 d = f.read(16384) 535 if not d: 536 break 537 h.update(d) 538 f.close() 539 if h.hexdigest() == self.bepKeys['CHECKSUM_MD5']: 540 sys.stdout.write(' OK\n') 541 else: 542 sys.stdout.write(' FAILED\n') 543 sys.exit() 544 sys.stdout.flush() 545 else: 546 print "CHECKSUM_MD5 not found" 547 523 548 def unpack(self): 524 549 """Unpack the source archive (into the work directory)""" 525 550 # create work dir
