Add "-o grub.iso" like cmdline options support.

* util/grub-install.in: Improve cmdline option parsing.
	* util/grub-mkconfig.in: Likewise.
	* util/grub-mkrescue.in: Likewise.
	* util/grub-reboot.in: Likewise.
	* util/grub-set-default.in: Likewise.
	* util/i386/efi/grub-install.in: Likewise.
	* util/ieee1275/grub-install.in: Likewise.
	* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
This commit is contained in:
BVK Chaitanya 2010-06-12 20:30:38 +05:30
commit 96e5c55634
9 changed files with 251 additions and 19 deletions

View file

@ -1,3 +1,16 @@
2010-06-12 BVK Chaitanya <bvk.groups@gmail.com>
Add "-o grub.iso" like cmdline options support.
* util/grub-install.in: Improve cmdline option parsing.
* util/grub-mkconfig.in: Likewise.
* util/grub-mkrescue.in: Likewise.
* util/grub-reboot.in: Likewise.
* util/grub-set-default.in: Likewise.
* util/i386/efi/grub-install.in: Likewise.
* util/ieee1275/grub-install.in: Likewise.
* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
2010-06-12 Colin Watson <cjwatson@ubuntu.com> 2010-06-12 Colin Watson <cjwatson@ubuntu.com>
* .bzrignore: Ignore 41_custom. * .bzrignore: Ignore 41_custom.

View file

@ -103,8 +103,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -112,33 +127,62 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
--font)
font=`argument $option "$@"`; shift;;
--font=*) --font=*)
font=`echo "$option" | sed 's/--font=//'` ;; font=`echo "$option" | sed 's/--font=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-setup)
grub_setup=`argument $option "$@"`; shift;;
--grub-setup=*) --grub-setup=*)
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;; grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift;;
--grub-mkimage=*) --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift;;
--grub-mkdevicemap=*) --grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift;;
--grub-probe=*) --grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-floppy) --no-floppy)
no_floppy="--no-floppy" ;; no_floppy="--no-floppy" ;;
--recheck) --recheck)
recheck=yes ;; recheck=yes ;;
--disk-module)
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
disk_module=`argument $option "$@"`; shift;
fi ;;
--disk-module=*) --disk-module=*)
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
disk_module=`echo "$option" | sed 's/--disk-module=//'` disk_module=`echo "$option" | sed 's/--disk-module=//'`
fi ;; fi ;;
# This is an undocumented feature... # This is an undocumented feature...
--debug) --debug)
debug=yes ;; debug=yes ;;
-f | --force) -f | --force)
setup_force="--force" ;; setup_force="--force" ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage

View file

@ -52,14 +52,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
# Check the arguments. argument () {
next_grub_cfg=false opt=$1
for option in "$@"; do shift
if $next_grub_cfg; then
grub_cfg=$option if test $# -eq 0; then
next_grub_cfg=false echo "$0: option requires an argument -- '$opt'" 1>&2
continue exit 1
fi fi
echo $1
}
# Check the arguments.
while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -67,9 +76,8 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
-o) -o | --output)
next_grub_cfg=: grub_cfg=`argument $option "$@"`; shift;;
;;
--output=*) --output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'` grub_cfg=`echo "$option" | sed 's/--output=//'`
;; ;;
@ -78,6 +86,10 @@ for option in "$@"; do
usage usage
exit 1 exit 1
;; ;;
*)
echo "Invalid parameter, $option" 1>&2
exit 1
;;
esac esac
done done
if $next_grub_cfg; then if $next_grub_cfg; then

View file

@ -53,7 +53,7 @@ Make GRUB rescue image.
-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
--output=FILE save output in FILE [required] -o, --output=FILE save output in FILE [required]
--modules=MODULES pre-load specified modules MODULES --modules=MODULES pre-load specified modules MODULES
--rom-directory=DIR save rom images in DIR [optional] --rom-directory=DIR save rom images in DIR [optional]
--xorriso=FILE use FILE as xorriso [optional] --xorriso=FILE use FILE as xorriso [optional]
@ -68,8 +68,23 @@ Mail xorriso support requests to <bug-xorriso@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -77,24 +92,47 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output)
output_image=`argument $option "$@"`; shift ;;
--output=*) --output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;; output_image=`echo "$option" | sed 's/--output=//'` ;;
--rom-directory)
rom_directory=`argument $option "$@"`; shift ;;
--rom-directory=*) --rom-directory=*)
rom_directory=`echo "$option" | sed 's/--rom-directory=//'` ;; rom_directory=`echo "$option" | sed 's/--rom-directory=//'` ;;
# Intentionally undocumented # Intentionally undocumented
--override-directory)
override_dir=`argument $option "$@"`
shift
PATH=${override_dir}:$PATH
export PATH
;;
--override-directory=*) --override-directory=*)
override_dir=`echo "${option}/" | sed 's/--override-directory=//'` override_dir=`echo "${option}/" | sed 's/--override-directory=//'`
PATH=${override_dir}:$PATH PATH=${override_dir}:$PATH
export PATH export PATH
;; ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*) --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--xorriso)
xorriso=`argument $option "$@"`; shift ;;
--xorriso=*) --xorriso=*)
xorriso=`echo "${option}/" | sed 's/--xorriso=//'` ;; xorriso=`echo "${option}/" | sed 's/--xorriso=//'` ;;
*) *)
source="${source} ${option}" ;; source="${source} ${option} $@"; break ;;
esac esac
done done

View file

@ -48,8 +48,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -57,8 +72,12 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage

View file

@ -48,8 +48,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -57,8 +72,12 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage

View file

@ -73,8 +73,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -82,16 +97,32 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*) --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift ;;
--grub-mkdevicemap=*) --grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift ;;
--grub-probe=*) --grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-floppy) --no-floppy)
no_floppy="--no-floppy" ;; no_floppy="--no-floppy" ;;
--recheck) --recheck)

View file

@ -76,8 +76,23 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -85,16 +100,32 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
--root-directory)
rootdir=`argument $option "$@"`; shift ;;
--root-directory=*) --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
--grub-mkdevicemap)
grub_mkdevicemap=`argument $option "$@"`; shift ;;
--grub-mkdevicemap=*) --grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*) --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-probe)
grub_probe=`argument $option "$@"`; shift ;;
--grub-probe=*) --grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
--no-nvram) --no-nvram)
update_nvram=no ;; update_nvram=no ;;
# This is an undocumented feature... # This is an undocumented feature...

View file

@ -54,10 +54,25 @@ Report bugs to <bug-grub@gnu.org>.
EOF EOF
} }
argument () {
opt=$1
shift
if test $# -eq 0; then
echo "$0: option requires an argument -- '$opt'" 1>&2
exit 1
fi
echo $1
}
input_dir=${pkglibdir} input_dir=${pkglibdir}
# Check the arguments. # Check the arguments.
for option in "$@"; do while test $# -gt 0
do
option=$1
shift
case "$option" in case "$option" in
-h | --help) -h | --help)
usage usage
@ -65,12 +80,22 @@ for option in "$@"; do
-v | --version) -v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;; exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*) --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;; modules=`echo "$option" | sed 's/--modules=//'` ;;
--pkglibdir)
input_dir=`argument $option "$@"`; shift ;;
--pkglibdir=*) --pkglibdir=*)
input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;; input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*) --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
-*) -*)
echo "Unrecognized option \`$option'" 1>&2 echo "Unrecognized option \`$option'" 1>&2
usage usage