]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
bootstrap: Add gnulib's base64 module
authorPatrick Steinhardt <ps@pks.im>
Fri, 27 Dec 2019 15:18:36 +0000 (16:18 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 10 Jan 2020 13:26:40 +0000 (14:26 +0100)
The upcoming support for LUKS2 disc encryption requires us to include a
parser for base64-encoded data, as it is used to represent salts and
digests. As gnulib already has code to decode such data, we can just
add it to the boostrapping configuration in order to make it available
in GRUB.

The gnulib module makes use of booleans via the <stdbool.h> header. As
GRUB does not provide any POSIX wrapper header for this, but instead
implements support for bool in <sys/types.h>, we need to patch
base64.h to not use <stdbool.h> anymore. We unfortunately cannot include
<sys/types.h> instead, as it would then use gnulib's internal header
while compiling the gnulib object but our own <sys/types.h> when
including it in a GRUB module. Because of this, the patch replaces the
include with a direct typedef.

A second fix is required to make available _GL_ATTRIBUTE_CONST, which
is provided by the configure script. As base64.h does not include
<config.h>, it is thus not available and results in a compile error.
This is fixed by adding an include of <config-util.h>.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
bootstrap.conf
conf/Makefile.extra-dist
grub-core/lib/gnulib-patches/fix-base64.patch [new file with mode: 0644]

index 988dda099aca8314b0d8857e2666a7f75ba1612b..22b908f36e3d67ff73bc6b41cb0cb42c05824314 100644 (file)
@@ -23,6 +23,7 @@ GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263
 # directly.
 gnulib_modules="
   argp
+  base64
   error
   fnmatch
   getdelim
@@ -78,7 +79,7 @@ cp -a INSTALL INSTALL.grub
 
 bootstrap_post_import_hook () {
   set -e
-  for patchname in fix-null-deref fix-width no-abort; do
+  for patchname in fix-base64 fix-null-deref fix-width no-abort; do
     patch -d grub-core/lib/gnulib -p2 \
       < "grub-core/lib/gnulib-patches/$patchname.patch"
   done
index 46c4e95e2faf51b0dca85fae614219d4b0b3efad..32b2178537d5d02744d66633f49b08e28de4be00 100644 (file)
@@ -28,6 +28,7 @@ EXTRA_DIST += grub-core/gensymlist.sh
 EXTRA_DIST += grub-core/genemuinit.sh
 EXTRA_DIST += grub-core/genemuinitheader.sh
 
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-base64.patch
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
 EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch b/grub-core/lib/gnulib-patches/fix-base64.patch
new file mode 100644 (file)
index 0000000..e075b6f
--- /dev/null
@@ -0,0 +1,23 @@
+diff --git a/lib/base64.h b/lib/base64.h
+index 9cd0183b8..a2aaa2d4a 100644
+--- a/lib/base64.h
++++ b/lib/base64.h
+@@ -18,11 +18,16 @@
+ #ifndef BASE64_H
+ # define BASE64_H
++/* Get _GL_ATTRIBUTE_CONST */
++# include <config-util.h>
++
+ /* Get size_t. */
+ # include <stddef.h>
+-/* Get bool. */
+-# include <stdbool.h>
++#ifndef GRUB_POSIX_BOOL_DEFINED
++typedef enum { false = 0, true = 1 } bool;
++#define GRUB_POSIX_BOOL_DEFINED 1
++#endif
+ # ifdef __cplusplus
+ extern "C" {