From 0bd4e723f50f0e7e8e79719bb231064cdec67ea4 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 7 Nov 2022 12:29:43 -0500 Subject: [PATCH] cmd-buildextend-live: avoid no-op `renameat(2)` for FCOS 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. --- src/cmd-buildextend-live | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cmd-buildextend-live b/src/cmd-buildextend-live index c95064f810..c913cf667e 100755 --- a/src/cmd-buildextend-live +++ b/src/cmd-buildextend-live @@ -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.