Make --version uniform and avoid hard-coded program name.

This commit is contained in:
Grégoire Sutre 2010-06-08 12:52:42 +02:00
parent e8a6f3b6a5
commit 0ea7c4f93c
12 changed files with 70 additions and 30 deletions

View file

@ -1,3 +1,22 @@
2010-06-08 Grégoire Sutre <gregoire.sutre@gmail.com>
Make --version uniform and avoid hard-coded program name.
* util/grub-mkimage.c (main): Use `program_name' instead of
hard-coded string.
* util/i386/pc/grub-setup.c (main): Likewise.
* util/sparc64/ieee1275/grub-setup.c (parse_options): Likewise.
* util/grub-install.in: Save the basename of $0 in $self, and use the
latter in informational messages. Use the same format for --version
as the binary programs.
* 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-08 Grégoire Sutre <gregoire.sutre@gmail.com>
* util/i386/pc/grub-setup.c (setup): Use absolute offsets for start of

View file

@ -34,6 +34,8 @@ font=@datadir@/@PACKAGE_TARNAME@/ascii.pf2
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
localedir=@datadir@/locale
self=`basename $0`
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
@ -61,7 +63,7 @@ fi
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION] install_device
Usage: $self [OPTION] install_device
Install GRUB on your drive.
-h, --help print this message and exit
@ -91,10 +93,10 @@ fi
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and
$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 grub-install will copy
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>.
@ -108,7 +110,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;

View file

@ -23,7 +23,8 @@ exec_prefix=@exec_prefix@
sbindir=@sbindir@
libdir=@libdir@
sysconfdir=@sysconfdir@
package_version=@PACKAGE_VERSION@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_os=@host_os@
datarootdir=@datarootdir@
datadir=@datadir@
@ -31,6 +32,8 @@ pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
grub_cfg=""
grub_mkconfig_dir=${sysconfdir}/grub.d
self=`basename $0`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -38,7 +41,7 @@ grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION]
Usage: $self [OPTION]
Generate a grub config file
-o, --output=FILE output generated config to FILE [default=stdout]
@ -62,7 +65,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${package_version})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
-o)
next_grub_cfg=:
@ -113,7 +116,7 @@ if [ "$EUID" != 0 ] ; then
done ;;
esac
if [ $root != t ] ; then
echo "$0: You must run this as root" >&2
echo "$self: You must run this as root" >&2
exit 1
fi
fi
@ -284,7 +287,7 @@ cat << EOF
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by $0 using templates
# It is automatically generated by $self using templates
# from ${grub_mkconfig_dir} and settings from ${sysconfdir}/default/grub
#
EOF

View file

@ -1307,7 +1307,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -30,6 +30,8 @@ target_cpu=@target_cpu@
native_platform=@platform@
pkglib_DATA="@pkglib_DATA@"
self=`basename $0`
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot
qemu_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu
@ -44,7 +46,7 @@ grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] SOURCE...
Usage: $self [OPTION] SOURCE...
Make GRUB rescue image.
-h, --help print this message and exit
@ -54,7 +56,7 @@ Make GRUB rescue image.
--rom-directory=DIR save rom images in DIR [optional]
--grub-mkimage=FILE use FILE as grub-mkimage
$0 generates a bootable rescue image with specified source files or directories.
$self generates a bootable rescue image with specified source files or directories.
Report bugs to <bug-grub@gnu.org>.
EOF
@ -67,7 +69,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;

View file

@ -22,6 +22,10 @@ transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
@ -30,7 +34,7 @@ rootdir=
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Usage: $self [OPTION] entry
Set the default boot entry for GRUB, for the next boot only.
-h, --help print this message and exit
@ -51,7 +55,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;

View file

@ -22,6 +22,10 @@ transform="@program_transform_name@"
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
self=`basename $0`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
@ -30,7 +34,7 @@ rootdir=
# Print the usage.
usage () {
cat <<EOF
Usage: $0 [OPTION] entry
Usage: $self [OPTION] entry
Set the default boot entry for GRUB.
-h, --help print this message and exit
@ -51,7 +55,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;

View file

@ -33,6 +33,8 @@ host_os=@host_os@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
localedir=@datadir@/locale
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -50,7 +52,7 @@ debug=no
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION]
Usage: $self [OPTION]
Install GRUB on your EFI partition.
-h, --help print this message and exit
@ -64,7 +66,7 @@ Install GRUB on your EFI partition.
--no-floppy do not probe any floppy drive
--recheck probe a device map even if it already exists
grub-install copies GRUB images into the DIR/boot directory specified by
$self copies GRUB images into the DIR/boot directory specified by
--root-directory.
Report bugs to <bug-grub@gnu.org>.
@ -78,7 +80,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
@ -219,7 +221,7 @@ $grub_mkimage -O ${target_cpu}-efi --output=${grubdir}/grub.efi $modules || exit
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
echo "Check if this is correct or not. If any of the lines is incorrect,"
echo "fix it and re-run the script \`grub-install'."
echo "fix it and re-run the script \`$self'."
echo
cat $device_map

View file

@ -702,7 +702,7 @@ main (int argc, char *argv[])
break;
case 'V':
printf ("grub-setup (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':

View file

@ -34,6 +34,8 @@ target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@ -53,7 +55,7 @@ nvsetenv=`which nvsetenv`
# Print the usage.
usage () {
cat <<EOF
Usage: grub-install [OPTION] [install_device]
Usage: $self [OPTION] [install_device]
Install GRUB on your drive.
-h, --help print this message and exit
@ -66,7 +68,7 @@ Install GRUB on your drive.
--grub-probe=FILE use FILE as grub-probe
--no-nvram don't update the boot-device NVRAM variable
grub-install copies GRUB images into the DIR/boot directory specified by
$self copies GRUB images into the DIR/boot directory specified by
--root-directory, and uses nvsetenv to set the Open Firmware boot-device
variable.
@ -81,7 +83,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
@ -231,7 +233,7 @@ fi
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
echo "Check if this is correct or not. If any of the lines is incorrect,"
echo "fix it and re-run the script \`grub-install'."
echo "fix it and re-run the script \`$self'."
echo
cat $device_map

View file

@ -30,13 +30,15 @@ target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
self=`basename $0`
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
# Usage: usage
# Print the usage.
usage () {
cat <<EOF
Usage: grub-mkrescue [OPTION] output_image
Usage: $self [OPTION] output_image
Make GRUB rescue image.
-h, --help print this message and exit
@ -46,7 +48,7 @@ Make GRUB rescue image.
default: ${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimage
grub-mkimage generates a bootable rescue CD image for PowerMac and CHRP.
$self generates a bootable rescue CD image for PowerMac and CHRP.
Report bugs to <bug-grub@gnu.org>.
EOF
@ -61,7 +63,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
echo "grub-mkrescue (GNU GRUB ${PACKAGE_VERSION})"
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;

View file

@ -503,7 +503,7 @@ parse_options (struct grub_setup_info *gp, int argc, char *argv[])
break;
case 'V':
printf ("grub-setup (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':