From: Chris Gianelloni Date: Wed, 13 Dec 2006 17:22:29 +0000 (+0000) Subject: Added patch from Daniel Drake in bug #156445 to add userspace suspen... X-Git-Tag: v3.4.10.902~287 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8b4b874b64d40c9a8c5872c4416b7c8bdd22a30e;p=genkernel.git Added patch from Daniel Drake in bug #156445 to add userspace suspend support to genkernel. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@465 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- diff --git a/ChangeLog b/ChangeLog index a790918..115495e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ # Copyright 2006-2006 Gentoo Foundation; Distributed under the GPL v2 # $Header: $ + 13 Dec 2006; Chris Gianelloni gen_cmdline.sh, + gen_compile.sh, gen_configkernel.sh, gen_determineargs.sh, + gen_initramfs.sh, gen_initrd.sh, generic/initrd.scripts, generic/linuxrc, + genkernel.8, genkernel.conf: + Added patch from Daniel Drake in bug #156445 to add + userspace suspend support to genkernel. + 13 Dec 2006; Chris Gianelloni gen_initramfs.sh, gen_initrd.sh: Added debug level to LUKS print_info messages for bug #156410. diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 8351189..bd61f6f 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -77,6 +77,7 @@ longusage() { echo " --lvm2 Include LVM2 support" # echo " --unionfs Include UNIONFS support" echo " --dmraid Include DMRAID support" + echo " --suspend Include userspace suspend/resume (uswsusp) support" echo " --slowusb Enables extra pauses for slow USB CD boots" echo " --bootloader=grub Add new kernel to GRUB configuration" echo " --linuxrc= Specifies a user created linuxrc" @@ -226,6 +227,17 @@ parse_cmdline() { CMD_LVM2=1 print_info 2 "CMD_LVM2: $CMD_LVM2" ;; + --suspend) + if [ ! -e /etc/suspend.conf ] + then + echo 'Error: --suspend requires sys-power/suspend to be installed' + echo ' on the host system; try "emerge sys-power/suspend".' + echo ' Once installed, configure the resume settings in /etc/suspend.conf' + exit 1 + fi + CMD_SUSPEND=1 + print_info 2 "CMD_SUSPEND: $CMD_SUSPEND" + ;; --no-busybox) CMD_NO_BUSYBOX=1 print_info 2 "CMD_NO_BUSYBOX: $CMD_NO_BUSYBOX" diff --git a/gen_compile.sh b/gen_compile.sh index ac5045f..8f47642 100644 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -187,8 +187,10 @@ compile_generic() { local RET [ "$#" -lt '2' ] && gen_die 'compile_generic(): improper usage!' + local target=${1} + local argstype=${2} - if [ "${2}" = 'kernel' ] || [ "${2}" = 'runtask' ] + if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ] then export_kernel_args MAKE=${KERNEL_MAKE} @@ -197,42 +199,43 @@ compile_generic() { export_utils_args MAKE=${UTILS_MAKE} fi - case "$2" in + case "${argstype}" in kernel) ARGS="`compile_kernel_args`" ;; utils) ARGS="`compile_utils_args`" ;; *) ARGS="" ;; # includes runtask esac - + shift 2 + # the eval usage is needed in the next set of code # as ARGS can contain spaces and quotes, eg: # ARGS='CC="ccache gcc"' - if [ "${2}" == 'runtask' ] + if [ "${argstype}" == 'runtask' ] then - print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${1}" 1 0 1 - eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${1} + print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1 + eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $* RET=$? elif [ "${DEBUGLEVEL}" -gt "1" ] then # Output to stdout and debugfile - print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1}" 1 0 1 - eval ${MAKE} ${MAKEOPTS} ${ARGS} ${1} 2>&1 | tee -a ${DEBUGFILE} + print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1 + eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${DEBUGFILE} RET=${PIPESTATUS[0]} else # Output to debugfile only - print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1}" 1 0 1 - eval ${MAKE} ${MAKEOPTS} ${ARGS} ${1} >> ${DEBUGFILE} 2>&1 + print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1 + eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${DEBUGFILE} 2>&1 RET=$? fi [ "${RET}" -ne '0' ] && - gen_die "Failed to compile the \"${1}\" target..." + gen_die "Failed to compile the \"${target}\" target..." unset MAKE unset ARGS - if [ "${2}" = 'kernel' ] + if [ "${argstype}" = 'kernel' ] then unset_kernel_args - elif [ "${2}" = 'utils' ] + elif [ "${argstype}" = 'utils' ] then unset_utils_args fi @@ -529,6 +532,39 @@ compile_dmraid() { fi } +compile_suspend() { + [ -f "${SUSPEND_BINCACHE}" ] && return + [ -f "${SUSPEND_SRCTAR}" ] || + gen_die "Could not find SUSPEND source tarball: ${SUSPEND_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!" + cd ${TEMP} + rm -rf ${SUSPEND_DIR} > /dev/null + /bin/tar -zxpf ${SUSPEND_SRCTAR} || + gen_die 'Could not extract SUSPEND source tarball!' + [ -d "${SUSPEND_DIR}" ] || + gen_die "SUSPEND directory ${DMRAID_DIR} is invalid!" + + cd "${SUSPEND_DIR}" + if [ -f "${GK_SHARE}/pkg/suspend-0.5-Makefile.patch" ] + then + patch -p1 -i \ + ${GK_SHARE}/pkg/suspend-0.5-Makefile.patch \ + || gen_die "Failed patching suspend" + fi + + print_info 1 'suspend: >> Compiling...' + compile_generic '' utils CC_FLAGS= LD_FLAGS= + + print_info 1 ' >> Copying to bincache...' + mkdir -p "${TEMP}/bincache/sbin" + cp -f resume "${TEMP}/bincache/sbin" || + gen_die 'Could not copy resume binary' + cd "${TEMP}/bincache" + /bin/tar -cjf "${SUSPEND_BINCACHE}" * || + gen_die 'Could not create suspend binary cache' + cd "${TEMP}" + rm -rf bincache suspend-0.5 +} + compile_modutils() { # I've disabled dietlibc support for the time being since the # version we use misses a few needed system calls. diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 5b87283..44ed630 100644 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -120,4 +120,11 @@ config_kernel() { then sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g' fi + + # This check isn't complete: SOFTWARE_SUSPEND has extra deps on some systems such as CPU hotplug + if isTrue ${CMD_SUSPEND} + then + sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_SOFTWARE_SUSPEND is.*/CONFIG_SOFTWARE_SUSPEND=y/g' + fi + } diff --git a/gen_determineargs.sh b/gen_determineargs.sh index fcafe33..241e874 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -212,6 +212,7 @@ determine_real_args() { UNIONFS_BINCACHE=`cache_replace "${UNIONFS_BINCACHE}"` UNIONFS_MODULES_BINCACHE=`cache_replace "${UNIONFS_MODULES_BINCACHE}"` BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"` + SUSPEND_BINCACHE=`cache_replace "${SUSPEND_BINCACHE}"` DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"` BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"` @@ -230,6 +231,7 @@ determine_real_args() { UNIONFS_BINCACHE=`arch_replace "${UNIONFS_BINCACHE}"` UNIONFS_MODULES_BINCACHE=`arch_replace "${UNIONFS_MODULES_BINCACHE}"` BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"` + SUSPEND_BINCACHE=`arch_replace "${SUSPEND_BINCACHE}"` if [ "${CMD_BOOTSPLASH}" != '' ] then @@ -423,6 +425,13 @@ determine_real_args() { else LVM2=0 fi + + if isTrue "${CMD_SUSPEND}" + then + SUSPEND=1 + else + SUSPEND=0 + fi if isTrue "${CMD_EVMS2}" then diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 182213f..d8474c4 100644 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -173,6 +173,23 @@ create_unionfs_tools_cpio(){ fi } +create_suspend_cpio(){ + if [ -d "${TEMP}/initramfs-suspend-temp" ]; + then + rm -r "${TEMP}/initramfs-suspend-temp/" + fi + print_info 1 'SUSPEND: Adding support (compiling binaries)...' + compile_suspend + mkdir -p "${TEMP}/initramfs-suspend-temp/" + /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" || + gen_die "Could not extract suspend binary cache!" + mkdir -p "${TEMP}/initramfs-suspend-temp/etc" + cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" || + gen_die 'Could not copy /etc/suspend.conf' + cd "${TEMP}/initramfs-suspend-temp/" + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-suspend-${SUSPEND_VER}.cpio.gz +} + create_dmraid_cpio(){ # DMRAID if [ "${DMRAID}" = '1' ] @@ -510,6 +527,10 @@ merge_initramfs_cpio_archives(){ then MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz" fi + if [ "${SUSPEND}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-suspend-${SUSPEND_VER}.cpio.gz" ] + then + MERGE_LIST="${MERGE_LIST} initramfs-suspend-${SUSPEND_VER}.cpio.gz" + fi if [ "${EVMS2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-evms2.cpio.gz" @@ -616,6 +637,12 @@ create_initramfs() { print_info 1 " >> Creating unionfs tools cpio archive..." create_unionfs_tools_cpio fi + + if [ "${SUSPEND}" -eq '1' ] + then + print_info 1 " >> Creating suspend cpio archive..." + create_suspend_cpio + fi if [ "${LVM2}" -eq '1' ] then diff --git a/gen_initrd.sh b/gen_initrd.sh index df2c4dc..575586b 100644 --- a/gen_initrd.sh +++ b/gen_initrd.sh @@ -117,12 +117,12 @@ create_base_initrd_sys() { # /bin/tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initrd-temp" || gen_die 'Could not extract udev binary cache!' # if [ ! -e "${TEMP}/initrd-temp/bin/udevstart" ] # then -# ln -sf "./udev" "${TEMP}/initrd-temp/bin/udevstart" || gen_die 'Could not symlink udev -> udevstart!' +# ln -sf "./udev" "${TEMP}/initrd-temp/bin/udevstart" || gen_die 'Could not symlink udev -> udevstart!' # fi # if [ ! -e "${TEMP}/initrd-temp/bin/udevsend" ] # then -# ln -sf "./udev" "${TEMP}/initrd-temp/bin/udevsend" || gen_die 'Could not symlink udev -> udevsend!' +# ln -sf "./udev" "${TEMP}/initrd-temp/bin/udevsend" || gen_die 'Could not symlink udev -> udevsend!' # fi # fi @@ -144,6 +144,17 @@ create_base_initrd_sys() { gen_die "Could not extract unionfs tools binary cache!"; fi + # Suspend + if [ "${SUSPEND}" = '1' ] + then + print_info 1 'SUSPEND: Adding support (compiling binaries)...' + compile_suspend + /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initrd-temp" || + gen_die "Could not extract suspend binary cache!" + mkdir -p "${TEMP}/initrd-temp/etc" + cp -f /etc/suspend.conf "${TEMP}/initrd-temp/etc" || + gen_die 'Could not copy /etc/suspend.conf' + fi # DMRAID if [ "${DMRAID}" = '1' ] diff --git a/generic/initrd.scripts b/generic/initrd.scripts index 672d61e..8965a4a 100644 --- a/generic/initrd.scripts +++ b/generic/initrd.scripts @@ -743,6 +743,18 @@ setup_unionfs() { fi } +suspend_resume() { + [ -x /sbin/resume ] || return 0 + /sbin/resume + local ret=$? + + if [ "${ret}" -eq 0 ]; then + exit 0 + fi + + return 0 +} + suspend2_resume() { if [ -d /proc/suspend2 ] || [ -d /sys/power/suspend2 ]; then local splash_theme diff --git a/generic/linuxrc b/generic/linuxrc index e647b2e..b5c1d7b 100644 --- a/generic/linuxrc +++ b/generic/linuxrc @@ -250,6 +250,7 @@ fi # Run debug shell if requested rundebugshell +suspend_resume suspend2_resume if [ "${CDROOT}" -eq '1' ] diff --git a/genkernel.8 b/genkernel.8 index 298d24e..c55205b 100644 --- a/genkernel.8 +++ b/genkernel.8 @@ -186,6 +186,13 @@ Add in LVM2 support from static binaries if they exist on the system, or compile static LVM2 binaries if static ones do not exist. .RE .TP +\fB\-\-suspend\fR +.RS +Add support for userspace suspend/resume (uswsusp). This option requires +Linux 2.6.17 or newer, \fBsys-power/suspend\fR installed on the host system, +and resume configured in \fB/etc/suspend.conf\fR. +.RE +.TP \fB\-\-no-udev\fR Force devfs on 2.6 series kernels. Not recommended or supported. .TP diff --git a/genkernel.conf b/genkernel.conf index eebb1c0..ec42e09 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -142,3 +142,9 @@ E2FSPROGS_VER="VERSION_E2FSPROGS" E2FSPROGS_DIR="e2fsprogs-${E2FSPROGS_VER}" E2FSPROGS_SRCTAR="${GK_SHARE}/pkg/e2fsprogs-${E2FSPROGS_VER}.tar.gz" BLKID_BINCACHE="%%CACHE%%/blkid-${E2FSPROGS_VER}-%%ARCH%%.bz2" + +SUSPEND_VER="VERSION_SUSPEND" +SUSPEND_DIR="suspend-${SUSPEND_VER}" +SUSPEND_SRCTAR="${GK_SHARE}/pkg/suspend-${SUSPEND_VER}.tar.gz" +SUSPEND_BINCACHE="%%CACHE%%/suspend-${SUSPEND_VER}-%%ARCH%%.tar.bz2" +