Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1490686 Details for
Bug 1614637
Broken bash syntax in /etc/grub.d/01_fallback_counting
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to clean this up.
0001-Reimplement-boot_counter.patch (text/plain), 5.04 KB, created by
Peter Jones
on 2018-10-04 18:26:01 UTC
(
hide
)
Description:
Patch to clean this up.
Filename:
MIME Type:
Creator:
Peter Jones
Created:
2018-10-04 18:26:01 UTC
Size:
5.04 KB
patch
obsolete
>From 603fb7f40c5aa39c178ba253c9574321e81eb608 Mon Sep 17 00:00:00 2001 >From: Peter Jones <pjones@redhat.com> >Date: Thu, 4 Oct 2018 14:22:09 -0400 >Subject: [PATCH] Reimplement boot_counter > >This adds "increment" and "decrement" commands, and uses them to maintain our >variables in 01_fallback_counter. It also simplifies the counter logic, so >that there are no nested tests that conflict with each other. > >Apparently, this *really* wasn't tested well enough. > >Resolves: rhbz#1614637 >Signed-off-by: Peter Jones <pjones@redhat.com> >--- > Makefile.util.def | 6 ++ > grub-core/Makefile.core.def | 1 + > grub-core/commands/increment.c | 105 ++++++++++++++++++++++++++++ > util/grub.d/01_fallback_counting.in | 14 ++++ > 4 files changed, 126 insertions(+) > create mode 100644 grub-core/commands/increment.c > create mode 100644 util/grub.d/01_fallback_counting.in > >diff --git a/Makefile.util.def b/Makefile.util.def >index cba4d500198..c8cb91308d9 100644 >--- a/Makefile.util.def >+++ b/Makefile.util.def >@@ -448,6 +448,12 @@ script = { > installdir = grubconf; > }; > >+script = { >+ name = '01_fallback_counting'; >+ common = util/grub.d/01_fallback_counting.in; >+ installdir = grubconf; >+}; >+ > script = { > name = '01_menu_auto_hide'; > common = util/grub.d/01_menu_auto_hide.in; >diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def >index 701e5d32fa2..061ba1423cd 100644 >--- a/grub-core/Makefile.core.def >+++ b/grub-core/Makefile.core.def >@@ -1843,6 +1843,7 @@ module = { > common = script/argv.c; > > common = commands/menuentry.c; >+ common = commands/increment.c; > > common = unidata.c; > common_nodist = grub_script.tab.c; >diff --git a/grub-core/commands/increment.c b/grub-core/commands/increment.c >new file mode 100644 >index 00000000000..e7bd245d8aa >--- /dev/null >+++ b/grub-core/commands/increment.c >@@ -0,0 +1,105 @@ >+/* increment.c - Commands to increment and decrement variables. */ >+/* >+ * 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> >+#include <grub/env.h> >+ >+GRUB_MOD_LICENSE ("GPLv3+"); >+ >+typedef enum { >+ INCREMENT, >+ DECREMENT, >+} operation; >+ >+static grub_err_t >+incr_decr(operation op, int argc, char *argv[]) >+{ >+ const char *old; >+ char *new; >+ long value; >+ >+ if (argc < 1) >+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no variable specified")); >+ if (argc > 1) >+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("too many arguments")); >+ >+ old = grub_env_get (argv[0]); >+ if (!old) >+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("No such variable \"%s\""), >+ argv[0]); >+ >+ value = grub_strtol (old, NULL, 0); >+ if (grub_errno != GRUB_ERR_NONE) >+ return grub_errno; >+ >+ switch (op) >+ { >+ case INCREMENT: >+ value += 1; >+ break; >+ case DECREMENT: >+ value -= 1; >+ break; >+ } >+ >+ new = grub_xasprintf ("%ld", value); >+ if (!new) >+ return grub_errno; >+ >+ grub_env_set (argv[0], new); >+ grub_free (new); >+ >+ return GRUB_ERR_NONE; >+} >+ >+static grub_err_t >+grub_cmd_incr(struct grub_command *cmd UNUSED, >+ int argc, char *argv[]) >+{ >+ return incr_decr(INCREMENT, argc, argv); >+} >+ >+static grub_err_t >+grub_cmd_decr(struct grub_command *cmd UNUSED, >+ int argc, char *argv[]) >+{ >+ return incr_decr(DECREMENT, argc, argv); >+} >+ >+static grub_command_t cmd_incr, cmd_decr; >+ >+GRUB_MOD_INIT(increment) >+{ >+ cmd_incr = grub_register_command ("increment", grub_cmd_incr, N_("VARIABLE"), >+ N_("increment VARIABLE")); >+ cmd_decr = grub_register_command ("decrement", grub_cmd_decr, N_("VARIABLE"), >+ N_("decrement VARIABLE")); >+} >+ >+GRUB_MOD_FINI(increment) >+{ >+ grub_unregister_command (cmd_incr); >+ grub_unregister_command (cmd_decr); >+} >diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in >new file mode 100644 >index 00000000000..29dd597f067 >--- /dev/null >+++ b/util/grub.d/01_fallback_counting.in >@@ -0,0 +1,14 @@ >+#! /bin/sh -e >+ >+# Boot Counting >+cat << EOF >+if [ -z "\${boot_counter}" ]; then >+ set boot_counter=0 >+elif [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then >+ increment default >+ set boot_counter=-1 >+else >+ decrement boot_counter >+fi >+save_env boot_counter >+EOF >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1614637
: 1490686