Skip to content

Commit

Permalink
cmd-buildextend-live: avoid no-op renameat(2) for FCOS
Browse files Browse the repository at this point in the history
On FCOS, the EFI directory is already correctly named in the src config
repo. So there's no need to do any renames at all. The previous code
still worked because `renameat(2)` with the src and dest being the same
file is a no-op.

This is a bit too implicit though. Let's just add a check to be more
clear. This avoids us also unnecessarily iterating over
`kargs_json['files']`.

While here, add a print statement when this logic kicks in.
  • Loading branch information
jlebon committed Nov 7, 2022
1 parent 37b7f46 commit 0bd4e72
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,15 @@ def generate_iso():
if len(grubfilepath) != 1:
raise Exception(f'Found != 1 grub.cfg files: {grubfilepath}')
srcpath = os.path.dirname(grubfilepath[0])
os.rename(srcpath, f"EFI/{vendor_id}", src_dir_fd=dfd, dst_dir_fd=dfd)
if srcpath != f'EFI/{vendor_id}':
print(f"Renaming '{srcpath}' to 'EFI/{vendor_id}'")
os.rename(srcpath, f"EFI/{vendor_id}", src_dir_fd=dfd, dst_dir_fd=dfd)
# And update kargs.json
for file in kargs_json['files']:
if file['path'] == grubfilepath[0]:
file['path'] = f'EFI/{vendor_id}/grub.cfg'
os.close(dfd)

# And update kargs.json
for file in kargs_json['files']:
if file['path'] == grubfilepath[0]:
file['path'] = f'EFI/{vendor_id}/grub.cfg'

# Delete fallback and its CSV file. Its purpose is to create
# EFI boot variables, which we don't want when booting from
# removable media.
Expand Down

0 comments on commit 0bd4e72

Please sign in to comment.