]> git.proxmox.com Git - grub2.git/commitdiff
add gcry to utils
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 17:04:21 +0000 (19:04 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 17:04:21 +0000 (19:04 +0200)
.bzrignore
Makefile.util.def
autogen.sh
include/grub/crypto.h
util/grub-probe.c
util/import_gcry.py

index 55cbdaeebec34f44a31a083e92fe64aba0dc7183..204fc182fb9ec6684b2232ed8d854264f0b443cf 100644 (file)
@@ -135,3 +135,4 @@ widthspec.bin
 widthspec.h
 docs/stamp-1
 docs/version-dev.texi
+Makefile.utilgcry.def
index 40c67c2330cfd466b39fdb7a08d5720a15f4624c..693a7d127b536a0bf3b6e306586ee7bd86033f6f 100644 (file)
@@ -21,12 +21,16 @@ library = {
   common = grub-core/kern/list.c;
   common = grub-core/kern/misc.c;
   common = grub-core/kern/partition.c;
+  common = grub-core/lib/crypto.c;
+  common = grub-core/disk/luks.c;
+  common = grub-core/disk/AFSplitter.c;
+  common = grub-core/lib/pbkdf2.c;
+  common = grub-core/commands/extcmd.c;
+  common = grub-core/lib/arg.c;
 };
 
 library = {
   name = libgrubmods.a;
-  cflags = '$(CFLAGS_GCRY)';
-  cppflags = '$(CPPFLAGS_GCRY)';
 
   common_nodist = grub_script.tab.c;
   common_nodist = grub_script.yy.c;
@@ -35,7 +39,6 @@ library = {
   common_nodist = grub_script.tab.h;
 
   common = grub-core/commands/blocklist.c;
-  common = grub-core/commands/extcmd.c;
   common = grub-core/commands/ls.c;
   common = grub-core/disk/dmraid_nvidia.c;
   common = grub-core/disk/loopback.c;
@@ -75,15 +78,10 @@ library = {
   common = grub-core/fs/zfs/zfs_lzjb.c;
   common = grub-core/fs/zfs/zfs_sha256.c;
   common = grub-core/fs/zfs/zfs_fletcher.c;
-  common = grub-core/lib/arg.c;
-  common = grub-core/lib/crypto.c;
   common = grub-core/lib/envblk.c;
   common = grub-core/lib/hexdump.c;
-  common = grub-core/lib/libgcrypt-grub/cipher/sha512.c;
-  common = grub-core/lib/libgcrypt-grub/cipher/crc.c;
   common = grub-core/lib/LzFind.c;
   common = grub-core/lib/LzmaEnc.c;
-  common = grub-core/lib/pbkdf2.c;
   common = grub-core/lib/crc.c;
   common = grub-core/normal/datetime.c;
   common = grub-core/normal/misc.c;
@@ -123,6 +121,7 @@ program = {
 
   ldadd = libgrubmods.a;
   ldadd = libgrubkern.a;
+  ldadd = libgrubgcry.a;
   ldadd = grub-core/gnulib/libgnu.a;
   ldadd = '$(LIBLZMA)';
   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
@@ -173,6 +172,7 @@ program = {
 
   ldadd = libgrubmods.a;
   ldadd = libgrubkern.a;
+  ldadd = libgrubgcry.a;
   ldadd = grub-core/gnulib/libgnu.a;
   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
   cflags = '$(CFLAGS_GCRY)';
@@ -211,6 +211,7 @@ program = {
 
   ldadd = libgrubmods.a;
   ldadd = libgrubkern.a;
+  ldadd = libgrubgcry.a;
   ldadd = grub-core/gnulib/libgnu.a;
   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
 };
@@ -257,6 +258,7 @@ program = {
 
   ldadd = libgrubmods.a;
   ldadd = libgrubkern.a;
+  ldadd = libgrubgcry.a;
   ldadd = grub-core/gnulib/libgnu.a;
   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
 };
index d14707aadd5641b7e4a8b548cca6f298688b355c..db719cd1decaed9f75dfbe70a95087c9d0d9aacf 100755 (executable)
@@ -26,7 +26,7 @@ if [ "x${GRUB_CONTRIB}" != x ]; then
   [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
 fi
 
-UTIL_DEFS=Makefile.util.def
+UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
 CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
 
 for extra in contrib/*/Makefile.util.def; do
index ebe78e7a1a1468b20c8f183815ab4c89a423e664..a8ca2106dc210932f6df11c5334b1e8c8959c549 100644 (file)
@@ -274,4 +274,10 @@ grub_password_get (char buf[], unsigned buf_size);
 
 extern void (*grub_crypto_autoload_hook) (const char *name);
 
+#ifdef GRUB_UTIL
+void grub_gcry_init_all (void);
+void grub_gcry_fini_all (void);
+#endif
+
+
 #endif
index 0d5dac9021df260df50884d2271f1445c2b8155b..6c6220b8b7b660e64f6a84502c9ba32fe5266d10 100644 (file)
@@ -393,6 +393,7 @@ main (int argc, char *argv[])
 
   /* Initialize all modules. */
   grub_init_all ();
+  grub_gcry_init_all ();
 
   grub_lvm_fini ();
   grub_mdraid09_fini ();
@@ -410,6 +411,7 @@ main (int argc, char *argv[])
     probe (argument, NULL);
 
   /* Free resources.  */
+  grub_gcry_fini_all ();
   grub_fini_all ();
   grub_util_biosdisk_fini ();
 
index b2a0a54519f7cb2c3491429148e1c634343e39bc..3a110f0281d2ff5900c964fac04d671379a86b86 100644 (file)
@@ -42,7 +42,15 @@ except:
 cipher_files = os.listdir (cipher_dir_in)
 conf = open (os.path.join ("grub-core", "Makefile.gcry.def"), "w")
 conf.write ("AutoGen definitions Makefile.tpl;\n\n")
+confutil = open ("Makefile.utilgcry.def", "w")
+confutil.write ("AutoGen definitions Makefile.tpl;\n\n")
+confutil.write ("library = {\n");
+confutil.write ("  name = libgrubgcry.a;\n");
+confutil.write ("  cflags = '$(CFLAGS_GCRY)';\n");
+confutil.write ("  cppflags = '$(CPPFLAGS_GCRY)';\n");
+confutil.write ("\n");
 chlog = ""
+modules = []
 
 # Strictly speaking CRC32/CRC24 work on bytes so this value should be 1
 # But libgcrypt uses 64. Let's keep the value for compatibility. Since
@@ -249,6 +257,7 @@ for cipher_file in cipher_files:
                     % (cipher_file, cipher_file.replace ("-glue.c", ".c"))
             else:
                 modfiles = "lib/libgcrypt-grub/cipher/%s" % cipher_file
+            modules.append (modname)
             chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname
             if nch:
                 chlognew = "%s\n       %s" % (chlognew, chmsg)
@@ -283,6 +292,7 @@ for cipher_file in cipher_files:
             conf.write ("  name = %s;\n" % modname)
             for src in modfiles.split():
                 conf.write ("  common = %s;\n" % src)
+                confutil.write ("  common = grub-core/%s;\n" % src)
             conf.write ("  cflags = '$(CFLAGS_GCRY)';\n");
             conf.write ("  cppflags = '$(CPPFLAGS_GCRY)';\n");
             conf.write ("};\n\n")
@@ -329,6 +339,32 @@ fw.close ()
 infile = os.path.join (cipher_dir_in, "ChangeLog")
 outfile = os.path.join (cipher_dir_out, "ChangeLog")
 
+conf.close ();
+
+initfile = open (os.path.join (cipher_dir_out, "init.c"), "w")
+for module in modules:
+    initfile.write ("extern void grub_%s_init (void);\n" % module)
+    initfile.write ("extern void grub_%s_fini (void);\n" % module)
+initfile.write ("\n")
+initfile.write ("void\n")
+initfile.write ("grub_gcry_init_all (void)\n")
+initfile.write ("{\n")
+for module in modules:
+    initfile.write ("  grub_%s_init ();\n" % module)
+initfile.write ("}\n")
+initfile.write ("\n")
+initfile.write ("void\n")
+initfile.write ("grub_gcry_fini_all (void)\n")
+initfile.write ("{\n")
+for module in modules:
+    initfile.write ("  grub_%s_fini ();\n" % module)
+initfile.write ("}\n")
+initfile.close ()
+
+confutil.write ("  common = grub-core/lib/libgcrypt-grub/cipher/init.c;\n")
+confutil.write ("};\n");
+confutil.close ();
+
 
 f=open (infile, "r")
 fw=open (outfile, "w")