mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-29 02:31:05 +00:00
2004-06-20 Yoshinori K. Okuji <okuji@enbug.org>
This is a big change on saving a default entry. This change makes it possible to set up a quite robust system using GRUB. Now we do not use the second sector of Stage 2 to store an entry number but use the file /boot/grub/default. This file must be generated by grub-set-default, although this file is plain-text. * util/grub-set-default.in: New file. * util/grub-install.in (grub_set_default): New variable. Use /grub instead of /boot/grub on OpenBSD as well as NetBSD. Run grub-set-default to make a default file. * util/Makefile.am (sbin_SCRIPTS): Added grub-set-default. * stage2/stage2.c (run_menu): Change the fallback handling to support multiple fallback entries. (cmain): Likewise. Also, get a saved entry from a default file if possible, before reading a config file. * stage2/shared.h (DEFAULT_FILE_BUF): New macro. (DEFAULT_FILE_BUFLEN): Likewise. (CMDLINE_BUF): Set to DEFAULT_FILE_BUF + DEFAULT_FILE_BUFLEN. (MENU_BUFLEN): Set to 0x8000 + PASSWORD_BUF - MENU_BUF. (fallback_entry): Removed. (fallback_entries): Declared. (fallback_entryno): Likewise. (MAX_FALLBACK_ENTRIES): New macro. * stage2/cmdline.c (run_script): Use FALLBACK_ENTRYNO instead of FALLBACK_ENTRY. * stage2/builtins.c (fallback_entry): Removed. (fallback_entryno): New variable. (fallback_entries): Likewise. (init_config): Initialize FALLBACK_ENTRYNO and FALLBACK_ENTRIES. (fallback_func): Rewritten completely. (savedefault_func): Likewise. * docs/grub.texi (grub-set-default): New direntry. (Installation): Describe grub-set-default for manual installations. (Making your system robust): New section. (Booting once-only): New subsection. (Booting fallback systems): Likewise. (fallback): Describe multiple fallback entries. (savedefault): Describe an optional argument. (Invoking grub-set-default): New chapter. (Future): Replaced with a description about GRUB 2. * configure.ac (AC_CONFIG_FILES): Added util/grub-set-default.
This commit is contained in:
1 parent
e15e075464
commit
5b5f6dc772
16 files changed
+705
-98
No files matched your search
+2
-1
@@ -1,5 +1,6 @@
|
||||
bin_PROGRAMS = mbchk
|
||||
sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo
|
||||
sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo \
|
||||
grub-set-default
|
||||
noinst_SCRIPTS = grub-image mkbimage
|
||||
|
||||
EXTRA_DIST = mkbimage
|
||||
|
||||
+8
-3
@@ -42,7 +42,8 @@ bin_PROGRAMS = mbchk$(EXEEXT)
|
||||
subdir = util
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||
$(srcdir)/grub-image.in $(srcdir)/grub-install.in \
|
||||
$(srcdir)/grub-md5-crypt.in $(srcdir)/grub-terminfo.in
|
||||
$(srcdir)/grub-md5-crypt.in $(srcdir)/grub-set-default.in \
|
||||
$(srcdir)/grub-terminfo.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
@@ -51,7 +52,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES = grub-image grub-install grub-md5-crypt \
|
||||
grub-terminfo
|
||||
grub-terminfo grub-set-default
|
||||
am__installdirs = $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir)
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
@@ -180,7 +181,9 @@ sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo
|
||||
sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo \
|
||||
grub-set-default
|
||||
|
||||
noinst_SCRIPTS = grub-image mkbimage
|
||||
EXTRA_DIST = mkbimage
|
||||
|
||||
@@ -229,6 +232,8 @@ grub-md5-crypt: $(top_builddir)/config.status $(srcdir)/grub-md5-crypt.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||
grub-terminfo: $(top_builddir)/config.status $(srcdir)/grub-terminfo.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||
grub-set-default: $(top_builddir)/config.status $(srcdir)/grub-set-default.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkdir_p) $(DESTDIR)$(bindir)
|
||||
|
||||
@@ -30,6 +30,7 @@ host_vendor=@host_vendor@
|
||||
pkgdatadir=${datadir}/${PACKAGE}/${host_cpu}-${host_vendor}
|
||||
|
||||
grub_shell=${sbindir}/grub
|
||||
grub_set_default=${sbindir}/grub-set-default
|
||||
log_file=/tmp/grub-install.log.$$
|
||||
img_file=/tmp/grub-install.img.$$
|
||||
rootdir=
|
||||
@@ -273,8 +274,8 @@ fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD, use /grub
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=/grub
|
||||
bootdir=${rootdir}
|
||||
@@ -410,6 +411,9 @@ for file in \
|
||||
cp -f $file ${grubdir} || exit 1
|
||||
done
|
||||
|
||||
# Make a default file.
|
||||
${grub_set_default} --root-directory=${rootdir} default
|
||||
|
||||
# Make sure that GRUB reads the same images as the host OS.
|
||||
test -n "$mkimg" && img_file=`$mkimg`
|
||||
test -n "$mklog" && log_file=`$mklog`
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Set a default boot entry for GRUB
|
||||
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# Initialize some variables.
|
||||
PACKAGE=@PACKAGE@
|
||||
VERSION=@VERSION@
|
||||
|
||||
rootdir=
|
||||
entry=
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: grub-set-default [OPTION] entry
|
||||
Set the default boot entry for GRUB.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--root-directory=DIR Use the directory DIR instead of the root directory
|
||||
|
||||
ENTRY is a number or the special keyword \`default'.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "grub-set-default (GNU GRUB ${VERSION})"
|
||||
exit 0 ;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if test "x$entry" != x; then
|
||||
echo "More than one entries?" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
# We don't care about what the user specified actually.
|
||||
entry="${option}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test "x$entry" = x; then
|
||||
echo "entry not specified." 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine the GRUB directory. This is different among OSes.
|
||||
grubdir=${rootdir}/boot/grub
|
||||
if test -d ${grubdir}; then
|
||||
:
|
||||
else
|
||||
grubdir=${rootdir}/grub
|
||||
if test -d ${grubdir}; then
|
||||
:
|
||||
else
|
||||
echo "No GRUB directory found under ${rootdir}/" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
file=${grubdir}/default
|
||||
if test -f ${file}; then
|
||||
chmod 0600 ${file}
|
||||
rm -f ${file}
|
||||
fi
|
||||
cat <<EOF > $file
|
||||
$entry
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# WARNING: If you want to edit this file directly, do not remove any line
|
||||
# from this file, including this warning. Using `grub-set-default' is
|
||||
# strongly recommended.
|
||||
EOF
|
||||
|
||||
# Bye.
|
||||
exit 0
|
||||
Reference in new issue
Block a user