Added patch from Daniel Drake <dsd@gentoo.org> in bug #156445 to add userspace suspen...
authorChris Gianelloni <wolf31o2@gentoo.org>
Wed, 13 Dec 2006 17:22:29 +0000 (17:22 +0000)
committerChris Gianelloni <wolf31o2@gentoo.org>
Wed, 13 Dec 2006 17:22:29 +0000 (17:22 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@465 67a159dc-881f-0410-a524-ba9dfbe2cb84

ChangeLog
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

index a79091874b05d2c02cb5281397ba2aa2179ac358..115495ec8e0c6e3fab4b859a200d141e04171faf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 # 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.
index 83511898911d928d03d1321c73e819373e0add31..bd61f6ff51a164824e1d4cbd432fa5deeb6125ba 100755 (executable)
@@ -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=<file>        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"
index ac5045f278af3299aa7e9e6824aadf9b0ce43557..8f476421ef5f047ac31fded6ba02d0c9d0038a9a 100644 (file)
@@ -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.
index 5b87283a7877ca9ea23bef2979b16c56a7bf48e1..44ed63054f5b1c0bcd23b162401f6ce3e4c4cd02 100644 (file)
@@ -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
+
 }
index fcafe33f92b89134d2b99b3c7cda08507b847e2c..241e8749273ccdb50c6d8398aeb1a65f52adc7a6 100644 (file)
@@ -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
index 182213f98906e5115bd5998245efe3662a91ee9a..d8474c49839266a268610b4dc5b3420ac2773993 100644 (file)
@@ -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
index df2c4dc4c04a18ccf9d81273c321dd931b3637e2..575586b86b7b6f84595b13c5cf3f630756a6fef1 100644 (file)
@@ -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' ]
index 672d61e68a2b173f185029bacacbe13ffda4d338..8965a4aedcf4aa99a51580c6b72f444ec0ccb0ac 100644 (file)
@@ -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
index e647b2e7b728e91e835ccb3d2cd51715b6501a11..b5c1d7b3a4c032fe23e8fc6a293054161dacc011 100644 (file)
@@ -250,6 +250,7 @@ fi
 # Run debug shell if requested
 rundebugshell
 
+suspend_resume
 suspend2_resume
 
 if [ "${CDROOT}" -eq '1' ]
index 298d24e2eeb22fb8739eedc04f4f9654e218cde7..c55205b0674da1469ab082164d7d9226cedc2de7 100644 (file)
@@ -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
index eebb1c09d742b142cdf16e4fe1ea1e2220a9b5de..ec42e09aed88c60e2de14d5723a6a7ff468a2f5b 100755 (executable)
@@ -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"
+