Re: [Test patch 2] Re: Duplicate files /boot/grub/locale/*.mo~ in iso file made by grub-mkrescue
Adam Purkrt <[email protected]> Sun, 1 Jun 2025 16:11:32 +0200
| Newsgroups | gmane.comp.boot-loaders.grub.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi, your patch works fine for me! Best regards, Adam On 6/1/25 2:32 PM, Thomas Schmitt wrote: > Hi, > > i implemented and tested a grub-install-common call to suppress the > creation of backup files. > So this is an alternative to my previous test patch (which deletes the > backup files before the xorriso run). Apply it to original GRUB, not to > the already patched version. > > My test run was on Debian 12 > > ./grub-mkrescue -o output_wo_backup.iso \ > --locale-directory=/usr/share/locale > > with a symbolic link from /usr/local/lib/grub to /usr/lib/grub . > > The number of files written by xorriso was 625, like with the other > patch. I looked for .mo~ files by > > xorriso -indev output_wo_backup.iso -lsl /boot/grub/locale -- > > but there were only the original .mo files. > > > Have a nice day :) > > Thomas > > > Signed-off-by: Thomas Schmitt <[email protected]> > > ======================================================================= > > diff --git a/include/grub/util/install.h b/include/grub/util/install.h > index 5c0a52ca2..5fbde58ed 100644 > --- a/include/grub/util/install.h > +++ b/include/grub/util/install.h > @@ -301,4 +301,15 @@ grub_set_install_backup_ponr (void) > } > #endif > > +/* > + * The call grub_set_install_no_backup() disables creation of backup files. > + * This is safe if the original files surely were not valid before the program > + * run which calls functions from grub-install-common. E.g. in grub-mkrescue > + * which installs files to a freshly created directory tree in /tmp. > + * If ever, grub_set_install_no_backup() should be called early in the program > + * run before any calls to functions like grub_install_copy_files(). > + */ > +void > +grub_set_install_no_backup (void); > + > #endif > diff --git a/util/grub-install-common.c b/util/grub-install-common.c > index 22bccb6a3..2273ebde6 100644 > --- a/util/grub-install-common.c > +++ b/util/grub-install-common.c > @@ -221,6 +221,14 @@ grub_set_install_backup_ponr (void) > } > #endif > > +static int grub_install_no_backup = 0; > + > +void > +grub_set_install_no_backup (void) > +{ > + grub_install_no_backup = 1; > +} > + > static void > clean_grub_dir_real (const char *di, enum clean_grub_dir_mode mode) > { > @@ -343,9 +351,16 @@ append_to_backup_dirs (const char *dir __attribute__ ((unused))) > static void > clean_grub_dir (const char *di) > { > - clean_grub_dir_real (di, CLEAN_BACKUP); > - clean_grub_dir_real (di, CREATE_BACKUP); > - append_to_backup_dirs (di); > + if (grub_install_no_backup) > + { > + clean_grub_dir_real (di, CLEAN_NEW); > + } > + else > + { > + clean_grub_dir_real (di, CLEAN_BACKUP); > + clean_grub_dir_real (di, CREATE_BACKUP); > + append_to_backup_dirs (di); > + } > } > > struct install_list > diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c > index 6dc71a8a1..11e372461 100644 > --- a/util/grub-mkrescue.c > +++ b/util/grub-mkrescue.c > @@ -519,6 +519,8 @@ main (int argc, char *argv[]) > xorriso_push ("mkisofs"); > xorriso_push ("-graft-points"); > > + grub_set_install_no_backup (); > + > iso9660_dir = grub_util_make_temporary_dir (); > grub_util_info ("temporary iso9660 dir is `%s'", iso9660_dir); > boot_grub = grub_util_path_concat (3, iso9660_dir, "boot", "grub"); > @@ -555,8 +557,6 @@ main (int argc, char *argv[]) > source_dirs[plat] = xstrdup (grub_install_source_directory); > } > > - grub_set_install_backup_ponr (); > - > if (system_area == SYS_AREA_AUTO || grub_install_source_directory) > { > if (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC]