diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2022-07-30 10:24:04 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-02 11:30:00 +0100 |
commit | be0ca8e685cb8aa6eb408147323f951635c8df0f (patch) | |
tree | 3aac4653d0deef97650cc4ebfaf35032476a7138 /scripts/lib | |
parent | 44cc49c67984f039dd9a9ef10681ef7ac381529a (diff) | |
download | poky-be0ca8e685cb8aa6eb408147323f951635c8df0f.tar.gz |
wic/bootimg-efi: Factor out some common bits
The paths for configuring grub and systemd-boot have some common bits
around copying the initrd files. This will even grow when adding dtb
support. Factor this out into a class function.
Along this, avoid evaluating 'create-unified-kernel-image' multiple
times in do_configure_systemdboot and suppress a bogus warning about
"Ignoring missing initrd" when it is turned on.
(From OE-Core rev: c700cfd88473b9ed4e12a6620fb089f41bd95a9e)
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index a65a5b9780..57e79f4516 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -35,6 +35,20 @@ class BootimgEFIPlugin(SourcePlugin): | |||
35 | name = 'bootimg-efi' | 35 | name = 'bootimg-efi' |
36 | 36 | ||
37 | @classmethod | 37 | @classmethod |
38 | def _copy_additional_files(cls, hdddir, initrd): | ||
39 | if initrd: | ||
40 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
41 | if not bootimg_dir: | ||
42 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
43 | |||
44 | initrds = initrd.split(';') | ||
45 | for rd in initrds: | ||
46 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) | ||
47 | exec_cmd(cp_cmd, True) | ||
48 | else: | ||
49 | logger.debug("Ignoring missing initrd") | ||
50 | |||
51 | @classmethod | ||
38 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): | 52 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): |
39 | """ | 53 | """ |
40 | Create loader-specific (grub-efi) config | 54 | Create loader-specific (grub-efi) config |
@@ -54,17 +68,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
54 | 68 | ||
55 | initrd = source_params.get('initrd') | 69 | initrd = source_params.get('initrd') |
56 | 70 | ||
57 | if initrd: | 71 | cls._copy_additional_files(hdddir, initrd) |
58 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
59 | if not bootimg_dir: | ||
60 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
61 | |||
62 | initrds = initrd.split(';') | ||
63 | for rd in initrds: | ||
64 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) | ||
65 | exec_cmd(cp_cmd, True) | ||
66 | else: | ||
67 | logger.debug("Ignoring missing initrd") | ||
68 | 72 | ||
69 | if not custom_cfg: | 73 | if not custom_cfg: |
70 | # Create grub configuration using parameters from wks file | 74 | # Create grub configuration using parameters from wks file |
@@ -119,25 +123,17 @@ class BootimgEFIPlugin(SourcePlugin): | |||
119 | 123 | ||
120 | bootloader = creator.ks.bootloader | 124 | bootloader = creator.ks.bootloader |
121 | 125 | ||
126 | unified_image = source_params.get('create-unified-kernel-image') == "true" | ||
127 | |||
122 | loader_conf = "" | 128 | loader_conf = "" |
123 | if source_params.get('create-unified-kernel-image') != "true": | 129 | if not unified_image: |
124 | loader_conf += "default boot\n" | 130 | loader_conf += "default boot\n" |
125 | loader_conf += "timeout %d\n" % bootloader.timeout | 131 | loader_conf += "timeout %d\n" % bootloader.timeout |
126 | 132 | ||
127 | initrd = source_params.get('initrd') | 133 | initrd = source_params.get('initrd') |
128 | 134 | ||
129 | if initrd and source_params.get('create-unified-kernel-image') != "true": | 135 | if not unified_image: |
130 | # obviously we need to have a common common deploy var | 136 | cls._copy_additional_files(hdddir, initrd) |
131 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
132 | if not bootimg_dir: | ||
133 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
134 | |||
135 | initrds = initrd.split(';') | ||
136 | for rd in initrds: | ||
137 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) | ||
138 | exec_cmd(cp_cmd, True) | ||
139 | else: | ||
140 | logger.debug("Ignoring missing initrd") | ||
141 | 137 | ||
142 | logger.debug("Writing systemd-boot config " | 138 | logger.debug("Writing systemd-boot config " |
143 | "%s/hdd/boot/loader/loader.conf", cr_workdir) | 139 | "%s/hdd/boot/loader/loader.conf", cr_workdir) |
@@ -185,7 +181,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
185 | for rd in initrds: | 181 | for rd in initrds: |
186 | boot_conf += "initrd /%s\n" % rd | 182 | boot_conf += "initrd /%s\n" % rd |
187 | 183 | ||
188 | if source_params.get('create-unified-kernel-image') != "true": | 184 | if not unified_image: |
189 | logger.debug("Writing systemd-boot config " | 185 | logger.debug("Writing systemd-boot config " |
190 | "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) | 186 | "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) |
191 | cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") | 187 | cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") |