install: embed_firmware: use correct suffix (MR 1979)

Embed the firmware from the right chroot suffix. Previously it would
always use the rootfs_{args.device} chroot, which does not work anymore
with upcoming 'pmbootstrap install --ondev --no-rootfs' as there will
only be the installer_{args.device} chroot.
This commit is contained in:
Oliver Smith 2020-10-06 17:44:56 +02:00 committed by Luca Weiss
parent 6793612a7e
commit a1d9f66d96
No known key found for this signature in database
GPG key ID: 72D843B89D4DD756

View file

@ -342,13 +342,16 @@ def setup_hostname(args):
pmb.chroot.root(args, ["sed", "-i", "-e", regex, "/etc/hosts"], suffix) pmb.chroot.root(args, ["sed", "-i", "-e", regex, "/etc/hosts"], suffix)
def embed_firmware(args): def embed_firmware(args, suffix):
""" """
This method will embed firmware, located at /usr/share, that are specified This method will embed firmware, located at /usr/share, that are specified
by the "sd_embed_firmware" deviceinfo parameter into the SD card image by the "sd_embed_firmware" deviceinfo parameter into the SD card image
(e.g. u-boot). Binaries that would overwrite the first partition are not (e.g. u-boot). Binaries that would overwrite the first partition are not
accepted, and if multiple binaries are specified then they will be checked accepted, and if multiple binaries are specified then they will be checked
for collisions with each other. for collisions with each other.
:param suffix: of the chroot, which holds the firmware files (either the
f"rootfs_{args.device}", or f"installer_{args.device}")
""" """
if not args.deviceinfo["sd_embed_firmware"]: if not args.deviceinfo["sd_embed_firmware"]:
return return
@ -362,7 +365,7 @@ def embed_firmware(args):
"deviceinfo_sd_embed_firmware_step_size " "deviceinfo_sd_embed_firmware_step_size "
"is not valid: {}".format(step)) "is not valid: {}".format(step))
device_rootfs = mount_device_rootfs(args, f"rootfs_{args.device}") device_rootfs = mount_device_rootfs(args, suffix)
binaries = args.deviceinfo["sd_embed_firmware"].split(",") binaries = args.deviceinfo["sd_embed_firmware"].split(",")
# Perform three checks prior to writing binaries to disk: 1) that binaries # Perform three checks prior to writing binaries to disk: 1) that binaries
@ -377,12 +380,12 @@ def embed_firmware(args):
except ValueError: except ValueError:
raise RuntimeError("Value for firmware binary offset is " raise RuntimeError("Value for firmware binary offset is "
"not valid: {}".format(offset)) "not valid: {}".format(offset))
binary_path = os.path.join(args.work, "chroot_rootfs_" + binary_path = os.path.join(args.work, f"chroot_{suffix}", "usr/share",
args.device, "usr/share", binary) binary)
if not os.path.exists(binary_path): if not os.path.exists(binary_path):
raise RuntimeError("The following firmware binary does not " raise RuntimeError("The following firmware binary does not "
"exist in the device rootfs: " f"exist in the {suffix} chroot: "
"{}".format("/usr/share/" + binary)) f"/usr/share/{binary}")
# Insure that embedding the firmware will not overrun the # Insure that embedding the firmware will not overrun the
# first partition # first partition
boot_part_start = args.deviceinfo["boot_part_start"] or "2048" boot_part_start = args.deviceinfo["boot_part_start"] or "2048"
@ -495,7 +498,7 @@ def install_system_image(args, size_reserve, suffix, step, steps,
create_home_from_skel(args) create_home_from_skel(args)
configure_apk(args) configure_apk(args)
copy_ssh_keys(args) copy_ssh_keys(args)
embed_firmware(args) embed_firmware(args, suffix)
pmb.chroot.shutdown(args, True) pmb.chroot.shutdown(args, True)
# Convert rootfs to sparse using img2simg # Convert rootfs to sparse using img2simg