merged with mainline
This commit is contained in:
commit
68b31b54f5
14 changed files with 363 additions and 104 deletions
57
ChangeLog
57
ChangeLog
|
@ -1,3 +1,60 @@
|
||||||
|
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
While and until loops support to GRUB script.
|
||||||
|
|
||||||
|
* include/grub/script_sh.h (grub_script_cmdwhile): New struct.
|
||||||
|
(grub_script_create_cmdwhile): New function prototype.
|
||||||
|
(grub_script_execute_cmdwhile): New function prototype.
|
||||||
|
* script/execute.c (grub_script_execute_cmdwhile): New function.
|
||||||
|
* script/parser.y (command): New commands.
|
||||||
|
(whilecmd): New grammar rule.
|
||||||
|
(untilcmd): New grammar rule.
|
||||||
|
* script/script.c (grub_script_create_cmdwhile): New function.
|
||||||
|
* util/grub-script-check.c (grub_script_execute_cmdwhile): New
|
||||||
|
function.
|
||||||
|
|
||||||
|
* tests/grub_script_while1.in: New testcase.
|
||||||
|
* conf/tests.rmk: Rule for new testcase.
|
||||||
|
|
||||||
|
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* util/grub.d/00_header.in: Add few missing quotes. Recognise *.jpeg
|
||||||
|
as *.jpg.
|
||||||
|
|
||||||
|
2010-04-09 Mario Vazquez <mariovazq@gmail.com>
|
||||||
|
|
||||||
|
GRUB_BACKGROUND support.
|
||||||
|
|
||||||
|
* util/grub-mkconfig.in: Export GRUB_BACKGROUND.
|
||||||
|
* util/grub.d/00_header.in: Parse GRUB_BACKGROUND.
|
||||||
|
|
||||||
|
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Load fonts and modules for gfxmenu in grub-mkconfig.
|
||||||
|
Idea by: Mario Vazquez
|
||||||
|
|
||||||
|
* util/grub.d/00_header.in: Load pf2 and image modules.
|
||||||
|
|
||||||
|
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
grub-mkconfig multiple terminal support.
|
||||||
|
|
||||||
|
* util/grub-mkconfig.in: Handle multiple terminals correctly.
|
||||||
|
* util/grub.d/00_header.in: Likewise.
|
||||||
|
|
||||||
|
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* Makefile.in: Specify files explicitly instead of using $< and $@ since
|
||||||
|
we use cd $(srcdir).
|
||||||
|
|
||||||
|
2010-04-08 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* util/grub.d/10_linux.in: Only use the first word of
|
||||||
|
GRUB_DISTRIBUTOR for --class, to avoid problems if somebody puts
|
||||||
|
spaces in GRUB_DISTRIBUTOR.
|
||||||
|
* util/grub.d/10_kfreebsd.in: Likewise.
|
||||||
|
* util/grub.d/10_hurd.in: Likewise.
|
||||||
|
|
||||||
2010-04-06 BVK Chaitanya <bvk.groups@gmail.com>
|
2010-04-06 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
Fix unit testing framework for Qemu 0.12.
|
Fix unit testing framework for Qemu 0.12.
|
||||||
|
|
|
@ -530,8 +530,8 @@ genkernsyms.sh: genkernsyms.sh.in config.status
|
||||||
$(SHELL) ./config.status
|
$(SHELL) ./config.status
|
||||||
|
|
||||||
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
|
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
|
||||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_
|
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES --keyword=_ --keyword=N_
|
||||||
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell
|
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES-shell -j --language=Shell
|
||||||
|
|
||||||
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
|
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
|
||||||
$(MSGMERGE) -U $@ $^
|
$(MSGMERGE) -U $@ $^
|
||||||
|
|
|
@ -53,15 +53,18 @@ grub_script_vars1_SOURCES = tests/grub_script_vars1.in
|
||||||
check_SCRIPTS += grub_script_for1
|
check_SCRIPTS += grub_script_for1
|
||||||
grub_script_for1_SOURCES = tests/grub_script_for1.in
|
grub_script_for1_SOURCES = tests/grub_script_for1.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_while1
|
||||||
|
grub_script_while1_SOURCES = tests/grub_script_while1.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_if
|
||||||
|
grub_script_if_SOURCES = tests/grub_script_if.in
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_blanklines
|
check_SCRIPTS += grub_script_blanklines
|
||||||
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_final_semicolon
|
check_SCRIPTS += grub_script_final_semicolon
|
||||||
grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
||||||
|
|
||||||
check_SCRIPTS += grub_script_if
|
|
||||||
grub_script_if_SOURCES = tests/grub_script_if.in
|
|
||||||
|
|
||||||
# List of tests to execute on "make check"
|
# List of tests to execute on "make check"
|
||||||
# SCRIPTED_TESTS = example_scripted_test
|
# SCRIPTED_TESTS = example_scripted_test
|
||||||
# SCRIPTED_TESTS += example_grub_script_test
|
# SCRIPTED_TESTS += example_grub_script_test
|
||||||
|
@ -72,9 +75,10 @@ SCRIPTED_TESTS = grub_script_echo1
|
||||||
SCRIPTED_TESTS += grub_script_echo_keywords
|
SCRIPTED_TESTS += grub_script_echo_keywords
|
||||||
SCRIPTED_TESTS += grub_script_vars1
|
SCRIPTED_TESTS += grub_script_vars1
|
||||||
SCRIPTED_TESTS += grub_script_for1
|
SCRIPTED_TESTS += grub_script_for1
|
||||||
|
SCRIPTED_TESTS += grub_script_while1
|
||||||
|
SCRIPTED_TESTS += grub_script_if
|
||||||
SCRIPTED_TESTS += grub_script_blanklines
|
SCRIPTED_TESTS += grub_script_blanklines
|
||||||
SCRIPTED_TESTS += grub_script_final_semicolon
|
SCRIPTED_TESTS += grub_script_final_semicolon
|
||||||
SCRIPTED_TESTS += grub_script_if
|
|
||||||
|
|
||||||
|
|
||||||
# dependencies between tests and testing-tools
|
# dependencies between tests and testing-tools
|
||||||
|
|
|
@ -121,6 +121,21 @@ struct grub_script_cmdfor
|
||||||
struct grub_script_cmd *list;
|
struct grub_script_cmd *list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A while/until command. */
|
||||||
|
struct grub_script_cmdwhile
|
||||||
|
{
|
||||||
|
struct grub_script_cmd cmd;
|
||||||
|
|
||||||
|
/* The command list used as condition. */
|
||||||
|
struct grub_script_cmd *cond;
|
||||||
|
|
||||||
|
/* The command list executed in each loop. */
|
||||||
|
struct grub_script_cmd *list;
|
||||||
|
|
||||||
|
/* The flag to indicate this as "until" loop. */
|
||||||
|
int until;
|
||||||
|
};
|
||||||
|
|
||||||
/* A menu entry generate statement. */
|
/* A menu entry generate statement. */
|
||||||
struct grub_script_cmd_menuentry
|
struct grub_script_cmd_menuentry
|
||||||
{
|
{
|
||||||
|
@ -234,6 +249,12 @@ grub_script_create_cmdfor (struct grub_parser_param *state,
|
||||||
struct grub_script_arglist *words,
|
struct grub_script_arglist *words,
|
||||||
struct grub_script_cmd *list);
|
struct grub_script_cmd *list);
|
||||||
|
|
||||||
|
struct grub_script_cmd *
|
||||||
|
grub_script_create_cmdwhile (struct grub_parser_param *state,
|
||||||
|
struct grub_script_cmd *cond,
|
||||||
|
struct grub_script_cmd *list,
|
||||||
|
int is_an_until_loop);
|
||||||
|
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_create_cmdmenu (struct grub_parser_param *state,
|
grub_script_create_cmdmenu (struct grub_parser_param *state,
|
||||||
struct grub_script_arglist *arglist,
|
struct grub_script_arglist *arglist,
|
||||||
|
@ -283,6 +304,7 @@ grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
||||||
|
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
||||||
|
|
||||||
/* Execute any GRUB pre-parsed command or script. */
|
/* Execute any GRUB pre-parsed command or script. */
|
||||||
|
|
|
@ -26,13 +26,24 @@
|
||||||
#include <grub/lib/arg.h>
|
#include <grub/lib/arg.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
|
|
||||||
|
/* Max digits for a char is 3 (0xFF is 255), similarly for an int it
|
||||||
|
is sizeof (int) * 3, and one extra for a possible -ve sign. */
|
||||||
|
#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
char errnobuf[ERRNO_DIGITS_MAX + 1];
|
||||||
|
|
||||||
if (cmd == 0)
|
if (cmd == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return cmd->exec (cmd);
|
ret = cmd->exec (cmd);
|
||||||
|
|
||||||
|
grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
|
||||||
|
grub_env_set ("?", errnobuf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARG_ALLOCATION_UNIT (32 * sizeof (char))
|
#define ARG_ALLOCATION_UNIT (32 * sizeof (char))
|
||||||
|
@ -260,13 +271,14 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
|
grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd;
|
struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd;
|
||||||
|
|
||||||
/* Loop over every command and execute it. */
|
/* Loop over every command and execute it. */
|
||||||
for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next)
|
for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next)
|
||||||
grub_script_execute_cmd (cmd);
|
ret = grub_script_execute_cmd (cmd);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute an if statement. */
|
/* Execute an if statement. */
|
||||||
|
@ -317,6 +329,26 @@ grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Execute a "while" or "until" command. */
|
||||||
|
grub_err_t
|
||||||
|
grub_script_execute_cmdwhile (struct grub_script_cmd *cmd)
|
||||||
|
{
|
||||||
|
int cond;
|
||||||
|
int result;
|
||||||
|
struct grub_script_cmdwhile *cmdwhile = (struct grub_script_cmdwhile *) cmd;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
do {
|
||||||
|
cond = grub_script_execute_cmd (cmdwhile->cond);
|
||||||
|
if (cmdwhile->until ? !cond : cond)
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = grub_script_execute_cmd (cmdwhile->list);
|
||||||
|
} while (1); /* XXX Put a check for ^C here */
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* Execute the menu entry generate statement. */
|
/* Execute the menu entry generate statement. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
||||||
|
|
|
@ -74,8 +74,10 @@
|
||||||
%token <arg> GRUB_PARSER_TOKEN_WORD "word"
|
%token <arg> GRUB_PARSER_TOKEN_WORD "word"
|
||||||
|
|
||||||
%type <arglist> word argument arguments0 arguments1
|
%type <arglist> word argument arguments0 arguments1
|
||||||
%type <cmd> script_init script grubcmd ifclause ifcmd forcmd command
|
|
||||||
%type <cmd> commands1 menuentry statement
|
%type <cmd> script_init script
|
||||||
|
%type <cmd> grubcmd ifclause ifcmd forcmd whilecmd untilcmd
|
||||||
|
%type <cmd> command commands1 menuentry statement
|
||||||
|
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%lex-param { struct grub_parser_param *state };
|
%lex-param { struct grub_parser_param *state };
|
||||||
|
@ -171,9 +173,11 @@ grubcmd: word arguments0
|
||||||
;
|
;
|
||||||
|
|
||||||
/* A single command. */
|
/* A single command. */
|
||||||
command: grubcmd { $$ = $1; }
|
command: grubcmd { $$ = $1; }
|
||||||
| ifcmd { $$ = $1; }
|
| ifcmd { $$ = $1; }
|
||||||
| forcmd { $$ = $1; }
|
| forcmd { $$ = $1; }
|
||||||
|
| whilecmd { $$ = $1; }
|
||||||
|
| untilcmd { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* A list of commands. */
|
/* A list of commands. */
|
||||||
|
@ -258,3 +262,25 @@ forcmd: "for" "name"
|
||||||
grub_script_lexer_deref (state->lexerstate);
|
grub_script_lexer_deref (state->lexerstate);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
whilecmd: "while"
|
||||||
|
{
|
||||||
|
grub_script_lexer_ref (state->lexerstate);
|
||||||
|
}
|
||||||
|
commands1 delimiters1 "do" commands1 delimiters1 "done"
|
||||||
|
{
|
||||||
|
$$ = grub_script_create_cmdwhile (state, $3, $6, 0);
|
||||||
|
grub_script_lexer_deref (state->lexerstate);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
untilcmd: "until"
|
||||||
|
{
|
||||||
|
grub_script_lexer_ref (state->lexerstate);
|
||||||
|
}
|
||||||
|
commands1 delimiters1 "do" commands1 delimiters1 "done"
|
||||||
|
{
|
||||||
|
$$ = grub_script_create_cmdwhile (state, $3, $6, 1);
|
||||||
|
grub_script_lexer_deref (state->lexerstate);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
|
@ -245,6 +245,28 @@ grub_script_create_cmdfor (struct grub_parser_param *state,
|
||||||
return (struct grub_script_cmd *) cmd;
|
return (struct grub_script_cmd *) cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a "while" or "until" command. */
|
||||||
|
struct grub_script_cmd *
|
||||||
|
grub_script_create_cmdwhile (struct grub_parser_param *state,
|
||||||
|
struct grub_script_cmd *cond,
|
||||||
|
struct grub_script_cmd *list,
|
||||||
|
int is_an_until_loop)
|
||||||
|
{
|
||||||
|
struct grub_script_cmdwhile *cmd;
|
||||||
|
|
||||||
|
cmd = grub_script_malloc (state, sizeof (*cmd));
|
||||||
|
if (! cmd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cmd->cmd.exec = grub_script_execute_cmdwhile;
|
||||||
|
cmd->cmd.next = 0;
|
||||||
|
cmd->cond = cond;
|
||||||
|
cmd->list = list;
|
||||||
|
cmd->until = is_an_until_loop;
|
||||||
|
|
||||||
|
return (struct grub_script_cmd *) cmd;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a command that adds a menu entry to the menu. Title is an
|
/* Create a command that adds a menu entry to the menu. Title is an
|
||||||
argument that is parsed to generate a string that can be used as
|
argument that is parsed to generate a string that can be used as
|
||||||
the title. The sourcecode for this entry is passed in SOURCECODE.
|
the title. The sourcecode for this entry is passed in SOURCECODE.
|
||||||
|
|
32
tests/grub_script_while1.in
Normal file
32
tests/grub_script_while1.in
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#! @builddir@/grub-shell-tester
|
||||||
|
|
||||||
|
echo one
|
||||||
|
foo=""
|
||||||
|
while test "$foo" != "1111"; do foo="${foo}1"; echo "$foo"; done
|
||||||
|
|
||||||
|
echo two
|
||||||
|
foo=""
|
||||||
|
while test "$foo" != "aaaa"
|
||||||
|
do
|
||||||
|
foo="${foo}a"
|
||||||
|
echo $foo
|
||||||
|
done
|
||||||
|
|
||||||
|
foo=""
|
||||||
|
until test "$foo" = "1111"; do foo="${foo}1"; echo $foo; done
|
||||||
|
foo=""
|
||||||
|
until test "$foo" = "aaaa"
|
||||||
|
do
|
||||||
|
foo="${foo}a"
|
||||||
|
echo $foo
|
||||||
|
done
|
||||||
|
|
||||||
|
# check "$?" in condition gets its value from while body commands
|
||||||
|
foo=""
|
||||||
|
false
|
||||||
|
while test "$?" != "0"
|
||||||
|
do
|
||||||
|
echo $foo
|
||||||
|
foo="${foo}1"
|
||||||
|
test "$foo" = "111111"
|
||||||
|
done
|
|
@ -140,60 +140,73 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then
|
||||||
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
|
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case x${GRUB_TERMINAL_OUTPUT} in
|
termoutdefault=0
|
||||||
x | xgfxterm)
|
if [ "x${GRUB_TERMINAL_OUTPUT}" == x ]; then
|
||||||
# If this platform supports gfxterm, try to use it.
|
GRUB_TERMINAL_OUTPUT=gfxterm;
|
||||||
if test -e ${grub_prefix}/gfxterm.mod ; then
|
termoutdefault=1;
|
||||||
# FIXME: this should do something smarter than just loading first
|
fi
|
||||||
# video backend.
|
|
||||||
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
|
||||||
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then
|
|
||||||
GRUB_TERMINAL_OUTPUT=gfxterm
|
|
||||||
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
|
|
||||||
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
xconsole | xserial | xofconsole) ;;
|
|
||||||
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# check for terminals that require fonts
|
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
||||||
case ${GRUB_TERMINAL_OUTPUT} in
|
if [ x${x} == xgfxterm ]; then
|
||||||
gfxterm)
|
# If this platform supports gfxterm, try to use it.
|
||||||
if [ -n "$GRUB_FONT" ] ; then
|
if ! test -e ${grub_prefix}/gfxterm.mod ; then
|
||||||
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
|
if [ "x$termoutdefault" != "x1" ]; then
|
||||||
GRUB_FONT_PATH=${GRUB_FONT}
|
echo "gfxterm isn't available on your platform" >&2 ; exit 1
|
||||||
else
|
fi
|
||||||
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
|
GRUB_TERMINAL_OUTPUT=
|
||||||
exit 1
|
break;
|
||||||
|
fi
|
||||||
|
# FIXME: this should do something smarter than just loading first
|
||||||
|
# video backend.
|
||||||
|
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
|
||||||
|
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
|
||||||
|
if [ "x$termoutdefault" != "x1" ]; then
|
||||||
|
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
|
||||||
|
fi
|
||||||
|
GRUB_TERMINAL_OUTPUT=
|
||||||
|
fi
|
||||||
|
if [ -n "$GRUB_FONT" ] ; then
|
||||||
|
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
|
||||||
|
GRUB_FONT_PATH=${GRUB_FONT}
|
||||||
|
else
|
||||||
|
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
|
||||||
|
for basename in unicode unifont ascii; do
|
||||||
|
path="${dir}/${basename}.pf2"
|
||||||
|
if is_path_readable_by_grub ${path} > /dev/null ; then
|
||||||
|
GRUB_FONT_PATH=${path}
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "${basename}" = "ascii" ] ; then
|
||||||
|
# make sure all our children behave in conformance with ascii..
|
||||||
|
export LANG=C
|
||||||
|
fi
|
||||||
|
break 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ -z "${GRUB_FONT_PATH}" ] ; then
|
||||||
|
if [ "x$termoutdefault" != "x1" ]; then
|
||||||
|
echo "No font for gfxterm found." >&2 ; exit 1
|
||||||
|
fi
|
||||||
|
GRUB_TERMINAL_OUTPUT=
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
|
|
||||||
for basename in unicode unifont ascii; do
|
|
||||||
path="${dir}/${basename}.pf2"
|
|
||||||
if is_path_readable_by_grub ${path} > /dev/null ; then
|
|
||||||
GRUB_FONT_PATH=${path}
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if [ "${basename}" = "ascii" ] ; then
|
|
||||||
# make sure all our children behave in conformance with ascii..
|
|
||||||
export LANG=C
|
|
||||||
fi
|
|
||||||
break 2
|
|
||||||
done
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
if [ -z "${GRUB_FONT_PATH}" ] ; then
|
done
|
||||||
# fallback to the native terminal for this platform
|
|
||||||
unset GRUB_TERMINAL_OUTPUT
|
for x in ${GRUB_TERMINAL_OUTPUT}; do
|
||||||
fi
|
case "x${x}" in
|
||||||
;;
|
xgfxterm) ;;
|
||||||
*)
|
xconsole | xserial | xofconsole)
|
||||||
# make sure all our children behave in conformance with ascii..
|
# make sure all our children behave in conformance with ascii..
|
||||||
export LANG=C
|
export LANG=C;;
|
||||||
esac
|
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# These are defined in this script, export them here so that user can
|
# These are defined in this script, export them here so that user can
|
||||||
# override them.
|
# override them.
|
||||||
|
@ -220,6 +233,7 @@ export GRUB_DEFAULT \
|
||||||
GRUB_DISABLE_LINUX_UUID \
|
GRUB_DISABLE_LINUX_UUID \
|
||||||
GRUB_DISABLE_LINUX_RECOVERY \
|
GRUB_DISABLE_LINUX_RECOVERY \
|
||||||
GRUB_GFXMODE \
|
GRUB_GFXMODE \
|
||||||
|
GRUB_BACKGROUND \
|
||||||
GRUB_THEME \
|
GRUB_THEME \
|
||||||
GRUB_GFXPAYLOAD_LINUX \
|
GRUB_GFXPAYLOAD_LINUX \
|
||||||
GRUB_DISABLE_OS_PROBER \
|
GRUB_DISABLE_OS_PROBER \
|
||||||
|
|
|
@ -87,6 +87,12 @@ grub_script_execute_cmdfor (struct grub_script_cmd *cmd __attribute__ ((unused))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_script_execute_cmdwhile (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,19 +59,92 @@ function savedefault {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
|
serial=0;
|
||||||
serial:* | *:serial)
|
gfxterm=0;
|
||||||
|
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||||
|
if [ xserial = "x$x" ]; then
|
||||||
|
serial=1;
|
||||||
|
fi
|
||||||
|
if [ xgfxterm = "x$x" ]; then
|
||||||
|
gfxterm=1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "x$serial" = x1 ]; then
|
||||||
if ! test -e ${grub_prefix}/serial.mod ; then
|
if ! test -e ${grub_prefix}/serial.mod ; then
|
||||||
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
echo "Serial terminal not available on this platform." >&2 ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
|
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
|
||||||
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
|
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
|
||||||
GRUB_SERIAL_COMMAND=serial
|
GRUB_SERIAL_COMMAND=serial
|
||||||
fi
|
fi
|
||||||
echo "${GRUB_SERIAL_COMMAND}"
|
echo "${GRUB_SERIAL_COMMAND}"
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
|
if [ "x$gfxterm" = x1 ]; then
|
||||||
|
# Make the font accessible
|
||||||
|
prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
|
||||||
|
set gfxmode=${GRUB_GFXMODE}
|
||||||
|
insmod gfxterm
|
||||||
|
insmod ${GRUB_VIDEO_BACKEND}
|
||||||
|
EOF
|
||||||
|
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
|
||||||
|
&& is_path_readable_by_grub "$GRUB_THEME"; then
|
||||||
|
echo "Found theme: $GRUB_THEME" >&2
|
||||||
|
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"` | sed -e "s/^/ /"
|
||||||
|
cat << EOF
|
||||||
|
insmod gfxmenu
|
||||||
|
EOF
|
||||||
|
themedir="`dirname "$GRUB_THEME"`"
|
||||||
|
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
|
||||||
|
if [ -f "$x" ]; then
|
||||||
|
cat << EOF
|
||||||
|
loadfont (\$root)`make_system_path_relative_to_its_root $x`
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
|
||||||
|
cat << EOF
|
||||||
|
insmod jpeg
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
|
||||||
|
cat << EOF
|
||||||
|
insmod png
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
|
||||||
|
cat << EOF
|
||||||
|
insmod tga
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
||||||
|
EOF
|
||||||
|
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
|
||||||
|
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
|
||||||
|
echo "Found background: $GRUB_BACKGROUND" >&2
|
||||||
|
case "$GRUB_BACKGROUND" in
|
||||||
|
*.png) reader=png ;;
|
||||||
|
*.tga) reader=tga ;;
|
||||||
|
*.jpg|*.jpeg) reader=jpeg ;;
|
||||||
|
*) echo "Unsupported image format" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"` | sed -e "s/^/ /"
|
||||||
|
cat << EOF
|
||||||
|
insmod $reader
|
||||||
|
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat << EOF
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
case x${GRUB_TERMINAL_INPUT} in
|
case x${GRUB_TERMINAL_INPUT} in
|
||||||
x)
|
x)
|
||||||
|
@ -89,35 +162,6 @@ EOF
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case x${GRUB_TERMINAL_OUTPUT} in
|
case x${GRUB_TERMINAL_OUTPUT} in
|
||||||
xgfxterm)
|
|
||||||
# Make the font accessible
|
|
||||||
prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
|
|
||||||
|
|
||||||
cat << EOF
|
|
||||||
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
|
|
||||||
set gfxmode=${GRUB_GFXMODE}
|
|
||||||
insmod gfxterm
|
|
||||||
insmod ${GRUB_VIDEO_BACKEND}
|
|
||||||
if terminal_output gfxterm ; then true ; else
|
|
||||||
# For backward compatibility with versions of terminal.mod that don't
|
|
||||||
# understand terminal_output
|
|
||||||
terminal gfxterm
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
|
|
||||||
&& is_path_readable_by_grub $GRUB_THEME; then
|
|
||||||
echo "Found theme: $GRUB_THEME" >&2
|
|
||||||
prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /"
|
|
||||||
cat << EOF
|
|
||||||
insmod gfxmenu
|
|
||||||
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
|
|
||||||
set menuviewer=gfxmenu
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
cat << EOF
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
x)
|
x)
|
||||||
# Just use the native terminal
|
# Just use the native terminal
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -27,7 +27,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||||
OS=GNU
|
OS=GNU
|
||||||
else
|
else
|
||||||
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
||||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}"
|
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
at_least_one=false
|
at_least_one=false
|
||||||
|
|
|
@ -30,7 +30,7 @@ CLASS="--class os"
|
||||||
case "${GRUB_DISTRIBUTOR}" in
|
case "${GRUB_DISTRIBUTOR}" in
|
||||||
Debian)
|
Debian)
|
||||||
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
||||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') --class gnu-kfreebsd --class gnu ${CLASS}"
|
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
OS="FreeBSD"
|
OS="FreeBSD"
|
||||||
|
|
|
@ -31,7 +31,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||||
OS=GNU/Linux
|
OS=GNU/Linux
|
||||||
else
|
else
|
||||||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}"
|
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||||
|
|
Loading…
Reference in a new issue