Add new --boot-directory option to replace --root-directory

* util/grub-install.in: Add new --boot-directory option
	* util/grub-reboot.in: Likewise.
	* util/grub-set-default.in: Likewise.
This commit is contained in:
Yves Blusseau 2010-09-08 17:25:29 +02:00
parent b9fe6ea2ea
commit c0e53ea537
4 changed files with 70 additions and 55 deletions

View file

@ -1,3 +1,11 @@
2010-09-08 Yves Blusseau <blusseau@zetam.org>
Add new --boot-directory option to replace --root-directory
* util/grub-install.in: Add new --boot-directory option
* util/grub-reboot.in: Likewise.
* util/grub-set-default.in: Likewise.
2010-09-08 Yves Blusseau <blusseau@zetam.org> 2010-09-08 Yves Blusseau <blusseau@zetam.org>
* util/grub-mkconfig.in: Use new variable. * util/grub-mkconfig.in: Use new variable.

View file

@ -41,7 +41,8 @@ grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir= rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}` bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
modules= modules=
install_device= install_device=
@ -69,8 +70,8 @@ Install GRUB on your drive.
-h, --help print this message and exit -h, --help print this message and exit
-v, --version print the version information and exit -v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES --modules=MODULES pre-load specified modules MODULES
--root-directory=DIR install GRUB images under the directory DIR --boot-directory=DIR install GRUB images under the directory DIR/@grubdirname@
instead of the root directory instead of the $grubdir directory
--grub-setup=FILE use FILE as grub-setup --grub-setup=FILE use FILE as grub-setup
--grub-mkimage=FILE use FILE as grub-mkimage --grub-mkimage=FILE use FILE as grub-mkimage
--grub-mkdevicemap=FILE use FILE as grub-mkdevicemap --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
@ -88,11 +89,8 @@ fi
INSTALL_DEVICE can be a GRUB device name or a system device filename. INSTALL_DEVICE can be a GRUB device name or a system device filename.
$self copies GRUB images into /boot/grub (or /grub on NetBSD and $self copies GRUB images into $grubdir, and uses grub-setup
OpenBSD), and uses grub-setup to install grub into the boot sector. to install grub into the boot sector.
If the --root-directory option is used, then $self will copy
images into the operating system installation rooted at that directory.
Report bugs to <bug-grub@gnu.org>. Report bugs to <bug-grub@gnu.org>.
EOF EOF
@ -134,11 +132,17 @@ do
--font=*) --font=*)
;; ;;
# Accept for compatibility
--root-directory) --root-directory)
rootdir=`argument $option "$@"`; shift;; rootdir=`argument $option "$@"`; shift;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
--grub-setup) --grub-setup)
grub_setup=`argument $option "$@"`; shift;; grub_setup=`argument $option "$@"`; shift;;
--grub-setup=*) --grub-setup=*)
@ -215,23 +219,18 @@ if test $debug = yes; then
setup_verbose="--verbose" setup_verbose="--verbose"
fi fi
# Initialize these directories here, since ROOTDIR was initialized. if [ -z "$bootdir" ]; then
case "$host_os" in # Default bootdir if bootdir not initialized.
netbsd* | openbsd*) bootdir=/@bootdirname@
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/`echo grub | sed ${transform}` if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
device_map=${grubdir}/device.map device_map=${grubdir}/device.map
grub_probe="${grub_probe} --device-map=${device_map}" grub_probe="${grub_probe} --device-map=${device_map}"
# Check if GRUB is installed. # Check if GRUB is installed.

View file

@ -29,6 +29,8 @@ self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir= rootdir=
bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
@ -39,8 +41,8 @@ Set the default boot entry for GRUB, for the next boot only.
-h, --help print this message and exit -h, --help print this message and exit
-v, --version print the version information and exit -v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR --boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
instead of the root directory instead of the $grubdir directory
ENTRY is a number or a menu item title. ENTRY is a number or a menu item title.
@ -73,11 +75,17 @@ do
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
# Accept for compatibility
--root-directory) --root-directory)
rootdir=`argument $option "$@"`; shift ;; rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage
@ -99,21 +107,17 @@ if test "x$entry" = x; then
exit 1 exit 1
fi fi
# Initialize these directories here, since ROOTDIR was initialized. if [ -z "$bootdir" ]; then
case "$host_os" in # Default bootdir if bootdir not initialized.
netbsd* | openbsd*) bootdir=/@bootdirname@
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/`echo grub | sed ${transform}` if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'` prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
if [ "$prev_saved_entry" ]; then if [ "$prev_saved_entry" ]; then

View file

@ -29,6 +29,8 @@ self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir= rootdir=
bootdir=
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
@ -39,8 +41,8 @@ Set the default boot entry for GRUB.
-h, --help print this message and exit -h, --help print this message and exit
-v, --version print the version information and exit -v, --version print the version information and exit
--root-directory=DIR expect GRUB images under the directory DIR --boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
instead of the root directory instead of the $grubdir directory
ENTRY is a number or a menu item title. ENTRY is a number or a menu item title.
@ -73,11 +75,17 @@ do
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
# Accept for compatibility
--root-directory) --root-directory)
rootdir=`argument $option "$@"`; shift ;; rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--boot-directory)
bootdir=`argument $option "$@"`; shift;;
--boot-directory=*)
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage
@ -99,21 +107,17 @@ if test "x$entry" = x; then
exit 1 exit 1
fi fi
# Initialize these directories here, since ROOTDIR was initialized. if [ -z "$bootdir" ]; then
case "$host_os" in # Default bootdir if bootdir not initialized.
netbsd* | openbsd*) bootdir=/@bootdirname@
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
# instead of /boot/grub.
grub_prefix=`echo /grub | sed ${transform}`
bootdir=${rootdir}
;;
*)
# Use /boot/grub by default.
bootdir=${rootdir}/boot
;;
esac
grubdir=${bootdir}/`echo grub | sed ${transform}` if [ -n "$rootdir" ] ; then
# Initialize bootdir if rootdir was initialized.
bootdir=${rootdir}/@bootdirname@
fi
fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry $grub_editenv ${grubdir}/grubenv unset prev_saved_entry
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry" $grub_editenv ${grubdir}/grubenv set saved_entry="$entry"