From f1c46e0d3f8bda4cf3e00ba0492579dc3312fd62 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 23 Dec 2008 00:51:20 -0600 Subject: Cleanup archiso hook Fix squashfs mounting of all isomounts images, along with a few other changes Signed-off-by: Aaron Griffin --- archiso/hooks/archiso | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index 46ed43f..fdbd514 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -6,17 +6,27 @@ _mnt_bind() /bin/mount -o bind ${1} /real_root${2} } -# args: image file +# args: /path/to/image_file _mnt_squashfs() { - msg "::: Adding new union branch: ${1}" /bin/modprobe -q loop >/dev/null 2>&1 + + img="${1}" + base_img="${img##*/}"; + + if [ "${copytoram}" = "y" ]; then + msg ":: Copying squashfs image to RAM" + /bin/cat ${img} > "/tmpfs/${base_img}" + img="/tmpfs/${base_img}" + fi + + msg "::: Adding new union branch: ${base_img%.*}" mkdir -p "/tmpfs/mnt/loop${LOOP_NUM}" # sometimes it takes udev a while to create device nodes - until [ -e "/dev/loop${LOOP_NUM}" ]; do + while [ ! -e "/dev/loop${LOOP_NUM}" ]; do sleep 1 done - if ! /bin/losetup "/dev/loop${LOOP_NUM}" ${1}; then + if ! /bin/losetup "/dev/loop${LOOP_NUM}" ${img}; then echo "ERROR: Cannot mount loop device /dev/loop${LOOP_NUM}" break fi @@ -46,14 +56,13 @@ run_hook () msg ":: Scanning for boot device..." /bin/mkdir -p /bootmnt - bootmnt="/bootmnt" found=0 /bin/modprobe -q isofs >/dev/null 2>&1 msg ":: Scanning cd drives..." for cdrom in /dev/hd[a-z] /dev/sr[0-9]* /dev/scd[a-z] /dev/sg[0-9]*; do - if mount -r -t iso9660 "${cdrom}" ${bootmnt} >/dev/null 2>&1; then - if [ -e "${bootmnt}/isomounts" ]; then + if mount -r -t iso9660 "${cdrom}" /bootmnt >/dev/null 2>&1; then + if [ -e "/bootmnt/isomounts" ]; then found=1 msg "${cdrom}" break @@ -61,15 +70,15 @@ run_hook () else echo "Failed to mount ${cdrom}" fi - [ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1 + [ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1 done if [ ${found} -eq 0 ]; then msg ":: Scanning usb drives..." for usb in /dev/sd[a-z][0-9]; do - if mount -r -t vfat "${usb}" ${bootmnt} >/dev/null 2>&1 ||\ - mount -r -t ext2 "${usb}" ${bootmnt} >/dev/null 2>&1; then - if [ -e "${bootmnt}/isomounts" ]; then + if mount -r -t vfat "${usb}" /bootmnt >/dev/null 2>&1 ||\ + mount -r -t ext2 "${usb}" /bootmnt >/dev/null 2>&1; then + if [ -e "/bootmnt/isomounts" ]; then found=1 msg "${usb}" break @@ -77,7 +86,7 @@ run_hook () else echo "Failed to mount ${usb}" fi - [ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1 + [ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1 done fi @@ -88,40 +97,31 @@ run_hook () exit 1 fi - base_img="${bootmnt}/root-image.sqfs" - if [ "${copytoram}" = "y" ]; then - msg ":: Copying squashfs image to RAM" - /bin/cat ${base_img} > /tmpfs/root-image.sqfs - base_img="/tmpfs/root-image.sqfs" - fi - /bin/modprobe -q squashfs >/dev/null 2>&1 + /bin/modprobe -q unionfs >/dev/null 2>&1 msg ":: Mounting root (union) filesystem" - /bin/modprobe -q unionfs >/dev/null 2>&1 /bin/mount -t unionfs -o dirs=/tmpfs=rw none /real_root export LOOP_NUM="0" - if [ -e "/isomounts" ]; then - msg ":: Mounting images" - while read img imgarch mountpoint type; do - # check if this line is a comment (starts with #) - [ "${img#"#"}" != "${img}" ] && continue - - [ "$imgarch" != "$arch" ] && continue - - if [ "${type}" = "bind" ]; then - _mnt_bind ${img} ${mountpoint} - elif [ "${type}" = "squashfs" ]; then - _mnt_squashfs "${img}" - fi - done < /isomounts - else - msg ":: No mountable images found" - fi + msg ":: Mounting images" + while read img imgarch mountpoint type; do + # check if this line is a comment (starts with #) + [ "${img#"#"}" != "${img}" ] && continue + + [ "$imgarch" != "$arch" ] && continue + + [ ! -f "/bootmnt/${img}" ] && continue + + if [ "${type}" = "bind" ]; then + _mnt_bind "/bootmnt/${img}" ${mountpoint} + elif [ "${type}" = "squashfs" ]; then + _mnt_squashfs "/bootmnt/${img}" + fi + done < "/bootmnt/isomounts" - # layer the "pristine" base system image last - _mnt_squashfs ${base_img} + # Bind our bootmnt dir into the live system + _mnt_bind /bootmnt bootmnt if [ -d /proc/sys/dev/cdrom ]; then echo 0 > /proc/sys/dev/cdrom/lock -- cgit v1.2.3-54-g00ecf