Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/base/, bin/
Date: Tue, 06 Oct 2015 19:54:41
Message-Id: 1444161159.2dac8da1679121bf992574d7fb5f8ed41c99c3c9.dolsen@gentoo
1 commit: 2dac8da1679121bf992574d7fb5f8ed41c99c3c9
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 8 06:15:25 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 6 19:52:39 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2dac8da1
7
8 Move the signal handler into the StageBase class so it can handle unbind() cleanup
9
10 Not quite complete, still errors on some unmounting
11
12 bin/catalyst | 19 -------------------
13 catalyst/base/stagebase.py | 19 +++++++++++++++++++
14 2 files changed, 19 insertions(+), 19 deletions(-)
15
16 diff --git a/bin/catalyst b/bin/catalyst
17 index 577e899..832399f 100755
18 --- a/bin/catalyst
19 +++ b/bin/catalyst
20 @@ -12,25 +12,6 @@ from __future__ import print_function
21
22 import sys
23
24 -# This block ensures that ^C interrupts are handled quietly.
25 -try:
26 - import signal
27 -
28 - def exithandler(_signum, _frame):
29 - signal.signal(signal.SIGINT, signal.SIG_IGN)
30 - signal.signal(signal.SIGTERM, signal.SIG_IGN)
31 - print()
32 - sys.exit(1)
33 -
34 - signal.signal(signal.SIGINT, exithandler)
35 - signal.signal(signal.SIGTERM, exithandler)
36 - signal.signal(signal.SIGPIPE, signal.SIG_DFL)
37 -
38 -except KeyboardInterrupt:
39 - print()
40 - sys.exit(1)
41 -
42 -
43 from catalyst.main import main
44
45 try:
46
47 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
48 index 813e5f1..90e8303 100644
49 --- a/catalyst/base/stagebase.py
50 +++ b/catalyst/base/stagebase.py
51 @@ -3,6 +3,7 @@ import os
52 import imp
53 import types
54 import shutil
55 +import signal
56 import sys
57 from stat import ST_UID, ST_GID, ST_MODE
58
59 @@ -191,6 +192,17 @@ class StageBase(TargetBase, ClearBase, GenBase):
60 if "portage_confdir" in self.settings:
61 file_locate(self.settings,["portage_confdir"],expand=0)
62
63 +
64 + # This block ensures that ^C interrupts are handled quietly.
65 + try:
66 + signal.signal(signal.SIGINT, self.exithandler)
67 + signal.signal(signal.SIGTERM, self.exithandler)
68 + signal.signal(signal.SIGPIPE, signal.SIG_DFL)
69 +
70 + except KeyboardInterrupt:
71 + print()
72 + sys.exit(1)
73 +
74 # Setup our mount points.
75 # initialize our target mounts.
76 self.target_mounts = TARGET_MOUNT_DEFAULTS.copy()
77 @@ -265,6 +277,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
78 # save resources, it is not always needed
79 self.compressor = None
80
81 + def exithandler(self, _signum, _frame):
82 + signal.signal(signal.SIGINT, signal.SIG_IGN)
83 + signal.signal(signal.SIGTERM, signal.SIG_IGN)
84 + self.unbind()
85 + print()
86 + sys.exit(1)
87 +
88 def override_cbuild(self):
89 if "CBUILD" in self.makeconf:
90 self.settings["CBUILD"]=self.makeconf["CBUILD"]