Alan Pevec
2008-Apr-17 22:11 UTC
[Ovirt-devel] [PATCH] misc-scripts/mount-livecd.sh - rebuild livecd iso for quick testing
rebuild livecd iso for quick testing adds setup-rw and rebuild options to mount-livecd.sh for quick&dirty modifications of LiveCD iso inst diff --git a/misc-scripts/mount-livecd.sh b/misc-scripts/mount-livecd.sh index 9fb2be9..b8ca5f4 100755 --- a/misc-scripts/mount-livecd.sh +++ b/misc-scripts/mount-livecd.sh @@ -1,10 +1,59 @@ #!/bin/bash +tmp=/tmp/livecd +squash=$tmp/squash +iso=$tmp/iso +initrd0=$tmp/initrd0 + setup() { + if grep -q /mnt/livecd-tmp /proc/mounts + then + echo "Already mounted, run $0 teardown" + exit 1 + fi mkdir -p /mnt/livecd-tmp /mnt/livecd-tmp2 /mnt/livecd-tmp3 mount -o loop $1 /mnt/livecd-tmp mount -o loop /mnt/livecd-tmp/LiveOS/squashfs.img /mnt/livecd-tmp2 +} + +setup_ro() { + setup $1 mount -o loop /mnt/livecd-tmp2/LiveOS/ext3fs.img /mnt/livecd-tmp3 + echo "Read-only LiveCD rootfs at /mnt/livecd-tmp3" +} + +setup_rw() { + setup $1 + rm -rf $tmp + mkdir -p $squash/LiveOS $iso/LiveOS $iso/isolinux $initrd0 + cp -v --sparse=always /mnt/livecd-tmp2/LiveOS/ext3fs.img \ + $squash/LiveOS/ext3fs.img + mount -o loop $squash/LiveOS/ext3fs.img /mnt/livecd-tmp3 + cd $initrd0 + pax -zrf /mnt/livecd-tmp/isolinux/initrd0.img + cd /mnt/livecd-tmp/isolinux/ + cp isolinux.* *c32 vmlinuz0 $iso/isolinux/ + echo "Writable LiveCD rootfs at /mnt/livecd-tmp3" + echo " initramfs at $initrd0" + echo " isolinux at $iso/isolinux" +} + +rebuild() { + if [ ! -d $tmp ] + then + echo "Run $0 setup-rw" + exit 1 + fi + umount /mnt/livecd-tmp3 + mksquashfs $squash $iso/LiveOS/squashfs.img + pushd $initrd0 + pax -wzx sv4cpio -f $iso/isolinux/initrd0.img * + popd + cdlabel=$(/lib/udev/vol_id -l $1) + # from imgcreate/live.py + mkisofs -J -r -hide-rr-moved -hide-joliet-trans-tbl -V $cdlabel -o $1 \ + -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \ + -boot-info-table -boot-load-size 4 $iso } teardown() { @@ -12,10 +61,11 @@ teardown() { umount /mnt/livecd-tmp2 umount /mnt/livecd-tmp rmdir /mnt/livecd-tmp* + rm -rf $tmp } usage() { - echo "Usage: mount-livecd <setup|teardown> <iso>" + echo "Usage: mount-livecd <setup|setup-rw|rebuild|teardown> <iso>" } if [ $# -ne 2 ]; then @@ -25,7 +75,13 @@ fi case "$1" in setup) - setup $2 + setup_ro $2 + ;; + setup-rw) + setup_rw $2 + ;; + rebuild) + rebuild $2 ;; teardown) teardown