Start development series 0.42-post
[zeroinstall/zeroinstall-rsl.git] / 0store-secure-add
blobf7428012be943191cd0bc2b2958772f8cc9f46be
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').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)