Implement kernel bootstrap up to building Linux.

This commit is contained in:
rick-masters 2023-03-01 04:08:10 +00:00
parent ae7e1f9498
commit 6881d5dcf8
56 changed files with 4869 additions and 209 deletions

View file

@ -34,6 +34,7 @@ def create_configuration_file(args):
config.write("CHROOT_ONLY_SYSA=" + str(args.bwrap) + "\n")
config.write("UPDATE_CHECKSUMS=" + str(args.update_checksums) + "\n")
config.write("DISK=sda1\n")
config.write("KERNEL_BOOTSTRAP=" + str(args.kernel_bootstrap) + "\n")
# pylint: disable=too-many-statements
def main():
@ -86,6 +87,9 @@ def main():
parser.add_argument("-b", "--bare-metal", help="Build images for bare metal",
action="store_true")
parser.add_argument("--kernel-bootstrap",
help="Bootstrap kernels.",
action="store_true")
args = parser.parse_args()
@ -199,27 +203,42 @@ print(shutil.which('chroot'))
'/init')
elif args.bare_metal:
system_c.prepare(create_disk_image=True)
system_a.prepare(create_initramfs=True)
print("Please:")
print(" 1. Take tmp/sysa/initramfs and your kernel, boot using this.")
print(" 2. Take tmp/sysc/disk.img and put this on a writable storage medium.")
if args.kernel_bootstrap:
system_a.prepare(create_initramfs=True, kernel_bootstrap=True)
print("Please:")
print(" 1. Take tmp/sysa/sysa.img and write it to a boot drive and then boot it.")
else:
system_c.prepare(create_disk_image=True)
system_a.prepare(create_initramfs=True)
print("Please:")
print(" 1. Take tmp/sysa/initramfs and your kernel, boot using this.")
print(" 2. Take tmp/sysc/disk.img and put this on a writable storage medium.")
else:
system_c.prepare(create_disk_image=True)
system_a.prepare(create_initramfs=True)
if args.kernel_bootstrap:
system_a.prepare(create_initramfs=True, kernel_bootstrap=True)
run(args.qemu_cmd,
'-enable-kvm',
'-m', "4G",
'-no-reboot',
'-drive', 'file=' + os.path.join(system_a.tmp_dir, 'sysa.img') + ',format=raw',
'-machine', 'kernel-irqchip=split',
'-nic', 'user,ipv6=off,model=e1000',
'-nographic')
else:
system_c.prepare(create_disk_image=True)
system_a.prepare(create_initramfs=True)
run(args.qemu_cmd,
'-enable-kvm',
'-m', str(args.qemu_ram) + 'M',
'-no-reboot',
'-hda', tmpdir.get_disk("sysc"),
'-nic', 'user,ipv6=off,model=e1000',
'-kernel', args.kernel,
'-initrd', system_a.initramfs_path,
'-nographic',
'-append', 'console=ttyS0')
run(args.qemu_cmd,
'-enable-kvm',
'-m', str(args.qemu_ram) + 'M',
'-no-reboot',
'-hda', tmpdir.get_disk("sysc"),
'-nic', 'user,ipv6=off,model=e1000',
'-kernel', args.kernel,
'-initrd', system_a.initramfs_path,
'-nographic',
'-append', 'console=ttyS0')
if __name__ == "__main__":
main()