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 E5C09138359 for ; Thu, 29 Oct 2020 16:16:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 337FBE098F; Thu, 29 Oct 2020 16:16:44 +0000 (UTC) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (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 2E44FE098F for ; Thu, 29 Oct 2020 16:16:44 +0000 (UTC) Received: by mail-qt1-f174.google.com with SMTP id i7so2168637qti.6 for ; Thu, 29 Oct 2020 09:16:44 -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=aEa7G2c8/gWJTRdfwbYTBKyQuKCrX0y0aKdTGWNftvY=; b=W0rveyeLF3NOQGlTutJkyhvq9IQTigUF/GSh6C8XgL92MLl+74z4blYI2NGKWfZSWT T/lAuBa0rpkvgW493z6y/48ASb5t/HJQ8vwvtXvyOREOZc+6UrBIFi5lKVeyX7WiiYrT dLELXpNwVg//a9ITkNJvn/rpwGZBL6bUYMUhpfos5V0dUAJZZtggwy6GxbZF+UYPnB17 U/tyGyLQztjHVN6AdvDt2608s4T8VoqEsi8m2WKK6Hoi2ghANVcqjtdZVra4vkFfehBB seLRRFCXYTLPKcaFFy5ztkseE4vVBaGgsDmmvR10i+CBrcyqmG/MjBG463mhQEU4Uifg Q60A== X-Gm-Message-State: AOAM532mDvz/UA9XwDDCLKchxe52zKSbHPriPOgDc/sx5Z5FGU7+SOGc m6lQ+po/VP7S6aGRdsv/BBWrcUNM6WE= X-Google-Smtp-Source: ABdhPJyynRuDG0zq/MxwKEwmE1IU3GPmY9kvZcux9nAVqOLxQuZ58p+r3lZwoDj5JuWkNi04Y7eBAA== X-Received: by 2002:ac8:27e7:: with SMTP id x36mr4376819qtx.131.1603988203025; Thu, 29 Oct 2020 09:16:43 -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 p24sm1271243qtq.79.2020.10.29.09.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 09:16:42 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 04/12] catalyst: Move action_sequence out of self.settings[] Date: Thu, 29 Oct 2020 12:16:24 -0400 Message-Id: <20201029161632.146732-4-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: e1d32cb4-963b-43a1-8197-ddc55148f206 X-Archives-Hash: ad1668192228d269e9254047eb4e96b9 This self.settings[] dictionary is very similar to the god object anti-pattern. Moving action_sequence out it starts us down the road of fixing this. Signed-off-by: Matt Turner --- catalyst/base/stagebase.py | 17 +++++++++-------- catalyst/targets/embedded.py | 2 +- catalyst/targets/livecd_stage1.py | 2 +- catalyst/targets/livecd_stage2.py | 6 +++--- catalyst/targets/netboot.py | 2 +- catalyst/targets/stage1.py | 12 ++++++------ catalyst/targets/stage4.py | 2 +- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 73eacfbe..801df2fb 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -64,6 +64,7 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) + self.action_sequence = [] self.set_valid_build_kernel_vars(addlargs) TargetBase.__init__(self, myspec, addlargs) @@ -477,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: - self.settings["action_sequence"] = ["remove_chroot"] + self.action_sequence = ["remove_chroot"] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "setup_confdir", "portage_overlay", @@ -499,14 +500,14 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: - self.settings["action_sequence"].append("capture") + self.action_sequence.append("capture") if "keepwork" in self.settings["options"]: - self.settings["action_sequence"].append("clear_autoresume") + self.action_sequence.append("clear_autoresume") elif "seedcache" in self.settings["options"]: - self.settings["action_sequence"].append("remove_autoresume") + self.action_sequence.append("remove_autoresume") else: - self.settings["action_sequence"].append("remove_autoresume") - self.settings["action_sequence"].append("remove_chroot") + self.action_sequence.append("remove_autoresume") + self.action_sequence.append("remove_chroot") def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1380,7 +1381,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.purge() failure = False - for x in self.settings["action_sequence"]: + for x in self.action_sequence: log.notice('--- Running action sequence: %s', x) sys.stdout.flush() try: diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 99739512..3899cf1b 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,7 +41,7 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "config_profile_link", "setup_confdir", diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index f0b6be8b..b8c26cb1 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,7 +23,7 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "config_profile_link", "setup_confdir", diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 88c0d95c..cac16b6e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,7 +87,7 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "config_profile_link", "setup_confdir", @@ -99,7 +99,7 @@ class livecd_stage2(StageBase): "build_kernel" ] if "fetch" not in self.settings["options"]: - self.settings['action_sequence'] += [ + self.action_sequence += [ "bootloader", "preclean", "livecd_update", @@ -115,4 +115,4 @@ class livecd_stage2(StageBase): "setup_overlay", "create_iso", ] - self.settings["action_sequence"].append("clear_autoresume") + self.action_sequence.append("clear_autoresume") diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 5620e0d3..61583f0d 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -160,7 +160,7 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "config_profile_link", "setup_confdir", diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 2c09a41f..89b30fe1 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -87,15 +87,15 @@ class stage1(StageBase): chroot for re-use in stage2 without the need to unpack it. ''' if "fetch" not in self.settings["options"]: - self.settings["action_sequence"].append("capture") + self.action_sequence.append("capture") if "keepwork" in self.settings["options"]: - self.settings["action_sequence"].append("clear_autoresume") + self.action_sequence.append("clear_autoresume") elif "seedcache" in self.settings["options"]: - self.settings["action_sequence"].append("remove_autoresume") - self.settings["action_sequence"].append("clean_stage1") + self.action_sequence.append("remove_autoresume") + self.action_sequence.append("clean_stage1") else: - self.settings["action_sequence"].append("remove_autoresume") - self.settings["action_sequence"].append("remove_chroot") + self.action_sequence.append("remove_autoresume") + self.action_sequence.append("remove_chroot") def clean_stage1(self): '''seedcache is enabled, so salvage the /tmp/stage1root, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 346c0845..eef24a73 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,7 +39,7 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): - self.settings['action_sequence'] = [ + self.action_sequence = [ "unpack", "config_profile_link", "setup_confdir", -- 2.26.2