print_info 1 'udev: >> Compiling...'
ln -snf "${KERNEL_DIR}" klibc/linux ||
gen_die "Could not link to ${KERNEL_DIR}"
- compile_generic 'USE_KLIBC=true USE_LOG=false DEBUG=false udevdir=/dev all etc/udev/udev.conf' utils
+ compile_generic "KERNEL_DIR=$KERNEL_DIR USE_KLIBC=true USE_LOG=false DEBUG=false udevdir=/dev all etc/udev/udev.conf" utils
strip udev || gen_die 'Failed to strip the udev binary!'
print_info 1 ' >> Installing...'
- install -d "${TEMP}/udev/etc/udev" "${TEMP}/udev/sbin" ||
+ install -d "${TEMP}/udev/etc/udev" "${TEMP}/udev/sbin" "${TEMP}/udev/etc/udev/scripts" "${TEMP}/udev/etc/udev/rules.d" "${TEMP}/udev/etc/udev/permissions.d" ||
gen_die 'Could not create directory hierarchy'
install -m 0755 udev "${TEMP}/udev/sbin" ||
- gen_die 'Could not install udev binary'
- install -m 0644 etc/udev/udev.conf "etc/udev/udev.rules" \
- "etc/udev/udev.permissions" "${TEMP}/udev/etc/udev" ||
- gen_die 'Could not install udev configuration'
+ gen_die 'Could not install udev binary!'
+ install -m 0644 etc/udev/udev.conf "${TEMP}/udev/etc/udev" ||
+ gen_die 'Could not install udev configuration!'
+ install -m 0644 etc/udev/udev.rules.gentoo "${TEMP}/udev/etc/udev/rules.d/50-udev.rules" ||
+ gen_die 'Could not install udev rules!'
+ install -m 0644 etc/udev/udev.permissions "${TEMP}/udev/etc/udev/permissions.d/50-udev.permissions" ||
+ gen_die 'Could not install udev permissions!'
+ install -m 0755 extras/ide-devfs.sh "${TEMP}/udev/etc/udev/scripts" ||
+ gen_die 'Could not install udev scripts!'
cd "${TEMP}/udev"
print_info 1 ' >> Copying to bincache...'
fi
}
-if [ "${DO_keymap}" ]
-then
- chooseKeymap
-fi
+[ "${DO_keymap}" ] && chooseKeymap
+echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting filesystems${NORMAL}"
-echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting filesystems...${NORMAL}"
+# Check udev is on...
+[ "${KMAJOR}" -ge 2 ] && USE_UDEV_SUPPORT=1
+[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -ge '6' ] && USE_UDEV_SUPPORT=1
+[ "${USE_UDEV_SUPPORT}" -eq '1' -a -f /sbin/udev -a "${USE_UDEV_NORMAL}" -ne 0 ] && USE_UDEV_NORMAL=1
+
+# Disable udev support if /dev is already mounted as devfs
+[ -e /dev/.devfsd ] && USE_UDEV_NORMAL=0
+
+# If using 2.4 and udev; back off...
+[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -lt '6' -a "${USE_UDEV_NORMAL}" -eq 1 ] &&
+ USE_UDEV_NORMAL=0
mkdir /newroot
if [ "${CDROOT}" -eq '1' ]
then
mount -t tmpfs tmpfs /newroot
- mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo
- [ ! -e /newroot/dev/.devfsd ] && mount -t devfs devfs /newroot/dev
- devfsd /newroot/dev -np
- sleep 1
+ mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo /newroot/sys
+ if [ "${USE_UDEV_NORMAL}" -eq '1' ]
+ then
+ # Udev is semi-broken on non /sys sysfs mount points.
+ mount -t sysfs sys /sys 2> /dev/null
+ mount -t sysfs sys /newroot/sys 2> /dev/null
+ [ "$?" -eq '0' ] || USE_UDEV_NORMAL=0
+ fi
- findcdmount /newroot/dev/cdroms/*
- # not in /dev/cdroms try /dev/ide/cd
- if [ "${REAL_ROOT}" = '' ]
+ if [ "${USE_UDEV_NORMAL}" -eq '1' ]
then
- findcdmount /newroot/dev/ide/cd/*
+ cd /sys
+ runUdev
+ mv /dev/* /newroot/dev
+ else
+ if [ ! -e /newroot/dev/.devfsd ]
+ then
+ mount -t devfs devfs /newroot/dev
+ devfsd /newroot/dev -np
+ sleep 1
+ fi
fi
+ findcdmount /newroot/dev/cdroms/*
+
+ # Not in /dev/cdroms: try /dev/ide/cd
+ [ "${REAL_ROOT}" = '' ] && findcdmount /newroot/dev/ide/cd/*
if [ "${REAL_ROOT}" = '' ]
then
- exec /bin/ash
+ # Undo stuff
+ umount /newroot/dev 2>/dev/null
+ umount /newroot/sys 2>/dev/null
+ umount /sys 2>/dev/null
- # Undo stuff
- # kill_devfsd # We run devfsd with -np now
- sleep 1
- umount /newroot/dev/
- sleep 1
umount /newroot
- # shouldn't be anything in here b/c it was on tmpfs
rm -rf /newroot/*
+
+ echo 'Could not find CD to boot, something else needed!'
CDROOT=0
- echo "Could not find CD to boot, gonna need something else"
fi
fi
-# Check udev is on...
-[ "${KMAJOR}" -ge 2 ] && USE_UDEV_SUPPORT=1
-[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -ge '6' ] && USE_UDEV_SUPPORT=1
-[ "${USE_UDEV_SUPPORT}" -eq '1' -a -f /sbin/udev -a "${USE_UDEV_NORMAL}" -ne 0 ] && USE_UDEV_NORMAL=1
-
-# Disable udev support if /dev is already mounted as devfs
-[ -e /dev/.devfsd ] && USE_UDEV_NORMAL=0
-
-# If using 2.4 and udev; back off...
-[ "${KMAJOR}" -eq 2 -a "${KMINOR}" -lt '6' -a "${USE_UDEV_NORMAL}" -eq 1 ] &&
- USE_UDEV_NORMAL=0
-
# Try to mount sysfs, and if it fails, do not use udev
if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ]
then
mount -t sysfs sys /sys 2> /dev/null
- [ "$?" -eq "0" ] || USE_UDEV_NORMAL=0
+ [ "$?" -eq '0' ] || USE_UDEV_NORMAL=0
fi
-# Don't do else b/c we set CDROOT=0 if it fails to detect
+# Don't merge these two blocks; ^^ USE_UDEV_NORMAL=0...
if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ]
then
USE_DEVFS_NORMAL=0
- export ACTION=add
- export UDEV_NO_SLEEP=1
-
- # Add block devices and their partitions to /dev,
- # using information from /sys, and only those
- # devices (since other are not needed for boot).
-
cd /sys
- for x in block/*
- do
- export DEVPATH="/${x}"
- /sbin/udev block
-
- for y in ${x}/*
- do
- if [ -f "${y}/dev" ]
- then
- export DEVPATH="/${y}"
- /sbin/udev block
- fi
- done
- done
- cd /
-
- unset -v ACTION DEVPATH UDEV_NO_SLEEP
+ runUdev
elif [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ]
then
[ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev
break
else
echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting root...${NORMAL}"
-
mount -o rw ${REAL_ROOT} /newroot
+
if [ "$?" = '0' ]
then
break
umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!'
mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!'
rm /tmp/.initrd/dev -rf || '*: Failed to remove the initrd /dev!'
-elif [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ]
+elif [ "${USE_UDEV_NORMAL}" -eq '1' ]
then
umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!'
umount /tmp/.initrd/sys || echo '*: Failed to unmount the initrd /sys!'
elif [ "${CDROOT}" -eq '1' ]
then
- # If automount at boot was on with devfs, we'll want to umount it
- # also umount proc
- mount -t proc proc /proc
- umount /tmp/.initrd/proc > /dev/null 2>&1 || echo "*: Failed to unmount /tmp/.initrd/proc!"
+ umount /tmp/.initrd/proc || echo "*: Failed to unmount the initrd /proc!"
umount /dev > /dev/null 2>&1
mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!'
rm /tmp/.initrd/dev -rf || '*: Failed to remove the initrd /dev!'
- umount /proc > /dev/null 2>&1
fi
echo -n '.'