dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0255-Unify-file-copying-setup-across-different-install-sc.patch

f96e0b
From f07aaa099fe586b6df049097f62704cc5081a63a Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Thu, 4 Apr 2013 19:59:59 +0200
f96e0b
Subject: [PATCH 255/482] 	Unify file copying setup across different
f96e0b
 install scripts. Add 	options for performing partial install.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                 |   5 ++
f96e0b
 Makefile.util.def         |   7 ++
f96e0b
 gentpl.py                 |   4 +-
f96e0b
 util/grub-install.in      |  47 +++-----------
f96e0b
 util/grub-install_header  | 161 ++++++++++++++++++++++++++++++++++++++++++++++
f96e0b
 util/grub-mknetdir.in     |  47 +++-----------
f96e0b
 util/grub-mkrescue.in     |  42 +++---------
f96e0b
 util/grub-mkstandalone.in |  44 +++----------
f96e0b
 8 files changed, 212 insertions(+), 145 deletions(-)
f96e0b
 create mode 100644 util/grub-install_header
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 400a071..94f2631 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,4 +1,9 @@
f96e0b
 2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
+	Unify file copying setup across different install scripts. Add
f96e0b
+	options for performing partial install.
f96e0b
+
f96e0b
+2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 2013-04-04  Peter Jones <pjones@redhat.com>
f96e0b
 
f96e0b
 	* grub-core/disk/efi/efidisk.c: Handle partitions on non-512B disks.
f96e0b
diff --git a/Makefile.util.def b/Makefile.util.def
f96e0b
index 62bcf2d..513dc38 100644
f96e0b
--- a/Makefile.util.def
f96e0b
+++ b/Makefile.util.def
f96e0b
@@ -451,9 +451,13 @@ script = {
f96e0b
 script = {
f96e0b
   mansection = 1;
f96e0b
   name = grub-mkrescue;
f96e0b
+  x86 = util/grub-install_header;
f96e0b
   x86 = util/grub-mkrescue.in;
f96e0b
+  mips_qemu_mips = util/grub-install_header;
f96e0b
   mips_qemu_mips = util/grub-mkrescue.in;
f96e0b
+  mips_loongson = util/grub-install_header;
f96e0b
   mips_loongson = util/grub-mkrescue.in;
f96e0b
+  ia64_efi = util/grub-install_header;
f96e0b
   ia64_efi = util/grub-mkrescue.in;
f96e0b
   powerpc_ieee1275 = util/powerpc/ieee1275/grub-mkrescue.in;
f96e0b
   enable = i386_pc;
f96e0b
@@ -471,6 +475,7 @@ script = {
f96e0b
 script = {
f96e0b
   mansection = 1;
f96e0b
   name = grub-mkstandalone;
f96e0b
+  common = util/grub-install_header;
f96e0b
   common = util/grub-mkstandalone.in;
f96e0b
 };
f96e0b
 
f96e0b
@@ -479,6 +484,7 @@ script = {
f96e0b
   installdir = sbin;
f96e0b
   name = grub-install;
f96e0b
 
f96e0b
+  common = util/grub-install_header;
f96e0b
   common = util/grub-install.in;
f96e0b
   enable = noemu;
f96e0b
 };
f96e0b
@@ -488,6 +494,7 @@ script = {
f96e0b
   installdir = bin;
f96e0b
   name = grub-mknetdir;
f96e0b
 
f96e0b
+  common = util/grub-install_header;
f96e0b
   common = util/grub-mknetdir.in;
f96e0b
 };
f96e0b
 
f96e0b
diff --git a/gentpl.py b/gentpl.py
f96e0b
index 6d7f613..b159795 100644
f96e0b
--- a/gentpl.py
f96e0b
+++ b/gentpl.py
f96e0b
@@ -535,8 +535,8 @@ def script(platform):
f96e0b
     r += "[+ IF mansection +]" + manpage("grub-mkconfig_lib") + "[+ ENDIF +]"
f96e0b
     r += "[+ ENDIF +]"
f96e0b
 
f96e0b
-    r += rule("[+ name +]", platform_sources(platform) + " $(top_builddir)/config.status", """
f96e0b
-$(top_builddir)/config.status --file=$@:$<
f96e0b
+    r += rule("[+ name +]", "$(top_builddir)/config.status " + platform_sources(platform), """
f96e0b
+(skip=1; for x in $^; do if [ $$skip = 1 ]; then skip=0; else cat "$$x"; fi; done) | $(top_builddir)/config.status --file=$@:-
f96e0b
 chmod a+x [+ name +]
f96e0b
 """)
f96e0b
 
f96e0b
diff --git a/util/grub-install.in b/util/grub-install.in
f96e0b
index 9e63cf5..016b161 100644
f96e0b
--- a/util/grub-install.in
f96e0b
+++ b/util/grub-install.in
f96e0b
@@ -88,6 +88,8 @@ usage () {
f96e0b
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
f96e0b
     print_option_help "-v, --version" "$(gettext "print the version information and exit")"
f96e0b
     print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
f96e0b
+    grub_print_install_files_help
f96e0b
+
f96e0b
     dirmsg="$(gettext_printf "install GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
f96e0b
     print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
f96e0b
     # TRANSLATORS: "TARGET" as in "target platform".
f96e0b
@@ -120,17 +122,6 @@ echo
f96e0b
 gettext "Report bugs to <bug-grub@gnu.org>."; echo
f96e0b
 }
f96e0b
 
f96e0b
-argument () {
f96e0b
-  opt="$1"
f96e0b
-  shift
f96e0b
-
f96e0b
-  if test $# -eq 0; then
f96e0b
-      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
f96e0b
-      exit 1
f96e0b
-  fi
f96e0b
-  echo "$1"
f96e0b
-}
f96e0b
-
f96e0b
 allow_floppy=""
f96e0b
 force_file_id=
f96e0b
 efidir=
f96e0b
@@ -138,6 +129,12 @@ efidir=
f96e0b
 # Check the arguments.
f96e0b
 while test $# -gt 0
f96e0b
 do
f96e0b
+    grub_process_install_options "$@"
f96e0b
+    case "$grub_process_install_options_consumed" in
f96e0b
+	1) shift; continue;;
f96e0b
+	2) shift; shift; continue;;
f96e0b
+    esac
f96e0b
+
f96e0b
     option=$1
f96e0b
     shift
f96e0b
 
f96e0b
@@ -519,14 +516,8 @@ else
f96e0b
 fi
f96e0b
 
f96e0b
 # Copy the GRUB images to the GRUB directory.
f96e0b
-for file in "${grubdir}"/*.mod "${grubdir}"/*.lst "${grubdir}"/*.img "${grubdir}"/efiemu??.o "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.mod "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.lst "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/*.img "${grubdir}"/${grub_modinfo_target_cpu}-$grub_modinfo_platform/efiemu??.o; do
f96e0b
-    if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
f96e0b
-	rm -f "$file" || exit 1
f96e0b
-    fi
f96e0b
-done
f96e0b
-for file in "${source_dir}"/*.mod "${source_dir}"/*.lst; do
f96e0b
-    cp -f "$file" "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform" || exit 1
f96e0b
-done
f96e0b
+grub_install_files "${source_dir}" "${grubdir}" "${grub_modinfo_target_cpu}-$grub_modinfo_platform" all
f96e0b
+
f96e0b
 if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ] ; then
f96e0b
     for file in "${source_dir}"/*.img "${source_dir}"/efiemu??.o; do
f96e0b
 	if test -f "$file"; then
f96e0b
@@ -535,24 +526,6 @@ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] || [ "$
f96e0b
     done
f96e0b
 fi
f96e0b
 
f96e0b
-# Copy gettext files
f96e0b
-mkdir -p "${grubdir}"/locale/
f96e0b
-for dir in "${localedir}"/*; do
f96e0b
-    if test -f "$dir/LC_MESSAGES/grub.mo"; then
f96e0b
-        cp -f "$dir/LC_MESSAGES/grub.mo" "${grubdir}/locale/${dir##*/}.mo"
f96e0b
-    fi
f96e0b
-done
f96e0b
-
f96e0b
-if test -f "${pkgdatadir}"/themes/starfield/theme.txt; then
f96e0b
-    mkdir -p "${grubdir}"/themes/starfield
f96e0b
-    cp "${pkgdatadir}"/themes/starfield/* "${grubdir}"/themes/starfield
f96e0b
-fi
f96e0b
-
f96e0b
-if test -f "${pkgdatadir}"/unicode.pf2; then
f96e0b
-    mkdir -p "${grubdir}"/fonts
f96e0b
-    cp "${pkgdatadir}"/unicode.pf2 "${grubdir}"/fonts
f96e0b
-fi
f96e0b
-
f96e0b
 if ! is_path_readable_by_grub "${grubdir}"; then
f96e0b
     gettext_printf "Path \`%s' is not readable by GRUB on boot. Installation is impossible. Aborting.\n" "${grubdir}" 1>&2
f96e0b
     exit 1
f96e0b
diff --git a/util/grub-install_header b/util/grub-install_header
f96e0b
new file mode 100644
f96e0b
index 0000000..7c2c0a5
f96e0b
--- /dev/null
f96e0b
+++ b/util/grub-install_header
f96e0b
@@ -0,0 +1,161 @@
f96e0b
+#! /bin/sh
f96e0b
+set -e
f96e0b
+
f96e0b
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst \
f96e0b
+handler.lst video.lst crypto.lst terminal.lst"
f96e0b
+
f96e0b
+grub_install_files () {
f96e0b
+    grub_install_files_source_directory="$1"
f96e0b
+    grub_install_files_target_directory="$2"
f96e0b
+    grub_install_files_platform="$3"
f96e0b
+    
f96e0b
+    mkdir -p "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
f96e0b
+    
f96e0b
+    for file in "${grub_install_files_target_directory}"/*.mod \
f96e0b
+"${grub_install_files_target_directory}"/*.lst \
f96e0b
+"${grub_install_files_target_directory}"/*.img \
f96e0b
+"${grub_install_files_target_directory}"/efiemu??.o \
f96e0b
+"${grub_install_files_target_directory}"/"${grub_install_files_platform}"/*.mod \
f96e0b
+"${grub_install_files_target_directory}"/"${grub_install_files_platform}"/*.lst \
f96e0b
+"${grub_install_files_target_directory}"/"${grub_install_files_platform}"/*.img \
f96e0b
+"${grub_install_files_target_directory}"/"${grub_install_files_platform}"/efiemu??.o;
f96e0b
+    do
f96e0b
+	if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
f96e0b
+	    rm -f "$file" || exit 1
f96e0b
+	fi
f96e0b
+    done
f96e0b
+
f96e0b
+    if [ x"$install_modules" = xall ]; then
f96e0b
+	for file in "${grub_install_files_source_directory}/"*.mod; do
f96e0b
+	    cp -f "$file" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
f96e0b
+	done
f96e0b
+    else
f96e0b
+	modules1=
f96e0b
+	modules2="$install_modules"
f96e0b
+	while [ x"$modules2" != x ]; do
f96e0b
+	    modules3=
f96e0b
+	    for x in $modules2; do
f96e0b
+		modules3="$modules3 $(grep "^$x:" "${grub_install_files_source_directory}/moddep.lst" | sed 's,^[^:]*:,,')"
f96e0b
+	    done
f96e0b
+	    modules1="$modules1 $modules2"
f96e0b
+	    modules2="$modules3"
f96e0b
+	done
f96e0b
+	for file in $(echo "$modules1" | sed 's, ,\n,g' |sort -u); do
f96e0b
+	    cp -f "${grub_install_files_source_directory}/$file.mod" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
f96e0b
+	done
f96e0b
+    fi
f96e0b
+    
f96e0b
+    for file in ${pkglib_DATA} efiemu32.o efiemu64.o; do
f96e0b
+	if test -f "${grub_install_files_source_directory}/${file}"; then
f96e0b
+            cp -f "${grub_install_files_source_directory}/${file}" "${grub_install_files_target_directory}"/"${grub_install_files_platform}"
f96e0b
+	fi
f96e0b
+    done
f96e0b
+    
f96e0b
+    # Copy gettext files
f96e0b
+    mkdir -p "${grub_install_files_target_directory}"/locale
f96e0b
+
f96e0b
+    for file in "${grub_install_files_target_directory}"/locale/*.mo; do
f96e0b
+	if test -f "$file"; then
f96e0b
+	    rm -f "$file" || exit 1
f96e0b
+	fi
f96e0b
+    done
f96e0b
+
f96e0b
+    if [ x"$install_locales" = xall ]; then
f96e0b
+	for file in "${grub_install_files_source_directory}"/po/*.mo; do
f96e0b
+	    if test -f "$file"; then
f96e0b
+		cp -f "$file" "${grub_install_files_target_directory}"/locale/
f96e0b
+	    fi
f96e0b
+	done
f96e0b
+	for dir in "${localedir}"/*; do
f96e0b
+	    if test -f "$dir/LC_MESSAGES/grub.mo" && ! test -f "${grub_install_files_target_directory}"/locale/"${dir##*/}.mo"; then
f96e0b
+		cp -f "$dir/LC_MESSAGES/grub.mo" "${grub_install_files_target_directory}"/locale/"${dir##*/}.mo"
f96e0b
+	    fi
f96e0b
+	done
f96e0b
+    else
f96e0b
+	for locale in $install_locales; do
f96e0b
+	    if test -f "${grub_install_files_source_directory}"/po/$locale.mo; then
f96e0b
+		cp -f " "${grub_install_files_source_directory}"/po/$locale.mo" "${grub_install_files_target_directory}"/locale/$locale.mo
f96e0b
+	    elif test -f "${localedir}/$locale/LC_MESSAGES/grub.mo"; then
f96e0b
+		cp -f "${localedir}/$locale/LC_MESSAGES/grub.mo" "${grub_install_files_target_directory}"/locale/$locale.mo
f96e0b
+	    fi
f96e0b
+	done
f96e0b
+    fi
f96e0b
+    for theme in ${install_themes} ; do
f96e0b
+	if test -f "${pkgdatadir}"/themes/"${theme}"/theme.txt; then
f96e0b
+	    mkdir -p "${grub_install_files_target_directory}"/themes/"${theme}"
f96e0b
+	    cp "${pkgdatadir}"/themes/"${theme}"/* "${grub_install_files_target_directory}"/themes/"${theme}"
f96e0b
+	fi
f96e0b
+    done
f96e0b
+
f96e0b
+    for font in ${install_fonts} ; do
f96e0b
+	if test -f "${pkgdatadir}"/"$font".pf2; then
f96e0b
+	    mkdir -p "${grub_install_files_target_directory}"/fonts
f96e0b
+	    cp "${pkgdatadir}"/"$font".pf2 "${grub_install_files_target_directory}"/fonts
f96e0b
+	fi
f96e0b
+    done
f96e0b
+}
f96e0b
+
f96e0b
+grub_print_install_files_help () {
f96e0b
+    print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies [default=all]")"
f96e0b
+    print_option_help "--themes=THEMES" "$(gettext_printf "install THEMES [default=%s]" "starfield")"
f96e0b
+    print_option_help "--fonts=FONTS" "$(gettext_printf "install FONTS [default=%s]" "unicode")"
f96e0b
+    print_option_help "--locales=LOCALES" "$(gettext_printf "install only LOCALES [default=all]")"
f96e0b
+}
f96e0b
+
f96e0b
+install_modules=all
f96e0b
+install_themes=starfield
f96e0b
+install_fonts=unicode
f96e0b
+install_locales=all
f96e0b
+
f96e0b
+argument () {
f96e0b
+  opt=$1
f96e0b
+  shift
f96e0b
+
f96e0b
+  if test $# -eq 0; then
f96e0b
+      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
f96e0b
+      exit 1
f96e0b
+  fi
f96e0b
+  echo $1
f96e0b
+}
f96e0b
+
f96e0b
+grub_process_install_options () {
f96e0b
+    option=$1
f96e0b
+    shift
f96e0b
+
f96e0b
+    grub_process_install_options_consumed=0
f96e0b
+
f96e0b
+    case "$option" in
f96e0b
+	--install-modules)
f96e0b
+	    install_modules=`argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
f96e0b
+	--install-modules=*)
f96e0b
+            install_modules=`echo "$option" | sed 's/--install-modules=//'`; grub_process_install_options_consumed=1; return ;;
f96e0b
+	--themes)
f96e0b
+	    install_themes=`argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
f96e0b
+	--themes=*)
f96e0b
+            install_themes=`echo "$option" | sed 's/--themes=//'`; grub_process_install_options_consumed=1; return ;;
f96e0b
+	--fonts)
f96e0b
+	    install_fonts=`argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
f96e0b
+	--fonts=*)
f96e0b
+            install_fonts=`echo "$option" | sed 's/--fonts=//'`; grub_process_install_options_consumed=1; return ;;
f96e0b
+	--locales)
f96e0b
+	    install_locales=`argument $option "$@"`; grub_process_install_options_consumed=2; return ;;
f96e0b
+	--locales=*)
f96e0b
+            install_locales=`echo "$option" | sed 's/--locales=//'`; grub_process_install_options_consumed=1; return ;;
f96e0b
+    esac
f96e0b
+}
f96e0b
+
f96e0b
diff --git a/util/grub-mknetdir.in b/util/grub-mknetdir.in
f96e0b
index e235af3..6df761a 100644
f96e0b
--- a/util/grub-mknetdir.in
f96e0b
+++ b/util/grub-mknetdir.in
f96e0b
@@ -1,5 +1,3 @@
f96e0b
-#! /bin/sh
f96e0b
-
f96e0b
 # Install GRUB on your drive.
f96e0b
 # Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
f96e0b
 #
f96e0b
@@ -26,7 +24,6 @@ PACKAGE_NAME=@PACKAGE_NAME@
f96e0b
 PACKAGE_TARNAME=@PACKAGE_TARNAME@
f96e0b
 PACKAGE_VERSION=@PACKAGE_VERSION@
f96e0b
 host_os=@host_os@
f96e0b
-pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
f96e0b
 datadir="@datadir@"
f96e0b
 if [ "x$pkgdatadir" = x ]; then
f96e0b
     pkgdatadir="${datadir}/@PACKAGE@"
f96e0b
@@ -65,6 +62,7 @@ usage () {
f96e0b
     print_option_help "-h, --help" "$(gettext "print this message and exit")"
f96e0b
     print_option_help "-v, --version" "$(gettext "print the version information and exit")"
f96e0b
     print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
f96e0b
+    grub_print_install_files_help
f96e0b
     print_option_help "--net-directory=$(gettext "DIR")" "$(gettext "root directory of TFTP server")"
f96e0b
     print_option_help "--subdir=$(gettext "DIR")" "$(gettext "relative subdirectory on network server")"
f96e0b
     print_option_help "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
f96e0b
@@ -77,20 +75,15 @@ usage () {
f96e0b
     gettext "Report bugs to <bug-grub@gnu.org>."; echo
f96e0b
 }
f96e0b
 
f96e0b
-argument () {
f96e0b
-  opt=$1
f96e0b
-  shift
f96e0b
-
f96e0b
-  if test $# -eq 0; then
f96e0b
-      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
f96e0b
-      exit 1
f96e0b
-  fi
f96e0b
-  echo $1
f96e0b
-}
f96e0b
-
f96e0b
 # Check the arguments.
f96e0b
 while test $# -gt 0
f96e0b
 do
f96e0b
+    grub_process_install_options "$@"
f96e0b
+    case "$grub_process_install_options_consumed" in
f96e0b
+	1) shift; continue;;
f96e0b
+	2) shift; shift; continue;;
f96e0b
+    esac
f96e0b
+
f96e0b
     option=$1
f96e0b
     shift
f96e0b
 
f96e0b
@@ -166,32 +159,10 @@ process_input_dir ()
f96e0b
     platform="$2"
f96e0b
     grubdir="${rootdir}/${subdir}/${platform}"
f96e0b
     config_opt=
f96e0b
-    mkdir -p "$grubdir" || exit 1
f96e0b
-
f96e0b
-    for file in "${grubdir}"/*.mod "${grubdir}"/*.lst "${grubdir}"/*.img "${grubdir}"/efiemu??.o; do
f96e0b
-	if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
f96e0b
-	    rm -f "$file" || exit 1
f96e0b
-	fi
f96e0b
-    done
f96e0b
-    for file in "${input_dir}"/*.mod; do
f96e0b
-        if test -f "$file"; then
f96e0b
-            cp -f "$file" "$grubdir/"
f96e0b
-        fi
f96e0b
-    done
f96e0b
-    for file in ${pkglib_DATA}; do
f96e0b
-	if test -f "${input_dir}/${file}"; then
f96e0b
-            cp -f "${input_dir}/${file}" "$grubdir/"
f96e0b
-	fi
f96e0b
-    done
f96e0b
 
f96e0b
-    mkdir -p "$grubdir/locale"
f96e0b
-    for file in ${input_dir}/po/*.mo; do
f96e0b
-        if test -f "$file"; then
f96e0b
-	    cp -f "$file" "$grubdir/locale/"
f96e0b
-	fi
f96e0b
-    done
f96e0b
+    grub_install_files "${input_dir}" "${rootdir}/${subdir}" "${platform}"
f96e0b
 
f96e0b
-    rm -f ${grubdir}/load.cfg
f96e0b
+    rm -f "${grubdir}"/load.cfg
f96e0b
 
f96e0b
     if [ "x${debug_image}" != x ]; then
f96e0b
        echo "set debug='${debug_image}'" >> ${grubdir}/load.cfg
f96e0b
diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in
f96e0b
index d279a9d..c57a0d9 100644
f96e0b
--- a/util/grub-mkrescue.in
f96e0b
+++ b/util/grub-mkrescue.in
f96e0b
@@ -1,5 +1,3 @@
f96e0b
-#! /bin/sh
f96e0b
-set -e
f96e0b
 
f96e0b
 # Make GRUB rescue image
f96e0b
 # Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
f96e0b
@@ -70,6 +68,8 @@ usage () {
f96e0b
     print_option_help "-v, --version" "$(gettext "print the version information and exit")"
f96e0b
     print_option_help "-o, --output=$filetrans" "$(gettext "save output in FILE [required]")"
f96e0b
     print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
f96e0b
+    grub_print_install_files_help
f96e0b
+    print_option_help "--install-modules=$(gettext "MODULES")" "$(gettext "install only MODULES and their dependencies on bootable media")"
f96e0b
     print_option_help "--rom-directory=$(gettext "DIR")" "$(gettext "save ROM images in DIR [optional]")"
f96e0b
     # TRANSLATORS: xorriso is a program for creating ISOs and burning CDs
f96e0b
     print_option_help "--xorriso=$filetrans" "$(gettext "use FILE as xorriso [optional]")"
f96e0b
@@ -83,20 +83,15 @@ usage () {
f96e0b
     gettext "Mail xorriso support requests to <bug-xorriso@gnu.org>."; echo
f96e0b
 }
f96e0b
 
f96e0b
-argument () {
f96e0b
-  opt=$1
f96e0b
-  shift
f96e0b
-
f96e0b
-  if test $# -eq 0; then
f96e0b
-      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
f96e0b
-      exit 1
f96e0b
-  fi
f96e0b
-  echo $1
f96e0b
-}
f96e0b
-
f96e0b
 # Check the arguments.
f96e0b
 while test $# -gt 0
f96e0b
 do
f96e0b
+    grub_process_install_options "$@"
f96e0b
+    case "$grub_process_install_options_consumed" in
f96e0b
+	1) shift; continue;;
f96e0b
+	2) shift; shift; continue;;
f96e0b
+    esac
f96e0b
+
f96e0b
     option=$1
f96e0b
     shift
f96e0b
 
f96e0b
@@ -171,26 +166,7 @@ mkdir -p ${iso9660_dir}/boot/grub
f96e0b
 
f96e0b
 process_input_dir ()
f96e0b
 {
f96e0b
-    input_dir="$1"
f96e0b
-    platform="$2"
f96e0b
-    mkdir -p "${iso9660_dir}/boot/grub/${platform}"
f96e0b
-    for file in "${input_dir}/"*.mod "${input_dir}/"efiemu32.o "${input_dir}/"efiemu64.o; do
f96e0b
-        if test -f "$file"; then
f96e0b
-            cp -f "$file" "${iso9660_dir}/boot/grub/${platform}/"
f96e0b
-        fi
f96e0b
-    done
f96e0b
-    for file in ${pkglib_DATA}; do
f96e0b
-	if test -f "${input_dir}/${file}"; then
f96e0b
-            cp -f "${input_dir}/${file}" "${iso9660_dir}/boot/grub/${platform}/"
f96e0b
-	fi
f96e0b
-    done
f96e0b
-
f96e0b
-    mkdir -p "${iso9660_dir}/boot/grub/locale"
f96e0b
-    for dir in "${localedir}"/*; do
f96e0b
-	if test -f "$dir/LC_MESSAGES/grub.mo"; then
f96e0b
-            cp -f "$dir/LC_MESSAGES/grub.mo" "${iso9660_dir}/boot/grub/locale/${dir##*/}.mo"
f96e0b
-	fi
f96e0b
-    done
f96e0b
+    grub_install_files "$1" "${iso9660_dir}/boot/grub" "$2"
f96e0b
 }
f96e0b
 
f96e0b
 make_image ()
f96e0b
diff --git a/util/grub-mkstandalone.in b/util/grub-mkstandalone.in
f96e0b
index 78b83e0..a5434c4 100644
f96e0b
--- a/util/grub-mkstandalone.in
f96e0b
+++ b/util/grub-mkstandalone.in
f96e0b
@@ -1,5 +1,4 @@
f96e0b
-#! /bin/sh
f96e0b
-set -e
f96e0b
+#!/bin/sh
f96e0b
 
f96e0b
 # Make GRUB rescue image
f96e0b
 # Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012  Free Software Foundation, Inc.
f96e0b
@@ -27,7 +26,6 @@ libdir="@libdir@"
f96e0b
 PACKAGE_NAME=@PACKAGE_NAME@
f96e0b
 PACKAGE_TARNAME=@PACKAGE_TARNAME@
f96e0b
 PACKAGE_VERSION=@PACKAGE_VERSION@
f96e0b
-pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
f96e0b
 datadir="@datadir@"
f96e0b
 if [ "x$pkgdatadir" = x ]; then
f96e0b
     pkgdatadir="${datadir}/@PACKAGE@"
f96e0b
@@ -64,25 +62,21 @@ usage () {
f96e0b
     echo
f96e0b
     print_option_help "-C, --compression=(xz|none|auto)" "$(gettext "choose the compression to use")"
f96e0b
     print_option_help "--modules=$(gettext "MODULES")" "$(gettext "pre-load specified modules MODULES")"
f96e0b
+    grub_print_install_files_help
f96e0b
     print_option_help  "--grub-mkimage=$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
f96e0b
     echo
f96e0b
     gettext "Report bugs to <bug-grub@gnu.org>."; echo
f96e0b
 }
f96e0b
 
f96e0b
-argument () {
f96e0b
-  opt=$1
f96e0b
-  shift
f96e0b
-
f96e0b
-  if test $# -eq 0; then
f96e0b
-      gettext_printf "%s: option requires an argument -- \`%s'\n" "$0" "$opt" 1>&2
f96e0b
-      exit 1
f96e0b
-  fi
f96e0b
-  echo $1
f96e0b
-}
f96e0b
-
f96e0b
 # Check the arguments.
f96e0b
 while test $# -gt 0
f96e0b
 do
f96e0b
+    grub_process_install_options "$@"
f96e0b
+    case "$grub_process_install_options_consumed" in
f96e0b
+	1) shift; continue;;
f96e0b
+	2) shift; shift; continue;;
f96e0b
+    esac
f96e0b
+
f96e0b
     option=$1
f96e0b
     shift
f96e0b
 
f96e0b
@@ -167,27 +161,7 @@ else
f96e0b
 fi
f96e0b
 
f96e0b
 memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
-mkdir -p "${memdisk_dir}"/boot/grub/"${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
f96e0b
-
f96e0b
-for file in "${source_directory}/"*.mod "${source_directory}/"efiemu32.o "${source_directory}/"efiemu64.o; do
f96e0b
-    if test -f "$file"; then
f96e0b
-        cp -f "$file" "${memdisk_dir}"/boot/grub/"${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
f96e0b
-    fi
f96e0b
-done
f96e0b
-
f96e0b
-for file in ${pkglib_DATA}; do
f96e0b
-    if test -f "${source_directory}/${file}"; then
f96e0b
-        cp -f "${source_directory}/${file}" "${memdisk_dir}"/boot/grub/"${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
f96e0b
-    fi
f96e0b
-done
f96e0b
-
f96e0b
-mkdir -p "${memdisk_dir}"/boot/grub/locale
f96e0b
-for file in "${source_directory}"/po/*.mo; do
f96e0b
-    if test -f "$file"; then
f96e0b
-	cp -f "$file" "${memdisk_dir}"/boot/grub/locale/
f96e0b
-    fi
f96e0b
-done
f96e0b
-
f96e0b
+grub_install_files "${source_directory}" "${memdisk_dir}"/boot/grub "${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
f96e0b
 for file in $source; do
f96e0b
     cp -f "$file" "${memdisk_dir}"/"$file";
f96e0b
 done
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b