buildextend-live: remove deleted files from kargs.json
re-introduced the problem fixed by some arches
remove bootloader configs after the config file list has been generated.
Defer writing out kargs.json until later, and filter out files that no
longer exist.
Fixes: ("buildextend-live: add JSON file to the ISO with kargs embed info")
@@ -376,14 +376,10 @@ def generate_iso():
fh.write('#' * karg_embed_area_length)
fh.seek(0)
fh.write(cmdline)
- kargs_json['files'].sort(key=lambda f: f['path'])
kargs_json.update(
size=karg_embed_area_length,
default=cmdline.strip(),
)
- with open(os.path.join(tmpisocoreos, kargs_file), 'w') as fh:
- json.dump(kargs_json, fh, indent=2, sort_keys=True)
- fh.write('\n')
# These sections are based on lorax templates
# see https://github.com/weldr/lorax/tree/master/share/templates.d/99-generic
@@ -570,6 +566,16 @@ 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']))]
+ kargs_json['files'].sort(key=lambda f: f['path'])
+ if kargs_json['files']:
+ with open(os.path.join(tmpisocoreos, kargs_file), 'w') as fh:
+ json.dump(kargs_json, fh, indent=2, sort_keys=True)
+ fh.write('\n')
+
# Define inputs and outputs
genisoargs += ['-o', tmpisofile, tmpisoroot]
