Allow passing a selections document in place of a feed
[zeroinstall/solver.git] / 0store-secure-add
blob1d5d36602a21edd56898c515784a8ae49b084d55
1 #!/usr/bin/env python
2 import sys, os
3 from zeroinstall import zerostore, SafeException
4 from zeroinstall.zerostore import cli, manifest
6 # import logging; logging.getLogger().setLevel(logging.DEBUG)
8 try:
9 if 'ENV_NOT_CLEARED' in os.environ:
10 raise SafeException("Environment not cleared. Check your sudoers file.")
11 if os.environ['HOME'] == 'Unclean':
12 raise SafeException("$HOME not set. Check your sudoers file has 'always_set_home' turned on for zeroinst.")
14 if len(sys.argv) != 2:
15 raise cli.UsageError('Usage: %s DIGEST' % sys.argv[0])
16 required_digest = sys.argv[1]
18 manifest_data = file('.manifest', 'rb').read()
20 stores = zerostore.Stores()
22 manifest.copy_tree_with_verify('.', '/var/cache/0install.net/implementations',
23 manifest_data, required_digest)
24 except (IOError, SafeException), ex:
25 print >>sys.stderr, ex
26 sys.exit(1)