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 DCF32138359 for ; Thu, 29 Oct 2020 16:16:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 30EF1E09AD; Thu, 29 Oct 2020 16:16:49 +0000 (UTC) Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 29599E09AD for ; Thu, 29 Oct 2020 16:16:49 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id k9so2401195qki.6 for ; Thu, 29 Oct 2020 09:16:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C84vX9wVgkN0wULq4cfNAXZ9ur6doBMfy681VD2g2zg=; b=RE6t/+1tAwddAF8uWhjIwIFzzyzPQfSIEoxrIeLDoc5/U8EOVsciJECWuW9zcMWivo FqLZIp6RUw0Njdq7G720n/VQogDd5LZO1qDC2JCbIPZxxatRqVtyFNF/QTvUZowGCahm 21+XjUv7o7QJ3OjhBFuTYPwBRPOaTasdFt9AJu+0VALGvqE2UOVZ77EuxfBPe1dS0zmX rr+XDd6jST993atdY4ENDUqqWBMwqoy/qLfX+z6hMhYqJKLiGc8FCXkQAcY2WN6pawgQ s1Mt/Lk7ETGaXhK84UA+M9ZJAbGB48o1y/++NXddLEauV7yiWsQzvwkQBhn/JaEnH76k aamA== X-Gm-Message-State: AOAM533sLLKVe+vE17rL5zDUS0xHXHYodqpGqPoufEmtE4J9wRw7v+Go uaHBZ8ploOC957HtAxbl/EorZVMn0dQ= X-Google-Smtp-Source: ABdhPJwhVrWQOBbRcp384pQtEFTBSHKbqE48MrzZNFmj/dPRrKQBl6Va8HXFEUbYDQvhm4vHaOv+0w== X-Received: by 2002:a37:7181:: with SMTP id m123mr4190470qkc.295.1603988208158; Thu, 29 Oct 2020 09:16:48 -0700 (PDT) Received: from localhost (2606-a000-131c-10bb-0000-0000-0000-1fc3.inf6.spectrum.com. [2606:a000:131c:10bb::1fc3]) by smtp.gmail.com with ESMTPSA id v17sm1336826qkb.13.2020.10.29.09.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 09:16:47 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 07/12] catalyst: Factor out run_sequence() Date: Thu, 29 Oct 2020 12:16:27 -0400 Message-Id: <20201029161632.146732-7-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029161632.146732-1-mattst88@gentoo.org> References: <20201029161632.146732-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 1a5a1dba-3932-49cb-91a8-6bf9b4065393 X-Archives-Hash: 617e8e866926cca2616f1a6d1d6ab900 This is preparation for the next patch, which will run the build sequence in a separate mount namespace. Signed-off-by: Matt Turner --- 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 75c84baa..06ec8727 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): -- 2.26.2