Include details of the selected implementations in bug reports
[0compile.git] / include_deps.py
blob9511821c9bee3ada7933962460f8d2cd344dc1d1
1 # Copyright (C) 2007, Thomas Leonard
2 # See http://0install.net/0compile.html
4 import sys, os, __main__
5 from logging import info
6 from zeroinstall.zerostore import manifest, Store
8 from support import *
10 def do_include_deps(args):
11 """include-deps"""
12 buildenv = BuildEnv()
14 depdir = os.path.realpath('dependencies')
15 ensure_dir(depdir)
17 dirs_to_copy = []
19 sels = buildenv.get_selections()
20 for needed_iface in sels.selections:
21 impl = buildenv.chosen_impl(needed_iface)
22 assert impl
23 if impl.id.startswith('/'):
24 raise SafeException("Can't export '%s' as it's a local implementation (not supported yet; sorry)" % impl)
25 dirs_to_copy.append(lookup(impl.id))
27 copied = 0
28 for cached in dirs_to_copy:
29 required_digest = os.path.basename(cached)
30 target_impl_dir = os.path.join(depdir, required_digest)
31 if not os.path.isdir(target_impl_dir):
32 if required_digest.startswith('sha1='):
33 shutil.copytree(cached, target_impl_dir)
34 else:
35 manifest_data = file(os.path.join(cached, '.manifest')).read()
36 manifest.copy_tree_with_verify(cached, depdir, manifest_data, required_digest)
37 copied += 1
39 print "Copied %d dependencies to %s (%d already there)" % (copied, depdir, len(dirs_to_copy) - copied)
41 __main__.commands.append(do_include_deps)