35 lines
1.3 KiB
Python
Executable file
35 lines
1.3 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
def main(tree, options):
|
|
root_fs_uuid = options["root_fs_uuid"]
|
|
|
|
# Create the configuration file that determines how grub.cfg is generated.
|
|
os.makedirs(f"{tree}/etc/default", exist_ok=True)
|
|
with open(f"{tree}/etc/default/grub", "w") as default:
|
|
default.write("GRUB_TIMEOUT=0\n"
|
|
"GRUB_ENABLE_BLSCFG=true\n")
|
|
|
|
os.makedirs(f"{tree}/boot/grub2", exist_ok=True)
|
|
with open(f"{tree}/boot/grub2/grubenv", "w") as env:
|
|
env.write("# GRUB Environment Block\n"
|
|
f"GRUB2_ROOT_FS_UUID={root_fs_uuid}\n"
|
|
f"GRUB2_BOOT_FS_UUID={root_fs_uuid}\n"
|
|
f"kernelopts=root=UUID={root_fs_uuid} rw\n")
|
|
with open(f"{tree}/boot/grub2/grub.cfg", "w") as cfg:
|
|
cfg.write("set timeout=0\n"
|
|
"load_env\n"
|
|
"search --no-floppy --fs-uuid --set=root ${GRUB2_ROOT_FS_UUID}\n"
|
|
"search --no-floppy --fs-uuid --set=boot ${GRUB2_BOOT_FS_UUID}\n"
|
|
"function load_video {\n"
|
|
" insmod all_video\n"
|
|
"}\n"
|
|
"blscfg\n")
|
|
|
|
if __name__ == '__main__':
|
|
args = json.load(sys.stdin)
|
|
r = main(args["tree"], args["options"])
|
|
sys.exit(r)
|