Cleanup archiso hook
Fix squashfs mounting of all isomounts images, along with a few other changes Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
parent
978fdafbff
commit
f1c46e0d3f
@ -6,17 +6,27 @@ _mnt_bind()
|
|||||||
/bin/mount -o bind ${1} /real_root${2}
|
/bin/mount -o bind ${1} /real_root${2}
|
||||||
}
|
}
|
||||||
|
|
||||||
# args: image file
|
# args: /path/to/image_file
|
||||||
_mnt_squashfs()
|
_mnt_squashfs()
|
||||||
{
|
{
|
||||||
msg "::: Adding new union branch: ${1}"
|
|
||||||
/bin/modprobe -q loop >/dev/null 2>&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}"
|
mkdir -p "/tmpfs/mnt/loop${LOOP_NUM}"
|
||||||
# sometimes it takes udev a while to create device nodes
|
# 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
|
sleep 1
|
||||||
done
|
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}"
|
echo "ERROR: Cannot mount loop device /dev/loop${LOOP_NUM}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -46,14 +56,13 @@ run_hook ()
|
|||||||
msg ":: Scanning for boot device..."
|
msg ":: Scanning for boot device..."
|
||||||
|
|
||||||
/bin/mkdir -p /bootmnt
|
/bin/mkdir -p /bootmnt
|
||||||
bootmnt="/bootmnt"
|
|
||||||
found=0
|
found=0
|
||||||
|
|
||||||
/bin/modprobe -q isofs >/dev/null 2>&1
|
/bin/modprobe -q isofs >/dev/null 2>&1
|
||||||
msg ":: Scanning cd drives..."
|
msg ":: Scanning cd drives..."
|
||||||
for cdrom in /dev/hd[a-z] /dev/sr[0-9]* /dev/scd[a-z] /dev/sg[0-9]*; do
|
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 mount -r -t iso9660 "${cdrom}" /bootmnt >/dev/null 2>&1; then
|
||||||
if [ -e "${bootmnt}/isomounts" ]; then
|
if [ -e "/bootmnt/isomounts" ]; then
|
||||||
found=1
|
found=1
|
||||||
msg "${cdrom}"
|
msg "${cdrom}"
|
||||||
break
|
break
|
||||||
@ -61,15 +70,15 @@ run_hook ()
|
|||||||
else
|
else
|
||||||
echo "Failed to mount ${cdrom}"
|
echo "Failed to mount ${cdrom}"
|
||||||
fi
|
fi
|
||||||
[ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1
|
[ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${found} -eq 0 ]; then
|
if [ ${found} -eq 0 ]; then
|
||||||
msg ":: Scanning usb drives..."
|
msg ":: Scanning usb drives..."
|
||||||
for usb in /dev/sd[a-z][0-9]; do
|
for usb in /dev/sd[a-z][0-9]; do
|
||||||
if mount -r -t vfat "${usb}" ${bootmnt} >/dev/null 2>&1 ||\
|
if mount -r -t vfat "${usb}" /bootmnt >/dev/null 2>&1 ||\
|
||||||
mount -r -t ext2 "${usb}" ${bootmnt} >/dev/null 2>&1; then
|
mount -r -t ext2 "${usb}" /bootmnt >/dev/null 2>&1; then
|
||||||
if [ -e "${bootmnt}/isomounts" ]; then
|
if [ -e "/bootmnt/isomounts" ]; then
|
||||||
found=1
|
found=1
|
||||||
msg "${usb}"
|
msg "${usb}"
|
||||||
break
|
break
|
||||||
@ -77,7 +86,7 @@ run_hook ()
|
|||||||
else
|
else
|
||||||
echo "Failed to mount ${usb}"
|
echo "Failed to mount ${usb}"
|
||||||
fi
|
fi
|
||||||
[ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1
|
[ ${found} -eq 0 ] && umount /bootmnt >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -88,21 +97,13 @@ run_hook ()
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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 squashfs >/dev/null 2>&1
|
||||||
|
/bin/modprobe -q unionfs >/dev/null 2>&1
|
||||||
|
|
||||||
msg ":: Mounting root (union) filesystem"
|
msg ":: Mounting root (union) filesystem"
|
||||||
/bin/modprobe -q unionfs >/dev/null 2>&1
|
|
||||||
/bin/mount -t unionfs -o dirs=/tmpfs=rw none /real_root
|
/bin/mount -t unionfs -o dirs=/tmpfs=rw none /real_root
|
||||||
|
|
||||||
export LOOP_NUM="0"
|
export LOOP_NUM="0"
|
||||||
if [ -e "/isomounts" ]; then
|
|
||||||
msg ":: Mounting images"
|
msg ":: Mounting images"
|
||||||
while read img imgarch mountpoint type; do
|
while read img imgarch mountpoint type; do
|
||||||
# check if this line is a comment (starts with #)
|
# check if this line is a comment (starts with #)
|
||||||
@ -110,18 +111,17 @@ run_hook ()
|
|||||||
|
|
||||||
[ "$imgarch" != "$arch" ] && continue
|
[ "$imgarch" != "$arch" ] && continue
|
||||||
|
|
||||||
if [ "${type}" = "bind" ]; then
|
[ ! -f "/bootmnt/${img}" ] && continue
|
||||||
_mnt_bind ${img} ${mountpoint}
|
|
||||||
elif [ "${type}" = "squashfs" ]; then
|
|
||||||
_mnt_squashfs "${img}"
|
|
||||||
fi
|
|
||||||
done < /isomounts
|
|
||||||
else
|
|
||||||
msg ":: No mountable images found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# layer the "pristine" base system image last
|
if [ "${type}" = "bind" ]; then
|
||||||
_mnt_squashfs ${base_img}
|
_mnt_bind "/bootmnt/${img}" ${mountpoint}
|
||||||
|
elif [ "${type}" = "squashfs" ]; then
|
||||||
|
_mnt_squashfs "/bootmnt/${img}"
|
||||||
|
fi
|
||||||
|
done < "/bootmnt/isomounts"
|
||||||
|
|
||||||
|
# Bind our bootmnt dir into the live system
|
||||||
|
_mnt_bind /bootmnt bootmnt
|
||||||
|
|
||||||
if [ -d /proc/sys/dev/cdrom ]; then
|
if [ -d /proc/sys/dev/cdrom ]; then
|
||||||
echo 0 > /proc/sys/dev/cdrom/lock
|
echo 0 > /proc/sys/dev/cdrom/lock
|
||||||
|
Loading…
Reference in New Issue
Block a user