a4c8e11404a47f7731f8875324315c5bd9f26da0
[gentoolkit.git] / bin / revdep-ng
1 #!/usr/bin/python
2 #
3 # Copyright 2010 Brian Dolbec <brian.dolbec@gmail.com>
4 # Copyright 2002-2010 Gentoo Technologies, Inc.
5 # Distributed under the terms of the GNU General Public License v2 or later
6 #
7 # $Header$
8
9 """'analyse' is a flexible utility for Gentoo linux which can display various
10 information about installed packages, such as the USE flags used and the
11 packages that use them.  It can also be used to help rebuild /etc/portage/package.*
12 files in the event of corruption, and possibly more.
13 """
14
15 from __future__ import print_function
16
17 import sys
18 # This block ensures that ^C interrupts are handled quietly.
19 try:
20         import signal
21
22         def exithandler(signum,frame):
23                 signal.signal(signal.SIGINT, signal.SIG_IGN)
24                 signal.signal(signal.SIGTERM, signal.SIG_IGN)
25                 print()
26                 sys.exit(1)
27
28         signal.signal(signal.SIGINT, exithandler)
29         signal.signal(signal.SIGTERM, exithandler)
30         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
31
32
33 except KeyboardInterrupt:
34         print()
35         sys.exit(1)
36
37 from gentoolkit import errors
38 from gentoolkit.revdep_rebuild import rebuild
39
40 try:
41         success = rebuild.main(rebuild.parse_options())
42         sys.exit(success)
43 except errors.GentoolkitException as err:
44         if '--debug' in sys.argv:
45                 raise
46         else:
47                 from gentoolkit import pprinter as pp
48                 sys.stderr.write(pp.error(str(err)))
49                 print()
50                 print("Add '--debug' to global options for traceback.")
51                 sys.exit(1)