@@ -35,9 +35,33 @@ echo -e "set timeout=3\nset timeout_style=menu\n$(cat ${ISO_EXTRACT_DIR}/boot/gr
35
35
sed -i ' /root=install:CDLABEL=INSTALL/ s|$| rd.kiwi.oem.installdevice={{.InstallDevice}} |' ${ISO_EXTRACT_DIR} /boot/grub2/grub.cfg
36
36
{{ end -}}
37
37
38
- # Ensure that kernel arguments are appended to ISO grub.cfg so they are applied to firstboot via kexec
39
38
{{ if (gt (len .KernelArgs) 0) -}}
40
- sed -i ' /root=install:CDLABEL=INSTALL/ s|$| rd.kiwi.install.pass.bootparam {{.KernelArgs}} |' ${ISO_EXTRACT_DIR} /boot/grub2/grub.cfg
39
+ # Remove all original kernel arguments from ISO command line that match input kernelArgs *and* have values
40
+ {{ range .KernelArgsList -}}
41
+ value=$( echo {{ . }} | cut -f1 -d" =" )
42
+ sed -i " s/$value =[^=]//" ${ISO_EXTRACT_DIR} /boot/grub2/grub.cfg
43
+ {{ end -}}
44
+
45
+ # Unpack the initrd from the SelfInstall ISO and copy the early microcode into new initrd
46
+ mkdir -p ${ISO_EXTRACT_DIR} /temp-initram/early/ ${ISO_EXTRACT_DIR} /temp-initram/main/
47
+ cp ${ISO_EXTRACT_DIR} /boot/x86_64/loader/initrd ${ISO_EXTRACT_DIR} /temp-initram/
48
+ cd ${ISO_EXTRACT_DIR} /temp-initram/early && lsinitrd --unpackearly ${ISO_EXTRACT_DIR} /temp-initram/initrd
49
+ find . -print0 | cpio --null --create --format=newc > ${ISO_EXTRACT_DIR} /temp-initram/new-initrd
50
+ # NOTE: We pipe the following command to true to avoid issues with mknod failing when unprivileged
51
+ cd ${ISO_EXTRACT_DIR} /temp-initram/main && lsinitrd --unpack ${ISO_EXTRACT_DIR} /temp-initram/initrd || true
52
+
53
+ # Remove the original kernel arguments from initrd config that match input kernelArgs and add desired ones
54
+ {{ range .KernelArgsList -}}
55
+ value=$( echo {{ . }} | cut -f1 -d" =" )
56
+ sed -i " s/$value =[^=]//" config.bootoptions
57
+ {{ end -}}
58
+ sed -i ' 1s|$| {{ .KernelArgs }}|' config.bootoptions
59
+
60
+ # Repack the contents of the initrd into the new file, including the new kernel cmdline arguments
61
+ find . | cpio --create --format=newc >> ${ISO_EXTRACT_DIR} /temp-initram/new-initrd
62
+
63
+ # Add the desired kernel cmdline arguments to the ISO kernel cmdline so they're available during deployment
64
+ sed -i ' /root=install:CDLABEL=INSTALL/ s|$| {{.KernelArgs}} |' ${ISO_EXTRACT_DIR} /boot/grub2/grub.cfg
41
65
{{ end -}}
42
66
43
67
cd ${RAW_EXTRACT_DIR}
@@ -51,5 +75,8 @@ xorriso -indev ${ISO_SOURCE} \
51
75
-map ${ARTEFACTS_DIR} /artefacts \
52
76
{{- if .InstallDevice }}
53
77
-map ${ISO_EXTRACT_DIR} /boot/grub2/grub.cfg /boot/grub2/grub.cfg \
78
+ {{- end }}
79
+ {{- if (gt (len .KernelArgs) 0) }}
80
+ -map ${ISO_EXTRACT_DIR} /temp-initram/new-initrd /boot/x86_64/loader/initrd \
54
81
{{- end }}
55
82
-boot_image any replay -changes_pending yes
0 commit comments