diff options
author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2016-07-12 16:50:03 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-31 14:38:32 +0000 |
commit | 66d08e0fdad5deb0d5228a0fadb1a1ef5d0142cc (patch) | |
tree | 0cf212338616759660db5c025e1bf81f3c6056cb /scripts/lib/wic/plugins/source | |
parent | 62310b3726cbbbd34da74f90e7de92ad831aa297 (diff) | |
download | poky-66d08e0fdad5deb0d5228a0fadb1a1ef5d0142cc.tar.gz |
wic: Look for image artifacts in a common location
Rather than have each image type look for artifacts in image-specific
locations, move towards having them look for artifacts in a common
location, in this case DEPLOY_DIR_IMAGE
Use the existing deploy.bbclass to have the bootloaders put their binaries
in DEPLOY_DIR_IMAGE and then wic will find them and place them in the image
(From OE-Core rev: 1c8acea91e775b1b6f8b25e774aaba3e790fc59b)
Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins/source')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 39 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 18 |
2 files changed, 43 insertions, 14 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 305e910d6a..74a1557f91 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -42,7 +42,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
42 | name = 'bootimg-efi' | 42 | name = 'bootimg-efi' |
43 | 43 | ||
44 | @classmethod | 44 | @classmethod |
45 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir): | 45 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): |
46 | """ | 46 | """ |
47 | Create loader-specific (grub-efi) config | 47 | Create loader-specific (grub-efi) config |
48 | """ | 48 | """ |
@@ -82,7 +82,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
82 | cfg.close() | 82 | cfg.close() |
83 | 83 | ||
84 | @classmethod | 84 | @classmethod |
85 | def do_configure_systemdboot(cls, hdddir, creator, cr_workdir): | 85 | def do_configure_systemdboot(cls, hdddir, creator, cr_workdir, source_params): |
86 | """ | 86 | """ |
87 | Create loader-specific systemd-boot/gummiboot config | 87 | Create loader-specific systemd-boot/gummiboot config |
88 | """ | 88 | """ |
@@ -98,6 +98,19 @@ class BootimgEFIPlugin(SourcePlugin): | |||
98 | loader_conf += "default boot\n" | 98 | loader_conf += "default boot\n" |
99 | loader_conf += "timeout %d\n" % bootloader.timeout | 99 | loader_conf += "timeout %d\n" % bootloader.timeout |
100 | 100 | ||
101 | initrd = source_params.get('initrd') | ||
102 | |||
103 | if initrd: | ||
104 | # obviously we need to have a common common deploy var | ||
105 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
106 | if not bootimg_dir: | ||
107 | msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | ||
108 | |||
109 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir) | ||
110 | exec_cmd(cp_cmd, True) | ||
111 | else: | ||
112 | msger.debug("Ignoring missing initrd") | ||
113 | |||
101 | msger.debug("Writing systemd-boot config %s/hdd/boot/loader/loader.conf" \ | 114 | msger.debug("Writing systemd-boot config %s/hdd/boot/loader/loader.conf" \ |
102 | % cr_workdir) | 115 | % cr_workdir) |
103 | cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w") | 116 | cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w") |
@@ -127,6 +140,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
127 | boot_conf += "options LABEL=Boot root=%s %s\n" % \ | 140 | boot_conf += "options LABEL=Boot root=%s %s\n" % \ |
128 | (creator.rootdev, bootloader.append) | 141 | (creator.rootdev, bootloader.append) |
129 | 142 | ||
143 | if initrd: | ||
144 | boot_conf += "initrd /%s\n" % initrd | ||
145 | |||
130 | msger.debug("Writing systemd-boot config %s/hdd/boot/loader/entries/boot.conf" \ | 146 | msger.debug("Writing systemd-boot config %s/hdd/boot/loader/entries/boot.conf" \ |
131 | % cr_workdir) | 147 | % cr_workdir) |
132 | cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") | 148 | cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") |
@@ -148,9 +164,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
148 | 164 | ||
149 | try: | 165 | try: |
150 | if source_params['loader'] == 'grub-efi': | 166 | if source_params['loader'] == 'grub-efi': |
151 | cls.do_configure_grubefi(hdddir, creator, cr_workdir) | 167 | cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params) |
152 | elif source_params['loader'] == 'systemd-boot': | 168 | elif source_params['loader'] == 'systemd-boot': |
153 | cls.do_configure_systemdboot(hdddir, creator, cr_workdir) | 169 | cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) |
154 | else: | 170 | else: |
155 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) | 171 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) |
156 | except KeyError: | 172 | except KeyError: |
@@ -167,9 +183,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
167 | In this case, prepare content for an EFI (grub) boot partition. | 183 | In this case, prepare content for an EFI (grub) boot partition. |
168 | """ | 184 | """ |
169 | if not bootimg_dir: | 185 | if not bootimg_dir: |
170 | bootimg_dir = get_bitbake_var("HDDDIR") | 186 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
171 | if not bootimg_dir: | 187 | if not bootimg_dir: |
172 | msger.error("Couldn't find HDDDIR, exiting\n") | 188 | msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") |
173 | # just so the result notes display it | 189 | # just so the result notes display it |
174 | creator.set_bootimg_dir(bootimg_dir) | 190 | creator.set_bootimg_dir(bootimg_dir) |
175 | 191 | ||
@@ -181,17 +197,20 @@ class BootimgEFIPlugin(SourcePlugin): | |||
181 | (staging_kernel_dir, hdddir) | 197 | (staging_kernel_dir, hdddir) |
182 | exec_cmd(install_cmd) | 198 | exec_cmd(install_cmd) |
183 | 199 | ||
200 | |||
184 | try: | 201 | try: |
185 | if source_params['loader'] == 'grub-efi': | 202 | if source_params['loader'] == 'grub-efi': |
186 | shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, | 203 | shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, |
187 | "%s/grub.cfg" % cr_workdir) | 204 | "%s/grub.cfg" % cr_workdir) |
188 | cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir) | 205 | for mod in [x for x in os.listdir(bootimg_dir) if x.startswith("grub-efi-")]: |
189 | exec_cmd(cp_cmd, True) | 206 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[9:]) |
207 | exec_cmd(cp_cmd, True) | ||
190 | shutil.move("%s/grub.cfg" % cr_workdir, | 208 | shutil.move("%s/grub.cfg" % cr_workdir, |
191 | "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) | 209 | "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) |
192 | elif source_params['loader'] == 'systemd-boot': | 210 | elif source_params['loader'] == 'systemd-boot': |
193 | cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir) | 211 | for mod in [x for x in os.listdir(bootimg_dir) if x.startswith("systemd-")]: |
194 | exec_cmd(cp_cmd, True) | 212 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:]) |
213 | exec_cmd(cp_cmd, True) | ||
195 | else: | 214 | else: |
196 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) | 215 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) |
197 | except KeyError: | 216 | except KeyError: |
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py index a637ce5025..b54a2290d8 100644 --- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py +++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py | |||
@@ -249,6 +249,7 @@ class IsoImagePlugin(SourcePlugin): | |||
249 | part.rootfs_dir = rootfs_dir | 249 | part.rootfs_dir = rootfs_dir |
250 | 250 | ||
251 | # Prepare rootfs.img | 251 | # Prepare rootfs.img |
252 | hdd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
252 | img_iso_dir = get_bitbake_var("ISODIR") | 253 | img_iso_dir = get_bitbake_var("ISODIR") |
253 | rootfs_img = "%s/rootfs.img" % img_iso_dir | 254 | rootfs_img = "%s/rootfs.img" % img_iso_dir |
254 | if not os.path.isfile(rootfs_img): | 255 | if not os.path.isfile(rootfs_img): |
@@ -278,10 +279,19 @@ class IsoImagePlugin(SourcePlugin): | |||
278 | if os.path.isfile(part.source_file): | 279 | if os.path.isfile(part.source_file): |
279 | os.remove(part.source_file) | 280 | os.remove(part.source_file) |
280 | 281 | ||
281 | # Prepare initial ramdisk | 282 | # Support using a different initrd other than default |
282 | initrd = "%s/initrd" % img_iso_dir | 283 | if source_params.get('initrd'): |
283 | if not os.path.isfile(initrd): | 284 | initrd = source_params['initrd'] |
284 | initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir) | 285 | if not hdd_dir: |
286 | msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | ||
287 | cp_cmd = "cp %s/%s %s" % (hdd_dir, initrd, cr_workdir) | ||
288 | else: | ||
289 | # Prepare initial ramdisk | ||
290 | initrd = "%s/initrd" % hdd_dir | ||
291 | if not os.path.isfile(initrd): | ||
292 | initrd = "%s/initrd" % img_iso_dir | ||
293 | if not os.path.isfile(initrd): | ||
294 | initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir) | ||
285 | 295 | ||
286 | install_cmd = "install -m 0644 %s %s/initrd" \ | 296 | install_cmd = "install -m 0644 %s %s/initrd" \ |
287 | % (initrd, isodir) | 297 | % (initrd, isodir) |