Opps, forgot to delete/add some of the updated patches in files/

This commit is contained in:
Kris Moore 2015-06-07 22:38:33 +00:00
parent 7d456e01cf
commit 12e4fe286a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=388791
13 changed files with 294 additions and 286 deletions

View file

@ -1,182 +0,0 @@
diff --git a/grub-core/osdep/freebsd/getroot.c b/grub-core/osdep/freebsd/getroot.c
index ccc1d70..64c0aad 100644
--- grub-core/osdep/freebsd/getroot.c
+++ grub-core/osdep/freebsd/getroot.c
@@ -296,6 +296,105 @@ grub_util_get_grub_dev_os (const char *os_dev)
return grub_dev;
}
+int grub_util_check_geom_label(const char *name)
+{
+ struct gmesh mesh;
+ struct gclass *class;
+ struct ggeom *geom;
+ struct gprovider *pp;
+ struct gprovider *pplabel;
+ struct gconsumer *cp;
+ const char *geom_name;
+ const char *test_name;
+ int err;
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ if (strcasecmp (class->lg_name, "label") == 0)
+ break;
+ if (!class)
+ grub_util_error ("%s", _("couldn't find geom `label' class"));
+
+ if (strncmp (name, "/dev/", sizeof ("/dev/") - 1) == 0)
+ test_name = name + sizeof ("/dev/") - 1;
+ else
+ test_name = name;
+
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ {
+ geom_name = pp->lg_name;
+ if (strcasecmp (geom_name, test_name) != 0)
+ continue;
+
+ LIST_FOREACH(cp, &geom->lg_consumer, lg_consumer)
+ {
+ pplabel = cp->lg_provider;
+ if (pplabel == NULL)
+ continue;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+const char *
+grub_util_convert_geom_label_to_dev (const char *name, int *full_path)
+{
+ struct gmesh mesh;
+ struct gclass *class;
+ struct ggeom *geom;
+ struct gprovider *pp;
+ struct gprovider *pplabel;
+ struct gconsumer *cp;
+ static char buf[256];
+ const char *geom_name;
+ int err;
+
+ grub_util_info ("Converting label '%s' to device", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ if (strcasecmp (class->lg_name, "label") == 0)
+ break;
+ if (!class)
+ grub_util_error ("%s", _("couldn't find geom `label' class"));
+
+
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ {
+ geom_name = pp->lg_name;
+ if (strcasecmp (geom_name, name) != 0)
+ continue;
+
+ LIST_FOREACH(cp, &geom->lg_consumer, lg_consumer)
+ {
+ pplabel = cp->lg_provider;
+ if (pplabel == NULL)
+ continue;
+
+ if ( full_path )
+ snprintf(buf, sizeof(buf), "/dev/%s", pplabel->lg_name);
+ else
+ snprintf(buf, sizeof(buf), "%s", pplabel->lg_name);
+ return buf;
+ }
+ }
+ }
+ grub_util_error ("%s", _("couldn't convert gptid to real device name"));
+ return 0;
+}
+
/* FIXME: geom actually gives us the whole container hierarchy.
It can be used more efficiently than this. */
void
diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
index e3887cb..cd010ce 100644
--- grub-core/osdep/unix/getroot.c
+++ grub-core/osdep/unix/getroot.c
@@ -504,6 +504,12 @@ grub_guess_root_devices (const char *dir_in)
if (!os_dev)
os_dev = find_root_devices_from_libzfs (dir);
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ if (os_dev)
+ if ( grub_util_check_geom_label(os_dev) )
+ os_dev = grub_util_convert_geom_label_to_dev (os_dev + sizeof ("/dev/") - 1, 1);
+#endif
+
if (os_dev)
{
char **cur;
diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h
index 73fa2d3..3c43db4 100644
--- include/grub/emu/getroot.h
+++ include/grub/emu/getroot.h
@@ -44,6 +44,8 @@ char *grub_util_get_grub_dev (const char *os_dev);
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
void grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out,
char **name_out);
+int grub_util_check_geom_label(const char *name);
+const char *grub_util_convert_geom_label_to_dev (const char *name, int *full_path);
#endif
#include <sys/stat.h>
diff --git a/util/grub-install.c b/util/grub-install.c
index 7d61c32..5900535 100644
--- util/grub-install.c
+++ util/grub-install.c
@@ -236,7 +236,16 @@ argp_parser (int key, char *arg, struct argp_state *state)
case ARGP_KEY_ARG:
if (install_device)
grub_util_error ("%s", _("More than one install device?"));
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ /* Check if passing a FreeBSD geom label */
+ if ( grub_util_check_geom_label(arg) )
+ install_device = \
+ xstrdup(grub_util_convert_geom_label_to_dev (arg + sizeof ("/dev/") - 1, 1));
+ else
install_device = xstrdup (arg);
+#else
+ install_device = xstrdup (arg);
+#endif
return 0;
default:
diff --git a/util/grub-probe.c b/util/grub-probe.c
index ecb7b6b..21e3fa3 100644
--- util/grub-probe.c
+++ util/grub-probe.c
@@ -799,7 +799,16 @@ argp_parser (int key, char *arg, struct argp_state *state)
case ARGP_KEY_ARG:
assert (arguments->ndevices < arguments->device_max);
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ /* Check if passing a FreeBSD geom label */
+ if ( grub_util_check_geom_label(arg) )
+ arguments->devices[arguments->ndevices++] = \
+ xstrdup(grub_util_convert_geom_label_to_dev (arg + sizeof ("/dev/") - 1, 1));
+ else
arguments->devices[arguments->ndevices++] = xstrdup(arg);
+#else
+ arguments->devices[arguments->ndevices++] = xstrdup(arg);
+#endif
break;
default:

View file

@ -1,76 +0,0 @@
--- grub-core/disk/geli.c.orig 2014-12-30 11:08:32.000000000 -0500
+++ grub-core/disk/geli.c 2015-01-13 13:42:46.758595608 -0500
@@ -225,7 +225,7 @@
/* Look for GELI magic sequence. */
if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header->version) > 5
+ || grub_le_to_cpu32 (header->version) > 7
|| grub_le_to_cpu32 (header->version) < 1)
grub_util_error ("%s", _("wrong ELI magic or version"));
@@ -265,7 +265,7 @@
/* Look for GELI magic sequence. */
if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header.version) > 5
+ || grub_le_to_cpu32 (header.version) > 7
|| grub_le_to_cpu32 (header.version) < 1)
{
grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
@@ -401,6 +401,7 @@
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
+ grub_uint8_t geli_cipher_key[64];
char passphrase[MAX_PASSPHRASE] = "";
unsigned i;
gcry_err_code_t gcry_err;
@@ -440,6 +441,9 @@
if (!grub_password_get (passphrase, MAX_PASSPHRASE))
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied");
+ /* Set the GELI passphrase to GRUB env, for passing to FreeBSD kernel */
+ grub_env_set ("gelipassphrase", passphrase);
+
/* Calculate the PBKDF2 of the user supplied passphrase. */
if (grub_le_to_cpu32 (header.niter) != 0)
{
@@ -524,6 +528,19 @@
continue;
grub_printf_ (N_("Slot %d opened\n"), i);
+ if (grub_le_to_cpu32 (header.version) >= 7)
+ {
+ /* GELI >=7 uses the cipher_key */
+ grub_memcpy (geli_cipher_key, candidate_key.cipher_key,
+ sizeof (candidate_key.cipher_key));
+ }
+ else
+ {
+ /* GELI <=6 uses the iv_key */
+ grub_memcpy (geli_cipher_key, candidate_key.iv_key,
+ sizeof (candidate_key.iv_key));
+ }
+
/* Set the master key. */
if (!dev->rekey)
{
@@ -540,13 +557,13 @@
grub_size_t real_keysize = keysize;
if (grub_le_to_cpu16 (header.alg) == 0x16)
real_keysize *= 2;
- /* For a reason I don't know, the IV key is used in rekeying. */
- grub_memcpy (dev->rekey_key, candidate_key.iv_key,
- sizeof (candidate_key.iv_key));
+
+ grub_memcpy (dev->rekey_key, geli_cipher_key,
+ sizeof (geli_cipher_key));
dev->rekey_derived_size = real_keysize;
dev->last_rekey = -1;
COMPILE_TIME_ASSERT (sizeof (dev->rekey_key)
- >= sizeof (candidate_key.iv_key));
+ >= sizeof (geli_cipher_key));
}
dev->iv_prefix_len = sizeof (candidate_key.iv_key);

View file

@ -0,0 +1,11 @@
--- grub-core/lib/libgcrypt/src/types.h.orig 2014-03-03 16:00:26 UTC
+++ grub-core/lib/libgcrypt/src/types.h
@@ -113,6 +113,8 @@
#endif
#endif
+typedef uint64_t u64;
+
typedef union {
int a;
short b;

View file

@ -0,0 +1,108 @@
--- grub-core/osdep/freebsd/getroot.c.orig 2015-01-23 02:27:45 UTC
+++ grub-core/osdep/freebsd/getroot.c
@@ -296,6 +296,105 @@ grub_util_get_grub_dev_os (const char *o
return grub_dev;
}
+int grub_util_check_geom_label(const char *name)
+{
+ struct gmesh mesh;
+ struct gclass *class;
+ struct ggeom *geom;
+ struct gprovider *pp;
+ struct gprovider *pplabel;
+ struct gconsumer *cp;
+ const char *geom_name;
+ const char *test_name;
+ int err;
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ if (strcasecmp (class->lg_name, "label") == 0)
+ break;
+ if (!class)
+ grub_util_error ("%s", _("couldn't find geom `label' class"));
+
+ if (strncmp (name, "/dev/", sizeof ("/dev/") - 1) == 0)
+ test_name = name + sizeof ("/dev/") - 1;
+ else
+ test_name = name;
+
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ {
+ geom_name = pp->lg_name;
+ if (strcasecmp (geom_name, test_name) != 0)
+ continue;
+
+ LIST_FOREACH(cp, &geom->lg_consumer, lg_consumer)
+ {
+ pplabel = cp->lg_provider;
+ if (pplabel == NULL)
+ continue;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+const char *
+grub_util_convert_geom_label_to_dev (const char *name, int *full_path)
+{
+ struct gmesh mesh;
+ struct gclass *class;
+ struct ggeom *geom;
+ struct gprovider *pp;
+ struct gprovider *pplabel;
+ struct gconsumer *cp;
+ static char buf[256];
+ const char *geom_name;
+ int err;
+
+ grub_util_info ("Converting label '%s' to device", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ if (strcasecmp (class->lg_name, "label") == 0)
+ break;
+ if (!class)
+ grub_util_error ("%s", _("couldn't find geom `label' class"));
+
+
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ LIST_FOREACH(pp, &geom->lg_provider, lg_provider)
+ {
+ geom_name = pp->lg_name;
+ if (strcasecmp (geom_name, name) != 0)
+ continue;
+
+ LIST_FOREACH(cp, &geom->lg_consumer, lg_consumer)
+ {
+ pplabel = cp->lg_provider;
+ if (pplabel == NULL)
+ continue;
+
+ if ( full_path )
+ snprintf(buf, sizeof(buf), "/dev/%s", pplabel->lg_name);
+ else
+ snprintf(buf, sizeof(buf), "%s", pplabel->lg_name);
+ return buf;
+ }
+ }
+ }
+ grub_util_error ("%s", _("couldn't convert gptid to real device name"));
+ return 0;
+}
+
/* FIXME: geom actually gives us the whole container hierarchy.
It can be used more efficiently than this. */
void

View file

@ -0,0 +1,15 @@
--- grub-core/osdep/unix/getroot.c.orig 2015-06-03 14:54:01 UTC
+++ grub-core/osdep/unix/getroot.c
@@ -507,6 +507,12 @@ grub_guess_root_devices (const char *dir
if (!os_dev)
os_dev = find_root_devices_from_libzfs (dir);
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ if (os_dev)
+ if ( grub_util_check_geom_label(os_dev) )
+ os_dev = grub_util_convert_geom_label_to_dev (os_dev + sizeof ("/dev/") - 1, 1);
+#endif
+
if (os_dev)
{
char **cur;

View file

@ -0,0 +1,100 @@
--- grub-core/osdep/unix/platform.c.orig 2014-03-03 16:00:26 UTC
+++ grub-core/osdep/unix/platform.c
@@ -81,52 +81,8 @@ get_ofpathname (const char *dev)
static void
grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
{
- int fd;
- pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd);
- char *line = NULL;
- size_t len = 0;
-
- if (!pid)
- {
- grub_util_warn (_("Unable to open stream from %s: %s"),
- "efibootmgr", strerror (errno));
- return;
- }
-
- FILE *fp = fdopen (fd, "r");
- if (!fp)
- {
- grub_util_warn (_("Unable to open stream from %s: %s"),
- "efibootmgr", strerror (errno));
- return;
- }
-
- line = xmalloc (80);
- len = 80;
- while (1)
- {
- int ret;
- char *bootnum;
- ret = getline (&line, &len, fp);
- if (ret == -1)
- break;
- if (grub_memcmp (line, "Boot", sizeof ("Boot") - 1) != 0
- || line[sizeof ("Boot") - 1] < '0'
- || line[sizeof ("Boot") - 1] > '9')
- continue;
- if (!strcasestr (line, efi_distributor))
- continue;
- bootnum = line + sizeof ("Boot") - 1;
- bootnum[4] = '\0';
- if (!verbosity)
- grub_util_exec ((const char * []){ "efibootmgr", "-q",
- "-b", bootnum, "-B", NULL });
- else
- grub_util_exec ((const char * []){ "efibootmgr",
- "-b", bootnum, "-B", NULL });
- }
-
- free (line);
+ // We don't have efibootmgr on FreeBSD, have to set externally
+ return;
}
void
@@ -134,40 +90,8 @@ grub_install_register_efi (grub_device_t
const char *efifile_path,
const char *efi_distributor)
{
- const char * efidir_disk;
- int efidir_part;
- efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk);
- efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1;
-
- if (grub_util_exec_redirect_null ((const char * []){ "efibootmgr", "--version", NULL }))
- {
- /* TRANSLATORS: This message is shown when required executable `%s'
- isn't found. */
- grub_util_error (_("%s: not found"), "efibootmgr");
- }
-
- /* On Linux, we need the efivars kernel modules. */
-#ifdef __linux__
- grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL });
-#endif
- /* Delete old entries from the same distributor. */
- grub_install_remove_efi_entries_by_distributor (efi_distributor);
-
- char *efidir_part_str = xasprintf ("%d", efidir_part);
-
- if (!verbosity)
- grub_util_exec ((const char * []){ "efibootmgr", "-q",
- "-c", "-d", efidir_disk,
- "-p", efidir_part_str, "-w",
- "-L", efi_distributor, "-l",
- efifile_path, NULL });
- else
- grub_util_exec ((const char * []){ "efibootmgr",
- "-c", "-d", efidir_disk,
- "-p", efidir_part_str, "-w",
- "-L", efi_distributor, "-l",
- efifile_path, NULL });
- free (efidir_part_str);
+ // We don't have efibootmgr on FreeBSD, have to set externally
+ return;
}
void

View file

@ -0,0 +1,11 @@
--- include/grub/emu/getroot.h.orig 2015-01-23 02:27:45 UTC
+++ include/grub/emu/getroot.h
@@ -44,6 +44,8 @@ char *grub_util_get_grub_dev (const char
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
void grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out,
char **name_out);
+int grub_util_check_geom_label(const char *name);
+const char *grub_util_convert_geom_label_to_dev (const char *name, int *full_path);
#endif
#include <sys/stat.h>

View file

@ -1,6 +1,6 @@
--- include/grub/gpt_partition.h.orig 2014-12-02 14:32:40.000000000 +0800
+++ include/grub/gpt_partition.h 2014-12-02 14:35:03.000000000 +0800
@@ -43,6 +43,14 @@
--- include/grub/gpt_partition.h.orig 2014-03-03 16:00:26 UTC
+++ include/grub/gpt_partition.h
@@ -43,6 +43,14 @@ typedef struct grub_gpt_part_type grub_g
{ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
}

View file

@ -0,0 +1,5 @@
--- po/LINGUAS.orig 2015-01-30 16:30:32 UTC
+++ po/LINGUAS
@@ -1 +1 @@
-ast ca da de de@hebrew de_CH en@arabic en@cyrillic en@greek en@hebrew en@piglatin en@quot eo es fi fr gl hu id it ja lt nb nl pa pl pt_BR ru sl sv tr uk vi zh_CN zh_TW
+ast ca da de eo es fi fr gl hu id it ja lt nb nl pa pl pt_BR ru sl sv tr uk vi zh_CN zh_TW

View file

@ -0,0 +1,19 @@
--- util/grub-install.c.orig 2015-06-03 14:54:01 UTC
+++ util/grub-install.c
@@ -236,7 +236,16 @@ argp_parser (int key, char *arg, struct
case ARGP_KEY_ARG:
if (install_device)
grub_util_error ("%s", _("More than one install device?"));
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ /* Check if passing a FreeBSD geom label */
+ if ( grub_util_check_geom_label(arg) )
+ install_device = \
+ xstrdup(grub_util_convert_geom_label_to_dev (arg + sizeof ("/dev/") - 1, 1));
+ else
+ install_device = xstrdup (arg);
+#else
install_device = xstrdup (arg);
+#endif
return 0;
default:

View file

@ -1,6 +1,6 @@
--- util/grub-mkconfig_lib.in.orig 2014-03-03 11:00:26.000000000 -0500
+++ util/grub-mkconfig_lib.in 2014-06-05 12:45:58.532199020 -0400
@@ -139,7 +139,17 @@
--- util/grub-mkconfig_lib.in.orig 2015-06-03 14:54:01 UTC
+++ util/grub-mkconfig_lib.in
@@ -139,7 +139,17 @@ prepare_grub_to_access_device ()
echo "insmod ${module}"
done

View file

@ -0,0 +1,19 @@
--- util/grub-probe.c.orig 2015-06-03 14:54:01 UTC
+++ util/grub-probe.c
@@ -805,7 +805,16 @@ argp_parser (int key, char *arg, struct
case ARGP_KEY_ARG:
assert (arguments->ndevices < arguments->device_max);
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ /* Check if passing a FreeBSD geom label */
+ if ( grub_util_check_geom_label(arg) )
+ arguments->devices[arguments->ndevices++] = \
+ xstrdup(grub_util_convert_geom_label_to_dev (arg + sizeof ("/dev/") - 1, 1));
+ else
+ arguments->devices[arguments->ndevices++] = xstrdup(arg);
+#else
arguments->devices[arguments->ndevices++] = xstrdup(arg);
+#endif
break;
default:

View file

@ -1,22 +0,0 @@
#!/bin/sh
PREFIX=${PKG_PREFIX-/usr/local}
if [ "$2" != "POST-INSTALL" ] ; then
exit 0
fi
# If this is during staging, we can skip for now
echo $PREFIX | grep -q '/stage/'
if [ $? -eq 0 ] ; then
exit 0
fi
# Copy over user-editable 40_custom script
if [ ! -e "${PREFIX}/etc/grub.d/40_custom" ] ; then
cp ${PREFIX}/etc/grub.d/40_custom.dist ${PREFIX}/etc/grub.d/40_custom
chmod 755 ${PREFIX}/etc/grub.d/40_custom
fi
exit 0