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 D191013835A for ; Thu, 29 Oct 2020 16:04:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 32BC8E0954; Thu, 29 Oct 2020 16:04:49 +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 19EC4E0954 for ; Thu, 29 Oct 2020 16:04:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 1AF84340E81 for ; Thu, 29 Oct 2020 16:04:48 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2374A3C5 for ; Thu, 29 Oct 2020 16:04:46 +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: <1603987421.6dbe9873976be48b0a226dd14925d5417db89643.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: 6dbe9873976be48b0a226dd14925d5417db89643 X-VCS-Branch: pending/mattst88 Date: Thu, 29 Oct 2020 16:04:46 +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: 8276eab4-7f67-4d7e-8a35-b42241cde3a9 X-Archives-Hash: a5e2f928dc0e0110b9232e6c82d89be4 commit: 6dbe9873976be48b0a226dd14925d5417db89643 Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 13:03:33 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 16:03:41 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6dbe9873 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 e2981d58..c2abf757 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):