b500c545cc536f582276789b24a1f1eca2ce358a
[portage.git] / bin / env-update
1 #!/usr/bin/python -O
2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 from __future__ import print_function
6
7 import errno
8 import sys
9
10 def usage(status):
11         print("Usage: env-update [--no-ldconfig]")
12         print("")
13         print("See the env-update(1) man page for more info")
14         sys.exit(status)
15
16 if "-h" in sys.argv or "--help" in sys.argv:
17         usage(0)
18
19 makelinks=1
20 if "--no-ldconfig" in sys.argv:
21         makelinks=0
22         sys.argv.pop(sys.argv.index("--no-ldconfig"))
23
24 if len(sys.argv) > 1:
25         print("!!! Invalid command line options!\n")
26         usage(1)
27
28 from os import path as osp
29 pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
30 sys.path.insert(0, pym_path)
31 import portage
32 portage._internal_caller = True
33
34 try:
35         portage.env_update(makelinks)
36 except IOError as e:
37         if e.errno == errno.EACCES:
38                 print("env-update: Need superuser access")
39                 sys.exit(1)
40         else:
41                 raise