# Copyright 2006-2006 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
+ 13 Dec 2006; Chris Gianelloni <wolf31o2@gentoo.org> 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 <dsd@gentoo.org> in bug #156445 to add
+ userspace suspend support to genkernel.
+
13 Dec 2006; Chris Gianelloni <wolf31o2@gentoo.org> gen_initramfs.sh,
gen_initrd.sh:
Added debug level to LUKS print_info messages for bug #156410.
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=<file> Specifies a user created linuxrc"
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"
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}
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
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.
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
+
}
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}"`
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
else
LVM2=0
fi
+
+ if isTrue "${CMD_SUSPEND}"
+ then
+ SUSPEND=1
+ else
+ SUSPEND=0
+ fi
if isTrue "${CMD_EVMS2}"
then
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' ]
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"
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
# /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
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' ]
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
# Run debug shell if requested
rundebugshell
+suspend_resume
suspend2_resume
if [ "${CDROOT}" -eq '1' ]
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
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"
+