From 34106bcee68974843ecb1164eb65f24b21a7d63e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 10 Apr 2022 13:37:44 -0400 Subject: [PATCH] Serialize `grub-script` literally into image.json Prep for injecting `image.json` into the ostree commit. To make that meaningful, it has to be entirely independent of coreos-assembler. This bit is crucial for being able to do image builds in a manner independent of coreos-assembler's content, using solely the ostree commit as input. --- src/cosalib/cmdlib.py | 3 +++ src/create_disk.sh | 2 +- src/image-default.yaml | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cosalib/cmdlib.py b/src/cosalib/cmdlib.py index 8bf128edc1..33e605d2cd 100644 --- a/src/cosalib/cmdlib.py +++ b/src/cosalib/cmdlib.py @@ -354,6 +354,9 @@ def generate_image_json(srcfile): r = yaml.safe_load(open("/usr/lib/coreos-assembler/image-default.yaml")) for k, v in flatten_image_yaml(srcfile).items(): r[k] = v + # Serialize our default GRUB config + with open("/usr/lib/coreos-assembler/grub.cfg") as f: + r['grub-script'] = f.read() return r diff --git a/src/create_disk.sh b/src/create_disk.sh index 61d52cd963..370bb2d311 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -364,7 +364,7 @@ install_grub_cfg() { # 0700 to match the RPM permissions which I think are mainly in case someone has # manually set a grub password mkdir -p -m 0700 $rootfs/boot/grub2 - cp -v $grub_script $rootfs/boot/grub2/grub.cfg + printf "%s" "$grub_script" > $rootfs/boot/grub2/grub.cfg } # Other arch-specific bootloader changes diff --git a/src/image-default.yaml b/src/image-default.yaml index 2810c34b05..c4bc05798a 100644 --- a/src/image-default.yaml +++ b/src/image-default.yaml @@ -4,7 +4,6 @@ bootfs: "ext4" rootfs: "xfs" # Add arguments here that will be passed to e.g. mkfs.xfs rootfs-args: "" -grub-script: "/usr/lib/coreos-assembler/grub.cfg" # Additional default kernel arguments injected into disk images extra-kargs: []