From 2b5cd0819fdf0d3f408f3e9d72060b90f4320c38 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 28 Sep 2006 04:36:34 +0000 Subject: Broke out boot-device locator for usb and cd booting seperatly. git-svn-id: http://phraktured.net/archiso@14 00a9fe69-e71b-0410-bb23-df0e5024db41 --- archiso-mkinitcpio.conf | 4 ++- archiso_hook | 51 +++++++++++++++++++++++++++++++++++++ archiso_install | 10 ++++++++ archlive_hook | 68 ------------------------------------------------- archlive_install | 11 -------- boot-cd_hook | 30 ++++++++++++++++++++++ boot-cd_install | 8 ++++++ boot-usb_hook | 30 ++++++++++++++++++++++ boot-usb_install | 15 +++++++++++ 9 files changed, 147 insertions(+), 80 deletions(-) create mode 100644 archiso_hook create mode 100644 archiso_install delete mode 100644 archlive_hook delete mode 100644 archlive_install create mode 100644 boot-cd_hook create mode 100644 boot-cd_install create mode 100644 boot-usb_hook create mode 100644 boot-usb_install diff --git a/archiso-mkinitcpio.conf b/archiso-mkinitcpio.conf index d9bcc88..55ae9f3 100644 --- a/archiso-mkinitcpio.conf +++ b/archiso-mkinitcpio.conf @@ -3,4 +3,6 @@ MODULES="" BINARIES="" FILES="" -HOOKS="base udev archlive ide scsi sata usb fw filesystems" + +HOOKS="base udev boot-cd archiso ide scsi sata usb fw filesystems" +#HOOKS="base udev boot-usb archiso ide scsi sata usb fw filesystems" diff --git a/archiso_hook b/archiso_hook new file mode 100644 index 0000000..c60df2b --- /dev/null +++ b/archiso_hook @@ -0,0 +1,51 @@ +# vim: set ft=sh: +run_hook () +{ + if [ "x${ramdisk_size}" = "x" ]; then + ramdisk_size="75%" + fi + msg -n ":: Mounting tmpfs, size=${ramdisk_size}..." + mount -t tmpfs -o "size=${ramdisk_size}" tmpfs /tmpfs + mkdir /tmpfs/bootcd + msg "done." + + if [ "x${BOOT_MOUNT}" -eq "x" ]; then + echo "ERROR: BOOT_MOUNT is not set. The boot-cd or boot-usb hook MUST" + echo " be run before this one. This image was improperly built" + exit 1 + fi + + squashimg="${BOOT_MOUNT}/archiso.sqfs" + if [ "${copytoram}" = "y" ]; then + /bin/cat ${squashimg} > /tmpfs/archiso.sqfs + squashimg="/tmpfs/archiso.sqfs" + fi + + msg ":: Mounting squashfs image" + /bin/modprobe -q squashfs >/dev/null 2>&1 + /bin/mkdir -p /tmpfs/squashfs_root + if ! /bin/losetup /dev/loop0 "${squashimg}" >/dev/null 2>&1; then + echo "ERROR: Cannot mount loop device /dev/loop0...aborting" + exit 1 + fi + + /bin/mount -r -t squashfs /dev/loop0 /tmpfs/squashfs_root + + msg ":: Mounting root (union) filesystem" + /bin/modprobe -q unionfs >/dev/null 2>&1 + /bin/mount -t unionfs -o dirs=/tmpfs=rw:/tmpfs/squashfs_root=ro none /real_root + + if [ -d /proc/sys/dev/cdrom ]; then + echo 0 > /proc/sys/dev/cdrom/lock + echo 1 > /proc/sys/dev/cdrom/autoeject + fi + + udevpid=$(/bin/minips -C udevd -o pid=) + [ "x${udevpid}" != "x" ] && /bin/kill -9 $udevpid 2>&1 >/dev/null + #Yep, we're bailing out here. We don't need kinit. + msg ":: Passing control to Archlinux Initscripts...Please Wait" + /bin/umount /sys + /bin/umount /proc + /bin/umount /dev + exec /bin/run-init -c /dev/console /real_root /sbin/init ${CMDLINE} +} diff --git a/archiso_install b/archiso_install new file mode 100644 index 0000000..d75a57e --- /dev/null +++ b/archiso_install @@ -0,0 +1,10 @@ +# vim: set ft=sh: +install () +{ + MODULES="cdrom ide-cd ide-core ide-generic unionfs squashfs isofs $(all_modules '/kernel/fs' | grep -v "nls") " + BINARIES="" + FILES="" + add_dir /real_root + add_dir /tmpfs + SCRIPT="archlive" +} diff --git a/archlive_hook b/archlive_hook deleted file mode 100644 index 0b3ea1b..0000000 --- a/archlive_hook +++ /dev/null @@ -1,68 +0,0 @@ -# vim: set ft=sh: -run_hook () -{ - if [ "x${ramdisk_size}" = "x" ]; then - ramdisk_size="75%" - fi - msg -n ":: Mounting tmpfs, size=${ramdisk_size}..." - mount -t tmpfs -o "size=${ramdisk_size}" tmpfs /tmpfs - mkdir /tmpfs/bootcd - msg "done." - - squashfound=0 - #TODO check for usb devices as well... - msg -n ":: Scanning for boot cdrom device..." - squashimg="/tmpfs/bootcd/archlive.sqfs" - - /bin/modprobe -q isofs >/dev/null 2>&1 - for cdrom in /dev/cd/*; do - if mount -r -t iso9660 "${cdrom}" /tmpfs/bootcd >/dev/null 2>&1; then - if [ -e "${squashimg}" ]; then - squashfound=1 - msg "${cdrom}" - break - fi - else - echo "Failed to mount ${cdrom}" - fi - [ ${squashfound} -eq 0 ] && umount /tmpfs/bootcd >/dev/null 2>&1 - done - - if [ ${squashfound} -eq 0 ]; then - echo "ERROR: cannot find booted cdrom device, cannot continue..." - exit 1 - fi - - if [ "${copytoram}" = "y" ]; then - /bin/cat /tmpfs/bootcd/archlive.sqfs > /tmpfs/archlive.sqfs - squashimg="/tmpfs/archlive.sqfs" - fi - - msg ":: Mounting squashfs image" - /bin/modprobe -q squashfs >/dev/null 2>&1 - /bin/mkdir -p /tmpfs/squashfs_root - if ! /bin/losetup /dev/loop0 "${squashimg}" >/dev/null 2>&1; then - echo "ERROR: Cannot mount loop device /dev/loop0...aborting" - exit 1 - fi - - /bin/mount -r -t squashfs /dev/loop0 /tmpfs/squashfs_root - - msg ":: Mounting root (union) filesystem" - /bin/modprobe -q unionfs >/dev/null 2>&1 - /bin/mount -t unionfs -o dirs=/tmpfs=rw:/tmpfs/squashfs_root=ro none /real_root - - if [ -d /proc/sys/dev/cdrom ]; then - echo 0 > /proc/sys/dev/cdrom/lock - echo 1 > /proc/sys/dev/cdrom/autoeject - fi - - udevpid=$(/bin/minips -C udevd -o pid=) - [ "x${udevpid}" != "x" ] && /bin/kill -9 $udevpid 2>&1 >/dev/null - #Yep, we're bailing out here. We don't need kinit. - msg ":: Passing control to Archlinux Initscripts...Please Wait" - /bin/umount /sys - /bin/umount /proc - /bin/umount /dev - exec /bin/run-init -c /dev/console /real_root /sbin/init ${CMDLINE} -} diff --git a/archlive_install b/archlive_install deleted file mode 100644 index bdb5857..0000000 --- a/archlive_install +++ /dev/null @@ -1,11 +0,0 @@ -# vim: set ft=sh: -install () -{ - MODULES="cdrom ide-cd ide-core ide-generic unionfs squashfs isofs $(all_modules '/kernel/fs' | grep -v "nls") " - BINARIES="" - FILES="" - add_binary /bin/mount /bin/mount.full - add_dir /real_root - add_dir /tmpfs - SCRIPT="archlive" -} diff --git a/boot-cd_hook b/boot-cd_hook new file mode 100644 index 0000000..d6d9da6 --- /dev/null +++ b/boot-cd_hook @@ -0,0 +1,30 @@ +# vim: set ft=sh: +run_hook () +{ + msg ":: Scanning for boot cdrom device..." + + /bin/mkdir -p /tmpfs/bootmnt + bootmnt="/tmpfs/bootmnt/" + found=0 + + /bin/modprobe -q isofs >/dev/null 2>&1 + for cdrom in /dev/cd/*; do + if mount -r -t iso9660 "${cdrom}" ${bootmnt} >/dev/null 2>&1; then + if [ -e "${bootmnt}/archiso.sqfs" ]; then + found=1 + msg "${cdrom}" + break + fi + else + echo "Failed to mount ${cdrom}" + fi + [ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1 + done + + if [ ${found} -eq 0 ]; then + echo "ERROR: cannot find booted cdrom device, cannot continue..." + exit 1 + else + export BOOT_MOUNT="${bootmnt}" + fi +} diff --git a/boot-cd_install b/boot-cd_install new file mode 100644 index 0000000..b7e82ae --- /dev/null +++ b/boot-cd_install @@ -0,0 +1,8 @@ +# vim: set ft=sh: +install () +{ + MODULES="cdrom ide-cd ide-core ide-generic unionfs squashfs isofs $(all_modules '/kernel/fs' | grep -v "nls") " + BINARIES="" + FILES="" + SCRIPT="from-cd" +} diff --git a/boot-usb_hook b/boot-usb_hook new file mode 100644 index 0000000..9898ff6 --- /dev/null +++ b/boot-usb_hook @@ -0,0 +1,30 @@ +# vim: set ft=sh: +run_hook () +{ + msg ":: Scanning for boot usb device..." + + /bin/mkdir -p /tmpfs/bootmnt + bootmnt="/tmpfs/bootmnt/" + found=0 + + 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}/archiso.sqfs" ]; then + found=1 + msg "${usb}" + break + fi + else + echo "Failed to mount ${usb}" + fi + [ ${found} -eq 0 ] && umount ${bootmnt} >/dev/null 2>&1 + done + + if [ ${found} -eq 0 ]; then + echo "ERROR: cannot find booted usb device, cannot continue..." + exit 1 + else + export BOOT_MOUNT="${bootmnt}" + fi +} diff --git a/boot-usb_install b/boot-usb_install new file mode 100644 index 0000000..a1296f9 --- /dev/null +++ b/boot-usb_install @@ -0,0 +1,15 @@ +# vim: set ft=sh: +install () +{ + MODULES="cdrom ide-cd ide-core ide-generic unionfs squashfs $(all_modules '/kernel/fs' | grep -v "nls") " + + MODULES="${MODULES} $(checked_modules "/usb/host" | grep -ve "_cs" -e "sl1811-hcd" -e "isp116x-hcd")" + + MODULES=$(echo ${MODULES}) #trim whitespace + if [ "x${MODULES}" != "x" ]; then + MODULES="${MODULES} usb_storage sd_mod sr_mod" + fi + BINARIES="" + FILES="" + SCRIPT="boot-usb" +} -- cgit v1.2.3-70-g09d2