Hi,

On Nov/20/2009, Robert Millan wrote:
> On Thu, Nov 19, 2009 at 10:22:57PM +0000, Carles Pina i Estany wrote:
> > 
> > Hello,
> > 
> > grub-mkrescue is trying to execute cp -dpRl (l for link). If the origin
> > and destination directories are in different file systems this fails.
> 
> One of the purposes of grub-mkrescue is to generate images that are
> bootable using GRUB.  These images might be complete CDs or DVDs,
> making a complete copy very undesireable.

I see...

> I think I'd rather remove the copiing stage altogether and operate on
> the original directory (this is not so strange, e.g. -boot-info-table
> in mkisofs also modifies original data and is widely used).

I'm not convinced about it, but I'm not familiar in these utilities
either.

Find attached a second patch that lets the user to specify where the
utilities are.

With this _and_ some manual things with the modules I've generated and
ISO image that boots using qemu.

Which approach do you have in mind for the modules? Which modules should
be copied and where? 

(I see some modules inside the core img, I guess that this is what
should be in the core image and then the modules that the user specifies
in the option --modules should be copied into boot/grub/ (or in 386-pc?)
or something by default?)

Yes, I know that could be better done (avoid copying, more options,
etc.) but I'm doing this to do some comfortable tests with qemu and
gettext :-)

If you tell what you wanted to do I can try to do tomorrow and carry on
with other things.

-- 
Carles Pina i Estany
        http://pinux.info
2009-11-21  Carles Pina i Estany <car...@pina.cat>

	* util/grub-mkrescue.in: copies the files instead of hard linking
	(removes option -l from cp)
	* adds the option --grub-utilities-directory to specify the
	directory of the grub utilities used by grub-mkrescue
	* adds the optoin --pc_dir to overwrite the detected by
	default
	* source from /boot/grub/grub.cfg to the specific by architecture

=== modified file 'util/grub-mkrescue.in'
--- util/grub-mkrescue.in	2009-11-14 18:38:11 +0000
+++ util/grub-mkrescue.in	2009-11-21 01:37:30 +0000
@@ -30,19 +30,22 @@
 
 coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
 pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
-grub_mkisofs="grub-mkisofs"
+grub_utilities_directory=""	# by default, from $PATH
 
 # Usage: usage
 # Print the usage.
 usage () {
     cat <<EOF
-Usage: $0 [OPTION] SOURCE...
+Usage: $0 [OPTION] SOURCE... 
 Make GRUB rescue image.
 
   -h, --help              print this message and exit
   -v, --version           print the version information and exit
   --modules=MODULES       pre-load specified modules MODULES
   --output=FILE           save output in FILE
+  --pc_dir=DIR            use images from directory DIR instead of ${pc_dir}
+  --grub-utilities-directory=DIR  use the grub utilities from DIR instead 
+                          of PATH (e.g. grub-mkisofs, grub-mkimage, ...)
 
 $0 generates a bootable rescue image with specified source files or directories.
 
@@ -63,6 +66,10 @@
 	modules=`echo "$option" | sed 's/--modules=//'` ;;
     --output=*)
 	output_image=`echo "$option" | sed 's/--output=//'` ;;
+    --grub-utilities-directory=*)
+        grub_utilities_directory=`echo "${option}/" | sed 's/--grub-utilities-directory=//'` ;;
+    --pc_dir=*)
+        pc_dir=`echo "$option" | sed 's/--pc_dir=//'` ;;
     -*)
 	echo "Unrecognized option \`$option'" 1>&2
 	usage
@@ -92,6 +99,7 @@
 
 # build coreboot core.img
 if test -e ${coreboot_dir} ; then
+    echo "Generates coreboot"
     memdisk_img=`mktemp`
     memdisk_dir=`mktemp -d`
     mkdir -p ${memdisk_dir}/boot/grub
@@ -111,26 +119,28 @@
 
     tar -C ${memdisk_dir} -cf ${memdisk_img} boot
     rm -rf ${memdisk_dir}
-    grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
+    ${grub_utilities_directory}grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
         memdisk tar search iso9660 configfile sh \
         ata at_keyboard
     rm -f ${memdisk_img}
-    grub_mkisofs="${grub_mkisofs} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
+    grub_mkisofs_arguments="--modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
 fi
 
 if [ "${source}" != "" ] ; then
     for d in ${source}; do
       echo "Processing $d"
-      cp -dpRl "${d}" ${iso9660_dir}/
+      cp -dpR "${d}" ${iso9660_dir}/
     done
 fi
 
 # build eltorito core.img
 if test -e ${pc_dir} ; then
+    echo "Generates eltorito"
     core_img=`mktemp`
-    grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
+    ${grub_utilities_directory}grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
         memdisk tar search iso9660 configfile sh \
         biosdisk
+    mkdir -p ${iso9660_dir}/boot/grub/i386-pc/
     cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
     rm -f ${core_img}
 
@@ -138,14 +148,14 @@
     (for i in ${modules} ; do
         echo "insmod $i"
     done ; \
-    echo "source /boot/grub/grub.cfg") \
-    > ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
+    echo "source /boot/grub/i386-pc/grub.cfg") \
+    > ${iso9660_dir}/boot/grub/grub.cfg
 
-    grub_mkisofs="${grub_mkisofs} -b boot/grub/i386-pc/eltorito.img -boot-info-table"
+    grub_mkisofs_arguments="-b boot/grub/i386-pc/eltorito.img -boot-info-table"
 fi
 
 # build iso image
-${grub_mkisofs} -o ${output_image} -r -J ${iso9660_dir}
+${grub_utilities_directory}grub-mkisofs ${grub_mkisofs_arguments} -o ${output_image} -r -J ${iso9660_dir}
 rm -rf ${iso9660_dir}
 
 exit 0

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to