From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#35283: [PATCH] grub-mkrescue: Allow users to specify a FAT serial number Date: Sun, 21 Apr 2019 18:32:21 +0200 Message-ID: <871s1v720a.fsf_-___3693.3582670585$1555864401$gmane$org@gnu.org> References: <875zrafck7.fsf_-_@gnu.org> <11201672983044432889@scdbackup.webframe.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:57477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIFOs-0002CP-DQ for bug-guix@gnu.org; Sun, 21 Apr 2019 12:33:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIFOq-0003ty-Js for bug-guix@gnu.org; Sun, 21 Apr 2019 12:33:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIFOp-0003t9-Is for bug-guix@gnu.org; Sun, 21 Apr 2019 12:33:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIFOn-0000RW-Ry for bug-guix@gnu.org; Sun, 21 Apr 2019 12:33:03 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <11201672983044432889@scdbackup.webframe.org> (Thomas Schmitt's message of "Fri, 19 Apr 2019 14:46:48 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: bug-grub@gnu.org Cc: 35283@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, While investigating reproducible ISO images for Guix=C2=B9, I found that =E2=80=98grub-mkrescue=E2=80=99 would invoke =E2=80=99mformat=E2=80=99 with= out the =E2=80=98-N=E2=80=99 option. Consequently, =E2=80=98mformat=E2=80=99 would pick a random serial number, = thereby making the =E2=80=98efi.img=E2=80=99 build process non-deterministic. I came up with the gross hack attached: the =E2=80=98grub-mkrescue=E2=80=99= caller can set the =E2=80=98GRUB_FAT_SERIAL_NUMBER=E2=80=99 environment variable, which =E2=80=98grub-mkrescue=E2=80=99 translates into a =E2=80=98-N=E2=80=99 flag= for =E2=80=98mformat=E2=80=99. We could perhaps achieve the same result differently, for instance by adding an option to =E2=80=98grub-mkrescue=E2=80=99. WDYT? Thanks, Ludo=E2=80=99. =C2=B9 https://issues.guix.info/issue/35283 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=grub-efi-fat-serial-number.patch Content-Transfer-Encoding: quoted-printable Content-Description: the patch Change 'grub-mkrescue' to honor the 'GRUB_FAT_SERIAL_NUMBER' environment variable. That way, the caller can specify a fixed serial number (instead of the randomly chosen one) to create EFI images (the 'efi.img' file) that are reproducible bit-for-bit. Patch by Ludovic Court=C3=A8s . --- grub-2.02/util/grub-mkrescue.c 2019-04-20 19:15:26.180242812 +0200 +++ grub-2.02/util/grub-mkrescue.c 2019-04-20 21:56:34.672370849 +0200 @@ -788,8 +788,15 @@ main (int argc, char *argv[]) =20 efiimgfat =3D grub_util_path_concat (2, iso9660_dir, "efi.img"); int rv; - rv =3D grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2= 880", "-L", "16", "-i", - efiimgfat, "::", NULL }); + + const char *fat_serial_number =3D getenv ("GRUB_FAT_SERIAL_NUMBER"); + const char *mformat_args[] =3D + { "mformat", "-C", "-f", "2880", "-L", "16", + fat_serial_number !=3D NULL ? "-N" : "-C", + fat_serial_number !=3D NULL ? fat_serial_number : "-C", + "-i", efiimgfat, "::", NULL }; + + rv =3D grub_util_exec (mformat_args); if (rv !=3D 0) grub_util_error ("`%s` invocation failed\n", "mformat"); rv =3D grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efii= mgfat, efidir_efi, "::/", NULL }); --=-=-=--