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
10 def do_include_deps(args
):
14 depdir
= os
.path
.realpath('dependencies')
19 sels
= buildenv
.get_selections()
20 for needed_iface
in sels
.selections
:
21 impl
= buildenv
.chosen_impl(needed_iface
)
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))
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
)
35 manifest_data
= file(os
.path
.join(cached
, '.manifest')).read()
36 manifest
.copy_tree_with_verify(cached
, depdir
, manifest_data
, required_digest
)
39 print "Copied %d dependencies to %s (%d already there)" % (copied
, depdir
, len(dirs_to_copy
) - copied
)
41 __main__
.commands
.append(do_include_deps
)