test_keyword: fix test_main and mark so nosetests will ignore it
[gentoolkit.git] / bin / revdep-rebuild
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 """'revdep-rebuild' scans libraries and binaries for missing shared library dependencies and attempts to fix them by re-emerging
10 those broken binaries and shared libraries. It is useful when an upgraded package breaks other software packages that are
11 dependent upon the upgraded package.
12 """
13
14 from __future__ import print_function
15
16 import sys
17 # This block ensures that ^C interrupts are handled quietly.
18 try:
19         import signal
20
21         def exithandler(signum,frame):
22                 signal.signal(signal.SIGINT, signal.SIG_IGN)
23                 signal.signal(signal.SIGTERM, signal.SIG_IGN)
24                 print()
25                 sys.exit(1)
26
27         signal.signal(signal.SIGINT, exithandler)
28         signal.signal(signal.SIGTERM, exithandler)
29         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
30
31
32 except KeyboardInterrupt:
33         print()
34         sys.exit(1)
35
36 from gentoolkit import errors
37 from gentoolkit.revdep_rebuild import rebuild
38
39 try:
40         success = rebuild.main(rebuild.parse_options())
41         sys.exit(success)
42 except errors.GentoolkitException as err:
43         if '--debug' in sys.argv:
44                 raise
45         else:
46                 from gentoolkit import pprinter as pp
47                 sys.stderr.write(pp.error(str(err)))
48                 print()
49                 print("Add '--debug' to global options for traceback.")
50                 sys.exit(1)