# HG changeset patch # User Doug Simon # Date 1406548533 -7200 # Node ID 89be7c4db12c4ba7fd84c9b5c09ef5859fc3e3f4 # Parent edf653f515213435957b7481ed2bb24cae325940 made sha1 signatures mandatory for libraries; made libraries for all downloading performed by commands in mx_graal diff -r edf653f51521 -r 89be7c4db12c mx/mx_graal.py --- a/mx/mx_graal.py Mon Jul 28 11:35:17 2014 +0200 +++ b/mx/mx_graal.py Mon Jul 28 13:55:33 2014 +0200 @@ -1481,10 +1481,14 @@ else: executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer') - archive = join(libpath, 'c1visualizer_2014-04-22.zip') - if not exists(executable) or not exists(archive): - if not exists(archive): - mx.download(archive, ['https://java.net/downloads/c1visualizer/c1visualizer_2014-04-22.zip']) + # Check whether the current C1Visualizer installation is the up-to-date + if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)): + mx.log('Updating C1Visualizer') + shutil.rmtree(join(libpath, 'c1visualizer')) + + archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True) + + if not exists(executable): zf = zipfile.ZipFile(archive, 'r') zf.extractall(libpath) @@ -1827,8 +1831,20 @@ flavor = 'att' lib = mx.add_lib_suffix('hsdis-' + _arch()) path = join(_graal_home, 'lib', lib) + + sha1s = { + 'att/hsdis-amd64.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72', + 'att/hsdis-amd64.so' : '58919ba085d4ef7a513f25bae75e7e54ee73c049', + 'intel/hsdis-amd64.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30', + 'intel/hsdis-amd64.so' : '844ed9ffed64fe9599638f29a8450c50140e3192', + 'intel/hsdis-amd64.dylib' : 'fdb13ef0d7d23d93dacaae9c98837bea0d4fc5a2', + } + if not exists(path): - mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavor + "/" + lib]) + flavoredLib = flavor + "/" + lib + sha1 = sha1s[flavoredLib] + sha1path = path + '.sha1' + mx.download_file_with_sha1('hsdis', path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavoredLib], sha1, sha1path, True, True, sources=False) if copyToDir is not None and exists(copyToDir): shutil.copy(path, copyToDir) @@ -1844,10 +1860,8 @@ args = parser.parse_args(args) - path = join(_graal_home, 'lib', 'hcfdis-1.jar') - if not exists(path): - mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-2.jar']) - mx.run_java(['-jar', path] + args.files) + path = mx.library('HCFDIS').get_path(resolve=True) + mx.run_java(['-cp', path, 'com.oracle.max.hcfdis.HexCodeFileDis'] + args.files) if args.map is not None: addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)') @@ -1904,11 +1918,7 @@ def jol(args): """Java Object Layout""" - jolurl = "http://lafo.ssw.uni-linz.ac.at/truffle/jol/jol-internals.jar" - joljar = "lib/jol-internals.jar" - if not exists(joljar): - mx.download(joljar, [jolurl]) - + joljar = mx.library('JOL_INTERNALS').get_path(resolve=True) candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s)) if len(candidates) > 10: print "Found %d candidates. Please be more precise." % (len(candidates)) @@ -2054,8 +2064,7 @@ if not exists(findbugsLib): tmp = tempfile.mkdtemp(prefix='findbugs-download-tmp', dir=_graal_home) try: - findbugsDist = join(tmp, 'findbugs.zip') - mx.download(findbugsDist, ['http://lafo.ssw.uni-linz.ac.at/graal-external-deps/findbugs-3.0.0.zip', 'http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0.zip']) + findbugsDist = mx.library('FINDBUGS_DIST').get_path(resolve=True) with zipfile.ZipFile(findbugsDist) as zf: candidates = [e for e in zf.namelist() if e.endswith('/lib/findbugs.jar')] assert len(candidates) == 1, candidates diff -r edf653f51521 -r 89be7c4db12c mx/projects --- a/mx/projects Mon Jul 28 11:35:17 2014 +0200 +++ b/mx/projects Mon Jul 28 13:55:33 2014 +0200 @@ -20,8 +20,24 @@ library@HAMCREST@sourceUrls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/hamcrest-core-1.3-sources.jar,http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar library@HAMCREST@sourceSha1=1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b -library@CHECKSTYLE@path=lib/checkstyle-5.5-all.jar -library@CHECKSTYLE@urls=jar:http://sourceforge.net/projects/checkstyle/files/checkstyle/5.5/checkstyle-5.5-bin.zip/download!/checkstyle-5.5/checkstyle-5.5-all.jar +#library@CHECKSTYLE@path=lib/checkstyle-5.5-all.jar +#library@CHECKSTYLE@urls=jar:http://sourceforge.net/projects/checkstyle/files/checkstyle/5.5/checkstyle-5.5-bin.zip/download!/checkstyle-5.5/checkstyle-5.5-all.jar + +library@HCFDIS@path=lib/hcfdis-2.jar +library@HCFDIS@urls=http://lafo.ssw.uni-linz.ac.at/hcfdis-2.jar +library@HCFDIS@sha1=bc8b2253436485e9dbaf81771c259ccfa1a24c80 + +library@FINDBUGS_DIST@path=lib/findbugs-dist-3.0.0.zip +library@FINDBUGS_DIST@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/findbugs-3.0.0.zip,http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0.zip/download +library@FINDBUGS_DIST@sha1=6e56d67f238dbcd60acb88a81655749aa6419c5b + +library@C1VISUALIZER_DIST@path=lib/c1visualizer_2014-04-22.zip +library@C1VISUALIZER_DIST@urls=https://java.net/downloads/c1visualizer/c1visualizer_2014-04-22.zip +library@C1VISUALIZER_DIST@sha1=220488d87affb569b893c7201f8ce5d2b0e03141 + +library@JOL_INTERNALS@path=lib/jol-internals.jar +library@JOL_INTERNALS@urls=http://lafo.ssw.uni-linz.ac.at/truffle/jol/jol-internals.jar +library@JOL_INTERNALS@sha1=508bcd26a4d7c4c44048990c6ea789a3b11a62dc library@FINDBUGS@path=lib/findbugs-3.0.0.jar library@FINDBUGS@urls=jar:http://lafo.ssw.uni-linz.ac.at/graal-external-deps/findbugs-3.0.0.zip!/findbugs-3.0.0/lib/findbugs.jar,jar:http://sourceforge.net/projects/findbugs/files/findbugs/3.0.0/findbugs-3.0.0.zip/download!/findbugs-3.0.0/lib/findbugs.jar diff -r edf653f51521 -r 89be7c4db12c mxtool/mx.py --- a/mxtool/mx.py Mon Jul 28 11:35:17 2014 +0200 +++ b/mxtool/mx.py Mon Jul 28 13:55:33 2014 +0200 @@ -487,7 +487,17 @@ return join(prefix, path) return path -def _download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False): +def sha1OfFile(path): + with open(path, 'rb') as f: + d = hashlib.sha1() + while True: + buf = f.read(4096) + if not buf: + break + d.update(buf) + return d.hexdigest() + +def download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False): def _download_lib(): cacheDir = get_env('MX_CACHE_DIR', join(_opts.user_home, '.mx', 'cache')) if not exists(cacheDir): @@ -495,7 +505,7 @@ base = basename(path) cachePath = join(cacheDir, base + '_' + sha1) - if not exists(cachePath) or _sha1OfFile(cachePath) != sha1: + if not exists(cachePath) or sha1OfFile(cachePath) != sha1: if exists(cachePath): log('SHA1 of ' + cachePath + ' does not match expected value (' + sha1 + ') - re-downloading') print 'Downloading ' + ("sources " if sources else "") + name + ' from ' + str(urls) @@ -505,6 +515,8 @@ if d != '' and not exists(d): os.makedirs(d) if 'symlink' in dir(os): + if exists(path): + os.unlink(path) os.symlink(cachePath, path) else: shutil.copy(cachePath, path) @@ -515,30 +527,21 @@ def _writeSha1Cached(): with open(sha1path, 'w') as f: - f.write(_sha1OfFile(path)) - - def _sha1OfFile(path): - with open(path, 'rb') as f: - d = hashlib.sha1() - while True: - buf = f.read(4096) - if not buf: - break - d.update(buf) - return d.hexdigest() + f.write(sha1OfFile(path)) if resolve and mustExist and not exists(path): assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path _download_lib() - if sha1 and not exists(sha1path): - _writeSha1Cached() - - if sha1 and sha1 != _sha1Cached(): - _download_lib() - if sha1 != _sha1OfFile(path): - abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") - _writeSha1Cached() + if exists(path): + if sha1 and not exists(sha1path): + _writeSha1Cached() + + if sha1 and sha1 != _sha1Cached(): + _download_lib() + if sha1 != sha1OfFile(path): + abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?") + _writeSha1Cached() return path @@ -604,12 +607,26 @@ self.sha1 = sha1 self.sourcePath = sourcePath self.sourceUrls = sourceUrls + if sourcePath == path: + assert sourceSha1 is None or sourceSha1 == sha1 + sourceSha1 = sha1 self.sourceSha1 = sourceSha1 self.deps = deps - abspath = _make_absolute(self.path, self.suite.dir) + abspath = _make_absolute(path, self.suite.dir) if not optional and not exists(abspath): if not len(urls): abort('Non-optional library {} must either exist at {} or specify one or more URLs from which it can be retrieved'.format(name, abspath)) + + def _checkSha1PropertyCondition(propName, cond, inputPath): + if not cond: + absInputPath = _make_absolute(inputPath, self.suite.dir) + if exists(absInputPath): + abort('Missing "{}" property for library {}. Add the following line to projects file:\nlibrary@{}@{}={}'.format(propName, name, name, propName, sha1OfFile(absInputPath))) + abort('Missing "{}" property for library {}'.format(propName, name)) + + _checkSha1PropertyCondition('sha1', sha1, path) + _checkSha1PropertyCondition('sourceSha1', not sourcePath or sourceSha1, sourcePath) + for url in urls: if url.endswith('/') != self.path.endswith(os.sep): abort('Path for dependency directory must have a URL ending with "/": path=' + self.path + ' url=' + url) @@ -631,7 +648,7 @@ if includedInJDK and java().javaCompliance >= JavaCompliance(includedInJDK): return None - return _download_file_with_sha1(self.name, path, self.urls, self.sha1, sha1path, resolve, not self.optional) + return download_file_with_sha1(self.name, path, self.urls, self.sha1, sha1path, resolve, not self.optional) def get_source_path(self, resolve): if self.sourcePath is None: @@ -639,7 +656,7 @@ path = _make_absolute(self.sourcePath, self.suite.dir) sha1path = path + '.sha1' - return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True) + return download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True) def append_to_classpath(self, cp, resolve): path = self.get_path(resolve)