Blob Blame Raw
From 899f59e4357a2a3bfb5a2e58ad83700f16d347a7 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Fri, 28 Dec 2012 06:57:17 +0000
Subject: [PATCH 071/482] Apply program name transformations at build-time
 rather than at run-time.  Fixes Debian bug #696465.

* acinclude.m4 (grub_TRANSFORM): New macro.
* configure.ac: Create output variables with transformed names for
most programs.
* util/bash-completion.d/grub-completion.bash.in: Use
pre-transformed variables for program names.
* util/grub-install.in: Likewise.
* util/grub-kbdcomp.in: Likewise.
* util/grub-mkconfig.in: Likewise.
* util/grub-mkconfig_lib.in: Likewise.
* util/grub-mknetdir.in: Likewise.
* util/grub-mkrescue.in: Likewise.
* util/grub-mkstandalone.in: Likewise.
* util/grub-reboot.in: Likewise.
* util/grub-set-default.in: Likewise.
* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
* tests/util/grub-shell-tester.in: Remove unused assignment.
* tests/util/grub-shell.in: Likewise.
* util/grub.d/00_header.in: Likewise.
---
 ChangeLog                                      | 24 ++++++++++++++++++++++++
 acinclude.m4                                   |  6 ++++++
 configure.ac                                   | 16 ++++++++++++++++
 tests/util/grub-shell-tester.in                |  2 --
 tests/util/grub-shell.in                       |  2 --
 util/bash-completion.d/grub-completion.bash.in | 24 ++++++++++++------------
 util/grub-install.in                           | 14 ++++++--------
 util/grub-kbdcomp.in                           |  4 +---
 util/grub-mkconfig.in                          |  7 +++----
 util/grub-mkconfig_lib.in                      |  6 ++----
 util/grub-mknetdir.in                          |  4 +---
 util/grub-mkrescue.in                          |  4 +---
 util/grub-mkstandalone.in                      |  4 +---
 util/grub-reboot.in                            |  4 +---
 util/grub-set-default.in                       |  4 +---
 util/grub.d/00_header.in                       |  2 --
 util/powerpc/ieee1275/grub-mkrescue.in         |  4 +---
 17 files changed, 76 insertions(+), 55 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0f04f5c..b8bd215 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2012-12-28  Colin Watson  <cjwatson@ubuntu.com>
 
+	Apply program name transformations at build-time rather than at
+	run-time.  Fixes Debian bug #696465.
+
+	* acinclude.m4 (grub_TRANSFORM): New macro.
+	* configure.ac: Create output variables with transformed names for
+	most programs.
+	* util/bash-completion.d/grub-completion.bash.in: Use
+	pre-transformed variables for program names.
+	* util/grub-install.in: Likewise.
+	* util/grub-kbdcomp.in: Likewise.
+	* util/grub-mkconfig.in: Likewise.
+	* util/grub-mkconfig_lib.in: Likewise.
+	* util/grub-mknetdir.in: Likewise.
+	* util/grub-mkrescue.in: Likewise.
+	* util/grub-mkstandalone.in: Likewise.
+	* util/grub-reboot.in: Likewise.
+	* util/grub-set-default.in: Likewise.
+	* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
+	* tests/util/grub-shell-tester.in: Remove unused assignment.
+	* tests/util/grub-shell.in: Likewise.
+	* util/grub.d/00_header.in: Likewise.
+
+2012-12-28  Colin Watson  <cjwatson@ubuntu.com>
+
 	Backport gnulib fixes for C11.  Fixes Savannah bug #37738.
 
 	* grub-core/gnulib/stdio.in.h (gets): Warn on use only if
diff --git a/acinclude.m4 b/acinclude.m4
index 0eb2e2a..49a1a75 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -452,3 +452,9 @@ else
   AC_MSG_RESULT([no])
 [fi]
 ])
+
+dnl Create an output variable with the transformed name of a GRUB utility
+dnl program.
+AC_DEFUN([grub_TRANSFORM],[dnl
+AC_SUBST(AS_TR_SH([$1]), [`AS_ECHO([$1]) | sed "$program_transform_name"`])dnl
+])
diff --git a/configure.ac b/configure.ac
index ea3830a..a41f117 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,22 @@ AC_CONFIG_HEADER([config-util.h])
 
 # Program name transformations
 AC_ARG_PROGRAM
+grub_TRANSFORM([grub-bios-setup])
+grub_TRANSFORM([grub-editenv])
+grub_TRANSFORM([grub-install])
+grub_TRANSFORM([grub-mkconfig])
+grub_TRANSFORM([grub-mkfont])
+grub_TRANSFORM([grub-mkimage])
+grub_TRANSFORM([grub-mklayout])
+grub_TRANSFORM([grub-mkpasswd-pbkdf2])
+grub_TRANSFORM([grub-mkrelpath])
+grub_TRANSFORM([grub-mkrescue])
+grub_TRANSFORM([grub-probe])
+grub_TRANSFORM([grub-reboot])
+grub_TRANSFORM([grub-script-check])
+grub_TRANSFORM([grub-set-default])
+grub_TRANSFORM([grub-setup])
+grub_TRANSFORM([grub-sparc64-setup])
 
 # Optimization flag.  Allow user to override.
 if test "x$TARGET_CFLAGS" = x; then
diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in
index 80c8830..5adce0a 100644
--- a/tests/util/grub-shell-tester.in
+++ b/tests/util/grub-shell-tester.in
@@ -18,8 +18,6 @@ set -e
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index f4fa23a..04e64da 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -18,8 +18,6 @@ set -e
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in
index 64d49fe..5f4b249 100644
--- a/util/bash-completion.d/grub-completion.bash.in
+++ b/util/bash-completion.d/grub-completion.bash.in
@@ -165,12 +165,12 @@ _grub_set_entry () {
     fi
 }
 
-__grub_set_default_program=$( echo grub-set-default | sed "@program_transform_name@" )
+__grub_set_default_program="@grub_set_default@"
 have ${__grub_set_default_program} && \
     complete -F _grub_set_entry -o filenames ${__grub_set_default_program}
 unset __grub_set_default_program
 
-__grub_reboot_program=$( echo grub-reboot | sed "@program_transform_name@" )
+__grub_reboot_program="@grub_reboot@"
 have ${__grub_reboot_program} && \
  complete -F _grub_set_entry -o filenames ${__grub_reboot_program}
 unset __grub_reboot_program
@@ -197,7 +197,7 @@ _grub_editenv () {
                 create list set unset"
 }
 
-__grub_editenv_program=$( echo grub-editenv | sed "@program_transform_name@" )
+__grub_editenv_program="@grub_editenv@"
 have ${__grub_editenv_program} && \
  complete -F _grub_editenv -o filenames ${__grub_editenv_program}
 unset __grub_editenv_program
@@ -218,7 +218,7 @@ _grub_mkconfig () {
         _filedir
     fi
 }
-__grub_mkconfig_program=$( echo grub-mkconfig | sed "@program_transform_name@" )
+__grub_mkconfig_program="@grub_mkconfig@"
 have ${__grub_mkconfig_program} && \
  complete -F _grub_mkconfig -o filenames ${__grub_mkconfig_program}
 unset __grub_mkconfig_program
@@ -252,7 +252,7 @@ _grub_setup () {
         _filedir
     fi
 }
-__grub_setup_program=$( echo grub-setup | sed "@program_transform_name@" )
+__grub_setup_program="@grub_setup@"
 have ${__grub_setup_program} && \
  complete -F _grub_setup -o filenames ${__grub_setup_program}
 unset __grub_setup_program
@@ -298,7 +298,7 @@ _grub_install () {
         _filedir
     fi
 }
-__grub_install_program=$( echo grub-install | sed "@program_transform_name@" )
+__grub_install_program="@grub_install@"
 have ${__grub_install_program} && \
  complete -F _grub_install -o filenames ${__grub_install_program}
 unset __grub_install_program
@@ -320,7 +320,7 @@ _grub_mkfont () {
         _filedir
     fi
 }
-__grub_mkfont_program=$( echo grub-mkfont | sed "@program_transform_name@" )
+__grub_mkfont_program="@grub_mkfont@"
 have ${__grub_mkfont_program} && \
  complete -F _grub_mkfont -o filenames ${__grub_mkfont_program}
 unset __grub_mkfont_program
@@ -351,7 +351,7 @@ _grub_mkrescue () {
         _filedir
     fi
 }
-__grub_mkrescue_program=$( echo grub-mkrescue | sed "@program_transform_name@" )
+__grub_mkrescue_program="@grub_mkrescue@"
 have ${__grub_mkrescue_program} && \
  complete -F _grub_mkrescue -o filenames ${__grub_mkrescue_program}
 unset __grub_mkrescue_program
@@ -393,7 +393,7 @@ _grub_mkimage () {
         _filedir
     fi
 }
-__grub_mkimage_program=$( echo grub-mkimage | sed "@program_transform_name@" )
+__grub_mkimage_program="@grub_mkimage@"
 have ${__grub_mkimage_program} && \
  complete -F _grub_mkimage -o filenames ${__grub_mkimage_program}
 unset __grub_mkimage_program
@@ -415,7 +415,7 @@ _grub_mkpasswd_pbkdf2 () {
         _filedir
     fi
 }
-__grub_mkpasswd_pbkdf2_program=$( echo grub-mkpasswd-pbkdf2 | sed "@program_transform_name@" )
+__grub_mkpasswd_pbkdf2_program="@grub_mkpasswd_pbkdf2@"
 have ${__grub_mkpasswd_pbkdf2_program} && \
  complete -F _grub_mkpasswd_pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
 unset __grub_mkpasswd_pbkdf2_program
@@ -453,7 +453,7 @@ _grub_probe () {
         _filedir
     fi
 }
-__grub_probe_program=$( echo grub-probe | sed "@program_transform_name@" )
+__grub_probe_program="@grub_probe@"
 have ${__grub_probe_program} && \
  complete -F _grub_probe -o filenames ${__grub_probe_program}
 unset __grub_probe_program
@@ -475,7 +475,7 @@ _grub_script_check () {
         _filedir
     fi
 }
-__grub_script_check_program=$( echo grub-script-check | sed "@program_transform_name@" )
+__grub_script_check_program="@grub_script_check@"
 have ${__grub_script_check_program} && \
  complete -F _grub_script_check -o filenames ${__grub_script_check_program}
 
diff --git a/util/grub-install.in b/util/grub-install.in
index 9dc4e0b..218bbd9 100644
--- a/util/grub-install.in
+++ b/util/grub-install.in
@@ -17,8 +17,6 @@
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -44,10 +42,10 @@ localedir="@datadir@/locale"
 
 self="`basename $0`"
 
-grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
-grub_probe="${sbindir}/`echo grub-probe | sed ${transform}`"
-grub_editenv="${bindir}/`echo grub-editenv | sed ${transform}`"
-grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed ${transform}`"
+grub_mkimage="${bindir}/@grub_mkimage@"
+grub_probe="${sbindir}/@grub_probe@"
+grub_editenv="${bindir}/@grub_editenv@"
+grub_mkrelpath="${bindir}/@grub_mkrelpath@"
 rootdir=
 bootdir=
 grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`"
@@ -347,11 +345,11 @@ else
 fi
 
 if test "x$grub_setup" = x && [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ]; then
-    grub_setup="${sbindir}/`echo grub-bios-setup | sed ${transform}`"
+    grub_setup="${sbindir}/@grub_bios_setup@"
 fi
 
 if test "x$grub_setup" = x && [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "sparc64-ieee1275" ]; then
-    grub_setup="${sbindir}/`echo grub-sparc64-setup | sed ${transform}`"
+    grub_setup="${sbindir}/@grub_sparc64_setup@"
 fi
 
 if test "x$install_device" = x && ([ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-pc" ] \
diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in
index 29f0456..715c483 100644
--- a/util/grub-kbdcomp.in
+++ b/util/grub-kbdcomp.in
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 bindir="@bindir@"
@@ -11,7 +9,7 @@ if [ "x$pkgdatadir" = x ]; then
     pkgdatadir="${datadir}/@PACKAGE@"
 fi
 
-grub_mklayout="${bindir}/`echo grub-mklayout | sed ${transform}`"
+grub_mklayout="${bindir}/@grub_mklayout@"
 
 ckbcomp_options=""
 
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 516be86..4263367 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -17,7 +17,6 @@ set -e
 # You should have received a copy of the GNU General Public License
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
-transform="@program_transform_name@"
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -39,9 +38,9 @@ grub_mkconfig_dir="${sysconfdir}"/grub.d
 
 self=`basename $0`
 
-grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
-grub_editenv="${bindir}/`echo grub-editenv | sed "${transform}"`"
-grub_script_check="${bindir}/`echo grub-script-check | sed "${transform}"`"
+grub_probe="${sbindir}/@grub_probe@"
+grub_editenv="${bindir}/@grub_editenv@"
+grub_script_check="${bindir}/@grub_script_check@"
 
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR="@localedir@"
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 3574839..e560dd7 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -14,8 +14,6 @@
 # You should have received a copy of the GNU General Public License
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -25,10 +23,10 @@ sbindir="@sbindir@"
 pkgdatadir="${datadir}/@PACKAGE@"
 
 if test "x$grub_probe" = x; then
-  grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
+  grub_probe="${sbindir}/@grub_probe@"
 fi
 if test "x$grub_mkrelpath" = x; then
-  grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed "${transform}"`"
+  grub_mkrelpath="${bindir}/@grub_mkrelpath@"
 fi
 
 if which gettext >/dev/null 2>/dev/null; then
diff --git a/util/grub-mknetdir.in b/util/grub-mknetdir.in
index d1ad763..e235af3 100644
--- a/util/grub-mknetdir.in
+++ b/util/grub-mknetdir.in
@@ -17,8 +17,6 @@
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -36,7 +34,7 @@ fi
 
 self=`basename $0`
 
-grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
+grub_mkimage="${bindir}/@grub_mkimage@"
 rootdir=/srv/tftp
 modules=
 
diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in
index f71099e..d279a9d 100644
--- a/util/grub-mkrescue.in
+++ b/util/grub-mkrescue.in
@@ -19,8 +19,6 @@ set -e
 
 # Initialize some variables.
 
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -49,7 +47,7 @@ efi64_dir="${libdir}/@PACKAGE@/x86_64-efi"
 ia64_dir="${libdir}/@PACKAGE@/ia64-efi"
 rom_directory=
 override_dir=
-grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
+grub_mkimage="${bindir}/@grub_mkimage@"
 
 xorriso=xorriso
 
diff --git a/util/grub-mkstandalone.in b/util/grub-mkstandalone.in
index 87a3b42..78b83e0 100644
--- a/util/grub-mkstandalone.in
+++ b/util/grub-mkstandalone.in
@@ -19,8 +19,6 @@ set -e
 
 # Initialize some variables.
 
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
@@ -40,7 +38,7 @@ self=`basename $0`
 source_directory=
 compression=auto
 format=
-grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
+grub_mkimage="${bindir}/@grub_mkimage@"
 source=
 
 export TEXTDOMAIN=@PACKAGE@
diff --git a/util/grub-reboot.in b/util/grub-reboot.in
index 93dbe6c..7516a03 100644
--- a/util/grub-reboot.in
+++ b/util/grub-reboot.in
@@ -17,8 +17,6 @@
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
@@ -32,7 +30,7 @@ fi
 
 self=`basename $0`
 
-grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
+grub_editenv=${bindir}/@grub_editenv@
 rootdir=
 bootdir=
 grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
diff --git a/util/grub-set-default.in b/util/grub-set-default.in
index 3d890be..443e56f 100644
--- a/util/grub-set-default.in
+++ b/util/grub-set-default.in
@@ -17,8 +17,6 @@
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
@@ -32,7 +30,7 @@ fi
 
 self=`basename $0`
 
-grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
+grub_editenv=${bindir}/@grub_editenv@
 rootdir=
 bootdir=
 grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index 765bfdc..3da5d12 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -17,8 +17,6 @@ set -e
 # You should have received a copy of the GNU General Public License
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 datarootdir="@datarootdir@"
diff --git a/util/powerpc/ieee1275/grub-mkrescue.in b/util/powerpc/ieee1275/grub-mkrescue.in
index b3b88f0..2615cab 100644
--- a/util/powerpc/ieee1275/grub-mkrescue.in
+++ b/util/powerpc/ieee1275/grub-mkrescue.in
@@ -18,8 +18,6 @@ set -e
 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
 # Initialize some variables.
-transform="@program_transform_name@"
-
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 bindir="@bindir@"
@@ -36,7 +34,7 @@ fi
 
 self=`basename $0`
 
-grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
+grub_mkimage="${bindir}/@grub_mkimage@"
 
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR="@localedir@"
-- 
1.8.2.1