|
|
5593c8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
5593c8 |
From: Peter Jones <pjones@redhat.com>
|
|
|
5593c8 |
Date: Tue, 11 Sep 2018 14:20:37 -0400
|
|
|
fd0330 |
Subject: [PATCH] Add a "version" command
|
|
|
5593c8 |
|
|
|
fd0330 |
This adds a command that shows you info about grub's version, the grub
|
|
|
fd0330 |
target platform, the compiler version, and if you built with
|
|
|
5593c8 |
--with-rpm-version=<string>, the rpm package version.
|
|
|
5593c8 |
|
|
|
5593c8 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
fd0330 |
[rharwood: don't say GNU, commit message cleanup]
|
|
|
fd0330 |
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
5593c8 |
---
|
|
|
5593c8 |
configure.ac | 13 ++++++++++
|
|
|
5593c8 |
grub-core/Makefile.core.def | 5 ++++
|
|
|
5593c8 |
grub-core/commands/version.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
5593c8 |
config.h.in | 1 +
|
|
|
5593c8 |
4 files changed, 75 insertions(+)
|
|
|
5593c8 |
create mode 100644 grub-core/commands/version.c
|
|
|
5593c8 |
|
|
|
5593c8 |
diff --git a/configure.ac b/configure.ac
|
|
|
fd0330 |
index 54462e0892..7b4e1854d3 100644
|
|
|
5593c8 |
--- a/configure.ac
|
|
|
5593c8 |
+++ b/configure.ac
|
|
|
fd0330 |
@@ -284,6 +284,19 @@ AC_SUBST(target_cpu)
|
|
|
5593c8 |
AC_SUBST(platform)
|
|
|
5593c8 |
|
|
|
5593c8 |
# Define default variables
|
|
|
5593c8 |
+have_with_rpm_version=n
|
|
|
5593c8 |
+AC_ARG_WITH([rpm_version],
|
|
|
5593c8 |
+ AS_HELP_STRING([--with-rpm-version=VERSION],
|
|
|
5593c8 |
+ [set the rpm package version [[guessed]]]),
|
|
|
5593c8 |
+ [have_with_rpm_version=y],
|
|
|
5593c8 |
+ [have_with_rpm_version=n])
|
|
|
5593c8 |
+if test x$have_with_rpm_version = xy; then
|
|
|
5593c8 |
+ rpm_version="$with_rpm_version"
|
|
|
5593c8 |
+else
|
|
|
5593c8 |
+ rpm_version=""
|
|
|
5593c8 |
+fi
|
|
|
5593c8 |
+GRUB_RPM_VERSION="$rpm_version"
|
|
|
5593c8 |
+AC_SUBST(GRUB_RPM_VERSION)
|
|
|
5593c8 |
|
|
|
5593c8 |
have_with_bootdir=n
|
|
|
5593c8 |
AC_ARG_WITH([bootdir],
|
|
|
5593c8 |
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
|
fd0330 |
index 4e7d90da76..4f203533f5 100644
|
|
|
5593c8 |
--- a/grub-core/Makefile.core.def
|
|
|
5593c8 |
+++ b/grub-core/Makefile.core.def
|
|
|
5593c8 |
@@ -579,6 +579,11 @@ image = {
|
|
|
5593c8 |
enable = mips_loongson;
|
|
|
5593c8 |
};
|
|
|
5593c8 |
|
|
|
5593c8 |
+module = {
|
|
|
5593c8 |
+ name = version;
|
|
|
5593c8 |
+ common = commands/version.c;
|
|
|
5593c8 |
+};
|
|
|
5593c8 |
+
|
|
|
5593c8 |
module = {
|
|
|
5593c8 |
name = disk;
|
|
|
5593c8 |
common = lib/disk.c;
|
|
|
5593c8 |
diff --git a/grub-core/commands/version.c b/grub-core/commands/version.c
|
|
|
5593c8 |
new file mode 100644
|
|
|
fd0330 |
index 0000000000..de0acb07ba
|
|
|
5593c8 |
--- /dev/null
|
|
|
5593c8 |
+++ b/grub-core/commands/version.c
|
|
|
5593c8 |
@@ -0,0 +1,56 @@
|
|
|
5593c8 |
+/* version.c - Command to print the grub version and build info. */
|
|
|
5593c8 |
+/*
|
|
|
5593c8 |
+ * GRUB -- GRand Unified Bootloader
|
|
|
5593c8 |
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
|
|
5593c8 |
+ *
|
|
|
5593c8 |
+ * GRUB is free software: you can redistribute it and/or modify
|
|
|
5593c8 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
5593c8 |
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
5593c8 |
+ * (at your option) any later version.
|
|
|
5593c8 |
+ *
|
|
|
5593c8 |
+ * GRUB is distributed in the hope that it will be useful,
|
|
|
5593c8 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
5593c8 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
5593c8 |
+ * GNU General Public License for more details.
|
|
|
5593c8 |
+ *
|
|
|
5593c8 |
+ * You should have received a copy of the GNU General Public License
|
|
|
5593c8 |
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
5593c8 |
+ */
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+#include <grub/dl.h>
|
|
|
5593c8 |
+#include <grub/term.h>
|
|
|
5593c8 |
+#include <grub/time.h>
|
|
|
5593c8 |
+#include <grub/types.h>
|
|
|
5593c8 |
+#include <grub/misc.h>
|
|
|
5593c8 |
+#include <grub/extcmd.h>
|
|
|
5593c8 |
+#include <grub/i18n.h>
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+static grub_err_t
|
|
|
5593c8 |
+grub_cmd_version (grub_command_t cmd UNUSED, int argc, char **args UNUSED)
|
|
|
5593c8 |
+{
|
|
|
5593c8 |
+ if (argc != 0)
|
|
|
5593c8 |
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected"));
|
|
|
5593c8 |
+
|
|
|
fd0330 |
+ grub_printf (_("GRUB version %s\n"), PACKAGE_VERSION);
|
|
|
5593c8 |
+ grub_printf (_("Platform %s-%s\n"), GRUB_TARGET_CPU, GRUB_PLATFORM);
|
|
|
5593c8 |
+ if (grub_strlen(GRUB_RPM_VERSION) != 0)
|
|
|
5593c8 |
+ grub_printf (_("RPM package version %s\n"), GRUB_RPM_VERSION);
|
|
|
5593c8 |
+ grub_printf (_("Compiler version %s\n"), __VERSION__);
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ return 0;
|
|
|
5593c8 |
+}
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+static grub_command_t cmd;
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+GRUB_MOD_INIT(version)
|
|
|
5593c8 |
+{
|
|
|
5593c8 |
+ cmd = grub_register_command ("version", grub_cmd_version, NULL,
|
|
|
5593c8 |
+ N_("Print version and build information."));
|
|
|
5593c8 |
+}
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+GRUB_MOD_FINI(version)
|
|
|
5593c8 |
+{
|
|
|
5593c8 |
+ grub_unregister_command (cmd);
|
|
|
5593c8 |
+}
|
|
|
5593c8 |
diff --git a/config.h.in b/config.h.in
|
|
|
fd0330 |
index 9e8f9911b1..c7e316f0f1 100644
|
|
|
5593c8 |
--- a/config.h.in
|
|
|
5593c8 |
+++ b/config.h.in
|
|
|
5593c8 |
@@ -59,6 +59,7 @@
|
|
|
5593c8 |
|
|
|
5593c8 |
#define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@"
|
|
|
5593c8 |
#define GRUB_PLATFORM "@GRUB_PLATFORM@"
|
|
|
5593c8 |
+#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@"
|
|
|
5593c8 |
|
|
|
5593c8 |
#define RE_ENABLE_I18N 1
|
|
|
5593c8 |
|