Description: Guard against scripts containing no commands Make grub-script-check fail on scripts containing no commands, to guard against corrupted grub-mkconfig setups that produce no useful output. Origin: backport, http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/5044 Author: Colin Watson Bug-Debian: http://bugs.debian.org/713886 Forwarded: not-needed Last-Update: 2013-06-25 Index: b/Makefile.util.def =================================================================== --- a/Makefile.util.def +++ b/Makefile.util.def @@ -701,6 +701,12 @@ script = { testcase; + name = grub_script_no_commands; + common = tests/grub_script_no_commands.in; +}; + +script = { + testcase; name = partmap_test; common = tests/partmap_test.in; }; Index: b/tests/grub_script_no_commands.in =================================================================== --- /dev/null +++ b/tests/grub_script_no_commands.in @@ -0,0 +1,21 @@ +#! /bin/sh +set -e + +# grub-script-check refuses to pass a file with no commands; this usually +# indicates a bug in the code generating that file. + +@builddir@/grub-script-check <cmd) + found_cmd = 1; grub_script_execute (script); grub_script_free (script); } @@ -191,6 +193,12 @@ fprintf (stderr, _("Syntax error at line %u\n"), lineno); return 1; } + if (! found_cmd) + { + fprintf (stderr, _("Script contains no commands and will do nothing\n"), + ctx.arguments.filename); + return 1; + } return 0; }