From: Tim Yamin Date: Wed, 28 Jul 2004 09:35:13 +0000 (+0000) Subject: >> 3.0.2e. Code formatting fixes from Bob Barry, as well as a patch for bug X-Git-Tag: v3.4.10.902~633 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=70112f85461106d34d87e1e5385612537302c30a;p=genkernel.git >> 3.0.2e. Code formatting fixes from Bob Barry, as well as a patch for bug #57953 from Martin Parm. Udev support, bug #49328. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@119 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- diff --git a/gen_bootloader.sh b/gen_bootloader.sh index 6570635..75491c0 100644 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -70,7 +70,7 @@ set_grub_bootloader() { sub(/\(.+\)/,"(" ch KV ch ")",$1); sub(/kernel-[[:alnum:][:punct:]]+/, "kernel-" KV, $3); sub(/initrd-[[:alnum:][:punct:]]+/, "initrd-" KV, $4); - print RS ch $0 }' + print RS ch $0 }' \ KV=$KV $GRUB_CONF.bak >> $GRUB_CONF fi } diff --git a/gen_cmdline.sh b/gen_cmdline.sh index b266571..3b1fa24 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -34,6 +34,7 @@ longusage() { echo " --install Install the kernel after building" echo " --no-install Do not install the kernel after building" echo " --no-initrdmodules Don't copy any modules to the initrd" + echo " --udev Add in udev support." echo " --callback=<...> Run the specified arguments after" echo " the kernel and modules have been" echo " compiled." @@ -58,13 +59,10 @@ longusage() { echo " --bootsplash= Force bootsplash using ." echo " --do-keymap-auto Forces keymap selection at boot." echo " --no-lvm2 Don't add in LVM2 support." - echo " --bootloader=grub Add new kernel to grub configuration" + echo " --bootloader=grub Add new kernel to GRUB configuration" echo " Internals" - echo " --tempdir= Location of Genkernel's temporary directory" + echo " --tempdir= Location of Genkernel's temporary directory" echo " --arch-override= Force to arch instead of autodetect" - echo " --busybox-config= Busybox configuration file to use" - echo " --busybox-bin= Don't compile busybox, use this _static_" - echo " bzip2'd binary" echo " Output Settings" echo " --minkernpackage= File to output a .tar.bz2'd kernel and initrd:" echo " No modules outside of the initrd will be" @@ -238,6 +236,10 @@ parse_cmdline() { CMD_NOINITRDMODULES=1 print_info 2 "CMD_NOINITRDMODULES: $CMD_NOINITRDMODULES" ;; + --udev) + CMD_UDEV=0 + print_info 2 "CMD_UDEV: $CMD_UDEV" + ;; --callback*) CMD_CALLBACK=`parse_opt "$*"` print_info 2 "CMD_CALLBACK: $CMD_CALLBACK/$*" @@ -276,14 +278,6 @@ parse_cmdline() { CMD_INSTALL_MOD_PATH=`parse_opt "$*"` print_info 2 "CMD_INSTALL_MOD_PATH: $CMD_INSTALL_MOD_PATH" ;; - --busybox-config*) - CMD_BUSYBOX_CONFIG=`parse_opt "$*"` - print_info 2 "CMD_BUSYBOX_CONFIG: $CMD_BUSYBOX_CONFIG" - ;; - --busybox-bin*) - CMD_BUSYBOX_BIN=`parse_opt "$*"` - print_info 2 "CMD_BUSYBOX_BIN: $CMD_BUSYBOX_BIN" - ;; --minkernpackage*) CMD_MINKERNPACKAGE=`parse_opt "$*"` print_info 2 "MINKERNPACKAGE: $CMD_MINKERNPACKAGE" diff --git a/gen_compile.sh b/gen_compile.sh index 5b37294..5d7e550 100644 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -108,7 +108,8 @@ unset_kernel_args() compile_generic() { local RET - [ "$#" -lt '2' ] && gen_die "compile_generic(): improper usage" + [ "$#" -lt '2' ] && + gen_die 'compile_generic(): improper usage!' if [ "${2}" = 'kernel' ] || [ "${2}" = 'runtask' ] then @@ -137,7 +138,8 @@ compile_generic() { ${MAKE} ${MAKEOPTS} ${1} >> ${DEBUGFILE} 2>&1 RET=$? fi - [ "${RET}" -ne '0' ] && gen_die "Failed to compile the \"${1}\" target..." + [ "${RET}" -ne '0' ] && + gen_die "Failed to compile the \"${1}\" target..." unset MAKE if [ "${2}" = 'kernel' ] @@ -152,8 +154,10 @@ compile_generic() { extract_dietlibc_bincache() { cd "${TEMP}" rm -rf "${TEMP}/diet" > /dev/null - tar -jxpf "${DIETLIBC_BINCACHE}" || gen_die "Could not extract dietlibc bincache!" - [ ! -d "${TEMP}/diet" ] && gen_die "${TEMP}/diet directory not found!" + tar -jxpf "${DIETLIBC_BINCACHE}" || + gen_die 'Could not extract dietlibc bincache!' + [ ! -d "${TEMP}/diet" ] && + gen_die "${TEMP}/diet directory not found!" cd - > /dev/null } @@ -192,7 +196,8 @@ compile_modules() { } compile_kernel() { - [ "${KERNEL_MAKE}" = '' ] && gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!" + [ "${KERNEL_MAKE}" = '' ] && + gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!" cd ${KERNEL_DIR} print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..." compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel @@ -203,23 +208,31 @@ compile_kernel() { fi if ! isTrue "${CMD_NOINSTALL}" then - cp "${KERNEL_BINARY}" "/boot/kernel-${KV}" || gen_die 'Could not copy the kernel binary to /boot!' - cp "System.map" "/boot/System.map-${KV}" || gen_die 'Could not copy System.map to /boot!' + cp "${KERNEL_BINARY}" "/boot/kernel-${KV}" || + gen_die 'Could not copy the kernel binary to /boot!' + cp "System.map" "/boot/System.map-${KV}" || + gen_die 'Could not copy System.map to /boot!' else - cp "${KERNEL_BINARY}" "${TEMP}/kernel-${KV}" || gen_die "Could not copy the kernel binary to ${TEMP}!" - cp "System.map" "${TEMP}/System.map-${KV}" || gen_die "Could not copy System.map to ${TEMP}!" + cp "${KERNEL_BINARY}" "${TEMP}/kernel-${KV}" || + gen_die "Could not copy the kernel binary to ${TEMP}!" + cp "System.map" "${TEMP}/System.map-${KV}" || + gen_die "Could not copy System.map to ${TEMP}!" fi } compile_busybox() { if [ ! -f "${BUSYBOX_BINCACHE}" ] then - [ -f "${BUSYBOX_SRCTAR}" ] || gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!" - [ -f "${BUSYBOX_CONFIG}" ] || gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!" + [ -f "${BUSYBOX_SRCTAR}" ] || + gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!" + [ -f "${BUSYBOX_CONFIG}" ] || + gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!" cd "${TEMP}" rm -rf ${BUSYBOX_DIR} > /dev/null - tar -jxpf ${BUSYBOX_SRCTAR} || gen_die 'Could not extract busybox source tarball!' - [ -d "${BUSYBOX_DIR}" ] || gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!' + tar -jxpf ${BUSYBOX_SRCTAR} || + gen_die 'Could not extract busybox source tarball!' + [ -d "${BUSYBOX_DIR}" ] || + gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!' cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config" cd "${BUSYBOX_DIR}" # Busybox and dietlibc don't play nice right now @@ -240,10 +253,14 @@ compile_busybox() { # UTILS_CC="${OLD_CC}" # fi print_info 1 'busybox: >> Copying to cache...' - [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] || gen_die 'Busybox executable does not exist!' - strip "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die 'Could not strip busybox binary!' - bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die 'bzip2 compression of busybox failed!' - mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" || gen_die 'Could not copy the busybox binary to package directory, does the directory exist?' + [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] || + gen_die 'Busybox executable does not exist!' + strip "${TEMP}/${BUSYBOX_DIR}/busybox" || + gen_die 'Could not strip busybox binary!' + bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" || + gen_die 'bzip2 compression of busybox failed!' + mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" || + gen_die 'Could not copy the busybox binary to the package directory, does the directory exist?' cd "${TEMP}" rm -rf "${BUSYBOX_DIR}" > /dev/null @@ -254,11 +271,13 @@ compile_modutils() { local ARGS if [ ! -f "${MODUTILS_BINCACHE}" ] then - [ ! -f "${MODUTILS_SRCTAR}" ] && gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!" + [ ! -f "${MODUTILS_SRCTAR}" ] && + gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!" cd "${TEMP}" rm -rf "${MODUTILS_DIR}" tar -jxpf "${MODUTILS_SRCTAR}" - [ ! -d "${MODUTILS_DIR}" ] && gen_die "Modutils directory ${MODUTILS_DIR} invalid!" + [ ! -d "${MODUTILS_DIR}" ] && + gen_die "Modutils directory ${MODUTILS_DIR} invalid!" cd "${MODUTILS_DIR}" print_info 1 "modutils: >> Configuring..." @@ -271,7 +290,8 @@ compile_modutils() { export_utils_args export ARCH=${ARCH} - ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 || gen_die 'Configuring modutils failed!' + ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 || + gen_die 'Configuring modutils failed!' unset_utils_args print_info 1 'modutils: >> Compiling...' @@ -284,10 +304,14 @@ compile_modutils() { fi print_info 1 'modutils: >> Copying to cache...' - [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] || gen_die "insmod.static does not exist after the compilation of modutils!" - strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die 'Could not strip insmod.static!' - bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die 'Compression of insmod.static failed!' - mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" || gen_die 'Could not move the compressed insmod binary to the package cache!' + [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] || + gen_die 'insmod.static does not exist after the compilation of modutils!' + strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || + gen_die 'Could not strip insmod.static!' + bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || + gen_die 'Compression of insmod.static failed!' + mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" || + gen_die 'Could not move the compressed insmod binary to the package cache!' cd "${TEMP}" rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null @@ -298,11 +322,13 @@ compile_module_init_tools() { local ARGS if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ] then - [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] && gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}" + [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] && + gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}" cd "${TEMP}" rm -rf "${MODULE_INIT_TOOLS_DIR}" tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}" - [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] && gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} invalid" + [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] && + gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} is invalid" cd "${MODULE_INIT_TOOLS_DIR}" print_info 1 'module-init-tools: >> Configuring' @@ -314,7 +340,8 @@ compile_module_init_tools() { fi export_utils_args - ./configure >> ${DEBUGFILE} 2>&1 || gen_die 'Configure of module-init-tools failed!' + ./configure >> ${DEBUGFILE} 2>&1 || + gen_die 'Configure of module-init-tools failed!' unset_utils_args print_info 1 ' >> Compiling...' compile_generic "all" utils @@ -326,11 +353,16 @@ compile_module_init_tools() { fi print_info 1 ' >> Copying to cache...' - [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] || gen_die 'insmod.static does not exist after the compilation of module-init-tools!' - strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die 'Could not strip insmod.static!' - bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die 'Compression of insmod.static failed!' - [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] || gen_die 'Could not find compressed insmod.static.bz2 binary!' - mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" || gen_die 'Could not move the compressed insmod binary to the package cache!' + [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] || + gen_die 'insmod.static does not exist after the compilation of module-init-tools!' + strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || + gen_die 'Could not strip insmod.static!' + bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || + gen_die 'Compression of insmod.static failed!' + [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] || + gen_die 'Could not find compressed insmod.static.bz2 binary!' + mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" || + gen_die 'Could not move the compressed insmod binary to the package cache!' cd "${TEMP}" rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null @@ -341,11 +373,13 @@ compile_devfsd() { local ARGS if [ ! -f "${DEVFSD_BINCACHE}" -o ! -f "${DEVFSD_CONF_BINCACHE}" ] then - [ ! -f "${DEVFSD_SRCTAR}" ] && gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}" + [ ! -f "${DEVFSD_SRCTAR}" ] && + gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}" cd "${TEMP}" rm -rf "${DEVFSD_DIR}" tar -jxpf "${DEVFSD_SRCTAR}" - [ ! -d "${DEVFSD_DIR}" ] && gen_die "Devfsd directory ${DEVFSD_DIR} invalid" + [ ! -d "${DEVFSD_DIR}" ] && + gen_die "Devfsd directory ${DEVFSD_DIR} invalid" cd "${DEVFSD_DIR}" if [ "${USE_DIETLIBC}" -eq '1' ] @@ -376,9 +410,9 @@ compile_devfsd() { [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!' mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!' - [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] || gen_die 'devfsd.conf does not exist after the compilation of devfsd!' - bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die 'Compression of devfsd.conf failed!' - mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die 'Could not move the compressed configuration to the package cache!' +# [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] || gen_die 'devfsd.conf does not exist after the compilation of devfsd!' +# bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die 'Compression of devfsd.conf failed!' +# mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die 'Could not move the compressed configuration to the package cache!' cd "${TEMP}" rm -rf "${DEVFSD_DIR}" > /dev/null @@ -405,11 +439,14 @@ compile_dietlibc() { if [ "${BUILD_DIETLIBC}" -eq '1' ] then - [ -f "${DIETLIBC_SRCTAR}" ] || gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}" + [ -f "${DIETLIBC_SRCTAR}" ] || + gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}" cd "${TEMP}" rm -rf "${DIETLIBC_DIR}" > /dev/null - tar -jxpf ${DIETLIBC_SRCTAR} || gen_die "Could not extract dietlibc source tarball" - [ -d "${DIETLIBC_DIR}" ] || gen_die "Dietlibc directory ${DIETLIBC_DIR} is invalid!" + tar -jxpf "${DIETLIBC_SRCTAR}" || + gen_die 'Could not extract dietlibc source tarball' + [ -d "${DIETLIBC_DIR}" ] || + gen_die "Dietlibc directory ${DIETLIBC_DIR} is invalid!" cd "${DIETLIBC_DIR}" print_info 1 "dietlibc: >> Compiling..." compile_generic "prefix=${TEMP}/diet" utils @@ -417,8 +454,10 @@ compile_dietlibc() { compile_generic "prefix=${TEMP}/diet install" utils print_info 1 " >> Copying to bincache..." cd ${TEMP} - tar -jcpf "${DIETLIBC_BINCACHE}" diet || gen_die "Could not tar up the dietlibc binary!" - [ -f "${DIETLIBC_BINCACHE}" ] || gen_die 'Dietlibc cache not created!' + tar -jcpf "${DIETLIBC_BINCACHE}" diet || + gen_die 'Could not tar up the dietlibc binary!' + [ -f "${DIETLIBC_BINCACHE}" ] || + gen_die 'Dietlibc cache not created!' echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}" cd "${TEMP}" @@ -426,3 +465,42 @@ compile_dietlibc() { rm -rf "${TEMP}/diet" > /dev/null fi } + +compile_udev() { + if [ ! -f "${UDEV_BINCACHE}" ] + then + cd "${TEMP}" + rm -rf "${UDEV_DIR}" udev + [ ! -f "${UDEV_SRCTAR}" ] && + gen_die "Could not find udev tarball: ${UDEV_SRCTAR}" + tar -jxpf "${UDEV_SRCTAR}" || + gen_die 'Could not extract udev tarball' + [ ! -d "${UDEV_DIR}" ] && + gen_die "Udev tarball ${UDEV_SRCTAR} is invalid" + + cd "${UDEV_DIR}" + 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 + strip udev || gen_die 'Failed to strip the udev binary!' + + print_info 1 ' >> Installing...' + install -d "${TEMP}/udev/etc/udev" "${TEMP}/udev/sbin" || + 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' + + cd "${TEMP}/udev" + print_info 1 ' >> Copying to bincache...' + tar -cjf "${UDEV_BINCACHE}" * || + gen_die 'Could not create binary cache' + + cd "${TEMP}" + rm -rf "${UDEV_DIR}" udev + fi +} + diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 129a5d0..f276226 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -91,6 +91,7 @@ determine_real_args() { DIETLIBC_BINCACHE_TEMP=`arch_replace "${DIETLIBC_BINCACHE_TEMP}"` DEVFSD_BINCACHE=`arch_replace "${DEVFSD_BINCACHE}"` DEVFSD_CONF_BINCACHE=`arch_replace "${DEVFSD_CONF_BINCACHE}"` + UDEV_BINCACHE=`arch_replace "${UDEV_BINCACHE}"` if [ "${CMD_BOOTSPLASH}" != '' ] then @@ -155,11 +156,11 @@ determine_real_args() { SAVE_CONFIG="${CMD_SAVE_CONFIG}" fi - if isTrue ${SAVE_CONFIG} + if isTrue "${SAVE_CONFIG}" then - ${SAVE_CONFIG}=1 + SAVE_CONFIG=1 else - ${SAVE_CONFIG}=0 + SAVE_CONFIG=0 fi if [ "${CMD_INSTALL_MOD_PATH}" != '' ] @@ -171,4 +172,11 @@ determine_real_args() { then BOOTLOADER="${CMD_BOOTLOADER}" fi + + if isTrue "${CMD_OLDCONFIG}" + then + OLDCONFIG=1 + else + OLDCONFIG=0 + fi } diff --git a/gen_initrd.sh b/gen_initrd.sh index c933223..75b88fd 100644 --- a/gen_initrd.sh +++ b/gen_initrd.sh @@ -4,16 +4,21 @@ create_initrd_loop() { local inodes [ "$#" -ne '1' ] && gen_die 'create_initrd_loop(): Not enough arguments!' - mkdir -p ${TEMP}/initrd-mount || gen_die 'Could not create loopback mount directory!' - dd if=/dev/zero of=${TEMP}/initrd-${KV} bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 || gen_die "Could not zero initrd-${KV}" - mke2fs -F -N500 -q "${TEMP}/initrd-${KV}" >> "${DEBUGFILE}" 2>&1 || gen_die "Could not format initrd-${KV}!" - mount -t ext2 -o loop "${TEMP}/initrd-${KV}" "${TEMP}/initrd-mount" >> "${DEBUGFILE}" 2>&1 || gen_die 'Could not mount the initrd filesystem!' + mkdir -p ${TEMP}/initrd-mount || + gen_die 'Could not create loopback mount directory!' + dd if=/dev/zero of=${TEMP}/initrd-${KV} bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 || + gen_die "Could not zero initrd-${KV}" + mke2fs -F -N500 -q "${TEMP}/initrd-${KV}" >> "${DEBUGFILE}" 2>&1 || + gen_die "Could not format initrd-${KV}!" + mount -t ext2 -o loop "${TEMP}/initrd-${KV}" "${TEMP}/initrd-mount" >> "${DEBUGFILE}" 2>&1 || + gen_die 'Could not mount the initrd filesystem!' } create_initrd_unmount_loop() { cd ${TEMP} - umount "${TEMP}/initrd-mount" || gen_die 'Could not unmount initrd system!' + umount "${TEMP}/initrd-mount" || + gen_die 'Could not unmount initrd system!' } move_initrd_to_loop() @@ -30,10 +35,12 @@ create_base_initrd_sys() { mkdir -p ${TEMP}/initrd-temp/usr mkdir -p ${TEMP}/initrd-temp/proc mkdir -p ${TEMP}/initrd-temp/temp + mkdir -p ${TEMP}/initrd-temp/sys mkdir -p ${TEMP}/initrd-temp/.initrd ln -s bin ${TEMP}/initrd-temp/sbin ln -s ../bin ${TEMP}/initrd-temp/usr/bin ln -s ../bin ${TEMP}/initrd-temp/usr/sbin + echo "/dev/ram0 / ext2 defaults" > ${TEMP}/initrd-temp/etc/fstab echo "proc /proc proc defaults 0 0" >> ${TEMP}/initrd-temp/etc/fstab @@ -46,20 +53,25 @@ create_base_initrd_sys() { MAKEDEV std MAKEDEV console - cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not copy busybox from bincache" - bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not uncompress busybox" + cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || + gen_die 'Could not copy busybox from bincache!' + bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || + gen_die 'Could not uncompress busybox!' chmod +x "${TEMP}/initrd-temp/bin/busybox" if [ "${NOINITRDMODULES}" = '' ] then if [ "${PAT}" -gt "4" ] then - cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache" + cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || + gen_die 'Could not copy insmod.static from bincache!' else - cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache" + cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || + gen_die 'Could not copy insmod.static from bincache' fi - bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static" + bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || + gen_die 'Could not uncompress insmod.static!' mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod" chmod +x "${TEMP}/initrd-temp/bin/insmod" fi @@ -68,18 +80,25 @@ 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" || + 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 # down devfsd we use with dietlibc -# cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not copy devfsd.conf from bincache" -# bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not uncompress devfsd.conf" +# cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || +# gen_die "could not copy devfsd.conf from bincache" +# bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || +# gen_die "could not uncompress devfsd.conf" # LVM2 if [ -e '/sbin/vgscan.static' -a -e '/sbin/vgchange.static' ] then if [ "${CMD_NOLVM2}" -ne '1' ] then - cp /sbin/vgscan.static "${TEMP}/initrd-temp/bin/vgscan" || gen_die 'Could not copy over vgscan!' - cp /sbin/vgchange.static "${TEMP}/initrd-temp/bin/vgchange" || gen_die 'Could not copy over vgchange!' + cp /sbin/vgscan.static "${TEMP}/initrd-temp/bin/vgscan" || + gen_die 'Could not copy over vgscan!' + cp /sbin/vgchange.static "${TEMP}/initrd-temp/bin/vgchange" || + gen_die 'Could not copy over vgchange!' fi # else # print_warning 1 "initrd: No LVM2 static binaries found; skipping support..." @@ -90,7 +109,8 @@ create_base_initrd_sys() { pivot_root ps awk pwd rm rmdir rmmod sed sh sleep tar test touch true umount uname \ xargs yes zcat chmod chown cut kill killall; do rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null - ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "Busybox error: could not link ${i}!" + ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || + gen_die "Busybox error: could not link ${i}!" done } @@ -247,7 +267,8 @@ create_initrd() { do if [ -f "/etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg" ] then - /sbin/splash -s -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg >> ${TEMP}/initrd-${KV} || gen_die "Error: could not copy ${bootRes} bootsplash!" + /sbin/splash -s -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg >> ${TEMP}/initrd-${KV} || + gen_die "Error: could not copy ${bootRes} bootsplash!" else print_warning 1 "splash: Did not find a bootsplash for the ${bootRes} resolution..." fi @@ -258,6 +279,7 @@ create_initrd() { fi if ! isTrue "${CMD_NOINSTALL}" then - cp ${TEMP}/initrd-${KV} /boot/initrd-${KV} || gen_die 'Could not copy the initrd to /boot!' + cp ${TEMP}/initrd-${KV} /boot/initrd-${KV} || + gen_die 'Could not copy the initrd to /boot!' fi } diff --git a/generic/linuxrc b/generic/linuxrc index 5d702a2..fa1679a 100644 --- a/generic/linuxrc +++ b/generic/linuxrc @@ -7,6 +7,7 @@ . /etc/initrd.scripts USE_DEVFS_NORMAL=1 +USE_UDEV_NORMAL=2 if [ "$$" != '1' ] then @@ -39,6 +40,12 @@ do nodevfs) USE_DEVFS_NORMAL=0 ;; + udev) + USE_UDEV_NORMAL=1 + ;; + noudev) + USE_UDEV_NORMAL=0 + ;; loop\=*) LOOP=`parse_opt "${x}"` ;; @@ -139,8 +146,54 @@ then fi fi +# 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 +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 + # Don't do else b/c we set CDROOT=0 if it fails to detect -if [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ] +if [ "${USE_UDEV_NORMAL}" -eq '1' -a "${CDROOT}" -eq '0' ] +then + 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 +elif [ "${CDROOT}" -eq '0' -a "${USE_DEVFS_NORMAL}" -eq '1' ] then [ ! -e /dev/.devfsd ] && mount -t devfs devfs /dev devfsd /dev -np @@ -324,6 +377,7 @@ fi echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting" cd /newroot +mkdir /newroot/proc /newroot/sys 2>/dev/null pivot_root . tmp/.initrd echo -n '.' @@ -332,6 +386,10 @@ 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' ] +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 diff --git a/genkernel b/genkernel index 3b4ed31..65fa1e7 100755 --- a/genkernel +++ b/genkernel @@ -1,7 +1,7 @@ #!/bin/bash # Genkernel v3 -GK_V='3.0.2d' +GK_V='3.0.2e' TEMP='/var/tmp/genkernel' TODEBUGCACHE=1 # Until an error occurs or DEBUGFILE is fully qualified. @@ -215,6 +215,7 @@ then fi compile_devfsd + compile_udev # Create initrd create_initrd diff --git a/genkernel.conf b/genkernel.conf index 9d21b1b..0353f61 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -86,3 +86,8 @@ DEVFSD_SRCTAR="${GK_SHARE}/pkg/devfsd-${DEVFSD_VER}.tar.bz2" DEVFSD_DIR="devfsd" DEVFSD_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-${DEVFSD_VER}-%%ARCH%%.bz2" DEVFSD_CONF_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-conf-${DIETLIBC_VER}-%%ARCH%%.bz2" + +UDEV_VER="030" +UDEV_DIR="udev-${UDEV_VER}" +UDEV_SRCTAR="${GK_SHARE}/pkg/udev-${UDEV_VER}.tar.bz2" +UDEV_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/udev-${UDEV_VER}-%%ARCH%%.tar.bz2" diff --git a/pkg/udev-030.tar.bz2 b/pkg/udev-030.tar.bz2 new file mode 100644 index 0000000..7ef7b48 Binary files /dev/null and b/pkg/udev-030.tar.bz2 differ