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

6b3c76
From 535107794dc13438bd2cd0c298667a0eb430c839 Mon Sep 17 00:00:00 2001
a85e8e
From: Vladimir Serbinenko <phcoder@gmail.com>
a85e8e
Date: Fri, 24 Jan 2014 18:09:25 +0100
6b3c76
Subject: [PATCH 042/261] * util/grub-install.c: List available targets.
a85e8e
a85e8e
---
6b3c76
 ChangeLog                   |  4 ++++
6b3c76
 include/grub/util/install.h |  2 ++
a85e8e
 util/grub-install-common.c  | 30 ++++++++++++++++++++++++++++++
a85e8e
 util/grub-install.c         | 10 ++++++++--
a85e8e
 4 files changed, 44 insertions(+), 2 deletions(-)
a85e8e
6b3c76
diff --git a/ChangeLog b/ChangeLog
6b3c76
index eee8e78a7..20e8baaa2 100644
6b3c76
--- a/ChangeLog
6b3c76
+++ b/ChangeLog
6b3c76
@@ -1,3 +1,7 @@
6b3c76
+2014-01-24  Vladimir Serbinenko  <phcoder@gmail.com>
6b3c76
+
6b3c76
+	* util/grub-install.c: List available targets.
6b3c76
+
6b3c76
 2014-01-23  Colin Watson  <cjwatson@ubuntu.com>
6b3c76
 
6b3c76
 	* util/grub-install.c (write_to_disk): Add an info message.
6b3c76
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
6b3c76
index bc987aadc..aedcd29f9 100644
6b3c76
--- a/include/grub/util/install.h
6b3c76
+++ b/include/grub/util/install.h
6b3c76
@@ -138,6 +138,8 @@ grub_install_get_platform_cpu (enum grub_install_plat platid);
6b3c76
 const char *
6b3c76
 grub_install_get_platform_platform (enum grub_install_plat platid);
6b3c76
 
6b3c76
+char *
6b3c76
+grub_install_get_platforms_string (void);
6b3c76
 
6b3c76
 typedef enum {
6b3c76
   GRUB_COMPRESSION_AUTO,
a85e8e
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
6b3c76
index 6ea0a8e17..c8bedcb2e 100644
a85e8e
--- a/util/grub-install-common.c
a85e8e
+++ b/util/grub-install-common.c
6b3c76
@@ -668,6 +668,36 @@ static struct
a85e8e
   }; 
a85e8e
 
6b3c76
 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
+
6b3c76
+char *
a85e8e
 grub_install_get_platform_name (enum grub_install_plat platid)
a85e8e
 {
6b3c76
   return xasprintf ("%s-%s", platforms[platid].cpu,
a85e8e
diff --git a/util/grub-install.c b/util/grub-install.c
6b3c76
index 787dc90fc..2e6226a37 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:
6b3c76
-- 
6b3c76
2.13.5
6b3c76