Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OsclR-0004cV-GW for mharc-grub-devel@gnu.org; Mon, 06 Sep 2010 10:33:41 -0400 Received: from [140.186.70.92] (port=55804 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsclI-0004XE-GI for grub-devel@gnu.org; Mon, 06 Sep 2010 10:33:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsclC-0005VF-Rd for grub-devel@gnu.org; Mon, 06 Sep 2010 10:33:28 -0400 Received: from smtpout01s1.x-echo.com ([193.252.149.37]:56318) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsclC-0005Ut-Dr for grub-devel@gnu.org; Mon, 06 Sep 2010 10:33:26 -0400 Received: from colinux.localdomain (localhost.localdomain [127.0.0.1]) by colinux.localdomain (SMTP Server) with ESMTP id C2B9F1000E for ; Mon, 6 Sep 2010 16:33:20 +0200 (CEST) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=MIMEBOUNDARY To: grub-devel@gnu.org From: Yves Blusseau Date: Mon, 06 Sep 2010 16:33:20 +0200 Message-ID: <20100906143320.11416.58407.stgit@colinux.localdomain> User-Agent: StGit/0.15-97-g9680 X-AV-Checked: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Add new --boot-directory option to replace --root-directory X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2010 14:33:39 -0000 This is a MIME message. --MIMEBOUNDARY Content-Disposition: inline MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit * 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 --MIMEBOUNDARY Content-Disposition: attachment; filename=boot-directory-option.patch MIME-Version: 1.0 Content-Type: text/plain; name=boot-directory-option.patch; charset="utf-8" Content-Transfer-Encoding: 7bit diff --git a/ChangeLog.bootdir-option b/ChangeLog.bootdir-option new file mode 100644 index 0000000..ed0e829 --- /dev/null +++ b/ChangeLog.bootdir-option @@ -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. diff --git a/util/grub-install.in b/util/grub-install.in index e6521f0..ec8cb83 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -40,8 +40,10 @@ grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` +grubdirname=`echo @grubdirname@ | sed ${transform}` rootdir= -grub_prefix=`echo /boot/grub | sed ${transform}` +bootdir= +grubdir=`echo "/@bootdirname@/@grubdirname@" | sed "${transform};s,//*,/,g"` modules= install_device= @@ -69,8 +71,8 @@ Install GRUB on your drive. -h, --help print this message and exit -v, --version print the version information and exit --modules=MODULES pre-load specified modules MODULES - --root-directory=DIR install GRUB images under the directory DIR - instead of the root directory + --boot-directory=DIR install GRUB images under the directory DIR/$grubdirname + instead of the $grubdir directory --grub-setup=FILE use FILE as grub-setup --grub-mkimage=FILE use FILE as grub-mkimage --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap @@ -88,11 +90,8 @@ fi 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 -OpenBSD), and uses grub-setup 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. +$self copies GRUB images into $grubdir, and uses grub-setup +to install grub into the boot sector. Report bugs to . EOF @@ -134,11 +133,17 @@ do --font=*) ;; +# 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=//'` ;; + --grub-setup) grub_setup=`argument $option "$@"`; shift;; --grub-setup=*) @@ -215,23 +220,18 @@ if test $debug = yes; then setup_verbose="--verbose" 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 +if [ -z "$bootdir" ]; then + # Default bootdir if bootdir not initialized. + bootdir=/@bootdirname@ -grubdir=${bootdir}/`echo grub | sed ${transform}` -device_map=${grubdir}/device.map + if [ -n "$rootdir" ] ; then + # Initialize bootdir if rootdir was initialized. + bootdir=${rootdir}/@bootdirname@ + fi +fi +grubdir=`echo "${bootdir}/@grubdirname@" | sed "${transform};s,//*,/,g"` +device_map=${grubdir}/device.map grub_probe="${grub_probe} --device-map=${device_map}" # Check if GRUB is installed. diff --git a/util/grub-reboot.in b/util/grub-reboot.in index e7a41f6..ea2f759 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -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 diff --git a/util/grub-set-default.in b/util/grub-set-default.in index 389c504..ad0df51 100644 --- a/util/grub-set-default.in +++ b/util/grub-set-default.in @@ -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" --MIMEBOUNDARY--