Add new --boot-directory option to replace --root-directory
PATCH 1/1 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.
* util/grub-mkconfig.in: Use new variable.
--- ChangeLog.bootdir-option | 5 +++++ util/grub-install.in | 46 +++++++++++++++++++++++----------------------- util/grub-reboot.in | 39 ++++++++++++++++++++++----------------- util/grub-set-default.in | 39 ++++++++++++++++++++++----------------- 4 files changed, 72 insertions(+), 57 deletions(-) create mode 100644 ChangeLog.bootdir-option
ChangeLog.bootdir-option new file +5 -0
@@ -0,0 +1,5 @@ +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.
util/grub-install.in +23 -23
84 lines not on this page · raw message
util/grub-reboot.in +22 -17
@@ -28,7 +28,10 @@ PACKAGE_VERSION=@PACKAGE_VERSION@ self=`basename $0` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` +grubdirname=`echo @grubdirname@ | sed ${transform}` rootdir= +bootdir= +grubdir=`echo "/@bootdirname@/@grubdirname@" | sed "${transform};s,//*,/,g"` # Usage: usage # Print the usage.
@@ -39,8 +42,8 @@ Set the default boot entry for GRUB, for the next boot only. -h, --help print this message and exit -v, --version print the version information and exit - --root-directory=DIR expect GRUB images under the directory DIR - instead of the root directory + --boot-directory=DIR expect GRUB images under the directory DIR/$grubdirname + instead of the $grubdir directory ENTRY is a number or a menu item title.
@@ -73,11 +76,17 @@ do echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; +# Accept for compatibility --root-directory) rootdir=`argument $option "$@"`; shift ;; --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 usage
@@ -99,21 +108,17 @@ if test "x$entry" = x; then exit 1 fi -# Initialize these directories here, since ROOTDIR was initialized. -case "$host_os" in -netbsd* | openbsd*) - # 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 [ -z "$bootdir" ]; then + # Default bootdir if bootdir not initialized. + bootdir=/@bootdirname@ + + if [ -n "$rootdir" ] ; then + # Initialize bootdir if rootdir was initialized. + bootdir=${rootdir}/@bootdirname@ + fi +fi + +grubdir=`echo "${bootdir}/@grubdirname@" | sed "${transform};s,//*,/,g"` prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'` if [ "$prev_saved_entry" ]; then
util/grub-set-default.in +22 -17
@@ -28,7 +28,10 @@ PACKAGE_VERSION=@PACKAGE_VERSION@ self=`basename $0` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` +grubdirname=`echo @grubdirname@ | sed ${transform}` rootdir= +bootdir= +grubdir=`echo "/@bootdirname@/@grubdirname@" | sed "${transform};s,//*,/,g"` # Usage: usage # Print the usage.
@@ -39,8 +42,8 @@ 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 expect GRUB images under the directory DIR - instead of the root directory + --boot-directory=DIR expect GRUB images under the directory DIR/$grubdirname + instead of the $grubdir directory ENTRY is a number or a menu item title.
@@ -73,11 +76,17 @@ do echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; +# Accept for compatibility --root-directory) rootdir=`argument $option "$@"`; shift ;; --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 usage
@@ -99,21 +108,17 @@ if test "x$entry" = x; then exit 1 fi -# Initialize these directories here, since ROOTDIR was initialized. -case "$host_os" in -netbsd* | openbsd*) - # 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 [ -z "$bootdir" ]; then + # Default bootdir if bootdir not initialized. + bootdir=/@bootdirname@ + + if [ -n "$rootdir" ] ; then + # Initialize bootdir if rootdir was initialized. + bootdir=${rootdir}/@bootdirname@ + fi +fi + +grubdir=`echo "${bootdir}/@grubdirname@" | sed "${transform};s,//*,/,g"` $grub_editenv ${grubdir}/grubenv unset prev_saved_entry $grub_editenv ${grubdir}/grubenv set saved_entry="$entry"