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>
* .bzrignore: Ignore 41_custom.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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