summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Yamin <plasmaroo@gentoo.org>2004-08-11 18:02:11 +0000
committerTim Yamin <plasmaroo@gentoo.org>2004-08-11 18:02:11 +0000
commit85917d6f0479262fc6dd93a086c67e619b39ccb0 (patch)
tree0f543db291bce5036e8c0afcf06708cede6f66a9
parentmodules_load cleaned up to match the version used for the 2004.2 release, (diff)
downloadgenkernel-85917d6f0479262fc6dd93a086c67e619b39ccb0.tar.gz
genkernel-85917d6f0479262fc6dd93a086c67e619b39ccb0.tar.bz2
genkernel-85917d6f0479262fc6dd93a086c67e619b39ccb0.zip
Added LiveCD udev support.
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@126 67a159dc-881f-0410-a524-ba9dfbe2cb84
-rwxr-xr-xgen_cmdline.sh2
-rw-r--r--gen_compile.sh17
-rw-r--r--gen_determineargs.sh7
-rw-r--r--gen_initrd.sh2
-rw-r--r--generic/initrd.scripts27
-rw-r--r--generic/linuxrc114
-rwxr-xr-xgenkernel5
7 files changed, 98 insertions, 76 deletions
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 2c776a29..966e2c03 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -238,7 +238,7 @@ parse_cmdline() {
print_info 2 "CMD_NOINITRDMODULES: $CMD_NOINITRDMODULES"
;;
--udev)
- CMD_UDEV=0
+ CMD_UDEV=1
print_info 2 "CMD_UDEV: $CMD_UDEV"
;;
--callback*)
diff --git a/gen_compile.sh b/gen_compile.sh
index ef702648..9d87a2ae 100644
--- a/gen_compile.sh
+++ b/gen_compile.sh
@@ -482,17 +482,22 @@ compile_udev() {
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...'
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index e6866a8d..1b0ea6fa 100644
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -190,4 +190,11 @@ determine_real_args() {
else
OLDCONFIG=0
fi
+
+ if isTrue "${CMD_UDEV}"
+ then
+ UDEV=1
+ else
+ UDEV=0
+ fi
}
diff --git a/gen_initrd.sh b/gen_initrd.sh
index 78a46872..8fb28f72 100644
--- a/gen_initrd.sh
+++ b/gen_initrd.sh
@@ -80,7 +80,7 @@ create_base_initrd_sys() {
bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress 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!"; }
# We make our own devfsd.conf these days, the default one doesn't work with the stripped
diff --git a/generic/initrd.scripts b/generic/initrd.scripts
index d40b18a8..bd9b7513 100644
--- a/generic/initrd.scripts
+++ b/generic/initrd.scripts
@@ -50,3 +50,30 @@ findcdmount() {
kill_devfsd() {
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
+}
diff --git a/generic/linuxrc b/generic/linuxrc
index e053bcbc..2e5d0d39 100644
--- a/generic/linuxrc
+++ b/generic/linuxrc
@@ -106,94 +106,80 @@ chooseKeymap() {
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
@@ -247,8 +233,8 @@ do
break
else
echo -e "${GOOD}>>${NORMAL}${BOLD} Mounting root...${NORMAL}"
-
mount -o rw ${REAL_ROOT} /newroot
+
if [ "$?" = '0' ]
then
break
@@ -387,20 +373,16 @@ then
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 '.'
diff --git a/genkernel b/genkernel
index 3f04396a..eb0f339b 100755
--- a/genkernel
+++ b/genkernel
@@ -1,7 +1,7 @@
#!/bin/bash
# Genkernel v3
-GK_V='3.0.2e'
+GK_V='3.0.2f'
TEMP='/var/tmp/genkernel'
TODEBUGCACHE=1 # Until an error occurs or DEBUGFILE is fully qualified.
@@ -216,7 +216,8 @@ then
fi
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