aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:57:05 +0600
committerAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:57:05 +0600
commit6563293d18daed502ccdb663f3c72b4bae5fe23a (patch)
treed0a7d53a7c137feb4073c963408829f88ea75c92 /portage_with_autodep/bin/emerge
parentupdated portage to 2.2.8-r1 (diff)
downloadautodep-master.tar.gz
autodep-master.tar.bz2
autodep-master.zip
updated portage to 2.2.8-r1HEADmaster
Diffstat (limited to 'portage_with_autodep/bin/emerge')
-rwxr-xr-xportage_with_autodep/bin/emerge99
1 files changed, 56 insertions, 43 deletions
diff --git a/portage_with_autodep/bin/emerge b/portage_with_autodep/bin/emerge
index 6f69244..4d9ea5a 100755
--- a/portage_with_autodep/bin/emerge
+++ b/portage_with_autodep/bin/emerge
@@ -1,66 +1,79 @@
#!/usr/bin/python
-# Copyright 2006-2011 Gentoo Foundation
+# Copyright 2006-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from __future__ import print_function
+import platform
import signal
import sys
-# This block ensures that ^C interrupts are handled quietly.
+
+# This block ensures that ^C interrupts are handled quietly. We handle
+# KeyboardInterrupt instead of installing a SIGINT handler, since
+# exiting from signal handlers intermittently causes python to ignore
+# the SystemExit exception with a message like this:
+# Exception SystemExit: 130 in <function remove at 0x7fd2146c1320> ignored
try:
- def exithandler(signum,frame):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
+ def exithandler(signum, _frame):
signal.signal(signal.SIGTERM, signal.SIG_IGN)
sys.exit(128 + signum)
- signal.signal(signal.SIGINT, exithandler)
signal.signal(signal.SIGTERM, exithandler)
# Prevent "[Errno 32] Broken pipe" exceptions when
# writing to a pipe.
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-except KeyboardInterrupt:
- sys.exit(128 + signal.SIGINT)
+ def debug_signal(_signum, _frame):
+ import pdb
+ pdb.set_trace()
-def debug_signal(signum, frame):
- import pdb
- pdb.set_trace()
-signal.signal(signal.SIGUSR1, debug_signal)
+ if platform.python_implementation() == 'Jython':
+ debug_signum = signal.SIGUSR2 # bug #424259
+ else:
+ debug_signum = signal.SIGUSR1
+
+ signal.signal(debug_signum, debug_signal)
-try:
- from _emerge.main import emerge_main
-except ImportError:
from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
+ pym_path = osp.join(osp.dirname(osp.dirname(
+ osp.realpath(__file__))), "pym")
+ sys.path.insert(0, pym_path)
+ import portage
+ portage._internal_caller = True
+ portage._disable_legacy_globals()
from _emerge.main import emerge_main
-if __name__ == "__main__":
- import sys
- from portage.exception import ParseError, PermissionDenied
- try:
- retval = emerge_main()
- except PermissionDenied as e:
- sys.stderr.write("Permission denied: '%s'\n" % str(e))
- sys.exit(e.errno)
- except ParseError as e:
- sys.stderr.write("%s\n" % str(e))
- sys.exit(1)
- except SystemExit:
- raise
- except Exception:
- # If an unexpected exception occurs then we don't want the mod_echo
- # output to obscure the traceback, so dump the mod_echo output before
- # showing the traceback.
- import traceback
- tb_str = traceback.format_exc()
+ if __name__ == "__main__":
+ from portage.exception import ParseError, PermissionDenied
try:
- from portage.elog import mod_echo
- except ImportError:
- pass
- else:
- mod_echo.finalize()
- sys.stderr.write(tb_str)
- sys.exit(1)
- sys.exit(retval)
+ retval = emerge_main()
+ except PermissionDenied as e:
+ sys.stderr.write("Permission denied: '%s'\n" % str(e))
+ sys.exit(e.errno)
+ except ParseError as e:
+ sys.stderr.write("%s\n" % str(e))
+ sys.exit(1)
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except Exception:
+ # If an unexpected exception occurs then we don't want the
+ # mod_echo output to obscure the traceback, so dump the
+ # mod_echo output before showing the traceback.
+ import traceback
+ tb_str = traceback.format_exc()
+ try:
+ from portage.elog import mod_echo
+ except ImportError:
+ pass
+ else:
+ mod_echo.finalize()
+ sys.stderr.write(tb_str)
+ sys.exit(1)
+ sys.exit(retval)
+
+except KeyboardInterrupt:
+ sys.stderr.write("\n\nExiting on signal %(signal)s\n" %
+ {"signal": signal.SIGINT})
+ sys.stderr.flush()
+ sys.exit(128 + signal.SIGINT)