tools: Use common hash_file implementation

Change-Id: Idf0dce913e012bfc3bcf12d6cd19d322af69505b
This commit is contained in:
Dave Borowitz
2015-11-18 15:25:24 -05:00
parent 5da89cf34c
commit 868f76458a
3 changed files with 6 additions and 24 deletions

View File

@@ -15,5 +15,6 @@ python_binary(
python_binary(
name = 'run_npm_binary',
main = 'run_npm_binary.py',
deps = ['//tools:util'],
visibility = ['PUBLIC'],
)

View File

@@ -25,16 +25,7 @@ import sys
import tarfile
import tempfile
def hash_file(p):
d = hashlib.sha1()
with open(p, 'rb') as f:
while True:
b = f.read(8192)
if not b:
break
d.update(b)
return d.hexdigest()
from tools import util
def extract(path, outdir, bin):
@@ -80,7 +71,8 @@ def main(args):
return 1
name, version = parts
outdir = '%s-%s' % (path[:-len(suffix)], hash_file(path))
sha1 = util.hash_file(hashlib.sha1(), path).hexdigest()
outdir = '%s-%s' % (path[:-len(suffix)], sha1)
rel_bin = os.path.join('package', 'bin', name)
bin = os.path.join(outdir, rel_bin)
if not os.path.isfile(bin):