Mercurial > hg > truffle
comparison mxtool/mx.py @ 8457:b27261747964
mx: merge provider configuration files in distribution jars
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 25 Mar 2013 15:39:31 +0100 |
parents | b6b9ab1fde62 |
children | 67f19ede4891 |
comparison
equal
deleted
inserted
replaced
8456:d815f0ac9ed3 | 8457:b27261747964 |
---|---|
1656 for name in args.names: | 1656 for name in args.names: |
1657 if name.startswith('@'): | 1657 if name.startswith('@'): |
1658 dname = name[1:] | 1658 dname = name[1:] |
1659 d = distribution(dname) | 1659 d = distribution(dname) |
1660 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) | 1660 fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) |
1661 services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) | |
1661 zf = zipfile.ZipFile(tmp, 'w') | 1662 zf = zipfile.ZipFile(tmp, 'w') |
1662 for p in sorted_deps(d.deps): | 1663 for p in sorted_deps(d.deps): |
1663 outputDir = p.output_dir() | 1664 outputDir = p.output_dir() |
1664 for root, _, files in os.walk(outputDir): | 1665 for root, _, files in os.walk(outputDir): |
1665 for f in files: | 1666 relpath = root[len(outputDir) + 1:] |
1666 relpath = root[len(outputDir) + 1:] | 1667 if relpath == join('META-INF', 'services'): |
1667 arcname = join(relpath, f).replace(os.sep, '/') | 1668 for f in files: |
1668 zf.write(join(root, f), arcname) | 1669 with open(join(services, f), 'a') as outfile: |
1670 with open(join(root, f), 'r') as infile: | |
1671 for line in infile: | |
1672 outfile.write(line) | |
1673 else: | |
1674 for f in files: | |
1675 arcname = join(relpath, f).replace(os.sep, '/') | |
1676 zf.write(join(root, f), arcname) | |
1677 for f in os.listdir(services): | |
1678 arcname = join('META-INF', 'services', f).replace(os.sep, '/') | |
1679 zf.write(join(services, f), arcname) | |
1669 zf.close() | 1680 zf.close() |
1670 os.close(fd) | 1681 os.close(fd) |
1682 shutil.rmtree(services) | |
1671 # Atomic on Unix | 1683 # Atomic on Unix |
1672 shutil.move(tmp, d.path) | 1684 shutil.move(tmp, d.path) |
1673 #print time.time(), 'move:', tmp, '->', d.path | 1685 #print time.time(), 'move:', tmp, '->', d.path |
1674 d.notify_updated() | 1686 d.notify_updated() |
1675 | 1687 |