Skip to content

Commit

Permalink
cmd-buildextend-live: ensure files exist before writing kargs.json
Browse files Browse the repository at this point in the history
Rather than silently deleting files that no longer exist, flip this
around so that we assert they all exist. This will then ensure that new
code moving `grub.cfg` will also have to update `kargs_json`.
  • Loading branch information
jlebon committed Nov 7, 2022
1 parent d5cdce7 commit 37b7f46
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,11 @@ boot
'-efi-boot', 'images/efiboot.img',
'-no-emul-boot']

# We've done everything that might affect kargs, so filter out any files
# that no longer exist and write out the kargs JSON if it lists any files
kargs_json['files'] = [f for f in kargs_json['files']
if os.path.exists(os.path.join(tmpisoroot, f['path']))]
# Sanity-check that all kargs files that we found earlier still exist. This
# ensures that any modifications made also updated kargs_json as needed.
for f in kargs_json['files']:
fn = os.path.join(tmpisoroot, f['path'])
assert os.path.exists(fn), f"{fn} no longer exists"
kargs_json['files'].sort(key=lambda f: f['path'])
if kargs_json['files']:
# Store the location of "karg embed areas" for use by
Expand Down

0 comments on commit 37b7f46

Please sign in to comment.