[Concept,12/16] scripts: ubuntu-iso-to-uboot: Unlink stale output first

Message ID 20260421183511.2044469-13-sjg@u-boot.org
State New
Headers
Series efi-x86: Boot Ubuntu live ISOs via U-Boot + BLS, end to end |

Commit Message

Simon Glass April 21, 2026, 6:34 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

xorriso refuses to write into an existing non-empty file when -indev
and -outdev differ: it treats the outdev as a session to extend and
aborts with

  xorriso : FAILURE : -indev differs from -outdev and -outdev media
  holds non-zero data

This bites any second run, whether invoked by hand or by the
'qemu-efi-iso' writer method added to labgrid for the new CI role.

Unlink the destination so each invocation starts from a clean file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/ubuntu-iso-to-uboot.py | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/scripts/ubuntu-iso-to-uboot.py b/scripts/ubuntu-iso-to-uboot.py
index df38833a4c6..7fc20327f02 100755
--- a/scripts/ubuntu-iso-to-uboot.py
+++ b/scripts/ubuntu-iso-to-uboot.py
@@ -147,7 +147,13 @@  def repack_iso(
 
     -find is tolerant of missing files: if a distribution does not ship
     one of these binaries, the call is a no-op.
+
+    xorriso refuses to write to an existing non-empty file when -indev
+    and -outdev differ (it would treat the outdev as a session to
+    extend), so unlink any stale output first.
     """
+    if out_iso.exists():
+        out_iso.unlink()
     command.run(
         'xorriso',
         '-indev', str(in_iso),