aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Reyes (likewhoa) <design@missionaccomplish.com>2014-06-02 17:19:23 +0200
committerRick Farina (Zero_Chaos) <zerochaos@gentoo.org>2015-08-11 14:21:15 -0400
commiteee5452c2e3d6211a77699bc1e687fe41a5f5924 (patch)
treed8c59f517602dcaf718c323f18310b03c728c02f /defaults/linuxrc
parentcoding style changes (diff)
downloadgenkernel-eee5452c2e3d6211a77699bc1e687fe41a5f5924.tar.gz
genkernel-eee5452c2e3d6211a77699bc1e687fe41a5f5924.tar.bz2
genkernel-eee5452c2e3d6211a77699bc1e687fe41a5f5924.zip
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.
Diffstat (limited to 'defaults/linuxrc')
-rw-r--r--defaults/linuxrc43
1 files changed, 29 insertions, 14 deletions
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 42749d6f..86b1954e 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