From: geoffhp@gmail.com
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2] wic: make engine.py:get_partitions() resilient to parted/dmidecode stderr output
Date: Thu, 11 Oct 2018 09:31:26 -0700 [thread overview]
Message-ID: <20181011163126.10434-1-geoffhp@gmail.com> (raw)
From: Geoff Parker <geoffhp@gmail.com>
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.
Signed-off-by: Geoff Parker <geoffhp@gmail.com>
---
scripts/lib/wic/engine.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index e6c830ce78..4662c665c0 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -266,10 +266,15 @@ class Disk:
out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath))
parttype = namedtuple("Part", "pnum start end size fstype")
splitted = out.splitlines()
- lsector_size, psector_size, self._ptable_format = splitted[1].split(":")[3:6]
+ # skip over possible errors in exec_cmd output
+ try:
+ idx =splitted.index("BYT;")
+ except ValueError:
+ raise WicError("Error getting partition information from %s" % (self.parted))
+ lsector_size, psector_size, self._ptable_format = splitted[idx + 1].split(":")[3:6]
self._lsector_size = int(lsector_size)
self._psector_size = int(psector_size)
- for line in splitted[2:]:
+ for line in splitted[idx + 2:]:
pnum, start, end, size, fstype = line.split(':')[:5]
partition = parttype(int(pnum), int(start[:-1]), int(end[:-1]),
int(size[:-1]), fstype)
--
2.19.1
next reply other threads:[~2018-10-11 16:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 16:31 geoffhp [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-10-11 5:16 [PATCH v2] wic: make engine.py:get_partitions() resilient to parted/dmidecode stderr output geoffhp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011163126.10434-1-geoffhp@gmail.com \
--to=geoffhp@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox