GNU GRUB program name transformations
PATCH 1/1 GNU GRUB program name transformations
Hi all,
I am maintaining a work-in-progress package [1] for the NetBSD package system, pkgsrc. I was wondering how to avoid conflict between GRUB Legacy and GRUB 2, letting them (their userspace utilities) coexist side-by-side. IIRC, one single utility that was conflicting was grub-install.
[1] http://pkgsrc-wip.cvs.sourceforge.net/pkgsrc-wip/wip/grub2/
[2] http://www.pkgsrc.org/
From my point of view, the best solution was to use the autoconf macro AC_ARG_PROGRAM adding program name transformation options, --program-transform-name, --program-prefix and --program-suffix. Side effect of this is that it allows you to have multiple instances of GRUB 2 installed more comfortably.
The question is whether it is a good thing to transform program names by default in vendor specific packages (as is done with current version of pkgsrc package). Alternative solution would be to transform GRUB Legacy filenames, which, though it might cause some confusion to Legacy users, seems to be more appropropriate. Does GRUB Legacy support such transformations in its most recent version?
Anone has other/better suggestions how to avoid GRUB Legacy/GRUB 2 conflict? I attach the patch which applies against current CVS snapshot to this message.
Regards,
Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
Makefile.in +6 -5
@@ -52,6 +52,7 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +transform = @program_transform_name@ mkinstalldirs = $(srcdir)/mkinstalldirs CC = @CC@
@@ -139,18 +140,18 @@ install-local: all $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_UTILITIES)'; for file in $$list; do \ if test -f "$$file"; then dir=; else dir="$(srcdir)"; fi; \ - dest="`echo $$file | sed 's,.*/,,'`"; \ + dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ $(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \ done $(mkinstalldirs) $(DESTDIR)$(sbindir) @list='$(sbin_UTILITIES)'; for file in $$list; do \ if test -f "$$file"; then dir=; else dir="$(srcdir)"; fi; \ - dest="`echo $$file | sed 's,.*/,,'`"; \ + dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ $(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(sbindir)/$$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,.*/,,'`"; \ + dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ $(INSTALL_SCRIPT) $$dir$$file $(DESTDIR)$(sbindir)/$$dest; \ done
@@ -164,11 +165,11 @@ uninstall: rm -f $(DESTDIR)$(pkglibdir)/$$dest; \ done @list='$(bin_UTILITIES)'; for file in $$list; do \ - dest="`echo $$file | sed 's,.*/,,'`"; \ + dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ rm -f $(DESTDIR)$(bindir)/$$dest; \ done @list='$(sbin_UTILITIES) $(sbin_SCRIPTS)'; for file in $$list; do \ - dest="`echo $$file | sed 's,.*/,,'`"; \ + dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ rm -f $(DESTDIR)$(sbindir)/$$dest; \ done
configure.ac +3 -0
@@ -40,6 +40,9 @@ AC_CONFIG_HEADER([config.h]) AC_CANONICAL_HOST AC_CANONICAL_TARGET +# Program name transformations +AC_ARG_PROGRAM + case "$host_cpu" in powerpc64) host_m32=1 ;; esac
util/i386/pc/grub-install.in +5 -4
@@ -29,11 +29,12 @@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ platform=@platform@ pkglibdir=${libdir}/${PACKAGE_TARNAME}/${target_cpu}-${platform} +transform=@program_transform_name@ -grub_setup=${sbindir}/grub-setup -grub_mkimage=${bindir}/grub-mkimage -grub_mkdevicemap=${sbindir}/grub-mkdevicemap -grub_probe=${sbindir}/grub-probe +grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` +grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` +grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` +grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` rootdir= grub_prefix=/boot/grub modules=
util/powerpc/ieee1275/grub-install.in +2 -1
@@ -31,8 +31,9 @@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ platform=@platform@ pkglibdir=${libdir}/${PACKAGE_TARNAME}/${target_cpu}-${platform} +transform=@program_transform_name@ -grub_mkimage=${bindir}/grub-mkimage +grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` rootdir= grub_prefix=/boot/grub modules=
Quoted 5 lines · Lubomir Kundrak
From my point of view, the best solution was to use the autoconf macro
AC_ARG_PROGRAMadding program name transformation options, --program-transform-name, --program-prefix and --program-suffix. Side effect of this is that it allows you to have multiple instances of GRUB 2 installed more comfortably.
I agree with this change. Thanks.
Besides the program names, you might want to change the path to which boot images are installed, i.e. /boot/grub. As long as this directory is shared, GRUB Legacy and GRUB 2 cannot coexist, well, at least not comfortably.
I sometimes wonder if it would be better to use a prefix "grub2-" instead of "grub-" for GRUB 2 by default. GRUB Legacy and GRUB 2 are from the same project GRUB, but they are fundamentally very different, so this might reduce some confusion.
Quoted 6 lines
The question is whether it is a good thing to transform program names by default in vendor specific packages (as is done with current version of pkgsrc package). Alternative solution would be to transform GRUB Legacy filenames, which, though it might cause some confusion to Legacy users, seems to be more appropropriate. Does GRUB Legacy support such transformations in its most recent version?
I suggest that you would not change GRUB Legacy for backward compatibility.
Okuji