From 87302487d20bda52735031bf8f53fa57c2e33a03 Mon Sep 17 00:00:00 2001
From: William Hubbs <williamh@gentoo.org>
Date: Sun, 6 Mar 2011 11:50:06 -0600
Subject: [PATCH] savecache should not fail if we are shutting down

Since mount-ro needs to run unconditionally, we need to have savecache
report that it ran successfully when the system is shutting down.

X-Gentoo-Bug: 356393
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=356393
---
 init.d/savecache.in | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/init.d/savecache.in b/init.d/savecache.in
index 2c981c65..d2d51b82 100644
--- a/init.d/savecache.in
+++ b/init.d/savecache.in
@@ -8,17 +8,22 @@ start()
 {
 	if [ -e "$RC_SVCDIR"/clock-skewed ]; then
 		ewarn "WARNING: clock skew detected!"
-		if ! yesno "savecache_skewed"; then
+		if ! yesno "${RC_GOINGDOWN}"; then
 			eerror "Not saving deptree cache"
 			return 1
 		fi
 	fi
 	ebegin "Saving dependency cache"
+	local rc=
 	if [ ! -d "$RC_LIBEXECDIR"/cache ]; then
 		rm -rf "$RC_LIBEXECDIR"/cache
 		if ! mkdir "$RC_LIBEXECDIR"/cache; then
-			eend $?
-			return $?
+			rc=$?
+			if yesno "${RC_GOINGDOWN}"; then
+				rc=0
+			fi
+			eend $rc
+			return $rc
 		fi
 	fi
 	local save=
@@ -28,5 +33,9 @@ start()
 	if [ -n "$save" ]; then
 		cp -p $save "$RC_LIBEXECDIR"/cache 2>/dev/null
 	fi
-	eend $?
+	rc=$?
+	if yesno "${RC_GOINGDOWN}"; then
+		rc=0
+	fi
+	eend $rc
 }