From c8bf8a5e6e9858010bfaf47485458f8bf677cea3 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 11 Oct 2016 09:37:29 +0200 Subject: md5 : normalizes input before computing the md5 fixes #1508 (#1977) Bottomline : - fetcher change the current working directory - relative paths were resolved differently depending on the prder f evaluation --- lib/spack/spack/cmd/md5.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/cmd/md5.py b/lib/spack/spack/cmd/md5.py index 506cf0913f..2ae279a41e 100644 --- a/lib/spack/spack/cmd/md5.py +++ b/lib/spack/spack/cmd/md5.py @@ -25,6 +25,7 @@ import argparse import hashlib import os +from urlparse import urlparse import llnl.util.tty as tty import spack.util.crypto @@ -49,13 +50,23 @@ def compute_md5_checksum(url): return value +def normalized(files): + for p in files: + result = urlparse(p) + value = p + if not result.scheme: + value = os.path.abspath(p) + yield value + + def md5(parser, args): if not args.files: setup_parser.parser.print_help() return 1 + urls = [x for x in normalized(args.files)] results = [] - for url in args.files: + for url in urls: try: checksum = compute_md5_checksum(url) results.append((checksum, url)) @@ -70,4 +81,4 @@ def md5(parser, args): checksum = 'checksum' if len(results) == 1 else 'checksums' tty.msg("%d MD5 %s:" % (len(results), checksum)) for checksum, url in results: - print "%s %s" % (checksum, url) + print("{0} {1}".format(checksum, url)) -- cgit v1.2.3-60-g2f50