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

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