Added LiveCD udev support.

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@126 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Tim Yamin 21 years ago
parent f0d73f2dae
commit 85917d6f04

@ -238,7 +238,7 @@ parse_cmdline() {
print_info 2 "CMD_NOINITRDMODULES: $CMD_NOINITRDMODULES" print_info 2 "CMD_NOINITRDMODULES: $CMD_NOINITRDMODULES"
;; ;;
--udev) --udev)
CMD_UDEV=0 CMD_UDEV=1
print_info 2 "CMD_UDEV: $CMD_UDEV" print_info 2 "CMD_UDEV: $CMD_UDEV"
;; ;;
--callback*) --callback*)

@ -482,17 +482,22 @@ compile_udev() {
print_info 1 'udev: >> Compiling...' print_info 1 'udev: >> Compiling...'
ln -snf "${KERNEL_DIR}" klibc/linux || ln -snf "${KERNEL_DIR}" klibc/linux ||
gen_die "Could not link to ${KERNEL_DIR}" 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!' strip udev || gen_die 'Failed to strip the udev binary!'
print_info 1 ' >> Installing...' 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' gen_die 'Could not create directory hierarchy'
install -m 0755 udev "${TEMP}/udev/sbin" || install -m 0755 udev "${TEMP}/udev/sbin" ||
gen_die 'Could not install udev binary' gen_die 'Could not install udev binary!'
install -m 0644 etc/udev/udev.conf "etc/udev/udev.rules" \ install -m 0644 etc/udev/udev.conf "${TEMP}/udev/etc/udev" ||
"etc/udev/udev.permissions" "${TEMP}/udev/etc/udev" || gen_die 'Could not install udev configuration!'
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" cd "${TEMP}/udev"
print_info 1 ' >> Copying to bincache...' print_info 1 ' >> Copying to bincache...'

@ -190,4 +190,11 @@ determine_real_args() {
else else
OLDCONFIG=0 OLDCONFIG=0
fi fi
if isTrue "${CMD_UDEV}"
then
UDEV=1
else
UDEV=0
fi
} }

@ -80,7 +80,7 @@ create_base_initrd_sys() {
bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd" bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
chmod +x "${TEMP}/initrd-temp/bin/devfsd" chmod +x "${TEMP}/initrd-temp/bin/devfsd"
[ "${CMD_UDEV}" ] && { tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initrd-temp" || [ "${UDEV}" -eq '1' ] && { tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initrd-temp" ||
gen_die "Could not extract udev binary cache!"; } gen_die "Could not extract udev binary cache!"; }
# We make our own devfsd.conf these days, the default one doesn't work with the stripped # We make our own devfsd.conf these days, the default one doesn't work with the stripped

@ -50,3 +50,30 @@ findcdmount() {
kill_devfsd() { kill_devfsd() {
killall devfsd > /dev/null 2>&1 killall devfsd > /dev/null 2>&1
} }
runUdev() {
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).
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
}

@ -106,94 +106,80 @@ chooseKeymap() {
fi fi
} }
if [ "${DO_keymap}" ] [ "${DO_keymap}" ] && chooseKeymap
then echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting filesystems${NORMAL}"
chooseKeymap
fi
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 mkdir /newroot
if [ "${CDROOT}" -eq '1' ] if [ "${CDROOT}" -eq '1' ]
then then
mount -t tmpfs tmpfs /newroot mount -t tmpfs tmpfs /newroot
mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo mkdir /newroot/dev /newroot/mnt /newroot/mnt/cdrom /newroot/mnt/livecd /newroot/tmp /newroot/tmp/.initrd /newroot/mnt/gentoo /newroot/sys
[ ! -e /newroot/dev/.devfsd ] && mount -t devfs devfs /newroot/dev if [ "${USE_UDEV_NORMAL}" -eq '1' ]
devfsd /newroot/dev -np then
sleep 1 # 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/* if [ "${USE_UDEV_NORMAL}" -eq '1' ]
# not in /dev/cdroms try /dev/ide/cd
if [ "${REAL_ROOT}" = '' ]
then 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 fi
findcdmount /newroot/dev/cdroms/*
# Not in /dev/cdroms: try /dev/ide/cd
[ "${REAL_ROOT}" = '' ] && findcdmount /newroot/dev/ide/cd/*
if [ "${REAL_ROOT}" = '' ] if [ "${REAL_ROOT}" = '' ]
then 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 umount /newroot
# shouldn't be anything in here b/c it was on tmpfs
rm -rf /newroot/* rm -rf /newroot/*
echo 'Could not find CD to boot, something else needed!'
CDROOT=0 CDROOT=0
echo "Could not find CD to boot, gonna need something else"
fi fi
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 # Try to mount sysfs, and if it fails, do not use udev
if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ] if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ]
then then
mount -t sysfs sys /sys 2> /dev/null mount -t sysfs sys /sys 2> /dev/null
[ "$?" -eq "0" ] || USE_UDEV_NORMAL=0 [ "$?" -eq '0' ] || USE_UDEV_NORMAL=0
fi 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' ] if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ]
then then
USE_DEVFS_NORMAL=0 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 cd /sys
for x in block/* runUdev
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
elif [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ] elif [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ]
then then
[ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev [ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev
@ -247,8 +233,8 @@ do
break break
else else
echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting root...${NORMAL}" echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting root...${NORMAL}"
mount -o rw ${REAL_ROOT} /newroot mount -o rw ${REAL_ROOT} /newroot
if [ "$?" = '0' ] if [ "$?" = '0' ]
then then
break break
@ -387,20 +373,16 @@ then
umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' 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!' 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!' 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 then
umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!' umount /tmp/.initrd/proc || echo '*: Failed to unmount the initrd /proc!'
umount /tmp/.initrd/sys || echo '*: Failed to unmount the initrd /sys!' umount /tmp/.initrd/sys || echo '*: Failed to unmount the initrd /sys!'
elif [ "${CDROOT}" -eq '1' ] elif [ "${CDROOT}" -eq '1' ]
then then
# If automount at boot was on with devfs, we'll want to umount it umount /tmp/.initrd/proc || echo "*: Failed to unmount the initrd /proc!"
# also umount proc
mount -t proc proc /proc
umount /tmp/.initrd/proc > /dev/null 2>&1 || echo "*: Failed to unmount /tmp/.initrd/proc!"
umount /dev > /dev/null 2>&1 umount /dev > /dev/null 2>&1
mount -n --move /tmp/.initrd/dev dev || echo '*: Failed to move over the /dev tree!' 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!' rm /tmp/.initrd/dev -rf || '*: Failed to remove the initrd /dev!'
umount /proc > /dev/null 2>&1
fi fi
echo -n '.' echo -n '.'

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Genkernel v3 # Genkernel v3
GK_V='3.0.2e' GK_V='3.0.2f'
TEMP='/var/tmp/genkernel' TEMP='/var/tmp/genkernel'
TODEBUGCACHE=1 # Until an error occurs or DEBUGFILE is fully qualified. TODEBUGCACHE=1 # Until an error occurs or DEBUGFILE is fully qualified.
@ -216,7 +216,8 @@ then
fi fi
compile_devfsd compile_devfsd
[ "${CMD_UDEV}" ] && compile_udev [ "${VER}" -gt '2' ] || [ "${VER}" -eq '2' -a "${PAT}" -ge '6' ] && UDEV=1 && print_info 1 'udev: Target is a 2.6 kernel, support enabled.'
[ "${UDEV}" -eq '1' ] && compile_udev
# Create initrd # Create initrd
create_initrd create_initrd

Loading…
Cancel
Save