Gentoo Archives: gentoo-commits

From: Richard Farina <zerochaos@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:aufs commit in: defaults/
Date: Wed, 29 Apr 2015 19:04:16
Message-Id: 1430328705.09cce549319068807b9e1dba7a3ad3160da3f160.zerochaos@gentoo
1 commit: 09cce549319068807b9e1dba7a3ad3160da3f160
2 Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
3 AuthorDate: Mon Jun 2 15:19:23 2014 +0000
4 Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 29 17:31:45 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=09cce549
7
8 This improves the way we handle RC_NO_UMOUNT variable in openrc so that
9 future changes can scale and fixes previous bugs which didn't actually
10 remove duplicates.
11
12 defaults/linuxrc | 43 +++++++++++++++++++++++++++++--------------
13 1 file changed, 29 insertions(+), 14 deletions(-)
14
15 diff --git a/defaults/linuxrc b/defaults/linuxrc
16 index 42749d6..86b1954 100644
17 --- a/defaults/linuxrc
18 +++ b/defaults/linuxrc
19 @@ -816,24 +816,39 @@ then
20
21 # RC_NO_UMOUNTS variable for a clean shutdown/reboot
22 RC_MOUNTS=$(grep 'RC_NO_UMOUNTS' "${CHROOT}"/etc/rc.conf)
23 - RESULTS=false
24
25 # Iterate through ${RC_MOUNTS} to find our duplicate(s) and or remove obsolete lines when ever
26 # our RC_NO_UMOUNTS variable changes.
27 - printf '%s\n' ${RC_MOUNTS} | while read -r mount; do
28 - if [[ "${mount}" = "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"" ]]; then
29 - RESULTS=true
30 - else
31 - # Escape characters in ${mounts} for use in sed
32 - mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
33 -
34 - # Remove non matching pattern
35 - sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
36 - fi
37 - done
38 + if [ -n "${RC_MOUNTS}" ]; then
39 + printf '%s\n' ${RC_MOUNTS} |
40 + {
41 + while read -r mount; do
42 + # Remove double quotes from ${mount}
43 + new_mount=$(echo ${mount} | sed 's/"//g')
44 +
45 + if [[ "${new_mount}" = "RC_NO_UMOUNTS="${RC_NO_UMOUNTS}"" ]]; then
46 + RESULTS=false
47 + else
48 + # Escape characters in ${mounts} for use in sed
49 + mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
50 +
51 + # Remove non matching pattern
52 + sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
53 +
54 + RESULTS=true
55 + fi
56 + done
57 +
58 + # no RC_NO_UMOUNTS match found
59 + if ${RESULTS}; then return 1;fi
60 + }
61 + else
62 + echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
63 + fi
64
65 - if ! ${RESULTS}; then
66 - echo 'RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/overlay|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"'>> "${CHROOT}"/etc/rc.conf
67 + # An RC_NO_UMOUNTS was not found that matches our current one
68 + if [ $? -eq 1 ]; then
69 + echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
70 fi
71
72 # Fstab change for aufs