[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] [libvirt-test-API] Use YABOOT instead of ISOLINUX to create bootable ISO.



On 05/03/2012 05:11 PM, Lin Qing wrote:
Yaboot is the bootloader of PowerPC  (ISOLINUX on AMD64/x86 systems, yaboot on PowerPC),
so should change the yaboot.conf firstly,then use mkiso command  to create bootable ISO.
Whether we consider to rewrite it in python language and add it as a function
into utils module instead of a shell script, in addition, I don't like 'if..else' in shell,
if we will support other bootloader in the future, we must add a new 'else' branch
in ksiso.sh, it hasn't a better expansibility. I'd like to use python 'getattr' as a dispatcher
to deal with this kind of case. if we need to add a new bootloader support, just need
to add a new function/interface, you don't need to change original codes.

Signed-off-by: Qing Lin <qinglbj linux vnet ibm com>
---
 utils/ksiso.sh |   57 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/utils/ksiso.sh b/utils/ksiso.sh
index 7cf30fc..8b3186c 100755
--- a/utils/ksiso.sh
+++ b/utils/ksiso.sh
@@ -23,28 +23,41 @@ cp -rf ${boot_iso_dir}/* $custom_iso_dir
 chmod -R 777 ${custom_iso_dir}/*
 umount $boot_iso_dir

-echo "- copy kickstart to custom work directory"
-cp $kscfg $custom_iso_dir
-
-echo "- edit isolinux.cfg and add kickstart entry"
-WORKING_ISO="${custom_iso_dir}/isolinux/isolinux.cfg"
-
-echo "label custom_ks
-  kernel vmlinuz $kernel_args
-  append initrd=initrd.img ks=cdrom:/$kscfg ramdisk_size=20000" >> $WORKING_ISO
-
-# change default boot target and timeout
-DEFAULT_LINE=`cat $WORKING_ISO | grep default | head -1`
-TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
-
-cat $WORKING_ISO | sed "s/${DEFAULT_LINE}/default custom_ks/" | sed "s/${TIMEOUT_LINE}/timeout 5/" > isocfgtmp
-
-mv -f isocfgtmp $WORKING_ISO
-
-# cd to custom_iso_dir, otherwise mkisofs seems to bomb...
-cd $custom_iso_dir
-mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o $cwd/$custom_iso .
-
+vlmid=`isoinfo -d -i $boot_iso |grep 'Volume id:'`
+vlmid=${vlmid#"Volume id: "}
+if [ -n "`echo $vlmid|grep ppc`" ];then
+	echo "- edit yaboot.conf and add kickstart entry"
+	WORKING_ISO="${custom_iso_dir}/etc/yaboot.conf"
+	# change timeout and  add kickstart entry
+	TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
+	APPEND_LINE=`cat $WORKING_ISO | grep append | head -1`
+	cat $WORKING_ISO | sed "s#${TIMEOUT_LINE}#timeout=5#" | sed "s#${APPEND_LINE}#append= \"root=live:CDLABEL=$vlmid ks=cdrom:/$kscfg \"#" > isocfgtmp
+	mv -f isocfgtmp $WORKING_ISO
+	cd $custom_iso_dir
+	mkisofs -R -V "$vlmid" -sysid PPC -chrp-boot -U -prep-boot ppc/chrp/yaboot -hfs-bless ppc/mac -no-desktop -allow-multidot -volset 4 -volset-size 1 -volset-seqno 1 -hfs-volid 4 -o $cwd/$custom_iso .
+else
+	echo "- copy kickstart to custom work directory"
+	cp $kscfg $custom_iso_dir
+
+	echo "- edit isolinux.cfg and add kickstart entry"
+	WORKING_ISO="${custom_iso_dir}/isolinux/isolinux.cfg"
+
+	echo "label custom_ks
+	  kernel vmlinuz $kernel_args
+	  append initrd=initrd.img ks=cdrom:/$kscfg ramdisk_size=20000" >> $WORKING_ISO
+
+	# change default boot target and timeout
+	DEFAULT_LINE=`cat $WORKING_ISO | grep default | head -1`
+	TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
+
+	cat $WORKING_ISO | sed "s/${DEFAULT_LINE}/default custom_ks/" | sed "s/${TIMEOUT_LINE}/timeout 5/" > isocfgtmp
+
+	mv -f isocfgtmp $WORKING_ISO
+
+	# cd to custom_iso_dir, otherwise mkisofs seems to bomb...
+	cd $custom_iso_dir
+	mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o $cwd/$custom_iso .
+fi
 EXITVAL=$?
 if [ $EXITVAL -ne '0' ] ; then
     echo -e "\n mkisofs exited with $EXITVAL!"
--
-- libvir-list mailing list libvir-list redhat com https://www.redhat.com/mailman/listinfo/libvir-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]