Fixed handling of ~ in Debian versions
[zeroinstall.git] / 0store-secure-add
blobe57496c0c0d523ed02604d458fd13ea800c0dbc2
1 #!/usr/bin/env python
3 from __future__ import print_function
5 import sys, os
6 from zeroinstall import zerostore, SafeException
7 from zeroinstall.zerostore import cli, manifest
9 # Make all system files world-readable, even if the default
10 # system umask is more strict.
11 os.umask(0o022)
13 # import logging; logging.getLogger().setLevel(logging.DEBUG)
15 try:
16 if 'ENV_NOT_CLEARED' in os.environ:
17 raise SafeException("Environment not cleared. Check your sudoers file.")
18 if os.environ['HOME'] == 'Unclean':
19 raise SafeException("$HOME not set. Check your sudoers file has 'always_set_home' turned on for zeroinst.")
21 if len(sys.argv) != 2:
22 raise cli.UsageError('Usage: %s DIGEST' % sys.argv[0])
23 required_digest = sys.argv[1]
25 manifest_data = open('.manifest', 'rb').read()
27 stores = zerostore.Stores()
29 manifest.copy_tree_with_verify('.', '/var/cache/0install.net/implementations',
30 manifest_data, required_digest)
31 except (IOError, SafeException) as ex:
32 print(ex, file=sys.stderr)
33 sys.exit(1)