Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/
Date: Thu, 29 Oct 2020 15:47:43
Message-Id: 1603985092.dfea0c040f43fba778ff1ef9747be5da50090333.mattst88@gentoo
1 commit: dfea0c040f43fba778ff1ef9747be5da50090333
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 29 13:03:33 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 29 15:24:52 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dfea0c04
7
8 catalyst: Factor out run_sequence()
9
10 This is preparation for the next patch, which will run the build
11 sequence in a separate mount namespace.
12
13 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
14
15 catalyst/base/stagebase.py | 40 +++++++++++++++++++++++-----------------
16 1 file changed, 23 insertions(+), 17 deletions(-)
17
18 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
19 index fd723e48..829bcc93 100644
20 --- a/catalyst/base/stagebase.py
21 +++ b/catalyst/base/stagebase.py
22 @@ -1362,6 +1362,22 @@ class StageBase(TargetBase, ClearBase, GenBase):
23
24 log.debug('setup_environment(); env = %r', self.env)
25
26 + def run_sequence(self, sequence):
27 + for func in sequence:
28 + log.notice('--- Running action sequence: %s', func)
29 + sys.stdout.flush()
30 + try:
31 + getattr(self, func)()
32 + except LockInUse:
33 + log.error('Unable to aquire the lock...')
34 + return False
35 + except Exception:
36 + log.error('Exception running action sequence %s',
37 + func, exc_info=True)
38 + return False
39 +
40 + return True
41 +
42 def run(self):
43 self.chroot_lock.write_lock()
44
45 @@ -1386,26 +1402,16 @@ class StageBase(TargetBase, ClearBase, GenBase):
46 log.info('StageBase: run() purge')
47 self.purge()
48
49 - failure = False
50 - for x in self.prepare_sequence + self.build_sequence + self.finish_sequence:
51 - log.notice('--- Running action sequence: %s', x)
52 - sys.stdout.flush()
53 - try:
54 - getattr(self, x)()
55 - except LockInUse:
56 - log.error('Unable to aquire the lock...')
57 - failure = True
58 - break
59 - except Exception:
60 - log.error('Exception running action sequence %s',
61 - x, exc_info=True)
62 - failure = True
63 - break
64 + if not self.run_sequence(self.prepare_sequence):
65 + return False
66
67 - if failure:
68 - log.notice('Cleaning up... Running unbind()')
69 + if not self.run_sequence(self.build_sequence):
70 self.unbind()
71 return False
72 +
73 + if not self.run_sequence(self.finish_sequence):
74 + return False
75 +
76 return True
77
78 def unmerge(self):