Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 14154:e666c172c9aa
mx: some cleanup around sha1 digest support
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Wed, 12 Mar 2014 11:40:33 +0100 |
parents | e328f28f7401 |
children | 1ac6195ee586 |
comparison
equal
deleted
inserted
replaced
14153:e328f28f7401 | 14154:e666c172c9aa |
---|---|
347 print 'Downloading ' + ("Sources " if sources else "") + name + ' from ' + str(urls) | 347 print 'Downloading ' + ("Sources " if sources else "") + name + ' from ' + str(urls) |
348 download(path, urls) | 348 download(path, urls) |
349 | 349 |
350 def _sha1Cached(): | 350 def _sha1Cached(): |
351 with open(sha1path, 'r') as f: | 351 with open(sha1path, 'r') as f: |
352 return f.readline()[0:40] | 352 return f.read()[0:40] |
353 | 353 |
354 def _writesha1Cached(): | 354 def _writeSha1Cached(): |
355 with open(sha1path, 'w') as f: | 355 with open(sha1path, 'w') as f: |
356 f.write(_sha1OfFile()) | 356 f.write(_sha1OfFile()) |
357 | 357 |
358 def _sha1OfFile(): | 358 def _sha1OfFile(): |
359 with open(path, 'rb') as f: | 359 with open(path, 'rb') as f: |
363 if resolve and mustExist and not exists(path): | 363 if resolve and mustExist and not exists(path): |
364 assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path | 364 assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path |
365 _download_lib() | 365 _download_lib() |
366 | 366 |
367 if sha1 and not exists(sha1path): | 367 if sha1 and not exists(sha1path): |
368 _writesha1Cached() | 368 _writeSha1Cached() |
369 | 369 |
370 if sha1 and sha1 != _sha1Cached(): | 370 if sha1 and sha1 != _sha1Cached(): |
371 _download_lib() | 371 _download_lib() |
372 if sha1 != _sha1OfFile(): | 372 if sha1 != _sha1OfFile(): |
373 abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") | 373 abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") |
374 _writesha1Cached() | 374 _writeSha1Cached() |
375 | 375 |
376 return path | 376 return path |
377 | 377 |
378 class Library(Dependency): | 378 class Library(Dependency): |
379 def __init__(self, suite, name, path, mustExist, urls, sha1, sourcePath, sourceUrls, sourceSha1): | 379 def __init__(self, suite, name, path, mustExist, urls, sha1, sourcePath, sourceUrls, sourceSha1): |
425 return None | 425 return None |
426 if not isabs(path): | 426 if not isabs(path): |
427 path = join(self.suite.dir, path) | 427 path = join(self.suite.dir, path) |
428 sha1path = path + '.sha1' | 428 sha1path = path + '.sha1' |
429 | 429 |
430 return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True) | 430 return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True) |
431 | 431 |
432 def append_to_classpath(self, cp, resolve): | 432 def append_to_classpath(self, cp, resolve): |
433 path = self.get_path(resolve) | 433 path = self.get_path(resolve) |
434 if path and (exists(path) or not resolve): | 434 if path and (exists(path) or not resolve): |
435 cp.append(path) | 435 cp.append(path) |