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