Updated test for new GNU Hello
[0compile.git] / include_deps.py
blobef3445be23299b4db905d93112c453da95a739e7
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 if not impl.id.startswith('package:'):
26 dirs_to_copy.append(lookup(impl))
28 copied = 0
29 for cached in dirs_to_copy:
30 required_digest = os.path.basename(cached)
31 target_impl_dir = os.path.join(depdir, required_digest)
32 if not os.path.isdir(target_impl_dir):
33 if required_digest.startswith('sha1='):
34 shutil.copytree(cached, target_impl_dir)
35 else:
36 manifest_data = file(os.path.join(cached, '.manifest')).read()
37 manifest.copy_tree_with_verify(cached, depdir, manifest_data, required_digest)
38 copied += 1
40 print "Copied %d dependencies to %s (%d already there)" % (copied, depdir, len(dirs_to_copy) - copied)
42 __main__.commands.append(do_include_deps)