diff options
author | Anuj Mittal <anuj.mittal@intel.com> | 2018-07-12 10:05:24 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-07-18 10:18:42 +0100 |
commit | 82756dcac05f7494805c339bb7ffe193afe536db (patch) | |
tree | 5073a0efefb236e2f1c57a5a29f326db7cea4ef3 /scripts/lib | |
parent | f7792e58a20f0303e324ad5876c21c9924b08da7 (diff) | |
download | poky-82756dcac05f7494805c339bb7ffe193afe536db.tar.gz |
wic/engine: fix errors when expanding partitions
The UEFI spec implies that GPT partitions should be assumed to be on a 2048
sector boundary (for a 512 byte sector) and the current logic just
divides the free sectors available by the number of partitions that need
re-sizing, which may or may not align and the final result might
overshoot the limits imposed after alignment.
Since we are expanding already aligned partitions, just divide up the
free space in multiples of 2048. Also use the exec_cmd wrapper instead
of the subprocess call directly.
Fixes [YOCTO #12840]
(From OE-Core rev: 5eef63f5afdfbab8e30748cb1bf42bf2e6524759)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/engine.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 94992365df..fe036f60e9 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -391,11 +391,8 @@ class Disk: | |||
391 | def write_ptable(parts, target): | 391 | def write_ptable(parts, target): |
392 | with tempfile.NamedTemporaryFile(prefix="wic-sfdisk-", mode='w') as outf: | 392 | with tempfile.NamedTemporaryFile(prefix="wic-sfdisk-", mode='w') as outf: |
393 | write_sfdisk_script(outf, parts) | 393 | write_sfdisk_script(outf, parts) |
394 | cmd = "{} --no-reread {} < {} 2>/dev/null".format(self.sfdisk, target, outf.name) | 394 | cmd = "{} --no-reread {} < {} ".format(self.sfdisk, target, outf.name) |
395 | try: | 395 | exec_cmd(cmd, as_shell=True) |
396 | subprocess.check_output(cmd, shell=True) | ||
397 | except subprocess.CalledProcessError as err: | ||
398 | raise WicError("Can't run '{}' command: {}".format(cmd, err)) | ||
399 | 396 | ||
400 | if expand is None: | 397 | if expand is None: |
401 | sparse_copy(self.imagepath, target) | 398 | sparse_copy(self.imagepath, target) |
@@ -412,6 +409,8 @@ class Disk: | |||
412 | for line in exec_cmd("{} -F {}".format(self.sfdisk, target)).splitlines(): | 409 | for line in exec_cmd("{} -F {}".format(self.sfdisk, target)).splitlines(): |
413 | if line.startswith("Unpartitioned space ") and line.endswith("sectors"): | 410 | if line.startswith("Unpartitioned space ") and line.endswith("sectors"): |
414 | free = int(line.split()[-2]) | 411 | free = int(line.split()[-2]) |
412 | # Align free space to a 2048 sector boundary. YOCTO #12840. | ||
413 | free = free - (free % 2048) | ||
415 | if free is None: | 414 | if free is None: |
416 | raise WicError("Can't get size of unpartitioned space") | 415 | raise WicError("Can't get size of unpartitioned space") |
417 | 416 | ||