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