| 842 | |
| 843 | |
| 844 | def verifyMavenDigests(artifacts): |
| 845 | print(" verify Maven artifacts' md5/sha1 digests...") |
| 846 | reJarWarPom = re.compile(r'\.(?:[wj]ar|pom)$') |
| 847 | for artifactFile in [a for a in artifacts if reJarWarPom.search(a)]: |
| 848 | if artifactFile + '.md5' not in artifacts: |
| 849 | raise RuntimeError('missing: MD5 digest for %s' % artifactFile) |
| 850 | if artifactFile + '.sha1' not in artifacts: |
| 851 | raise RuntimeError('missing: SHA1 digest for %s' % artifactFile) |
| 852 | with open(artifactFile + '.md5', encoding='UTF-8') as md5File: |
| 853 | md5Expected = md5File.read().strip() |
| 854 | with open(artifactFile + '.sha1', encoding='UTF-8') as sha1File: |
| 855 | sha1Expected = sha1File.read().strip() |
| 856 | md5 = hashlib.md5() |
| 857 | sha1 = hashlib.sha1() |
| 858 | inputFile = open(artifactFile, 'rb') |
| 859 | while True: |
| 860 | bytes = inputFile.read(65536) |
| 861 | if len(bytes) == 0: |
| 862 | break |
| 863 | md5.update(bytes) |
| 864 | sha1.update(bytes) |
| 865 | inputFile.close() |
| 866 | md5Actual = md5.hexdigest() |
| 867 | sha1Actual = sha1.hexdigest() |
| 868 | if md5Actual != md5Expected: |
| 869 | raise RuntimeError('MD5 digest mismatch for %s: expected %s but got %s' |
| 870 | % (artifactFile, md5Expected, md5Actual)) |
| 871 | if sha1Actual != sha1Expected: |
| 872 | raise RuntimeError('SHA1 digest mismatch for %s: expected %s but got %s' |
| 873 | % (artifactFile, sha1Expected, sha1Actual)) |
| 874 | |
| 875 | |
| 876 | def getPOMcoordinate(treeRoot): |