Unify more code in grub-install_header.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-29 12:26:43 +02:00
parent f7457fb231
commit c53b4e67e4
6 changed files with 44 additions and 149 deletions

View file

@ -1,3 +1,7 @@
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
Unify more code in grub-install_header.
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com> 2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
Add few new tests. Add few new tests.

View file

@ -17,38 +17,19 @@
# along with GRUB. If not, see <http://www.gnu.org/licenses/>. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables. # Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
sbindir="@sbindir@" sbindir="@sbindir@"
bindir="@bindir@"
libdir="@libdir@"
sysconfdir="@sysconfdir@" sysconfdir="@sysconfdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
host_os=@host_os@ host_os=@host_os@
target= target=
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
localedir="@datadir@/locale" localedir="@datadir@/locale"
self="`basename $0`"
grub_mkimage="${bindir}/@grub_mkimage@"
grub_probe="${sbindir}/@grub_probe@" grub_probe="${sbindir}/@grub_probe@"
grub_editenv="${bindir}/@grub_editenv@" grub_editenv="${bindir}/@grub_editenv@"
grub_mkrelpath="${bindir}/@grub_mkrelpath@" grub_mkrelpath="${bindir}/@grub_mkrelpath@"
rootdir= rootdir=
bootdir= bootdir=
grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`" grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`"
modules=
install_device= install_device=
force_lba= force_lba=
@ -73,8 +54,6 @@ fi
disk_module=unspecified disk_module=unspecified
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
usage () { usage () {
@ -85,8 +64,6 @@ usage () {
gettext "Install GRUB on your drive." ; echo gettext "Install GRUB on your drive." ; echo
echo echo
print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help grub_print_install_files_help
dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")" dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
@ -96,7 +73,6 @@ usage () {
# TRANSLATORS: "current" refers to the platform user's currently running on # TRANSLATORS: "current" refers to the platform user's currently running on
print_option_help "--target=$target_trans" "$(gettext "install GRUB for TARGET platform [default=current]")" print_option_help "--target=$target_trans" "$(gettext "install GRUB for TARGET platform [default=current]")"
print_option_help "--grub-setup=$(gettext "FILE")" "$(gettext "use FILE as grub-setup")" print_option_help "--grub-setup=$(gettext "FILE")" "$(gettext "use FILE as grub-setup")"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
print_option_help "--grub-mkrelpath=$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")" print_option_help "--grub-mkrelpath=$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
print_option_help "--grub-probe=$(gettext "FILE")" "$(gettext "use FILE as grub-probe")" print_option_help "--grub-probe=$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
# TRANSLATORS: "may break" doesn't just mean that option wouldn't have any # TRANSLATORS: "may break" doesn't just mean that option wouldn't have any
@ -140,14 +116,6 @@ do
-h | --help) -h | --help)
usage usage
exit 0 ;; exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--force-file-id) --force-file-id)
force_file_id=y ;; force_file_id=y ;;
@ -189,11 +157,6 @@ do
--bootloader-id=*) --bootloader-id=*)
bootloader_id="`echo "$option" | sed 's/--bootloader-id=//'`" ;; bootloader_id="`echo "$option" | sed 's/--bootloader-id=//'`" ;;
--grub-mkimage)
grub_mkimage="`argument $option "$@"`"; shift;;
--grub-mkimage=*)
grub_mkimage="`echo "$option" | sed 's/--grub-mkimage=//'`" ;;
--grub-mkrelpath) --grub-mkrelpath)
grub_mkrelpath="`argument "$option" "$@"`"; shift;; grub_mkrelpath="`argument "$option" "$@"`"; shift;;
--grub-mkrelpath=*) --grub-mkrelpath=*)

View file

@ -16,9 +16,34 @@ set -e
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
modules=
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst \ pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst \
handler.lst video.lst crypto.lst terminal.lst" handler.lst video.lst crypto.lst terminal.lst"
grub_mkimage="${bindir}/@grub_mkimage@"
grub_compress_file () { grub_compress_file () {
if [ "$compressor" != "" ] ; then if [ "$compressor" != "" ] ; then
"$compressor" $compressor_opts "$1" > "$2" "$compressor" $compressor_opts "$1" > "$2"
@ -121,6 +146,7 @@ grub_install_files () {
} }
grub_print_install_files_help () { grub_print_install_files_help () {
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies [default=all]")" print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies [default=all]")"
print_option_help "--themes=THEMES" "$(gettext_printf "install THEMES [default=%s]" "starfield")" print_option_help "--themes=THEMES" "$(gettext_printf "install THEMES [default=%s]" "starfield")"
print_option_help "--fonts=FONTS" "$(gettext_printf "install FONTS [default=%s]" "unicode")" print_option_help "--fonts=FONTS" "$(gettext_printf "install FONTS [default=%s]" "unicode")"
@ -129,6 +155,8 @@ grub_print_install_files_help () {
# TRANSLATORS: platform here isn't identifier. It can be translated. # TRANSLATORS: platform here isn't identifier. It can be translated.
dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")" dir_msg="$(gettext_printf "use images and modules under DIR [default=%s/<platform>]" "${libdir}/@PACKAGE@")"
print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg" print_option_help "-d, --directory=$(gettext "DIR")" "$dir_msg"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
} }
install_modules=all install_modules=all
@ -212,6 +240,18 @@ grub_process_install_options () {
source_directory=`argument $option "$@"`; grub_process_install_options_consumed=2 ;; source_directory=`argument $option "$@"`; grub_process_install_options_consumed=2 ;;
--override-directory=*) --override-directory=*)
source_directory=`echo "$option" | sed 's/--override-directory=//'` grub_process_install_options_consumed=1;; source_directory=`echo "$option" | sed 's/--override-directory=//'` grub_process_install_options_consumed=1;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; grub_process_install_options_consumed=2 ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'`;grub_process_install_options_consumed=1 ;;
--modules)
modules=`argument $option "$@"`; grub_process_install_options_consumed=2;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` grub_process_install_options_consumed=1;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
esac esac
} }

View file

@ -15,23 +15,8 @@
# along with GRUB. If not, see <http://www.gnu.org/licenses/>. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
# Initialize some variables. # Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_os=@host_os@ host_os=@host_os@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
grub_mkimage="${bindir}/@grub_mkimage@"
rootdir=/srv/tftp rootdir=/srv/tftp
modules= modules=
@ -48,11 +33,6 @@ efi32_dir="${libdir}/@PACKAGE@/i386-efi"
efi64_dir="${libdir}/@PACKAGE@/x86_64-efi" efi64_dir="${libdir}/@PACKAGE@/x86_64-efi"
itanium_dir="${libdir}/@PACKAGE@/ia64-efi" itanium_dir="${libdir}/@PACKAGE@/ia64-efi"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
usage () { usage () {
@ -60,12 +40,9 @@ usage () {
gettext; echo "Install GRUB on your drive."; echo gettext; echo "Install GRUB on your drive."; echo
echo echo
print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help grub_print_install_files_help
print_option_help "--net-directory=$(gettext "DIR")" "$(gettext "root directory of TFTP server")" print_option_help "--net-directory=$(gettext "DIR")" "$(gettext "root directory of TFTP server")"
print_option_help "--subdir=$(gettext "DIR")" "$(gettext "relative subdirectory on network server")" print_option_help "--subdir=$(gettext "DIR")" "$(gettext "relative subdirectory on network server")"
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
echo echo
gettext_printf "%s copies GRUB images into net_directory/subdir/target_cpu-platform\n" "$self" gettext_printf "%s copies GRUB images into net_directory/subdir/target_cpu-platform\n" "$self"
echo echo
@ -88,14 +65,6 @@ do
-h | --help) -h | --help)
usage usage
exit 0 ;; exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
--net-directory) --net-directory)
rootdir=`argument $option "$@"`; shift;; rootdir=`argument $option "$@"`; shift;;
@ -107,11 +76,6 @@ do
--subdir=*) --subdir=*)
subdir=`echo "$option" | sed 's/--subdir=//'` ;; subdir=`echo "$option" | sed 's/--subdir=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
# This is an undocumented feature... # This is an undocumented feature...
--debug) --debug)
debug=yes ;; debug=yes ;;

View file

@ -18,22 +18,6 @@
# Initialize some variables. # Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
self=`basename $0`
multiboot_dir="${libdir}/@PACKAGE@/i386-multiboot" multiboot_dir="${libdir}/@PACKAGE@/i386-multiboot"
coreboot_dir="${libdir}/@PACKAGE@/i386-coreboot" coreboot_dir="${libdir}/@PACKAGE@/i386-coreboot"
qemu_dir="${libdir}/@PACKAGE@/i386-qemu" qemu_dir="${libdir}/@PACKAGE@/i386-qemu"
@ -50,7 +34,6 @@ arcs_dir="${libdir}/@PACKAGE@/mips-arc"
arc_dir="${libdir}/@PACKAGE@/mipsel-arc" arc_dir="${libdir}/@PACKAGE@/mipsel-arc"
ppc_dir="${libdir}/@PACKAGE@/powerpc-ieee1275" ppc_dir="${libdir}/@PACKAGE@/powerpc-ieee1275"
rom_directory= rom_directory=
grub_mkimage="${bindir}/@grub_mkimage@"
grub_render_label="${bindir}/@grub_render_label@" grub_render_label="${bindir}/@grub_render_label@"
grub_glue_efi="${bindir}/@grub_glue_efi@" grub_glue_efi="${bindir}/@grub_glue_efi@"
label_font="${pkgdatadir}/unicode.pf2" label_font="${pkgdatadir}/unicode.pf2"
@ -61,13 +44,8 @@ product_version="${PACKAGE_VERSION}"
xorriso=xorriso xorriso=xorriso
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
localedir="@datadir@/locale" localedir="@datadir@/locale"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
usage () { usage () {
@ -77,15 +55,11 @@ usage () {
echo echo
filetrans="$(gettext FILE)" filetrans="$(gettext FILE)"
print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "-o, --output=$filetrans" "$(gettext "save output in FILE [required]")" print_option_help "-o, --output=$filetrans" "$(gettext "save output in FILE [required]")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help grub_print_install_files_help
print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies on bootable media")"
print_option_help "--rom-directory=$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")" print_option_help "--rom-directory=$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")"
# TRANSLATORS: xorriso is a program for creating ISOs and burning CDs # TRANSLATORS: xorriso is a program for creating ISOs and burning CDs
print_option_help "--xorriso=$filetrans" "$(gettext "use FILE as xorriso [optional]")" print_option_help "--xorriso=$filetrans" "$(gettext "use FILE as xorriso [optional]")"
print_option_help "--grub-mkimage=$filetrans" "$(gettext "use FILE as grub-mkimage")"
print_option_help "--grub-glue-efi=$filetrans" "$(gettext "use FILE as grub-glue-efi")" print_option_help "--grub-glue-efi=$filetrans" "$(gettext "use FILE as grub-glue-efi")"
print_option_help "--grub-render-label=$filetrans" "$(gettext "use FILE as grub-render-label")" print_option_help "--grub-render-label=$filetrans" "$(gettext "use FILE as grub-render-label")"
print_option_help "--label-font=$filetrans" "$(gettext "use FILE as font for label")" print_option_help "--label-font=$filetrans" "$(gettext "use FILE as font for label")"
@ -123,14 +97,6 @@ do
-h | --help) -h | --help)
usage usage
exit 0 ;; exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output) -o | --output)
output_image=`argument $option "$@"`; shift ;; output_image=`argument $option "$@"`; shift ;;
@ -164,11 +130,6 @@ do
--product-version=*) --product-version=*)
product_version=`echo "$option" | sed 's/--product-version=//'` ;; product_version=`echo "$option" | sed 's/--product-version=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--grub-glue-efi) --grub-glue-efi)
grub_glue_efi=`argument $option "$@"`; shift ;; grub_glue_efi=`argument $option "$@"`; shift ;;
--grub-glue-efi=*) --grub-glue-efi=*)

View file

@ -18,31 +18,10 @@
# Initialize some variables. # Initialize some variables.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
bindir="@bindir@"
libdir="@libdir@"
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
self=`basename $0`
compression=auto compression=auto
format= format=
grub_mkimage="${bindir}/@grub_mkimage@"
source= source=
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage # Usage: usage
# Print the usage. # Print the usage.
usage () { usage () {
@ -51,15 +30,12 @@ usage () {
gettext "Generate a standalone image (containing all modules) in the selected format" gettext "Generate a standalone image (containing all modules) in the selected format"
echo echo
print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")" print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
print_option_help "-O, --format=$(gettext "FORMAT")" "$(gettext "generate an image in FORMAT")"; echo print_option_help "-O, --format=$(gettext "FORMAT")" "$(gettext "generate an image in FORMAT")"; echo
print_option_help "" "$(gettext "available formats:") $formats" print_option_help "" "$(gettext "available formats:") $formats"
echo echo
print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use for core image")" print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use for core image")"
print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
grub_print_install_files_help grub_print_install_files_help
print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
echo echo
gettext "Report bugs to <bug-grub@gnu.org>."; echo gettext "Report bugs to <bug-grub@gnu.org>."; echo
} }
@ -80,25 +56,12 @@ do
-h | --help) -h | --help)
usage usage
exit 0 ;; exit 0 ;;
-v | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
--modules)
modules=`argument $option "$@"`; shift ;;
--modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
-o | --output) -o | --output)
output_image=`argument $option "$@"`; shift ;; output_image=`argument $option "$@"`; shift ;;
--output=*) --output=*)
output_image=`echo "$option" | sed 's/--output=//'` ;; output_image=`echo "$option" | sed 's/--output=//'` ;;
--grub-mkimage)
grub_mkimage=`argument $option "$@"`; shift ;;
--grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
--compression | -C) --compression | -C)
compression=`argument $option "$@"`; shift ;; compression=`argument $option "$@"`; shift ;;
--compression=*) --compression=*)