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:15
Message-Id: 1430328705.5a62af115cf85e15fbac4f35d98af2a5bf34d004.zerochaos@gentoo
1 commit: 5a62af115cf85e15fbac4f35d98af2a5bf34d004
2 Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
3 AuthorDate: Fri May 30 00:51:08 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=5a62af11
7
8 Enhanced the shutdown process and changed from using ${UNION} to ${CHROOT} to
9 better understand the logic behind things as CHROOT is set to ${UNION} anyways.
10
11 RC_NO_UMOUNTS is more dynamic now and should scale up.
12
13 defaults/initrd.defaults | 1 +
14 defaults/linuxrc | 45 +++++++++++++++++++++++++++++++--------------
15 2 files changed, 32 insertions(+), 14 deletions(-)
16
17 diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
18 index aa9f85c..9937e00 100755
19 --- a/defaults/initrd.defaults
20 +++ b/defaults/initrd.defaults
21 @@ -58,6 +58,7 @@ KSUFF='.ko'
22 REAL_ROOT=''
23 CONSOLE='/dev/console'
24 NEW_ROOT='/newroot'
25 +RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/overlay|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"
26 CDROOT='0'
27 CDROOT_DEV=''
28 CDROOT_TYPE='auto'
29
30 diff --git a/defaults/linuxrc b/defaults/linuxrc
31 index 0a91c58..5d4d2a1 100644
32 --- a/defaults/linuxrc
33 +++ b/defaults/linuxrc
34 @@ -805,24 +805,38 @@ then
35
36 if [ "${USE_AUFS_NORMAL}" -eq '1' ]
37 then
38 - union_insert_dir ${UNION} ${NEW_ROOT}/${FS_LOCATION}
39 + union_insert_dir ${CHROOT} ${NEW_ROOT}/${FS_LOCATION}
40
41 # Make sure fstab notes livecd is mounted ro. Makes system skip remount which fails on aufs dirs.
42 # TODO: remounting all tmpfs as RO seems weird, can we be more specific?
43 - sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' /${UNION}/etc/fstab > /${UNION}/etc/fstab.new
44 - mv /${UNION}/etc/fstab.new /${UNION}/etc/fstab
45 + #sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' /${UNION}/etc/fstab > /${UNION}/etc/fstab.new
46 + #mv /${UNION}/etc/fstab.new /${UNION}/etc/fstab
47
48 # RC_NO_UMOUNTS variable for a clean shutdown/reboot
49 - test ! $(grep 'RC_NO_UMOUNTS="/newroot|/newroot/mnt/aufs|\
50 -/newroot/mnt/changesdev|/mnt/livecd|/mnt/cdrom|/.unions/\
51 -memory|/.unions/memory/xino"' "${UNION}"/etc/rc.conf) &&
52 - echo "RC_NO_UMOUNTS=\"/newroot|/newroot/mnt/aufs|"\
53 -"/newroot/mnt/changesdev|/mnt/livecd|/mnt/cdrom|"\
54 -"/.unions/memory|/.unions/memory/xino\"">> "${UNION}"/etc/rc.conf
55 + RC_MOUNTS=$(grep 'RC_NO_UMOUNTS' "${CHROOT}"/etc/rc.conf)
56 + RESULTS=false
57 +
58 + # Iterate through ${RC_MOUNTS} to find our duplicate(s) and or remove obsolete lines when ever
59 + # our RC_NO_UMOUNTS variable changes.
60 + printf '%s\n' ${RC_MOUNTS} | while read -r mount; do
61 + if [[ "${mount}" = "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"" ]]; then
62 + RESULTS=true
63 + else
64 + # Escape characters in ${mounts} for use in sed
65 + mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
66 +
67 + # Remove non matching pattern
68 + sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
69 + fi
70 + done
71 +
72 + if ! ${RESULTS}; then
73 + echo 'RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/overlay|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"'>> "${CHROOT}"/etc/rc.conf
74 + fi
75
76 # Fstab change for aufs
77 - test ! $(grep aufs "${UNION}"/etc/fstab) &&
78 - echo "aufs / aufs defaults 0 0" > "${UNION}"/etc/fstab
79 + test ! $(grep -o ^aufs "${CHROOT}"/etc/fstab) &&
80 + echo "aufs / aufs defaults 0 0" > "${CHROOT}"/etc/fstab
81
82 warn_msg "Adding all modules in $MODULESD/modules/"
83 if [ -z "${MODULESD}" ]
84 @@ -834,9 +848,12 @@ memory|/.unions/memory/xino"' "${UNION}"/etc/rc.conf) &&
85 union_insert_modules ${NEW_ROOT}/mnt/modulesd
86 fi
87
88 - mkdir -p "${UNION}"/newroot/mnt/aufs
89 - test ${AUFS_CHANGES} && test ! -d "${UNION}"/newroot/mnt/changesdev &&
90 - mkdir "${UNION}"/newroot/mnt/changesdev
91 + # Create the directories for our new union mounts
92 + test ! -d "${CHROOT}${NEW_ROOT}" && mkdir -p "${CHROOT}${NEW_ROOT}"
93 +
94 + if ${AUFS_CHANGES} && [ ! -d "${CHROOT}${NEW_ROOT}/mnt/changesdev" ]; then
95 + mkdir -p "${CHROOT}${NEW_ROOT}/mnt/changesdev"
96 + fi
97 fi
98
99 # Unpacking additional packages from NFS mount