Blame SOURCES/0042-util-grub-install.c-List-available-targets.patch

d41074
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a85e8e
From: Vladimir Serbinenko <phcoder@gmail.com>
a85e8e
Date: Fri, 24 Jan 2014 18:09:25 +0100
d41074
Subject: [PATCH] * util/grub-install.c: List available targets.
a85e8e
a85e8e
---
a85e8e
 util/grub-install-common.c  | 30 ++++++++++++++++++++++++++++++
a85e8e
 util/grub-install.c         | 10 ++++++++--
d41074
 include/grub/util/install.h |  2 ++
d41074
 ChangeLog                   |  4 ++++
a85e8e
 4 files changed, 44 insertions(+), 2 deletions(-)
a85e8e
a85e8e
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
d41074
index 6ea0a8e1795..c8bedcb2e59 100644
a85e8e
--- a/util/grub-install-common.c
a85e8e
+++ b/util/grub-install-common.c
d41074
@@ -667,6 +667,36 @@ static struct
d41074
     [GRUB_INSTALL_PLATFORM_ARM_UBOOT] =        { "arm",     "uboot"     },
a85e8e
   }; 
a85e8e
 
d41074
+char *
a85e8e
+grub_install_get_platforms_string (void)
a85e8e
+{
a85e8e
+  char **arr = xmalloc (sizeof (char *) * ARRAY_SIZE (platforms));
a85e8e
+  int platform_strins_len = 0;
a85e8e
+  char *platforms_string;
a85e8e
+  char *ptr;
a85e8e
+  unsigned i;
a85e8e
+  for (i = 0; i < ARRAY_SIZE (platforms); i++)
a85e8e
+    {
a85e8e
+      arr[i] = xasprintf ("%s-%s", platforms[i].cpu,
a85e8e
+			  platforms[i].platform);
a85e8e
+      platform_strins_len += strlen (arr[i]) + 2;
a85e8e
+    }
a85e8e
+  ptr = platforms_string = xmalloc (platform_strins_len);
a85e8e
+  qsort (arr, ARRAY_SIZE (platforms), sizeof (char *), grub_qsort_strcmp);
a85e8e
+  for (i = 0; i < ARRAY_SIZE (platforms); i++)
a85e8e
+    {
a85e8e
+      strcpy (ptr, arr[i]);
a85e8e
+      ptr += strlen (arr[i]);
a85e8e
+      *ptr++ = ',';
a85e8e
+      *ptr++ = ' ';
a85e8e
+      free (arr[i]);
a85e8e
+    }
a85e8e
+  ptr[-2] = 0;
a85e8e
+  free (arr);
a85e8e
+ 
a85e8e
+  return platforms_string;
a85e8e
+}
a85e8e
+
d41074
 char *
a85e8e
 grub_install_get_platform_name (enum grub_install_plat platid)
a85e8e
 {
a85e8e
diff --git a/util/grub-install.c b/util/grub-install.c
d41074
index 787dc90fce5..2e6226a3716 100644
a85e8e
--- a/util/grub-install.c
a85e8e
+++ b/util/grub-install.c
a85e8e
@@ -256,7 +256,7 @@ static struct argp_option options[] = {
a85e8e
    OPTION_HIDDEN, 0, 2},
a85e8e
   {"target", OPTION_TARGET, N_("TARGET"),
a85e8e
    /* TRANSLATORS: "TARGET" as in "target platform".  */
a85e8e
-   0, N_("install GRUB for TARGET platform [default=%s]"), 2},
a85e8e
+   0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2},
a85e8e
   {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
a85e8e
   {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2},
a85e8e
   {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2},
a85e8e
@@ -340,7 +340,13 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
a85e8e
     case OPTION_BOOT_DIRECTORY:
a85e8e
       return xasprintf (text, GRUB_DIR_NAME, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME);
a85e8e
     case OPTION_TARGET:
a85e8e
-      return xasprintf (text, get_default_platform ());
a85e8e
+      {
a85e8e
+	char *plats = grub_install_get_platforms_string ();
a85e8e
+	char *ret;
a85e8e
+	ret = xasprintf (text, get_default_platform (), plats);
a85e8e
+	free (plats);
a85e8e
+	return ret;
a85e8e
+      }
a85e8e
     case ARGP_KEY_HELP_POST_DOC:
a85e8e
       return xasprintf (text, program_name, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME);
a85e8e
     default:
d41074
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
d41074
index bc987aadc16..aedcd29f905 100644
d41074
--- a/include/grub/util/install.h
d41074
+++ b/include/grub/util/install.h
d41074
@@ -138,6 +138,8 @@ grub_install_get_platform_cpu (enum grub_install_plat platid);
d41074
 const char *
d41074
 grub_install_get_platform_platform (enum grub_install_plat platid);
d41074
 
d41074
+char *
d41074
+grub_install_get_platforms_string (void);
d41074
 
d41074
 typedef enum {
d41074
   GRUB_COMPRESSION_AUTO,
d41074
diff --git a/ChangeLog b/ChangeLog
d41074
index eee8e78a726..20e8baaa23e 100644
d41074
--- a/ChangeLog
d41074
+++ b/ChangeLog
d41074
@@ -1,3 +1,7 @@
d41074
+2014-01-24  Vladimir Serbinenko  <phcoder@gmail.com>
d41074
+
d41074
+	* util/grub-install.c: List available targets.
d41074
+
d41074
 2014-01-23  Colin Watson  <cjwatson@ubuntu.com>
d41074
 
d41074
 	* util/grub-install.c (write_to_disk): Add an info message.