Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending commit in: bin/, catalyst/base/
Date: Thu, 09 Mar 2017 09:39:10
Message-Id: 1489052047.97d01ff55ca7450a78bdb62f2dcdb17a7d8acecb.dolsen@gentoo
1 commit: 97d01ff55ca7450a78bdb62f2dcdb17a7d8acecb
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: Thu Mar 9 09:34:07 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=97d01ff5
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 | 27 +++++++++++++++++++++++++++
14 2 files changed, 27 insertions(+), 19 deletions(-)
15
16 diff --git a/bin/catalyst b/bin/catalyst
17 index 72a4cb4..a64cfce 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 b857a64..ef58454 100644
49 --- a/catalyst/base/stagebase.py
50 +++ b/catalyst/base/stagebase.py
51 @@ -2,6 +2,7 @@
52 import os
53 import imp
54 import shutil
55 +import signal
56 import sys
57
58 from snakeoil import fileutils
59 @@ -206,6 +207,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 @@ -268,6 +280,21 @@ class StageBase(TargetBase, ClearBase, GenBase):
78 self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
79 self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
80
81 + # Initialize our (de)compressor's)
82 + self.decompressor = CompressMap(self.settings["decompress_definitions"],
83 + env=self.env,
84 + search_order=self.settings["decompressor_search_order"])
85 +
86 + # save resources, it is not always needed
87 + self.compressor = None
88 +
89 + def exithandler(self, _signum, _frame):
90 + signal.signal(signal.SIGINT, signal.SIG_IGN)
91 + signal.signal(signal.SIGTERM, signal.SIG_IGN)
92 + self.unbind()
93 + print()
94 + sys.exit(1)
95 +
96 def override_cbuild(self):
97 if "CBUILD" in self.makeconf:
98 self.settings["CBUILD"] = self.makeconf["CBUILD"]