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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5485C158046 for ; Sun, 13 Oct 2024 20:33:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1E798E085A; Sun, 13 Oct 2024 20:33:54 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 09EBEE085A for ; Sun, 13 Oct 2024 20:33:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4A6243430EF for ; Sun, 13 Oct 2024 20:33:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8420F1F45 for ; Sun, 13 Oct 2024 20:33:50 +0000 (UTC) From: "Andreas K. Hüttel" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andreas K. Hüttel" Message-ID: <1728851452.f23f553a565fbb22d25b52ef6e0bdc867a9323f2.dilfridge@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/targets/diskimage_stage2.py X-VCS-Directories: catalyst/targets/ X-VCS-Committer: dilfridge X-VCS-Committer-Name: Andreas K. Hüttel X-VCS-Revision: f23f553a565fbb22d25b52ef6e0bdc867a9323f2 X-VCS-Branch: master Date: Sun, 13 Oct 2024 20:33:50 +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: f0c3588b-490f-4625-9977-ecb1c8c1c8cc X-Archives-Hash: 8a449a31d66a07e685629ac03be68406 commit: f23f553a565fbb22d25b52ef6e0bdc867a9323f2 Author: Andreas K. Hüttel gentoo org> AuthorDate: Sun Oct 13 14:43:30 2024 +0000 Commit: Andreas K. Hüttel gentoo org> CommitDate: Sun Oct 13 20:30:52 2024 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f23f553a Add diskimage_stage2.py with parameters and sequence different from iso Signed-off-by: Andreas K. Hüttel gentoo.org> catalyst/targets/diskimage_stage2.py | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/catalyst/targets/diskimage_stage2.py b/catalyst/targets/diskimage_stage2.py new file mode 100644 index 00000000..bcad8b0d --- /dev/null +++ b/catalyst/targets/diskimage_stage2.py @@ -0,0 +1,114 @@ +""" +Disk image stage2 target, builds upon previous disk image stage1 tarball +""" +# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. + +from catalyst.support import (normpath, file_locate, CatalystError) +from catalyst.fileops import clear_dir +from catalyst.base.stagebase import StageBase + + +class diskimage_stage2(StageBase): + """ + Builder class for a disk image stage2 build. + """ + required_values = frozenset([ + "boot/kernel", + ]) + valid_values = required_values | frozenset([ + "diskimage/bootargs", + "diskimage/depclean", + "diskimage/empty", + "diskimage/fsops", + "diskimage/fsscript", + "diskimage/gk_mainargs", + "diskimage/modblacklist", + "diskimage/motd", + "diskimage/qcow2", + "diskimage/qcow2_size", + "diskimage/qcow2_efisize", + "diskimage/qcow2_roottype", + "diskimage/rcadd", + "diskimage/rcdel", + "diskimage/readme", + "diskimage/rm", + "diskimage/type", # generic, cloud-init, ssh, console + "diskimage/unmerge", + "diskimage/users", + "diskimage/verify", + "diskimage/volid", + "repos", + ]) + +# Types of bootable disk images planned for (diskimage/type): +# cloud-init - an image that starts cloud-init for configuration and then can be +# used out of the box +# console - an image that has an empty root password and allows passwordless +# login on the console only +# ssh - an image that populates /root/.ssh/authorized_keys and starts dhcp +# as well as sshd; obviously not fit for public distribution +# generic - an image with no means of logging in... needs postprocessing +# no services are started + + def __init__(self, spec, addlargs): + StageBase.__init__(self, spec, addlargs) + if "diskimage/type" not in self.settings: + self.settings["diskimage/type"] = "generic" + + file_locate(self.settings, ["controller_file"]) + + def set_spec_prefix(self): + self.settings["spec_prefix"] = "diskimage" + + def set_target_path(self): + '''Set the target path for the finished stage. + + This method runs the StageBase.set_target_path mehtod, + and additionally creates a staging directory for assembling + the final components needed to produce the iso image. + ''' + super(diskimage_stage2, self).set_target_path() + clear_dir(self.settings['target_path']) + + def run_local(self): + # what modules do we want to blacklist? + if "diskimage/modblacklist" in self.settings: + path = normpath(self.settings["chroot_path"] + + "/etc/modprobe.d/blacklist.conf") + try: + with open(path, "a") as myf: + myf.write("\n#Added by Catalyst:") + # workaround until config.py is using configparser + if isinstance(self.settings["diskimage/modblacklist"], str): + self.settings["diskimage/modblacklist"] = self.settings[ + "diskimage/modblacklist"].split() + for x in self.settings["diskimage/modblacklist"]: + myf.write("\nblacklist "+x) + except Exception as e: + raise CatalystError("Couldn't open " + + self.settings["chroot_path"] + + "/etc/modprobe.d/blacklist.conf.", + print_traceback=True) from e + + def set_action_sequence(self): + self.build_sequence.extend([ + self.run_local, + self.build_kernel + ]) + if "fetch" not in self.settings["options"]: + self.build_sequence.extend([ + self.preclean, + self.diskimage_update, + self.fsscript, + self.rcupdate, + self.unmerge, + ]) + self.finish_sequence.extend([ + self.remove, + self.empty, + self.clean, + self.create_qcow2, + ]) + self.set_completion_action_sequences() + # our output is the qcow2, not a stage archive + self.finish_sequence.remove(self.capture)