From d5ae7d902a40f26a8c26f4c6d300226689738716 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Thu, 14 Jun 2018 09:52:03 -0700 Subject: Sumo refresh Update external subtrees to latest Yocto sumo. Change-Id: I8364f32bef079841c6e57f1c587f4b1bedf62fef Signed-off-by: Brad Bishop --- .../lib/wic/canned-wks/qemux86-directdisk.wks | 2 +- poky/scripts/lib/wic/engine.py | 17 +++++++++-------- poky/scripts/lib/wic/plugins/source/bootimg-efi.py | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) (limited to 'poky/scripts/lib/wic') diff --git a/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks b/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks index 1f8466af2..cfa32bd38 100644 --- a/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks +++ b/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks @@ -4,5 +4,5 @@ include common.wks.inc -bootloader --timeout=0 --append="vga=0 uvesafb.mode_option=640x480-32 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 " +bootloader --timeout=0 --append="vga=0 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 " diff --git a/poky/scripts/lib/wic/engine.py b/poky/scripts/lib/wic/engine.py index edcfab39e..f0c5ff0aa 100644 --- a/poky/scripts/lib/wic/engine.py +++ b/poky/scripts/lib/wic/engine.py @@ -284,8 +284,8 @@ class Disk: aname = "_%s" % name if aname not in self.__dict__: setattr(self, aname, find_executable(name, self.paths)) - if aname not in self.__dict__: - raise WicError("Can't find executable {}".format(name)) + if aname not in self.__dict__ or self.__dict__[aname] is None: + raise WicError("Can't find executable '{}'".format(name)) return self.__dict__[aname] return self.__dict__[name] @@ -391,11 +391,8 @@ class Disk: def write_ptable(parts, target): with tempfile.NamedTemporaryFile(prefix="wic-sfdisk-", mode='w') as outf: write_sfdisk_script(outf, parts) - cmd = "{} --no-reread {} < {} 2>/dev/null".format(self.sfdisk, target, outf.name) - try: - subprocess.check_output(cmd, shell=True) - except subprocess.CalledProcessError as err: - raise WicError("Can't run '{}' command: {}".format(cmd, err)) + cmd = "{} --no-reread {} < {} ".format(self.sfdisk, target, outf.name) + exec_cmd(cmd, as_shell=True) if expand is None: sparse_copy(self.imagepath, target) @@ -412,11 +409,14 @@ class Disk: for line in exec_cmd("{} -F {}".format(self.sfdisk, target)).splitlines(): if line.startswith("Unpartitioned space ") and line.endswith("sectors"): free = int(line.split()[-2]) + # Align free space to a 2048 sector boundary. YOCTO #12840. + free = free - (free % 2048) if free is None: raise WicError("Can't get size of unpartitioned space") # calculate expanded partitions sizes sizes = {} + num_auto_resize = 0 for num, part in enumerate(parts['partitiontable']['partitions'], 1): if num in expand: if expand[num] != 0: # don't resize partition if size is set to 0 @@ -426,10 +426,11 @@ class Disk: sizes[num] = sectors elif part['type'] != 'f': sizes[num] = -1 + num_auto_resize += 1 for num, part in enumerate(parts['partitiontable']['partitions'], 1): if sizes.get(num) == -1: - part['size'] += free // len(sizes) + part['size'] += free // num_auto_resize # write resized partition table to the target write_ptable(parts, target) diff --git a/poky/scripts/lib/wic/plugins/source/bootimg-efi.py b/poky/scripts/lib/wic/plugins/source/bootimg-efi.py index beb74d7a7..0eb86a079 100644 --- a/poky/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/poky/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -45,7 +45,7 @@ class BootimgEFIPlugin(SourcePlugin): name = 'bootimg-efi' @classmethod - def do_configure_grubefi(cls, creator, cr_workdir): + def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): """ Create loader-specific (grub-efi) config """ @@ -62,6 +62,18 @@ class BootimgEFIPlugin(SourcePlugin): raise WicError("configfile is specified but failed to " "get it from %s." % configfile) + initrd = source_params.get('initrd') + + if initrd: + bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not bootimg_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + + cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir) + exec_cmd(cp_cmd, True) + else: + logger.debug("Ignoring missing initrd") + if not custom_cfg: # Create grub configuration using parameters from wks file bootloader = creator.ks.bootloader @@ -76,6 +88,10 @@ class BootimgEFIPlugin(SourcePlugin): grubefi_conf += "linux %s root=%s rootwait %s\n" \ % (kernel, creator.rootdev, bootloader.append) + + if initrd: + grubefi_conf += "initrd /%s\n" % initrd + grubefi_conf += "}\n" logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg", @@ -167,7 +183,7 @@ class BootimgEFIPlugin(SourcePlugin): try: if source_params['loader'] == 'grub-efi': - cls.do_configure_grubefi(creator, cr_workdir) + cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params) elif source_params['loader'] == 'systemd-boot': cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) else: -- cgit v1.2.3