From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-827923-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id AA623139737
	for <garchives@archives.gentoo.org>; Tue, 11 Aug 2015 18:38:03 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3B66C14220;
	Tue, 11 Aug 2015 18:37:59 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id D337CE087D
	for <gentoo-commits@lists.gentoo.org>; Tue, 11 Aug 2015 18:37:57 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 82C1F340D3C
	for <gentoo-commits@lists.gentoo.org>; Tue, 11 Aug 2015 18:37:56 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id D8817155
	for <gentoo-commits@lists.gentoo.org>; Tue, 11 Aug 2015 18:37:52 +0000 (UTC)
From: "Richard Farina" <zerochaos@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Richard Farina" <zerochaos@gentoo.org>
Message-ID: <1439317275.eee5452c2e3d6211a77699bc1e687fe41a5f5924.zerochaos@gentoo>
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
X-VCS-Repository: proj/genkernel
X-VCS-Files: defaults/linuxrc
X-VCS-Directories: defaults/
X-VCS-Committer: zerochaos
X-VCS-Committer-Name: Richard Farina
X-VCS-Revision: eee5452c2e3d6211a77699bc1e687fe41a5f5924
X-VCS-Branch: master
Date: Tue, 11 Aug 2015 18:37:52 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: aa9a927b-2ce7-45aa-8f34-80a89a8b2a78
X-Archives-Hash: bc2717e5dcdfb16aa6689bf0856c38ed

commit:     eee5452c2e3d6211a77699bc1e687fe41a5f5924
Author:     Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
AuthorDate: Mon Jun  2 15:19:23 2014 +0000
Commit:     Richard Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Tue Aug 11 18:21:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=eee5452c

This improves the way we handle RC_NO_UMOUNT variable in openrc so that
future changes can scale and fixes previous bugs which didn't actually
remove duplicates.

 defaults/linuxrc | 43 +++++++++++++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 42749d6..86b1954 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -816,24 +816,39 @@ then
 
                 # RC_NO_UMOUNTS variable for a clean shutdown/reboot
                 RC_MOUNTS=$(grep 'RC_NO_UMOUNTS' "${CHROOT}"/etc/rc.conf)
-                RESULTS=false
 
                 # Iterate through ${RC_MOUNTS} to find our duplicate(s) and or remove obsolete lines when ever
                 # our RC_NO_UMOUNTS variable changes.
-                printf '%s\n' ${RC_MOUNTS} | while read -r mount; do
-                        if [[ "${mount}" = "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"" ]]; then
-                                RESULTS=true
-                        else
-                                # Escape characters in ${mounts} for use in sed 
-                                mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
-
-                                # Remove non matching pattern
-                                sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
-                        fi
-                done
+                if [ -n "${RC_MOUNTS}" ]; then
+                        printf '%s\n' ${RC_MOUNTS} |
+                                {
+                                        while read -r mount; do
+                                                # Remove double quotes from ${mount}
+                                                new_mount=$(echo ${mount} | sed 's/"//g')
+
+                                                if [[ "${new_mount}" = "RC_NO_UMOUNTS="${RC_NO_UMOUNTS}"" ]]; then
+                                                        RESULTS=false
+                                                else
+                                                        # Escape characters in ${mounts} for use in sed
+                                                        mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
+
+                                                        # Remove non matching pattern
+                                                        sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
+
+                                                        RESULTS=true
+                                                fi
+                                        done
+
+                                        # no RC_NO_UMOUNTS match found
+                                        if ${RESULTS}; then return 1;fi
+                                }
+                else
+                        echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
+                fi
 
-                if ! ${RESULTS}; then
-                        echo 'RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/overlay|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"'>> "${CHROOT}"/etc/rc.conf
+                # An RC_NO_UMOUNTS was not found that matches our current one
+                if [ $? -eq 1 ]; then
+                        echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
                 fi
 
                 # Fstab change for aufs