1 |
commit: c81f01fd8561844a9fc9f9b7a2d8cd2b98910fae |
2 |
Author: Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 7 19:03:29 2017 +0000 |
4 |
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 7 19:03:29 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c81f01fd |
7 |
|
8 |
initialize overlayfs and aufs variables properly, enable unconditionally and warn if checks fail |
9 |
|
10 |
defaults/initrd.defaults | 6 ++ |
11 |
defaults/linuxrc | 239 ++++++++++++++++++++++++----------------------- |
12 |
2 files changed, 129 insertions(+), 116 deletions(-) |
13 |
|
14 |
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults |
15 |
index b028f72..e83f6fe 100755 |
16 |
--- a/defaults/initrd.defaults |
17 |
+++ b/defaults/initrd.defaults |
18 |
@@ -72,9 +72,15 @@ VERIFY=0 |
19 |
|
20 |
# AUFS variables |
21 |
aufs=0 |
22 |
+aufs_detected=0 |
23 |
aufs_union_file=/livecd.aufs |
24 |
aufs_modules_dir=mnt/cdrom |
25 |
|
26 |
+# Overlayfs variables |
27 |
+overlayfs=0 |
28 |
+overlayfs_detected=0 |
29 |
+overlayfs_modules_dir=mnt/cdrom |
30 |
+ |
31 |
LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop' |
32 |
|
33 |
DEFAULT_NFSOPTIONS="ro,nolock,rsize=1024,wsize=1024" |
34 |
|
35 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
36 |
index 6bb1b98..7edf8d5 100644 |
37 |
--- a/defaults/linuxrc |
38 |
+++ b/defaults/linuxrc |
39 |
@@ -256,18 +256,22 @@ do |
40 |
keymap=*) |
41 |
keymap=${x#*=} |
42 |
;; |
43 |
- locale=*) |
44 |
- locale=${x#*=} |
45 |
- ;; |
46 |
- aufs) |
47 |
- if [ -f /proc/config.gz ]; then |
48 |
- zcat /proc/config.gz | grep -E 'CONFIG_AUFS_FS=(m|y)' 1>/dev/null && aufs=1 |
49 |
- else |
50 |
- warn_msg "No CONFIG_IKCONFIG support" |
51 |
- warn_msg "AUFS is not guarantee to work on this medium" |
52 |
- aufs=1 |
53 |
- fi |
54 |
- ;; |
55 |
+ locale=*) |
56 |
+ locale=${x#*=} |
57 |
+ ;; |
58 |
+ aufs) |
59 |
+ aufs=1 |
60 |
+ if [ -f /proc/config.gz ]; then |
61 |
+ if zcat /proc/config.gz | grep -E 'CONFIG_AUFS_FS=(m|y)' 1>/dev/null; |
62 |
+ then |
63 |
+ aufs_detected=1 |
64 |
+ fi |
65 |
+ fi |
66 |
+ if [ "1" != "$aufs_detected" ]; then |
67 |
+ warn_msg "No CONFIG_IKCONFIG support" |
68 |
+ warn_msg "AUFS is not guarantee to work on this medium" |
69 |
+ fi |
70 |
+ ;; |
71 |
aufs\=*) |
72 |
if echo "${x#*=}" | grep , &>/dev/null; then |
73 |
aufs_dev_uid=${x#*,} |
74 |
@@ -281,24 +285,27 @@ do |
75 |
aufs_modules_dir=${x#*=} |
76 |
aufs_modules=1 |
77 |
;; |
78 |
- |
79 |
- overlayfs) |
80 |
- if [ -f /proc/config.gz ]; then |
81 |
- zcat /proc/config.gz | grep -E 'CONFIG_OVERLAY_FS=(m|y)' 1>/dev/null && overlayfs=1 |
82 |
- else |
83 |
- warn_msg "No CONFIG_IKCONFIG support" |
84 |
- warn_msg "OVERLAYFS is not guarantee to work on this medium" |
85 |
- overlayfs=1 |
86 |
- fi |
87 |
- ;; |
88 |
- overlayfs\=*) |
89 |
- if echo "${x#*=}" | grep , &>/dev/null; then |
90 |
- overlayfs_dev_uid=${x#*,} |
91 |
- overlayfs_dev=${x%,*} |
92 |
- else |
93 |
- overlayfs_dev=${x#*=} |
94 |
- fi |
95 |
- ;; |
96 |
+ overlayfs) |
97 |
+ overlayfs=1 |
98 |
+ if [ -f /proc/config.gz ]; then |
99 |
+ if zcat /proc/config.gz | grep -E 'CONFIG_OVERLAY_FS=(m|y)' 1>/dev/null; |
100 |
+ then |
101 |
+ overlayfs_detected=1 |
102 |
+ fi |
103 |
+ fi |
104 |
+ if [ "1" != "$overlayfs_detected" ]; then |
105 |
+ warn_msg "No CONFIG_IKCONFIG support" |
106 |
+ warn_msg "OVERLAYFS is not guarantee to work on this medium" |
107 |
+ fi |
108 |
+ ;; |
109 |
+ overlayfs\=*) |
110 |
+ if echo "${x#*=}" | grep , &>/dev/null; then |
111 |
+ overlayfs_dev_uid=${x#*,} |
112 |
+ overlayfs_dev=${x%,*} |
113 |
+ else |
114 |
+ overlayfs_dev=${x#*=} |
115 |
+ fi |
116 |
+ ;; |
117 |
# Allow user to specify the modules location |
118 |
overlayfs.modules\=*) |
119 |
overlayfs_modules_dir=${x#*=} |
120 |
@@ -877,94 +884,94 @@ FSTAB |
121 |
fi |
122 |
|
123 |
|
124 |
- if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then |
125 |
- setup_unionfs ${NEW_ROOT} /${FS_LOCATION} |
126 |
- CHROOT=/union |
127 |
- elif [ 1 != "$aufs" ] && [ 1 != "$overlayfs" ]; then |
128 |
- good_msg "Copying read-write image contents to tmpfs" |
129 |
- |
130 |
- # Copy over stuff that should be writable |
131 |
- ( |
132 |
- cd "${NEW_ROOT}/${FS_LOCATION}" |
133 |
- cp -a ${ROOT_TREES} "${NEW_ROOT}" |
134 |
- ) || |
135 |
- { |
136 |
- bad_msg "Copying failed, dropping into a shell." |
137 |
- do_rundebugshell |
138 |
- } |
139 |
- |
140 |
- # Now we do the links. |
141 |
- for x in ${ROOT_LINKS}; do |
142 |
- if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]; then |
143 |
- ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null |
144 |
- else |
145 |
- # List all subdirectories of x |
146 |
- find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | |
147 |
- while read directory; do |
148 |
- # Strip the prefix of the FS_LOCATION |
149 |
- directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}" |
150 |
- |
151 |
- # Skip this directory if we already linked a parent directory |
152 |
- if [ "${current_parent}" != '' ]; then |
153 |
- var=$(echo "${directory}" | grep "^${current_parent}") |
154 |
- if [ "${var}" != '' ]; then |
155 |
- continue |
156 |
- fi |
157 |
- fi |
158 |
- # Test if the directory exists already |
159 |
- if [ -e "/${NEW_ROOT}/${directory}" ]; then |
160 |
- # It does exist, link all the individual files |
161 |
- for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory}); do |
162 |
- if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then |
163 |
- ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null |
164 |
- fi |
165 |
- done |
166 |
- else |
167 |
- # It does not exist, make a link to the livecd |
168 |
- ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null |
169 |
- current_parent="${directory}" |
170 |
- fi |
171 |
- done |
172 |
- fi |
173 |
- done |
174 |
- |
175 |
- mkdir -p initramfs proc tmp run sys 2>/dev/null |
176 |
- chmod 1777 tmp |
177 |
- |
178 |
- fi |
179 |
- |
180 |
- # Have handy /mnt/cdrom (CDROOT_PATH) as well |
181 |
- if [ 1 = "$aufs" ]; then |
182 |
- [ ! -d "$CHROOT$CDROOT_PATH" ] && mkdir "$CHROOT$CDROOT_PATH" |
183 |
- mount --move "$CDROOT_PATH" "$CHROOT$CDROOT_PATH" |
184 |
+ if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then |
185 |
+ setup_unionfs ${NEW_ROOT} /${FS_LOCATION} |
186 |
+ CHROOT=/union |
187 |
+ elif [ 1 != "$aufs" ] && [ 1 != "$overlayfs" ]; then |
188 |
+ good_msg "Copying read-write image contents to tmpfs" |
189 |
+ |
190 |
+ # Copy over stuff that should be writable |
191 |
+ ( |
192 |
+ cd "${NEW_ROOT}/${FS_LOCATION}" |
193 |
+ cp -a ${ROOT_TREES} "${NEW_ROOT}" |
194 |
+ ) || |
195 |
+ { |
196 |
+ bad_msg "Copying failed, dropping into a shell." |
197 |
+ do_rundebugshell |
198 |
+ } |
199 |
+ |
200 |
+ # Now we do the links. |
201 |
+ for x in ${ROOT_LINKS}; do |
202 |
+ if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]; then |
203 |
+ ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null |
204 |
else |
205 |
- [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p "$NEW_ROOT$CDROOT_PATH" |
206 |
- mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH" |
207 |
+ # List all subdirectories of x |
208 |
+ find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | |
209 |
+ while read directory; do |
210 |
+ # Strip the prefix of the FS_LOCATION |
211 |
+ directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}" |
212 |
+ |
213 |
+ # Skip this directory if we already linked a parent directory |
214 |
+ if [ "${current_parent}" != '' ]; then |
215 |
+ var=$(echo "${directory}" | grep "^${current_parent}") |
216 |
+ if [ "${var}" != '' ]; then |
217 |
+ continue |
218 |
+ fi |
219 |
+ fi |
220 |
+ # Test if the directory exists already |
221 |
+ if [ -e "/${NEW_ROOT}/${directory}" ]; then |
222 |
+ # It does exist, link all the individual files |
223 |
+ for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory}); do |
224 |
+ if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then |
225 |
+ ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null |
226 |
+ fi |
227 |
+ done |
228 |
+ else |
229 |
+ # It does not exist, make a link to the livecd |
230 |
+ ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null |
231 |
+ current_parent="${directory}" |
232 |
+ fi |
233 |
+ done |
234 |
fi |
235 |
- |
236 |
- #UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||') |
237 |
- #if [ "${UML}" = 'UML' ] |
238 |
- #then |
239 |
- # # UML Fixes |
240 |
- # good_msg 'Updating for uml system' |
241 |
- #fi |
242 |
- |
243 |
- # Let Init scripts know that we booted from CD |
244 |
- export CDBOOT |
245 |
- CDBOOT=1 |
246 |
-else |
247 |
- if [ "${USE_UNIONFS_NORMAL}" = '1' ] |
248 |
- then |
249 |
- mkdir /union_changes |
250 |
- mount -t tmpfs tmpfs /union_changes |
251 |
- setup_unionfs /union_changes ${NEW_ROOT} |
252 |
- mkdir -p ${UNION}/tmp/.initrd |
253 |
- elif [ 1 = "$aufs" ]; then |
254 |
- aufs_insert_dir "$aufs_union" "$NEW_ROOT" |
255 |
- mkdir -p "$aufs_union/tmp/.initrd" |
256 |
- fi |
257 |
- |
258 |
-fi # if [ "${CDROOT}" = '1' ] |
259 |
+ done |
260 |
+ |
261 |
+ mkdir -p initramfs proc tmp run sys 2>/dev/null |
262 |
+ chmod 1777 tmp |
263 |
+ |
264 |
+ fi |
265 |
+ |
266 |
+ # Have handy /mnt/cdrom (CDROOT_PATH) as well |
267 |
+ if [ 1 = "$aufs" ]; then |
268 |
+ [ ! -d "$CHROOT$CDROOT_PATH" ] && mkdir "$CHROOT$CDROOT_PATH" |
269 |
+ mount --move "$CDROOT_PATH" "$CHROOT$CDROOT_PATH" |
270 |
+ else |
271 |
+ [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p "$NEW_ROOT$CDROOT_PATH" |
272 |
+ mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH" |
273 |
+ fi |
274 |
+ |
275 |
+ #UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||') |
276 |
+ #if [ "${UML}" = 'UML' ] |
277 |
+ #then |
278 |
+ # # UML Fixes |
279 |
+ # good_msg 'Updating for uml system' |
280 |
+ #fi |
281 |
+ |
282 |
+ # Let Init scripts know that we booted from CD |
283 |
+ export CDBOOT |
284 |
+ CDBOOT=1 |
285 |
+ else |
286 |
+ if [ "${USE_UNIONFS_NORMAL}" = '1' ] |
287 |
+ then |
288 |
+ mkdir /union_changes |
289 |
+ mount -t tmpfs tmpfs /union_changes |
290 |
+ setup_unionfs /union_changes ${NEW_ROOT} |
291 |
+ mkdir -p ${UNION}/tmp/.initrd |
292 |
+ elif [ 1 = "$aufs" ]; then |
293 |
+ aufs_insert_dir "$aufs_union" "$NEW_ROOT" |
294 |
+ mkdir -p "$aufs_union/tmp/.initrd" |
295 |
+ fi |
296 |
+ |
297 |
+ fi # if [ "${CDROOT}" = '1' ] |
298 |
|
299 |
# Mount the additional things as required by udev & systemd |
300 |
if [ -f ${NEW_ROOT}/etc/initramfs.mounts ]; then |