Allow 0alias options anywhere in the command line
[zeroinstall.git] / 0store-secure-add
blob3792e7ab0d8bd743a51f895e87b4cfa05d65a188
1 #!/usr/bin/env python
2 import sys, os
3 from zeroinstall import zerostore, SafeException
4 from zeroinstall.zerostore import cli, manifest
6 # Make all system files world-readable, even if the default
7 # system umask is more strict.
8 os.umask(0o022)
10 # import logging; logging.getLogger().setLevel(logging.DEBUG)
12 try:
13 if 'ENV_NOT_CLEARED' in os.environ:
14 raise SafeException("Environment not cleared. Check your sudoers file.")
15 if os.environ['HOME'] == 'Unclean':
16 raise SafeException("$HOME not set. Check your sudoers file has 'always_set_home' turned on for zeroinst.")
18 if len(sys.argv) != 2:
19 raise cli.UsageError('Usage: %s DIGEST' % sys.argv[0])
20 required_digest = sys.argv[1]
22 manifest_data = file('.manifest', 'rb').read()
24 stores = zerostore.Stores()
26 manifest.copy_tree_with_verify('.', '/var/cache/0install.net/implementations',
27 manifest_data, required_digest)
28 except (IOError, SafeException) as ex:
29 print >>sys.stderr, ex
30 sys.exit(1)