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

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