Fix file name transformations (mostly)
PATCH 1/1 Fix file name transformations (mostly)
Hi,
Attaching the patch that fixes ./configure's --program-transform-name option. Tested with --program-transform-name=s,grub,grub2, quite extensively. Only one more modification is needed to completely support this -- define DEFAULT_DIRECTORY with -D option of the preprocessor instead of hardcoding in include/grub/util/misc.h. Should be fairly trivial though.
2008-04-15 Lubomir Kundrak <[email protected]>
* Makefile.in: Honor program name transformations.
* util/grub.d/00_header.in: Honor program name transformations.
* util/grub.d/10_linux.in: Honor program name transformations.
* util/i386/pc/grub-install.in: Honor program name transformations.
* util/i386/pc/grub-mkrescue.in: Honor program name transformations.
* powerpc/ieee1275/grub-mkrescue.in: Honor program name transformations.
* util/update-grub.in: Honor program name transformations.
* util/update-grub_lib.in: Honor program name transformations.
Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
Makefile.in +2 -2
@@ -189,12 +189,12 @@ install-local: all dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \ done - $(mkinstalldirs) $(DESTDIR)$(libdir)/grub + $(mkinstalldirs) $(DESTDIR)$(libdir)/`echo grub | sed '$(transform)'` @list='$(lib_DATA)'; \ 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)$(libdir)/`echo grub | sed '$(transform)'`/$$dest; \ done install-strip:
util/grub.d/00_header.in +3 -1
@@ -16,13 +16,15 @@ # 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@ libdir=@libdir@ platform=@platform@ # for convert_system_path_to_grub_path() -. ${libdir}/grub/update-grub_lib +. ${libdir}/`echo grub | sed ${transform}`/update-grub_lib # Do this as early as possible, since other commands might depend on it. # (e.g. the `font' command might need lvm or raid modules)
util/grub.d/10_linux.in +3 -1
@@ -16,10 +16,12 @@ # 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@ libdir=@libdir@ -. ${libdir}/grub/update-grub_lib +. ${libdir}/`echo grub | sed ${transform}`/update-grub_lib if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux
util/i386/pc/grub-install.in +2 -2
@@ -36,7 +36,7 @@ grub_mkimage=${bindir}/`echo grub-mkimag grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` rootdir= -grub_prefix=`echo /boot/grub | sed ${transform}` +grub_prefix=/boot/`echo grub | sed ${transform}` modules= install_device=
@@ -46,7 +46,7 @@ recheck=no debug=no # for make_system_path_relative_to_its_root() -. ${libdir}/grub/update-grub_lib +. ${libdir}/`echo grub | sed ${transform}`/update-grub_lib # Usage: usage # Print the usage.
util/i386/pc/grub-mkrescue.in +2 -3
@@ -55,7 +55,6 @@ EOF image_type=cdrom input_dir=${pkglibdir} -grub_mkimage=grub-mkimage # Check the arguments. for option in "$@"; do
@@ -109,10 +108,10 @@ else fi memdisk_dir=`mktemp -d` -mkdir -p ${memdisk_dir}/boot/grub +mkdir -p ${memdisk_dir}/boot/`echo grub | sed ${transform}` cp ${input_dir}/*.mod \ ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ - ${memdisk_dir}/boot/grub/ + ${memdisk_dir}/boot/`echo grub | sed ${transform}`/ if test "x$overlay" = x ; then : ; else cp -dpR ${overlay}/* ${memdisk_dir}/
util/powerpc/ieee1275/grub-mkrescue.in +1 -1
@@ -101,7 +101,7 @@ grub.img Raw 'UNIX' 'tbxi' EOF iso_dir=`mktemp -d` -boot_dir=${iso_dir}/boot/grub +boot_dir=${iso_dir}/boot/`echo grub | sed ${transform}` mkdir ${iso_dir}/boot mkdir ${boot_dir} core_img=${boot_dir}/grub.img
util/update-grub.in +7 -7
@@ -23,7 +23,7 @@ exec_prefix=@exec_prefix@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ -grub_prefix=`echo /boot/grub | sed ${transform}` +grub_prefix=/boot/`echo /grub | sed ${transform}` grub_cfg=${grub_prefix}/grub.cfg update_grub_dir=${sysconfdir}/grub.d platform=@platform@
@@ -32,7 +32,7 @@ grub_mkdevicemap=${sbindir}/`echo grub-m grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` # for convert_system_path_to_grub_path(), font_path() -. ${libdir}/grub/update-grub_lib +. ${libdir}/`echo grub | sed ${transform}`/update-grub_lib if [ "x$UID" = "x" ] ; then UID=`id -u`
@@ -66,24 +66,24 @@ fi mkdir -p ${grub_prefix} if test -e ${grub_prefix}/device.map ; then : ; else - grub-mkdevicemap + ${grub_mkdevicemap} fi # Device containing our userland. Typically used for root= parameter. -GRUB_DEVICE="`grub-probe --target=device /`" +GRUB_DEVICE="`${grub_probe} --target=device /`" # Filesystem for the device containing our userland. Used for stuff like # choosing Hurd filesystem module. -GRUB_FS="`grub-probe --target=fs / 2> /dev/null || echo unknown`" +GRUB_FS="`${grub_probe} --target=fs / 2> /dev/null || echo unknown`" # GRUB path to /. Only used for "set root=". Not critical. -GRUB_DRIVE="`grub-probe --target=drive /`" || true +GRUB_DRIVE="`${grub_probe} --target=drive /`" || true # GRUB path to /boot GRUB_DRIVE_BOOT="`convert_system_path_to_grub_path /boot`" # GRUB path to /boot/grub -GRUB_DRIVE_BOOT_GRUB="`convert_system_path_to_grub_path /boot/grub`" +GRUB_DRIVE_BOOT_GRUB="`convert_system_path_to_grub_path ${grub_prefix}`" defaults=`echo ${sysconfdir}/sysconfig/grub | sed ${transform}` if test -f ${defaults}; then
util/update-grub_lib.in renamed from util/update-grub_lib.in.transform +2 -1
@@ -95,7 +95,8 @@ { # Prefer system path for space reasons (/boot/grub might be a very small # partition in case of OpenFirmware, etc). - for dir in ${pkgdatadir} /usr/share/grub /boot/grub ; do + for dir in ${pkgdatadir} ${pkgdatadir}/`echo grub | sed ${transform}` \ + /boot/`echo grub | sed ${transform}`; do # Prefer complete fonts over incomplete ones. for basename in unicode unifont ascii ; do path="${dir}/${basename}.pff"
util/update-grub.in exec_prefix=@exec_prefix@ · line 26
Quoted 9 lines · Lubomir Kundrak
diff -urp grub-1.96.orig/util/update-grub.in grub-1.96/util/update-grub.in
util/update-grub.in +1
-1@@ -23,7 +23,7 @@ exec_prefix=@exec_prefix@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ -grub_prefix=`echo /boot/grub | sed ${transform}` +grub_prefix=/boot/`echo /grub | sed ${transform}`
Is the second slash intentional?
util/update-grub_lib.in line 99
Quoted 9 lines
util/update-grub_lib.in renamed from util/update-grub_lib.in.transform +2
-1@@ -95,7 +95,8 @@ { # Prefer system path for space reasons (/boot/grub might be a very small # partition in case of OpenFirmware, etc). - for dir in ${pkgdatadir} /usr/share/grub /boot/grub ; do + for dir in ${pkgdatadir} ${pkgdatadir}/`echo grub | sed ${transform}` \ + /boot/`echo grub | sed ${transform}`; do
I'd prefer is grub_prefix was defined here too (for readability).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 12 lines · Robert Millan
util/update-grub.in exec_prefix=@exec_prefix@ · line 26
Quoted 9 lines · Lubomir Kundrak
diff -urp grub-1.96.orig/util/update-grub.in grub-1.96/util/update-grub.in
util/update-grub.in +1
-1@@ -23,7 +23,7 @@ exec_prefix=@exec_prefix@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ -grub_prefix=`echo /boot/grub | sed ${transform}` +grub_prefix=/boot/`echo /grub | sed ${transform}`Is the second slash intentional?
No.
Quoted 11 lines
util/update-grub_lib.in line 99
Quoted 9 lines
util/update-grub_lib.in renamed from util/update-grub_lib.in.transform +2
-1@@ -95,7 +95,8 @@ { # Prefer system path for space reasons (/boot/grub might be a very small # partition in case of OpenFirmware, etc). - for dir in ${pkgdatadir} /usr/share/grub /boot/grub ; do + for dir in ${pkgdatadir} ${pkgdatadir}/`echo grub | sed ${transform}` \ + /boot/`echo grub | sed ${transform}`; doI'd prefer is
grub_prefixwas defined here too (for readability).
Yep, there's space for improvement. See Pavel's reply to that mail.
Thanks,
Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
Quoted 8 lines · Lubomir Kundrak
Hi,
Attaching the patch that fixes ./configure's --program-transform-name option. Tested with --program-transform-name=s,grub,grub2, quite extensively. Only one more modification is needed to completely support this -- define
DEFAULT_DIRECTORYwith -D option of the preprocessor instead of hardcoding ininclude/grub/util/misc.h. Should be fairly trivial though.
I would prefer if we don't rush with "program-transform-name" at the expense of readability, but rather make other simplifications what would have a similar effect. I think ${libdir}/grub should be given a name (e.g. grublibdir) in configure.ac and substituted in the scripts.
As for /boot/grub, we are not installing anything there on "make install". I don't think it should be transformed. But we could accept a configuration option to change that directory.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 10 lines · Pavel Roskin
Quoted 8 lines · Lubomir Kundrak
Hi,
Attaching the patch that fixes ./configure's --program-transform-name option. Tested with --program-transform-name=s,grub,grub2, quite extensively. Only one more modification is needed to completely support this -- define
DEFAULT_DIRECTORYwith -D option of the preprocessor instead of hardcoding ininclude/grub/util/misc.h. Should be fairly trivial though.
Quoted 4 lines
I would prefer if we don't rush with "program-transform-name" at the expense of readability, but rather make other simplifications what would have a similar effect. I think ${libdir}/grub should be given a name (e.g. grublibdir) in configure.ac and substituted in the scripts.
That makes sense. Another solution would be to have shell library to include by all scripts and define variables with substituted names there.
Quoted 3 lines
As for
/boot/grub, we are not installing anything there on "make install". I don't think it should be transformed. But we could accept a configuration option to change that directory.
We should have a sensible default that wouldn't clash with GRUB Legacy's default.
Thanks,
Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
Quoted 6 lines · Lubomir Kundrak
Quoted 3 lines
As for
/boot/grub, we are not installing anything there on "make install". I don't think it should be transformed. But we could accept a configuration option to change that directory.We should have a sensible default that wouldn't clash with GRUB Legacy's default.
There is no clash here. Names of all files under /boot/grub are different, except device.map. But device.map has the same format and is system specific.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 6 lines · Pavel Roskin
Quoted 4 lines · Lubomir Kundrak
Quoted 3 lines
As for
/boot/grub, we are not installing anything there on "make install". I don't think it should be transformed. But we could accept a configuration option to change that directory.
Quoted 6 lines
Quoted 2 lines
We should have a sensible default that wouldn't clash with GRUB Legacy's default.
There is no clash here. Names of all files under
/boot/grubare different, except device.map. But device.map has the same format and is system specific.
Lubomir, if you're worried about making GRUB 2 and Legacy coexist, I can confirm you it's perfectly possible using the same directory. In Debian we do that in fact (I only had to fix grub-install removing menu.lst, but that's all).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
Quoted 6 lines · Pavel Roskin
Quoted 4 lines · Lubomir Kundrak
Quoted 3 lines
As for
/boot/grub, we are not installing anything there on "make install". I don't think it should be transformed. But we could accept a configuration option to change that directory.
Quoted 6 lines
Quoted 2 lines
We should have a sensible default that wouldn't clash with GRUB Legacy's default.
There is no clash here. Names of all files under
/boot/grubare different, except device.map. But device.map has the same format and is system specific.
Though I am convinced that directories were invented to avoid mixing apples with oranges (or dead horses, and ponnies, oh well), sharing device.map sounds usable and is a rather good argument.
I'll try to rework the patch and taka that into account.
Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)