commit 7a10446edd4e0afee06312d8f9daeacbd0282ae4
Author: mis <[email protected]>
Date:   Thu Mar 26 23:33:41 2020 +0100

    - swsusp as separate geninird module

 geninitrd-swsusp.patch | 151 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 131 insertions(+), 20 deletions(-)
---
diff --git a/geninitrd-swsusp.patch b/geninitrd-swsusp.patch
index f34e909..91ee5f6 100644
--- a/geninitrd-swsusp.patch
+++ b/geninitrd-swsusp.patch
@@ -1,24 +1,135 @@
---- geninitrd-12757/geninitrd.orig     2020-03-21 03:33:05.923455652 +0100
-+++ geninitrd-12757/geninitrd  2020-03-21 04:48:42.054252108 +0100
-@@ -1613,6 +1613,10 @@
-               if [ "${arg##init=}" != "${arg}" ]; then
-                       INIT=${arg##init=}
-               fi
-+              # if resume param starts with /dev/ then trigger swsups with it
-+              if [ "${arg##resume=/dev/}" != "${arg}" ]; then
-+                      RESUME=${arg##resume=}
-+              fi
-       done
-
-       # handling of invalid, rootfsflags, option
-@@ -1708,6 +1712,10 @@
+diff --git a/Makefile b/Makefile
+index 1994b97..a9039b1 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # when making release, make sure you do it as RELEASE document describes
+ NAME          := geninitrd
+ VERSION               := $(shell test -d .git && git describe --tags || echo 
git)
+-MODS          := ide luks multipath dmraid lvm md blkid udev tuxonice suspend 
fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
++MODS          := ide luks multipath dmraid lvm md blkid udev tuxonice suspend 
swsusp fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
+ FILES_MODS  := $(MODS:%=mod-%.sh)
+ FILES_ADDON := extract-ikconfig
+ FILES_UDEV  := 01-ignore.rules 59-persistent-storage.rules 
61-persistent-storage.rules 11-dm.rules
+diff --git a/geninitrd b/geninitrd
+index 7f5495f..ea7d438 100755
+--- a/geninitrd
++++ b/geninitrd
+@@ -1209,7 +1209,7 @@ if [ ! -f /proc/mounts ]; then
+       warn "/proc filesystem not mounted, may cause wrong results or failure."
+ fi
+ 
+-geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice 
suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd bcache
++geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev swsusp 
tuxonice suspend fbsplash condecor bootsplash uvesafb nfs sata scsi usbkbd 
bcache
+ 
+ while [ $# -gt 0 ]; do
+       case $1 in
+@@ -1245,6 +1245,9 @@ while [ $# -gt 0 ]; do
+       --without-fbcondecor)
+               FB_CON_DECOR=no
+               ;;
++      --without-swsusp)
++              USE_SWSUSP=no
++              ;;
+       --with-suspend)
+               USE_SUSPEND=yes
+               ;;
+@@ -1508,6 +1511,10 @@ if is_yes "$USE_SUSPEND"; then
+       find_modules_suspend
+ fi
+ 
++if is_yes "$USE_SWSUSP"; then
++      find_modules_swsusp
++fi
++
+ find_root "$fstab" || exit
+ verbose "Using $rootdev as device for rootfs"
+ 
+@@ -1703,6 +1710,7 @@ initrd_gen_stop_uvesafb
+ # resume after killing local processes
  initrd_gen_tuxonice
  initrd_gen_suspend
-
-+add_linuxrc <<-'EOF'
-+[ -n "$RESUME" ] && echo "$RESUME" > /sys/power/resume
-+EOF
-+
++initrd_gen_swsusp
+ 
  # clean up env
  add_linuxrc <<-'EOF'
- if [ ! "$DEBUGINITRD" ]; then
+diff --git a/mod-swsusp.sh b/mod-swsusp.sh
+new file mode 100644
+index 0000000..d6ade58
+--- /dev/null
++++ b/mod-swsusp.sh
+@@ -0,0 +1,74 @@
++#!/bin/sh
++# geninitrd mod: swsusp
++#
++USE_SWSUSP=${USE_SWSUSP:-yes}
++
++# resume device
++swap_dev=""
++
++# setup geninitrd module
++# @access     public
++setup_mod_swsusp() {
++      if ! is_yes "$USE_SWSUSP"; then
++              return
++      fi
++
++      swap_dev="$(awk '/^\/dev\// { print $1 }' /proc/swaps | head -1)"
++      if [ -z "$swap_dev" ]; then
++          warn "Cannot determine swap device. You may try add specific device 
to kernel command line"
++      else
++          verbose "swsusp: will try to resume from swap device $swap_dev"
++      fi
++}
++
++# find modules for for swsusp
++# @access     public
++find_modules_swsusp() {
++      swap_dev="$(awk '/^\/dev\// { print $1 }' /proc/swaps | head -1)"
++
++      # save state
++      local vgvolumes=$LVM_VGVOLUMES
++      find_modules_for_devpath $swap_dev
++
++      # check for saved state, differenciate between rootfs VG
++      if [ "$LVM_VGVOLUMES" != "$vgvolumes" ]; then
++              # add swap device to LVM_SUSPENDVG
++              LVM_SUSPENDVG="$LVM_SUSPENDVG $LVM_VGVOLUMES"
++              LVM_VGVOLUMES=$vgvolumes
++              verbose "swap device is on LVM"
++      fi
++}
++
++# generate initrd fragment
++# @access     public
++initrd_gen_swsusp() {
++      if ! is_yes "$USE_SWSUSP"; then
++              return
++      fi
++
++      verbose "Setting up swsusp..."
++
++      mkdir -p $DESTDIR${swap_dev%/*}
++      inst $swap_dev $swap_dev
++
++        mount_dev
++      mount_sys
++        echo "swap_dev=$swap_dev" | add_linuxrc
++
++      add_linuxrc <<-'EOF'
++      resume=no
++      for arg in $CMDLINE; do
++              if [ "${arg##resume=/dev/}" != "${arg}" ]; then
++                      swap_dev=${arg##resume=}
++                      resume=yes
++              elif [ "${arg##resume=}" != "${arg}" ]; then
++                      resume=${arg##resume=}
++              fi
++      done
++
++      if [ "$resume" = "yes" ] && [ -n "$swap_dev" ]; then
++              echo "Resuming from $swap_dev..."
++              echo "$swap_dev" > /sys/power/resume
++      fi
++      EOF
++}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/geninitrd.git/commitdiff/7a10446edd4e0afee06312d8f9daeacbd0282ae4

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to