From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1A94E138359 for ; Thu, 29 Oct 2020 15:47:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4EEA2E094A; Thu, 29 Oct 2020 15:47:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 37985E0949 for ; Thu, 29 Oct 2020 15:47:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2790A340E6E for ; Thu, 29 Oct 2020 15:47:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BC8773C4 for ; Thu, 29 Oct 2020 15:47:38 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1603985092.dfea0c040f43fba778ff1ef9747be5da50090333.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py X-VCS-Directories: catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: dfea0c040f43fba778ff1ef9747be5da50090333 X-VCS-Branch: pending/mattst88 Date: Thu, 29 Oct 2020 15:47:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 327da056-f34b-4494-a421-c53d94500c68 X-Archives-Hash: 07f5c9563e6bd7c74127f80bb07dbf8a commit: dfea0c040f43fba778ff1ef9747be5da50090333 Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 13:03:33 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 15:24:52 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dfea0c04 catalyst: Factor out run_sequence() This is preparation for the next patch, which will run the build sequence in a separate mount namespace. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index fd723e48..829bcc93 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1362,6 +1362,22 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) + def run_sequence(self, sequence): + for func in sequence: + log.notice('--- Running action sequence: %s', func) + sys.stdout.flush() + try: + getattr(self, func)() + except LockInUse: + log.error('Unable to aquire the lock...') + return False + except Exception: + log.error('Exception running action sequence %s', + func, exc_info=True) + return False + + return True + def run(self): self.chroot_lock.write_lock() @@ -1386,26 +1402,16 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() - failure = False - for x in self.prepare_sequence + self.build_sequence + self.finish_sequence: - log.notice('--- Running action sequence: %s', x) - sys.stdout.flush() - try: - getattr(self, x)() - except LockInUse: - log.error('Unable to aquire the lock...') - failure = True - break - except Exception: - log.error('Exception running action sequence %s', - x, exc_info=True) - failure = True - break + if not self.run_sequence(self.prepare_sequence): + return False - if failure: - log.notice('Cleaning up... Running unbind()') + if not self.run_sequence(self.build_sequence): self.unbind() return False + + if not self.run_sequence(self.finish_sequence): + return False + return True def unmerge(self):