summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Parker <geoffhp@gmail.com>2018-10-11 09:31:26 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-04-25 15:01:21 +0100
commitbc7a89f5ecf1cb01275409ff798b8e2e831d1a72 (patch)
tree11e1fc505bdb12130dc3e9456e57aa14e07da005
parent87c218c00682c250c27cacd813a5ab9bb9aa1843 (diff)
downloadpoky-bc7a89f5ecf1cb01275409ff798b8e2e831d1a72.tar.gz
wic: make engine.py:get_partitions() resilient to parted/dmidecode stderr output
Running wic commands on Debian 10 systems fail in scripts/lib/wic/engine.py:get_partitions() due to new stderr output captured when trying to parse the output from /sbin/parted as a non-root user. The parted command calls the dmidecode utility, which produces this error as a non-root user: /sys/firmware/dmi/tables/smbios_entry_point: Permission denied /dev/mem: Permission denied scripts/lib/wic/engine.py:get_partitions() calls misc.py:exec_cmd(), a subprocess wrapper which returns a combined stderr and sdtdout. These messages to stderr confuse the partition table parser in get_partitions(). This patch has the partition table parser ignore lines before the expected "BYT;" header string. Running wic in Debian 9 does not have this issue. (From OE-Core rev: 6b5681533eed4e6c00e1cc7ee442c93076f1c976) Signed-off-by: Geoff Parker <geoffhp@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/engine.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 4996bfffe7..4eefc94b84 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -266,10 +266,15 @@ class Disk:
266 out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath)) 266 out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath))
267 parttype = namedtuple("Part", "pnum start end size fstype") 267 parttype = namedtuple("Part", "pnum start end size fstype")
268 splitted = out.splitlines() 268 splitted = out.splitlines()
269 lsector_size, psector_size, self._ptable_format = splitted[1].split(":")[3:6] 269 # skip over possible errors in exec_cmd output
270 try:
271 idx =splitted.index("BYT;")
272 except ValueError:
273 raise WicError("Error getting partition information from %s" % (self.parted))
274 lsector_size, psector_size, self._ptable_format = splitted[idx + 1].split(":")[3:6]
270 self._lsector_size = int(lsector_size) 275 self._lsector_size = int(lsector_size)
271 self._psector_size = int(psector_size) 276 self._psector_size = int(psector_size)
272 for line in splitted[2:]: 277 for line in splitted[idx + 2:]:
273 pnum, start, end, size, fstype = line.split(':')[:5] 278 pnum, start, end, size, fstype = line.split(':')[:5]
274 partition = parttype(int(pnum), int(start[:-1]), int(end[:-1]), 279 partition = parttype(int(pnum), int(start[:-1]), int(end[:-1]),
275 int(size[:-1]), fstype) 280 int(size[:-1]), fstype)