Skip to contentSkip to conversation

File name transformations & grub-mkconfig --root-directory

PATCH In review Grégoire Sutre 3 participants 3 messages May 24, 2010 – May 28, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 File name transformations & grub-mkconfig --root-directory

Hi,

The attached patch fixes problems with file name transformations, which are partly broken in trunk. With this patch, several installations of grub can coexist with no conflict (at least they should), sharing however the same configuration directory (etc/grub.d).

It also adds --root-directory support to grub-mkconfig, and makes grub-mkconfig_lib's prepare_grub_to_access_device load partmap modules.

The main changes in the patch are:

- configure defines three new variables, accounting for transformations:

  . pkgdatadir       (${datadir}/grub)
  . pkglibrootdir    (${libdir}/grub)
  . defaultbootdir   (/boot/grub, or /grub if OS is NetBSD or OpenBSD)

- these variables are used in Makefile and in util/... scripts

- output of --help and of --version in scripts uses basename $0 and the same format as the one in binaries.

- in Makefile, the help2man, .info, and .mo rules also account for file name transformations.

- grub-mkconfig exports GRUB_DIR, which is used by grub-mkconfig_lib and by 00_header.

- prepare_grub_to_access_device also loads necessary part_* modules, which is required when e.g. only part_msdos is included in core.img but the file to be accessed is in (hd0,msdos1,bsd5).

The other changes are cosmetic (with no intended functional change).

Note: this patch also contains my small Unifont search patch previously sent to the list.

Grégoire

p.s. This corresponds to my branch gsutre/fixes, where the
modifications are split into small commits.

=== added file 'ChangeLog.fixes'

ChangeLog.fixes +69 -0
@@ -0,0 +1,69 @@
+2010-05-23  Grégoire Sutre  <[email protected]>
+
+	* 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-05-22  Grégoire Sutre  <[email protected]>
+
+	* configure.ac: Add `.' to the directories searched for unifont.
+	* util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Load
+	partmap modules.
+	* util/grub.d/00_header.in: Extra sanity checks for locale support.
+	* util/grub.d/10_netbsd.in: Added a comment.
+
+2010-05-22  Grégoire Sutre  <[email protected]>
+
+	* Makefile.in: apply file name transformation to .mo files.
+	* util/grub-install.in: Likewise.
+	* util/i386/efi/grub-install.in: Likewise.
+
+2010-05-21  Grégoire Sutre  <[email protected]>
+
+	* util/grub-install.in: Remove the dependency on grub-mkconfig_lib.
+	* util/grub-mkconfig.in: New option --root-directory=DIR.
+	(GRUB_DIR): Export new variable.
+	* util/grub-mkconfig_lib.in: Let grub-probe use ${GRUB_DIR}/device.map.
+	* util/grub.d/00_header.in: Use GRUB_DIR passed by grub-mkconfig.
+
+2010-05-21  Grégoire Sutre  <[email protected]>
+
+	* Makefile.in: Apply program name transformation to generated info file.
+
+2010-05-21  Grégoire Sutre  <[email protected]>
+
+	* configure.ac: Set and subsitute pkgdatadir, pkglibrootdir and
+	defaultbootdir.
+	* Makefile.in: Use pkgdatadir, pkglibrootdir and defaultbootdir.
+	* util/grub-install.in: Likewise.
+	* util/grub-mkconfig.in: Likewise.
+	* util/grub-mkconfig_lib.in: Likewise.
+	* util/grub-mkrescue.in: Likewise.
+	* util/grub-reboot.in: Likewise.
+	* util/grub-set-default.in: Likewise.
+	* util/grub.d/00_header.in: Likewise.
+	* util/grub.d/10_hurd.in: Likewise.
+	* util/grub.d/10_kfreebsd.in: Likewise.
+	* util/grub.d/10_linux.in: Likewise.
+	* util/grub.d/10_netbsd.in: Likewise.
+	* util/grub.d/10_windows.in: Likewise.
+	* util/grub.d/30_os-prober.in: Likewise.
+	* util/i386/efi/grub-install.in: Likewise.
+	* util/ieee1275/grub-install.in: Likewise.
+	* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
+	* util/update-grub_lib.in: Likewise.
+
+2010-05-19  Grégoire Sutre  <[email protected]>
+
+	* Makefile.in: Use installed files on help2man command line.
+	* util/grub-mkimage.c (main): Use `program_name' instead of
+	hardcoded string.
+	* util/i386/pc/grub-setup.c (main): Likewise.
+	* util/sparc64/ieee1275/grub-setup.c (parse_options): Likewise.

=== modified file 'Makefile.in'

Makefile.in +17 -15
@@ -39,8 +39,9 @@ localedir = @localedir@
 infodir = @infodir@
 mandir = @mandir@
 includedir = @includedir@
-pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'`
-pkglibdir =  $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'`
+pkgdatadir = @pkgdatadir@
+pkglibrootdir = @pkglibrootdir@
+pkglibdir = $(pkglibrootdir)/$(target_cpu)-$(platform)
 
 # Internationalization library.
 LIBINTL = @LIBINTL@
@@ -90,7 +91,7 @@ GNULIB_CFLAGS = $(GNULIB_UTIL_CFLAGS) $(
 ASFLAGS = @ASFLAGS@
 LDFLAGS = @LDFLAGS@ $(LIBS)
 CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
-	 -DGRUB_PKGLIBROOTDIR=\"$(libdir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'`\" -DLOCALEDIR=\"$(localedir)\"
+	 -DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\" -DLOCALEDIR=\"$(localedir)\"
 TARGET_CC = @TARGET_CC@
 TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
 TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
@@ -323,26 +324,26 @@ install-local: all
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
 	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  $(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
-	  $(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(builddir)/$$file; \
+	  $(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(DESTDIR)$(bindir)/$$dest; \
 	done
 	$(SHELL) $(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
 	@list='$(sbin_UTILITIES)'; for file in $$list; do \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
 	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  $(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(sbindir)/$$dest; \
-	  $(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(builddir)/$$file; \
+	  $(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(DESTDIR)$(sbindir)/$$dest; \
 	done
 	@list='$(bin_SCRIPTS)'; for file in $$list; do \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
 	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  $(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
-	  $(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(builddir)/$$file; \
+	  $(HELP2MAN) --section=1 -o $(DESTDIR)$(mandir)/man1/$$dest.1 $(DESTDIR)$(bindir)/$$dest; \
 	done
 	@list='$(sbin_SCRIPTS)'; for file in $$list; do \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
 	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  $(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(sbindir)/$$dest; \
-	  $(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(builddir)/$$file; \
+	  $(HELP2MAN) --section=8 -o $(DESTDIR)$(mandir)/man8/$$dest.8 $(DESTDIR)$(sbindir)/$$dest; \
 	done
 	$(SHELL) $(mkinstalldirs) $(DESTDIR)$(sysconfdir)/grub.d
 	@list='$(grub-mkconfig_SCRIPTS)'; for file in $$list; do \
@@ -355,26 +356,27 @@ install-local: all
 	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \
 	done
-	$(SHELL) $(mkinstalldirs) $(DESTDIR)$(libdir)/grub
+	$(SHELL) $(mkinstalldirs) $(DESTDIR)$(pkglibrootdir)
 	@list='$(lib_SCRIPTS)'; \
 	for file in $$list; do \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
 	  dest="`echo $$file | sed 's,.*/,,'`"; \
-	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(libdir)/grub/$$dest; \
+	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkglibrootdir)/$$dest; \
 	done
 	@langs='$(LINGUAS)'; \
 	for lang in $$langs; do \
-	  $(SHELL) $(mkinstalldirs) $(DESTDIR)/$(datadir)/locale/$$lang/LC_MESSAGES; \
+	  $(SHELL) $(mkinstalldirs) $(DESTDIR)$(datadir)/locale/$$lang/LC_MESSAGES; \
 	  file="po/$$lang.mo"; \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
-	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)/$(datadir)/locale/$$lang/LC_MESSAGES/$(PACKAGE).mo; \
+	  dest="`echo $(PACKAGE).mo | sed 's,.*/,,' | sed '$(transform)'`"; \
+	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(datadir)/locale/$$lang/LC_MESSAGES/$$dest; \
 	done
 	$(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir)
 	@list='$(info_INFOS)'; \
 	for file in $$list; do \
 	  if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
-	  dest="`echo $$file | sed 's,.*/,,'`"; \
-	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(infodir); \
+	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
+	  $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(infodir)/$$dest; \
 	  if (install-info --version && \
 	       install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
 	    install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$dest" || :; \
@@ -412,11 +414,11 @@ uninstall:
 	@list='$(lib_SCRIPTS)'; \
 	for file in $$list; do \
 	  dest="`echo $$file | sed 's,.*/,,'`"; \
-	  rm -f $(DESTDIR)$(libdir)/grub/$$dest; \
+	  rm -f $(DESTDIR)$(pkglibrootdir)/$$dest; \
 	done
 	@list='$(info_INFOS)'; \
 	for file in $$list; do \
-	  dest="`echo $$file | sed 's,.*/,,'`"; \
+	  dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
 	  if (install-info --version && \
 	       install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
 	    if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$dest"; then \

=== modified file 'configure.ac'

configure.ac +28 -5
@@ -179,11 +179,13 @@ if test "x$YACC" = x; then
   AC_MSG_ERROR([bison is not found])
 fi
 
-for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
-  if test -e $file ; then
-    AC_SUBST([FONT_SOURCE], [$file])
-    break
-  fi
+for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
+  for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
+    if test -f "$dir/unifont.$ext"; then
+      AC_SUBST([FONT_SOURCE], [$dir/unifont.$ext])
+      break 2
+    fi
+  done
 done
 
 AC_PROG_INSTALL
@@ -798,6 +800,27 @@ fi
 
 AC_SUBST(ASFLAGS)
 
+# Additional names and paths to be substituted in makefiles and scripts.
+pkgdatadir=${datadir}/`echo ${PACKAGE_TARNAME} | sed "${program_transform_name}"`
+pkglibrootdir=${libdir}/`echo ${PACKAGE_TARNAME} | sed "${program_transform_name}"`
+
+case "$host_os" in
+netbsd* | openbsd*)
+    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
+    # instead of /boot/grub.
+    defaultbootdir=
+    ;;
+*)
+    # Use /boot/grub by default.
+    defaultbootdir=/boot
+    ;;
+esac
+defaultbootdir=${defaultbootdir}/`echo ${PACKAGE_TARNAME} | sed "${program_transform_name}"`
+
+AC_SUBST([pkgdatadir])
+AC_SUBST([pkglibrootdir])
+AC_SUBST([defaultbootdir])
+
 # Output files.
 grub_CHECK_LINK_DIR
 if test x"$link_dir" = xyes ; then

=== added directory 'util/elf'
=== modified file 'util/grub-install.in'

grub-install.in +30 -47

160 lines not on this page · raw message

=== modified file 'util/grub-mkconfig.in'

grub-mkconfig.in +42 -45

169 lines not on this page · raw message

=== modified file 'util/grub-mkconfig_lib.in'

grub-mkconfig_lib.in +13 -1
@@ -22,7 +22,7 @@ datarootdir=@datarootdir@
 datadir=@datadir@
 bindir=@bindir@
 sbindir=@sbindir@
-pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
+pkgdatadir=@pkgdatadir@
 
 if test "x$grub_probe" = x; then
   grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@@ -31,6 +31,13 @@ if test "x$grub_mkrelpath" = x; then
   grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
 fi
 
+# GRUB_DIR should be set before sourcing this file, but let's be safe.
+if test "x${GRUB_DIR}" != "x"; then
+  if test -e "${GRUB_DIR}/device.map"; then
+    grub_probe="${grub_probe} --device-map=${GRUB_DIR}/device.map"
+  fi
+fi
+
 if $(which gettext >/dev/null 2>/dev/null) ; then
   gettext="gettext"
 else
@@ -105,6 +112,11 @@ prepare_grub_to_access_device ()
     echo "insmod ${module}"
   done
 
+  partmap="`${grub_probe} --device ${device} --target=partmap`"
+  for module in ${partmap} ; do
+    echo "insmod part_${module}"
+  done
+
   fs="`${grub_probe} --device ${device} --target=fs`"
   for module in ${fs} ; do
     echo "insmod ${module}"

=== modified file 'util/grub-mkimage.c'

grub-mkimage.c +1 -1
@@ -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':

=== modified file 'util/grub-mkrescue.in'

grub-mkrescue.in +13 -10
@@ -28,14 +28,17 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@
 PACKAGE_VERSION=@PACKAGE_VERSION@
 target_cpu=@target_cpu@
 native_platform=@platform@
+pkglibrootdir=@pkglibrootdir@
 pkglib_DATA="@pkglib_DATA@"
 
-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
-pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
-efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
-efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
+self=`basename $0`
+
+multiboot_dir=${pkglibrootdir}/i386-multiboot
+coreboot_dir=${pkglibrootdir}/i386-coreboot
+qemu_dir=${pkglibrootdir}/i386-qemu
+pc_dir=${pkglibrootdir}/i386-pc
+efi32_dir=${pkglibrootdir}/i386-efi
+efi64_dir=${pkglibrootdir}/x86_64-efi
 rom_directory=
 grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
 
@@ -43,7 +46,7 @@ grub_mkimage=${bindir}/`echo grub-mkimag
 # 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
@@ -53,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 <[email protected]>.
 EOF
@@ -66,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=//'` ;;
@@ -99,7 +102,7 @@ if [ "x${output_image}" = x ] ; then
 fi
 
 set $grub_mkimage dummy
-if test -f "$1"; then
+if test -x "$1"; then
     :
 else
     echo "$1: Not found." 1>&2

=== modified file 'util/grub-reboot.in'

grub-reboot.in +8 -16
@@ -22,6 +22,11 @@ transform="@program_transform_name@"
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+defaultbootdir=@defaultbootdir@
+
+self=`basename $0`
 
 grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
 rootdir=
@@ -30,7 +35,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 +56,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=//'` ;;
@@ -77,20 +82,7 @@ if test "x$entry" = x; then
 fi
 
 # Initialize these directories here, since ROOTDIR was initialized.
-case "$host_os" in
-netbsd* | openbsd*)
-    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
-    # instead of /boot/grub.
-    grub_prefix=`echo /grub | sed ${transform}`
-    bootdir=${rootdir}
-    ;;
-*)
-    # Use /boot/grub by default.
-    bootdir=${rootdir}/boot
-    ;;
-esac
-
-grubdir=${bootdir}/`echo grub | sed ${transform}`
+grubdir=${rootdir}${defaultbootdir}
 
 prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
 if [ "$prev_saved_entry" ]; then

=== modified file 'util/grub-set-default.in'

grub-set-default.in +8 -16
@@ -22,6 +22,11 @@ transform="@program_transform_name@"
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+defaultbootdir=@defaultbootdir@
+
+self=`basename $0`
 
 grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
 rootdir=
@@ -30,7 +35,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 +56,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=//'` ;;
@@ -77,20 +82,7 @@ if test "x$entry" = x; then
 fi
 
 # Initialize these directories here, since ROOTDIR was initialized.
-case "$host_os" in
-netbsd* | openbsd*)
-    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
-    # instead of /boot/grub.
-    grub_prefix=`echo /grub | sed ${transform}`
-    bootdir=${rootdir}
-    ;;
-*)
-    # Use /boot/grub by default.
-    bootdir=${rootdir}/boot
-    ;;
-esac
-
-grubdir=${bootdir}/`echo grub | sed ${transform}`
+grubdir=${rootdir}${defaultbootdir}
 
 $grub_editenv ${grubdir}/grubenv unset prev_saved_entry
 $grub_editenv ${grubdir}/grubenv set saved_entry="$entry"

=== modified file 'util/grub.d/00_header.in'

grub.d/00_header.in +6 -6
@@ -20,12 +20,12 @@ transform="@program_transform_name@"
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
-grub_prefix=`echo /boot/grub | sed ${transform}`
-locale_dir=`echo /boot/grub/locale | sed ${transform}`
+pkglibrootdir=@pkglibrootdir@
+
+locale_dir=${GRUB_DIR}/locale
 grub_lang=`echo $LANG | cut -d _ -f 1`
 
-. ${libdir}/grub/grub-mkconfig_lib
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 # Do this as early as possible, since other commands might depend on it.
 # (e.g. the `loadfont' command might need lvm or raid modules)
@@ -89,7 +89,7 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_T
 done
 
 if [ "x$serial" = x1 ]; then
-    if ! test -e ${grub_prefix}/serial.mod ; then
+    if ! test -e ${GRUB_DIR}/serial.mod ; then
 	echo "Serial terminal not available on this platform." >&2 ; exit 1
     fi
 
@@ -195,7 +195,7 @@ EOF
 esac
 
 # Gettext variables and module
-if [ "x${LANG}" != "xC" ] ; then
+if [ "x${LANG}" != "x" ] && [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then
     prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
   cat << EOF
 set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})

=== modified file 'util/grub.d/10_hurd.in'

grub.d/10_hurd.in +3 -2
@@ -18,8 +18,9 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
-. ${libdir}/grub/grub-mkconfig_lib
+pkglibrootdir=@pkglibrootdir@
+
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 CLASS="--class gnu --class os"
 

=== modified file 'util/grub.d/10_kfreebsd.in'

grub.d/10_kfreebsd.in +3 -2
@@ -19,8 +19,9 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
-libdir=@libdir@
-. ${libdir}/grub/grub-mkconfig_lib
+pkglibrootdir=@pkglibrootdir@
+
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@

=== modified file 'util/grub.d/10_linux.in'

grub.d/10_linux.in +3 -2
@@ -19,8 +19,9 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
-libdir=@libdir@
-. ${libdir}/grub/grub-mkconfig_lib
+pkglibrootdir=@pkglibrootdir@
+
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@

=== modified file 'util/grub.d/10_netbsd.in'

grub.d/10_netbsd.in +4 -2
@@ -19,8 +19,9 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
-libdir=@libdir@
-. ${libdir}/grub/grub-mkconfig_lib
+pkglibrootdir=@pkglibrootdir@
+
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 export TEXTDOMAIN=@PACKAGE@
 export TEXTDOMAINDIR=@localedir@
@@ -61,6 +62,7 @@ netbsd_entry ()
   printf "}\n"
 }
 
+# Cache the sequence of commands to access / (whose device is ${GRUB_DEVICE}).
 prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e 's,^,	,')"
 
 # We look for NetBSD kernels in / but not in subdirectories.  We simply

=== modified file 'util/grub.d/10_windows.in'

grub.d/10_windows.in +3 -2
@@ -18,8 +18,9 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
-. ${libdir}/grub/grub-mkconfig_lib
+pkglibrootdir=@pkglibrootdir@
+
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 case "`uname 2>/dev/null`" in
   CYGWIN*)  ;;

=== modified file 'util/grub.d/30_os-prober.in'

grub.d/30_os-prober.in +2 -2
@@ -18,9 +18,9 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
+pkglibrootdir=@pkglibrootdir@
 
-. ${libdir}/grub/grub-mkconfig_lib
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
   exit 0

=== modified file 'util/i386/efi/grub-install.in'

i386/efi/grub-install.in +23 -38

118 lines not on this page · raw message

=== modified file 'util/i386/pc/grub-setup.c'

i386/pc/grub-setup.c +1 -1
@@ -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':

=== modified file 'util/ieee1275/grub-install.in'

ieee1275/grub-install.in +23 -18

101 lines not on this page · raw message

=== modified file 'util/powerpc/ieee1275/grub-mkrescue.in'

powerpc/ieee1275/grub-mkrescue.in +6 -3
@@ -28,7 +28,10 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@
 PACKAGE_VERSION=@PACKAGE_VERSION@
 target_cpu=@target_cpu@
 platform=@platform@
-pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
+pkglibrootdir=@pkglibrootdir@
+pkglibdir=${pkglibrootdir}/${target_cpu}-${platform}
+
+self=`basename $0`
 
 grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
 
@@ -36,7 +39,7 @@ grub_mkimage=${bindir}/`echo grub-mkimag
 # 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
@@ -61,7 +64,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=//'` ;;

=== modified file 'util/sparc64/ieee1275/grub-setup.c'

sparc64/ieee1275/grub-setup.c +1 -1
@@ -503,7 +503,7 @@ parse_options (struct grub_setup_info *g
 	    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':

=== modified file 'util/update-grub_lib.in'

update-grub_lib.in +2 -2
@@ -16,8 +16,8 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
+pkglibrootdir=@pkglibrootdir@
 
-. ${libdir}/grub/grub-mkconfig_lib
+. ${pkglibrootdir}/grub-mkconfig_lib
 
 grub_warn "update-grub_lib is deprecated, use grub-mkconfig_lib instead"
#1 lore raw

A general comment, not specific your patch: IMO we should make these scripts in grub.d, standalone, i.e., instead of assuming some environment variables (like GRUB_DEVICE), they should accept values through command line arguments, like --root-device=/dev/sda or similar.

Thus, final result should be something like, with appropriate cmdline parameters, 10_linux script should print menu entries for all identified Linux distros, etc.

Signature · 1 line
bvk.chaitanya
#2 lore raw
Quoted 11 lines · BVK Chaitanya

A general comment, not specific your patch: IMO we should make these scripts in grub.d, standalone, i.e., instead of assuming some environment variables (like GRUB_DEVICE), they should accept values through command line arguments, like --root-device=/dev/sda or similar.

Thus, final result should be something like, with appropriate cmdline parameters, 10_linux script should print menu entries for all identified Linux distros, etc.

Why? Every change must have a clear goal. Here I don't see the usecase. End-user should never run those scripts directly. And for debugging it's more interesting to have this script run in the same environment as it's used.
Changing for the sake of changing is NOT good.

Quoted 3 lines
Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko