Implement kernel bootstrap up to building Linux.

This commit is contained in:
rick-masters 2023-03-31 18:08:50 +00:00
parent 5ea8dd3136
commit ecf99ab08b
52 changed files with 4898 additions and 139 deletions

View file

@ -34,6 +34,10 @@ 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")
if args.chroot or args.kernel:
config.write("KERNEL_BOOTSTRAP=False\n")
else:
config.write("KERNEL_BOOTSTRAP=True\n")
# pylint: disable=too-many-statements
def main():
@ -81,8 +85,7 @@ def main():
default="qemu-system-x86_64")
parser.add_argument("-qr", "--qemu-ram", help="Memory (in megabytes) allocated to QEMU VM",
default=4096)
parser.add_argument("-qk", "--kernel", help="Kernel to use (default is ./kernel)",
default="kernel")
parser.add_argument("-qk", "--kernel", help="Kernel to use (default is ./kernel)")
parser.add_argument("-b", "--bare-metal", help="Build images for bare metal",
action="store_true")
@ -108,6 +111,10 @@ def main():
if check_types() == 0:
raise ValueError("One of qemu, chroot, bwrap, or bare metal must be selected.")
if not args.kernel and os.path.isfile("kernel"):
print("WARNING: Implicit use of a provided kernel is DEPRECATED. Use the --kernel option!")
args.kernel = "kernel"
# Arch validation
if args.arch != "x86":
raise ValueError("Only x86 is supported at the moment.")
@ -199,27 +206,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:
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_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)
if args.kernel:
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')
else:
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')
if __name__ == "__main__":
main()