SHA256
1
0
forked from pool/systemd

Accepting request 227461 from home:tsaupe:branches:Base:System

add feature 316824 and address bug 869142

OBS-URL: https://build.opensuse.org/request/show/227461
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=573
This commit is contained in:
Dr. Werner Fink 2014-03-25 13:47:22 +00:00 committed by Git OBS Bridge
parent da5ebdb2e3
commit 35f3cd2dab
7 changed files with 265 additions and 100 deletions

View File

@ -1,94 +0,0 @@
From: Frederic Crozat <fcrozat@suse.com>
Date: Tue, 19 Feb 2013 11:20:31 +0100
Subject: Forward suspend / hibernate calls to pm-utils
forward suspend/hibernation calls to pm-utils, if installed (bnc#790157)
---
src/sleep/sleep.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
--- systemd-206.orig/src/sleep/sleep.c
+++ systemd-206/src/sleep/sleep.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <getopt.h>
+#include <stdlib.h>
#include "systemd/sd-id128.h"
#include "systemd/sd-messages.h"
@@ -35,6 +36,8 @@
#include "sleep-config.h"
static char* arg_verb = NULL;
+static bool delegate_to_pmutils = false;
+static const char *pmtools;
static int write_mode(char **modes) {
int r = 0;
@@ -50,9 +53,6 @@ static int write_mode(char **modes) {
r = k;
}
- if (r < 0)
- log_error("Failed to write mode to /sys/power/disk: %s",
- strerror(-r));
return r;
}
@@ -90,6 +90,8 @@ static int execute(char **modes, char **
_cleanup_fclose_ FILE *f = NULL;
const char* note = strappenda("SLEEP=", arg_verb);
+ if (!delegate_to_pmutils) {
+
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
f = fopen("/sys/power/state", "we");
@@ -102,6 +104,7 @@ static int execute(char **modes, char **
r = write_mode(modes);
if (r < 0)
return r;
+ }
arguments[0] = NULL;
arguments[1] = (char*) "pre";
@@ -114,8 +117,10 @@ static int execute(char **modes, char **
"MESSAGE=Suspending system...",
note,
NULL);
-
+ if (!delegate_to_pmutils)
r = write_state(&f, states);
+ else
+ r = -system(pmtools);
if (r < 0)
return r;
@@ -158,6 +163,7 @@ static int parse_argv(int argc, char *ar
};
int c;
+ struct stat buf;
assert(argc >= 0);
assert(argv);
@@ -196,6 +202,18 @@ static int parse_argv(int argc, char *ar
return -EINVAL;
}
+ if (streq(arg_verb, "suspend")) {
+ pmtools = "/usr/sbin/pm-suspend";
+ }
+ else if (streq(arg_verb, "hibernate") || streq(arg_verb, "hybrid-sleep")) {
+ if (streq(arg_verb, "hibernate"))
+ pmtools = "/usr/sbin/pm-hibernate";
+ else
+ pmtools = "/usr/sbin/pm-suspend-hybrid";
+ }
+
+ delegate_to_pmutils = (stat(pmtools, &buf) >= 0 && S_ISREG(buf.st_mode) && (buf.st_mode & 0111));
+
return 1 /* work to do */;
}

12
boot-local-start.patch Normal file
View File

@ -0,0 +1,12 @@
diff -Naur systemd-210/units/rc-local.service.in systemd-210-mod/units/rc-local.service.in
--- systemd-210/units/rc-local.service.in 2013-08-13 22:02:52.788756123 +0200
+++ systemd-210-mod/units/rc-local.service.in 2014-03-25 08:34:40.317587764 +0100
@@ -10,7 +10,7 @@
[Unit]
Description=@RC_LOCAL_SCRIPT_PATH_START@ Compatibility
ConditionFileIsExecutable=@RC_LOCAL_SCRIPT_PATH_START@
-After=network.target
+After=basic.target
[Service]
Type=forking

View File

@ -0,0 +1,28 @@
diff -Naur systemd-210/units/systemd-hibernate.service.in systemd-210-mod/units/systemd-hibernate.service.in
--- systemd-210/units/systemd-hibernate.service.in 2013-08-13 22:02:52.808756274 +0200
+++ systemd-210-mod/units/systemd-hibernate.service.in 2014-03-25 12:27:44.995995220 +0100
@@ -11,7 +11,10 @@
DefaultDependencies=no
Requires=sleep.target
After=sleep.target
+ConditionKernelCommandLine=resume
[Service]
Type=oneshot
+ExecStart=@rootbindir@/systemd-sleep-grub pre
ExecStart=@rootlibexecdir@/systemd-sleep hibernate
+ExecStopPost=@rootbindir@/systemd-sleep-grub post
diff -Naur systemd-210/units/systemd-hybrid-sleep.service.in systemd-210-mod/units/systemd-hybrid-sleep.service.in
--- systemd-210/units/systemd-hybrid-sleep.service.in 2013-08-13 22:02:52.809756282 +0200
+++ systemd-210-mod/units/systemd-hybrid-sleep.service.in 2014-03-25 12:27:56.115994902 +0100
@@ -11,7 +11,10 @@
DefaultDependencies=no
Requires=sleep.target
After=sleep.target
+ConditionKernelCommandLine=resume
[Service]
Type=oneshot
+ExecStart=@rootbindir@/systemd-sleep-grub pre
ExecStart=@rootlibexecdir@/systemd-sleep hybrid-sleep
+ExecStopPost=@rootbindir@/systemd-sleep-grub post

View File

@ -202,8 +202,6 @@ Patch42: systemd-pam_config.patch
Patch23: disable-nss-myhostname-warning-bnc-783841.patch
# PATCH-FIX-OPENSUSE handle-HOSTNAME.patch fcrozat@suse.com -- handle /etc/HOSTNAME (bnc#803653)
Patch24: handle-etc-HOSTNAME.patch
# PATCH-FIX-OPENSUSE Forward-suspend-hibernate-calls-to-pm-utils.patch fcrozat@suse.com bnc#790157 -- forward to pm-utils
Patch25: Forward-suspend-hibernate-calls-to-pm-utils.patch
# PATCH-FIX-UPSTREAM rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch rjschwei@suse.com -- add lid switch of ARM based Chromebook as a power switch to logind
Patch38: rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch
# PATCH-FIX-OPENSUSE use-usr-sbin-sulogin-for-emergency-service.patch arvidjaar@gmail.com -- fix path to sulogin
@ -586,7 +584,6 @@ cp %{SOURCE7} m4/
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
# check if this is still needed, or can be derived from fbdev uaccess rule
# http://lists.freedesktop.org/archives/systemd-devel/2012-November/007561.html
%patch27 -p1

204
systemd-sleep-grub Normal file
View File

@ -0,0 +1,204 @@
#!/bin/bash
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
set -x
prepare-parameters()
{
eval `grep LOADER_TYPE= /etc/sysconfig/bootloader`
if [ x"$LOADER_TYPE" = "xgrub2" -o x"$LOADER_TYPE" = "xgrub2-efi" ]; then
GRUBONCE="/usr/sbin/grub2-once"
GRUBDEFAULT="/boot/grub2/grubenv"
GRUB2EDITENV="/usr/bin/grub2-editenv"
GRUB2CONF="/boot/grub2/grub.cfg"
BLKID="/usr/sbin/blkid"
getkernels="getkernels-grub2"
fi
}
#####################################################################
# gets a list of available kernels from /boot/grub2/grub.cfg
# kernels are in the array $KERNELS, output to stdout to be eval-ed.
getkernels-grub2()
{
local I DUMMY MNT ROOTDEV
declare -i I=0 J=-1
# we need the root partition later to decide if this is the kernel to select
while read ROOTDEV MNT DUMMY; do
[ "$ROOTDEV" = "rootfs" ] && continue # not what we are searching for
if [ "$MNT" = "/" ]; then
break
fi
done < /proc/mounts
while read LINE; do
case $LINE in
menuentry\ *)
let J++
;;
set\ default*)
local DEFAULT=${LINE#*default=}
if echo $DEFAULT | grep -q saved_entry ; then
local SAVED=`$GRUB2EDITENV $GRUBDEFAULT list | sed -n s/^saved_entry=//p`
if [ -n "$SAVED" ]; then
DEFAULT_BOOT=$($GRUBONCE --show-mapped "$SAVED")
fi
fi
;;
linux*noresume*)
echo " Skipping grub entry #${J}, because it has the noresume option" >&2
;;
linux*root=*)
local ROOT
ROOT=${LINE#*root=}
DUMMY=($ROOT)
ROOT=${DUMMY[0]}
if [ x"${ROOT:0:5}" = "xUUID=" ]; then
UUID=${ROOT#UUID=}
if [ -n "$UUID" ]; then
ROOT=$($BLKID -U $UUID)
fi
fi
if [ "$(stat -Lc '%t:%T' $ROOT)" != "$(stat -Lc '%t:%T' $ROOTDEV)" ]; then
echo " Skipping grub entry #${J}, because its root= parameter ($ROOT)" >&2
echo " does not match the current root device ($ROOTDEV)." >&2
continue
fi
DUMMY=($LINE) # kernel (hd0,1)/boot/vmlinuz-ABC root=/dev/hda2
echo "KERNELS[$I]='${DUMMY[1]##*/}'" # vmlinuz-ABC
echo "MENU_ENTRIES[$I]=$J"
# DEBUG "Found kernel entry #${I}: '${DUMMY[1]##*/}'" INFO
let I++
;;
linux*)
# a kernel without "root="? We better skip that one...
echo " Skipping grub entry #${J}, because it has no root= option" >&2
;;
*) ;;
esac
done < "$GRUB2CONF"
}
#############################################################
# runs grubonce from the grub package to select which kernel
# to boot on next startup
grub-once()
{
if [ -x "$GRUBONCE" ]; then
echo " running '$GRUBONCE $1'"
$GRUBONCE $1
else
echo "WARNING: $GRUBONCE not found, not preparing bootloader"
fi
}
#############################################################
# restore grub default after (eventually failed) resume
grub-once-restore()
{
echo "INFO: running grub-once-restore"
prepare-parameters
$GRUB2EDITENV $GRUBDEFAULT unset next_entry
}
#############################################################################
# try to find a kernel image that matches the actually running kernel.
# We need this, if more than one kernel is installed. This works reasonably
# well with grub, if all kernels are named "vmlinuz-`uname -r`" and are
# located in /boot. If they are not, good luck ;-)
find-kernel-entry()
{
NEXT_BOOT=-1
ARCH=`uname -m`
declare -i I=0
# DEBUG "running kernel: $RUNNING" DIAG
while [ -n "${KERNELS[$I]}" ]; do
BOOTING="${KERNELS[$I]}"
if IMAGE=`readlink /boot/$BOOTING` && [ -e "/boot/${IMAGE##*/}" ]; then
# DEBUG "Found kernel symlink $BOOTING => $IMAGE" INFO
BOOTING=$IMAGE
fi
case $ARCH in
ppc*) BOOTING="${BOOTING#*vmlinux-}" ;;
*) BOOTING="${BOOTING#*vmlinuz-}" ;;
esac
if [ "$RUNNING" == "$BOOTING" ]; then
NEXT_BOOT=${MENU_ENTRIES[$I]}
echo " running kernel is grub menu entry $NEXT_BOOT (${KERNELS[$I]})"
break
fi
let I++
done
# if we have not found a kernel, issue a warning.
# if we have found a kernel, we'll do "grub-once" later, after
# prepare_suspend finished.
if [ $NEXT_BOOT -eq -1 ]; then
echo "WARNING: no kernelfile matching the running kernel found"
fi
}
#############################################################################
# if we did not find a kernel (or BOOT_LOADER is not GRUB) check,
# if the running kernel is still the one that will (probably) be booted for
# resume (default entry in menu.lst or, if there is none, the kernel file
# /boot/vmlinuz points to.)
# This will only work, if you use "original" SUSE kernels.
# you can always override with the config variable set to "yes"
prepare-grub()
{
echo "INFO: running prepare-grub"
prepare-parameters
eval `$getkernels`
RUNNING=`uname -r`
find-kernel-entry
RET=0
if [ $NEXT_BOOT -eq -1 ]; then
# which kernel is booted with the default entry?
BOOTING="${KERNELS[$DEFAULT_BOOT]}"
# if there is no default entry (no menu.lst?) we fall back to
# the default of /boot/vmlinuz.
[ -z "$BOOTING" ] && BOOTING="vmlinuz"
if IMAGE=`readlink /boot/$BOOTING` && [ -e "/boot/${IMAGE##*/}" ]; then
BOOTING=$IMAGE
fi
BOOTING="${BOOTING#*vmlinuz-}"
echo "running kernel: '$RUNNING', probably booting kernel: '$BOOTING'"
if [ "$BOOTING" != "$RUNNING" ]; then
echo "ERROR: kernel version mismatch, cannot suspend to disk"
echo "running: $RUNNING booting: $BOOTING" >> $INHIBIT
RET=1
fi
else
# set the bootloader to the running kernel
echo " preparing boot-loader: selecting entry $NEXT_BOOT, kernel /boot/$BOOTING"
T1=`date +"%s%N"`
sync; sync; sync # this is needed to speed up grub-once on reiserfs
T2=`date +"%s%N"`
echo " grub-once: `grub-once $NEXT_BOOT`"
T3=`date +"%s%N"`
S=$(((T2-T1)/100000000)); S="$((S/10)).${S:0-1}"
G=$(((T3-T2)/100000000)); G="$((G/10)).${G:0-1}"
echo " time needed for sync: $S seconds, time needed for grub: $G seconds."
fi
return $RET
}
###### main()
if [ "$1" = pre ] ; then
prepare-grub
fi
if [ "$1" = post ] ; then
grub-once-restore
fi

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Tue Mar 25 13:08:56 UTC 2014 - thomas.blume@suse.com
- add prepare-suspend-to-disk.patch
enable suspend conditions check and preparation for systemd-sleep
(fate#316824, bnc#856389, bnc#856392)
- remove Forward-suspend-hibernate-calls-to-pm-utils.patch since it is obsolete
(bnc#856392#c20)
- add boot-local-start.patch
fix startup for /etc/init.d/boot.local (bnc#869142)
-------------------------------------------------------------------
Mon Mar 24 11:19:38 UTC 2014 - coolo@suse.com

View File

@ -145,6 +145,7 @@ Source1060: boot.udev
Source1061: write_dev_root_rule
Source1062: systemd-udev-root-symlink
Source1063: udev-generate-peristent-rule.sh
Source1064: systemd-sleep-grub
#
# PATCH-FIX-UPSTREAM avoid-assertion-if-invalid-address-familily-is-passed-to-g.patch lnussel@suse.com bnc#791101 -- avoid assertion if invalid address familily is passed to gethostbyaddr_r
@ -197,8 +198,6 @@ Patch42: systemd-pam_config.patch
Patch23: disable-nss-myhostname-warning-bnc-783841.patch
# PATCH-FIX-OPENSUSE handle-HOSTNAME.patch fcrozat@suse.com -- handle /etc/HOSTNAME (bnc#803653)
Patch24: handle-etc-HOSTNAME.patch
# PATCH-FIX-OPENSUSE Forward-suspend-hibernate-calls-to-pm-utils.patch fcrozat@suse.com bnc#790157 -- forward to pm-utils
Patch25: Forward-suspend-hibernate-calls-to-pm-utils.patch
# PATCH-FIX-UPSTREAM rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch rjschwei@suse.com -- add lid switch of ARM based Chromebook as a power switch to logind
Patch38: rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch
# PATCH-FIX-OPENSUSE use-usr-sbin-sulogin-for-emergency-service.patch arvidjaar@gmail.com -- fix path to sulogin
@ -325,6 +324,11 @@ Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch
Patch1023: systemd-powerd-initctl-support.patch
# PATCH-FIX-SUSE systemctl-set-default-target.patch
Patch1024: systemctl-set-default-target.patch
# PATCH-FIX-SUSE prepare-suspend-to-disk.patch (fate #316824)
Patch1025: prepare-suspend-to-disk.patch
# PATCH-FIX-SUSE boot-local-start.patch (bnc #869142)
Patch1026: boot-local-start.patch
# PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch
Patch1999: systemd-install-compat_pkgconfig-always.patch
# PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run
@ -581,7 +585,6 @@ cp %{SOURCE7} m4/
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
# check if this is still needed, or can be derived from fbdev uaccess rule
# http://lists.freedesktop.org/archives/systemd-devel/2012-November/007561.html
%patch27 -p1
@ -657,6 +660,8 @@ cp %{SOURCE7} m4/
%patch1022 -p1
%patch1023 -p1
%patch1024 -p1
%patch1025 -p1
%patch1026 -p1
%patch1999 -p1
%patch2000 -p1
%patch2001 -p1
@ -771,6 +776,7 @@ install -m755 -D %{S:1061} %{buildroot}/%{_prefix}/lib/udev/write_dev_root_rule
sed -ie "s|@@PREFIX@@|%{_prefix}/lib/udev|g" %{S:1062}
install -m644 -D %{S:1062} %{buildroot}/%{_prefix}/lib/systemd/system/systemd-udev-root-symlink.service
install -m755 -D %{S:1063} %{buildroot}/%{_prefix}/lib/udev/udev-generate-peristent-rule
install -m755 -D %{S:1064} %{buildroot}/%{_bindir}/systemd-sleep-grub
mkdir -p %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants
ln -sf ../systemd-udev-root-symlink.service %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants
rm -rf %{buildroot}%{_sysconfdir}/rpm
@ -1107,6 +1113,7 @@ exit 0
/bin/systemd
/bin/systemd-ask-password
/bin/systemctl
%{_bindir}/systemd-sleep-grub
%{_bindir}/bootctl
%{_bindir}/busctl
%{_bindir}/kernel-install