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:22
Message-Id: 1430328705.b4d40c20a5cb327540ea2f7d84f818b39b8657dc.zerochaos@gentoo
1 commit: b4d40c20a5cb327540ea2f7d84f818b39b8657dc
2 Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
3 AuthorDate: Wed Jun 25 16:12:11 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=b4d40c20
7
8 This is commit contains several changes summarized below.
9
10 1. Changed renaming of RC_NO_UMOUNTS directories
11 2. Upper to lowercase variables because this is the year 2014
12 3. Renamed aufs related variables for better readability
13 4. Fixed a typo in mke2fs command which was missing an "&"
14 5. Cleaned up setup_squashfs_aufs() function
15 6. Fixed an issue with legacy squashfs implementation which caused
16 /mnt/cdrom to be shown twice in 'mount' and removed the --bind and
17 replaced this with --move
18 7. Restructured the union_* functions so that we don't parse 'ls'
19 and enabled globbing
20 8. Coding style changes
21 - rid of the unnecessary braces
22 - fix a missing & for mke2fs on livecd.aufs
23 - renamed variables for more readabilit
24 9. Better error handling for changesfs()
25 10. Removed aufs.persistent since 'aufs' already mounts a tmpfs which
26 uses half the available ram, and since this feature is not true
27 persistent we remove it in favor of aufs=<DEV>
28
29 defaults/initrd.defaults | 10 +--
30 defaults/initrd.scripts | 208 ++++++++++++++++++++++++-----------------------
31 defaults/linuxrc | 151 +++++++++++++++++-----------------
32 3 files changed, 185 insertions(+), 184 deletions(-)
33
34 diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
35 index 17847fe..782fd14 100755
36 --- a/defaults/initrd.defaults
37 +++ b/defaults/initrd.defaults
38 @@ -12,6 +12,8 @@ BAD="\033[31;1m"
39 BOLD="\033[1m"
40 GOOD="\033[32;1m"
41
42 +# Sets the default collation order
43 +LC_COLLATE=C
44 # From KNOPPIX LINUXRC
45 # Reset fb color mode
46 RESET="]R"
47 @@ -58,7 +60,7 @@ KSUFF='.ko'
48 REAL_ROOT=''
49 CONSOLE='/dev/console'
50 NEW_ROOT='/newroot'
51 -RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/rw_branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"
52 +RC_NO_UMOUNTS='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino'
53 CDROOT='0'
54 CDROOT_DEV=''
55 CDROOT_TYPE='auto'
56 @@ -68,10 +70,8 @@ CDROOT_PATH='/mnt/cdrom'
57 CDROOT_MARKER='/livecd'
58
59 # AUFS variables
60 -USE_AUFS_NORMAL=0
61 -AUFS_MODULES=false
62 -AUFS_CHANGES=false
63 -AUFS_CHANGESFILE=/livecd.aufs
64 +aufs=0
65 +aufs_union_file=/livecd.aufs
66
67 LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop'
68
69
70 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
71 index 9b88d6a..2e48504 100644
72 --- a/defaults/initrd.scripts
73 +++ b/defaults/initrd.scripts
74 @@ -178,20 +178,20 @@ devicelist(){
75 }
76
77 bootstrapFS() {
78 - if [ "${USE_AUFS_NORMAL}" -eq '1' ]; then
79 - # Directories used for rw changes in union mount filesystem
80 - UNION=/union MEMORY=/memory
81 + if [ 1 = "$aufs" ]; then
82 + # Directories used for rw aufs mount filesystem
83 + aufs_union=/union aufs_memory=/memory
84
85 - # Mountpoint for the changesdev
86 - CHANGESMNT=${NEW_ROOT}/mnt/changesdev
87 + # Mountpoint for the aufs dev
88 + aufs_dev_mnt=/mnt/aufs-dev
89
90 - if [ -z "$UID" ]; then
91 - CHANGES=${MEMORY}/aufs_changes/default
92 + if [ -z "$aufs_dev_uid" ]; then
93 + aufs_branch=$aufs_memory/aufs-branch/default
94 else
95 - CHANGES=${MEMORY}/aufs_changes/${UID}
96 + aufs_branch=$aufs_memory/aufs-branch/$aufs_dev_uid
97 fi
98
99 - mkdir -p ${MEMORY} ${UNION} ${CHANGESMNT}
100 + mkdir -p $aufs_memory $aufs_union $aufs_dev_mnt
101 else
102 # Legacy SquashFS implementation
103 good_msg "Making tmpfs for ${NEW_ROOT}"
104 @@ -280,37 +280,51 @@ mount_sysfs() {
105 [ ${ret} -eq 0 ] || bad_msg "Failed to mount /sys!"
106 }
107
108 -# Insert a directory tree ${2} to an union specified by ${1}
109 +# Insert a directory tree $2 to an union specified by $1
110 # Top-level read-write branch is specified by it's index 0
111 -# ${1} = union absolute path (starting with /)
112 -# ${2} = path to data directory
113 +# $1 = union absolute path (starting with /)
114 +# $2 = path to data directory
115 #
116 union_insert_dir() {
117 # Always mount it over the precedent (add:1:)
118 - mount -n -o remount,add:1:${2}=rr aufs ${1}
119 - if [ $? = '0' ]
120 - then
121 - good_msg "Addition of ${2} to ${1} successful"
122 + if mount -n -o "remount,add:1:$2=rr" aufs "$1"; then
123 + good_msg "Addition of $2 to $1 successful"
124 fi
125 }
126
127 -# Insert all modules found in $1, usually ${CDROOT_PATH}
128 +# Insert all modules found in $1, usually $CDROOT_PATH
129 # added to allow users to add their own apps.
130 union_insert_modules() {
131 - for module in $(ls ${NEW_ROOT}/${1}/modules/*.mo 2>/dev/null| sort)
132 - do
133 - mkdir -p ${MEMORY}/modules/$(basename ${module} .mo)
134 - union_insert_dir $UNION ${MEMORY}/modules/$(basename ${module} .mo)
135 - done
136 - for module in $(ls ${NEW_ROOT}/${1}/modules/*.lzm 2>/dev/null| sort)
137 - do
138 - mkdir -p ${MEMORY}/modules/$(basename ${module} .lzm)
139 - mount -o loop,ro ${module} ${MEMORY}/modules/$(basename ${module} .lzm)
140 - union_insert_dir $UNION ${MEMORY}/modules/$(basename ${module} .lzm)
141 - done
142 + local module
143 +
144 + for module in "$NEW_ROOT/$1/modules/"*.mo; do
145 + union_mod "$module" || bad_msg "Unable to load module: '$module'"
146 + done
147 +
148 + for module in "$NEW_ROOT/$1/modules/"*.lzm; do
149 + union_mod "$module" lzm || bad_msg "Unable to load module: '$module'"
150 + done
151 }
152
153 -# Implements RC_NO_UMOUNTS variable into ${CHROOT}/etc/rc.conf for a cleaner shutdown process
154 +# Helper function for union_insert_modules()
155 +union_mod() {
156 + [ -e "$1" ] || return 0
157 +
158 + local mod
159 +
160 + mod=${1##*/}
161 + mod=${mod%.*}
162 +
163 + mkdir -p "$aufs_memory/modules/$mod" || return
164 +
165 + if [ lzm = "$2" ]; then
166 + mount -o loop,ro "$1" "$aufs_memory/modules/$mod"
167 + fi
168 +
169 + union_insert_dir "$aufs_union" "$aufs_memory/modules/$mod"
170 +}
171 +
172 +# Implements RC_NO_UMOUNTS variable into $CHROOT/etc/rc.conf for a cleaner shutdown process
173 # This should really go into /etc/init.d/localmounts but until then we manually set this here
174 conf_rc_no_umounts() {
175 local conf nomount fnd
176 @@ -357,7 +371,7 @@ is_int(){
177 done
178 }
179
180 -# Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint
181 +# Function to create an ext2 fs on $aufs_dev, $aufs_dev_mnt mountpoint
182 create_changefs() {
183 local size
184
185 @@ -372,102 +386,98 @@ create_changefs() {
186 elif [ 15 -ge "$size" ]; then
187 bad_msg "Please give a size of at least 16 Megabytes"
188 else
189 - if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then
190 - good_msg "Creation of $AUFS_CHANGESFILE, ${size}Mb on $CHANGESDEV successful, formatting it ext2"
191 - mke2fs -F "$CHANGESMNT$AUFS_CHANGESFILE" >/dev/null
192 - AUFS_CHANGES=true
193 + if dd if=/dev/zero "of=$aufs_dev_mnt$aufs_union_file" bs=1M count="$size" &>/dev/null; then
194 + good_msg "Creation of $aufs_union_file, ${size}Mb on $aufs_dev successful, formatting it ext2"
195 + mke2fs -F "$aufs_dev_mnt$aufs_union_file" &>/dev/null
196 break
197 else
198 - rm -f "$CHANGESMNT$AUFS_CHANGESFILE"
199 - bad_msg "Unable to create ${AUFS_CHANGESFILE#*/} on $CHANGESDEV of ${size}Mb"
200 + rm "$aufs_dev_mnt$aufs_union_file"
201 + bad_msg "Unable to create ${aufs_union_file#*/} on $aufs_dev of ${size}Mb"
202 bad_msg "Ensure your disk is not full or read-only"
203
204 read -p '<< Type "a" to abort, anything else to continue : ' doabort
205 - if [ a = "$doabort" ]; then return 1; fi
206 + if [ a = "$doabort" ]; then
207 + bad_msg "Aborting creation of $aufs_union_file!"
208 + umount "$aufs_dev" && rmdir "$aufs_dev_mnt"
209 + return 1
210 + fi
211 fi
212 fi
213 done
214 - return 0
215 + return $?
216 }
217
218 setup_aufs() {
219 bootstrapCD
220
221 - if [ -n "$AUFS" ]; then
222 - if [ detect = "$AUFS" ]; then
223 - CHANGESMNT=$NEW_ROOT$CDROOT_PATH
224 - CHANGESDEV=$REAL_ROOT
225 - else
226 - CHANGESDEV=$AUFS
227 - good_msg "Mounting $CHANGESDEV to $MEMORY for aufs support"
228 + if [ -n "$aufs_dev" ]; then
229 + good_msg "Mounting $aufs_dev to $aufs_memory for aufs support"
230
231 - if ! mount -t auto "$CHANGESDEV" "$CHANGESMNT" &>/dev/null; then
232 - bad_msg "Mount of $CHANGESDEV failed, falling back to ramdisk based aufs"
233 - unset AUFS
234 - fi
235 + if ! mount -t auto "$aufs_dev" "$aufs_dev_mnt" &>/dev/null; then
236 + bad_msg "Mount of $aufs_dev failed, falling back to ramdisk based aufs"
237 + unset aufs_dev
238 fi
239
240 - # Check and attempt to create the changesfile
241 - if [ ! -e $CHANGESMNT$AUFS_CHANGESFILE ] && [ -n "$AUFS" ]; then
242 - create_changefs
243 - mount -t auto "$CHANGESMNT$AUFS_CHANGESFILE" "$MEMORY"
244 - elif [ -n "$AUFS" ]; then
245 - while :; do
246 - if mount -t auto "$CHANGESMNT$AUFS_CHANGESFILE" "$MEMORY" &>/dev/null; then
247 + # Check and attempt to create the AUFS union file
248 + if [ ! -e $aufs_dev_mnt$aufs_union_file ] && [ -n "$aufs_dev" ]; then
249 + create_changefs && mount -t auto "$aufs_dev_mnt$aufs_union_file" "$aufs_memory"
250 + elif [ -n "$aufs_dev" ]; then
251 + while :; do
252 + if mount -t auto "$aufs_dev_mnt$aufs_union_file" "$aufs_memory" &>/dev/null; then
253 break
254 else
255 bad_msg "Mounting of changes file failed, Running e2fsck"
256
257 if ! hash e2fsck &>/dev/null; then
258 bad_msg "/sbin/e2fsck not found! aborting filesystem check"
259 - bad_msg "Moving ${AUFS_CHANGESFILE#*/} to ${AUFS_CHANGESFILE#*/}.bad"
260 + bad_msg "Moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
261
262 - mv "$CHANGESMNT$AUFS_CHANGESFILE" "$CHANGESMNT$AUFS_CHANGESFILE.bad"
263 + mv "$aufs_dev_mnt$aufs_union_file" "$aufs_dev_mnt$aufs_union_file.bad"
264 break
265 -
266 fi
267
268 - if e2fsck "$CHANGESMNT$AUFS_CHANGESFILE" &>/dev/null; then
269 + if e2fsck "$aufs_dev_mnt$aufs_union_file" &>/dev/null; then
270 good_msg "e2fsck ran successfully. Please verify data after bootup"
271 else
272 - bad_msg "Your ${AUFS_CHANGESFILE#*/} image might be corrupted"
273 - bad_msg "moving ${AUFS_CHANGESFILE#*/} to ${AUFS_CHANGESFILE#*/}.bad"
274 + bad_msg "Your ${aufs_union_file#*/} image might be corrupted"
275 + bad_msg "moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
276
277 - mv "$CHANGESMNT$AUFS_CHANGESFILE" "$CHANGESMNT$AUFS_CHANGESFILE.bad"
278 - break
279 - fi
280 - fi
281 - done
282 - fi
283 - # mount tmpfs only in the case when changes= boot parameter was
284 - # empty or we were not able to mount the storage device
285 - if [ 1 = "$CDROOT" ] && [ ! -f "$CHANGESMNT$AUFS_CHANGESFILE" ]; then
286 - XINO=$MEMORY
287 - umount "$MEMORY" &>/dev/null
288 + mv "$aufs_dev_mnt$aufs_union_file" "$aufs_dev_mnt$aufs_union_file.bad"
289 + break
290 + fi
291 + fi
292 + done
293 + fi
294 +
295 + # Mount tmpfs only in the case when aufs= boot parameter was
296 + # empty or we were not able to mount the storage device
297 + if [ 1 = "$CDROOT" ] && [ ! -f "$aufs_dev_mnt$aufs_union_file" ]; then
298 + aufs_xino=$aufs_memory
299 + umount "$aufs_memory" &>/dev/null
300
301 - bad_msg "Create an extfs ${AUFS_CHANGESFILE#*/} file on this device"
302 + bad_msg "Create an extfs ${aufs_union_file#*/} file on this device"
303 bad_msg "if you wish to have aufs data persistency on reboots"
304 - bad_msg "Falling back to ramdisk based aufs"
305 - good_msg "Mounting ramdisk to $MEMORY for aufs support"
306 + bad_msg "Falling back to ramdisk based aufs"
307 + good_msg "Mounting ramdisk to $aufs_memory for aufs support"
308
309 - mount -t tmpfs tmpfs "$MEMORY"
310 - else
311 - XINO=$MEMORY/xino
312 + mount -t tmpfs tmpfs "$aufs_memory"
313 + else
314 + aufs_xino=$aufs_memory/xino
315
316 - mkdir -p "$XINO"
317 - mount -t tmpfs aufs-xino "$XINO"
318 - fi
319 - else
320 - XINO=$MEMORY
321 + mkdir -p "$aufs_xino"
322 + mount -t tmpfs aufs-xino "$aufs_xino"
323 + fi
324 + else
325 + aufs_xino=$aufs_memory
326
327 - good_msg "Mounting ramdisk to $MEMORY for aufs support"
328 - mount -t tmpfs tmpfs "$MEMORY"
329 - fi
330 + good_msg "Mounting ramdisk to $aufs_memory for aufs support"
331 + mount -t tmpfs tmpfs "$aufs_memory"
332 + fi
333
334 - mkdir -p "$CHANGES"
335 - if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=$XINO/.aufs.xino,br:$CHANGES=rw" aufs "$UNION"; then
336 - bad_msg "Can't setup union $UNION in directory!"
337 - USE_AUFS_NORMAL=0
338 + mkdir -p "$aufs_branch"
339 + if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=$aufs_xino/.aufs.xino,br:$aufs_branch=rw" aufs "$aufs_union"; then
340 + bad_msg "Can't setup union $aufs_union in directory!"
341 + aufs=0
342 fi
343 }
344
345 @@ -1420,24 +1430,18 @@ getdvhoff() {
346
347 setup_squashfs_aufs() {
348 # Setup aufs directories and vars
349 - rw_branch=/mnt/rw_branch ro_branch=/mnt/livecd
350 + aufs_rw_branch=/mnt/aufs-rw-branch aufs_ro_branch=/mnt/livecd
351
352 - for dir in $rw_branch $ro_branch; do
353 + for dir in $aufs_rw_branch $aufs_ro_branch; do
354 [ ! -d $dir ] && mkdir -p "$dir"
355 done
356
357 good_msg "Loading aufs module ..."
358 modprobe aufs &>/dev/null
359
360 - mount -t squashfs -o loop,ro "$CDROOT_PATH/$LOOPEXT$LOOP" "$ro_branch"
361 - mount -t tmpfs none "$rw_branch"
362 - mount -t aufs -o "br:$rw_branch:$ro_branch" aufs "$NEW_ROOT"
363 -
364 - [ ! -d $NEW_ROOT$rw_branch ] && mkdir -p "$NEW_ROOT$rw_branch"
365 - [ ! -d $NEW_ROOT$ro_branch ] && mkdir -p "$NEW_ROOT$ro_branch"
366 - for mount in $rw_branch $ro_branch; do
367 - mount --move "$mount" "$NEW_ROOT$mount"
368 - done
369 + mount -t squashfs -o loop,ro "$CDROOT_PATH/$LOOPEXT$LOOP" "$aufs_ro_branch"
370 + mount -t tmpfs none "$aufs_rw_branch"
371 + mount -t aufs -o "br:$aufs_rw_branch:$aufs_ro_branch" aufs "$NEW_ROOT"
372 }
373
374 setup_unionfs() {
375
376 diff --git a/defaults/linuxrc b/defaults/linuxrc
377 index 5a341af..276f150 100644
378 --- a/defaults/linuxrc
379 +++ b/defaults/linuxrc
380 @@ -251,26 +251,22 @@ do
381 keymap=${x#*=}
382 ;;
383 aufs)
384 - USE_AUFS_NORMAL=1
385 + aufs=1
386 ;;
387 aufs\=*)
388 - USE_AUFS_NORMAL=1
389 + aufs=1
390
391 if echo "${x#*=}" | grep , &>/dev/null; then
392 - UID=${x#*,}
393 - AUFS=${x%,*}
394 + aufs_dev_uid=${x#*,}
395 + aufs_dev=${x%,*}
396 else
397 - AUFS=${x#*=}
398 + aufs_dev=${x#*=}
399 fi
400 ;;
401 - aufs.persistent)
402 - USE_AUFS_NORMAL=1
403 - AUFS=detect
404 - ;;
405 # Allow user to specify the modules location
406 aufs.modules\=*)
407 - MODULESD=${x#*=}
408 - AUFS_MODULES=true
409 + aufs_modules_dev=${x#*=}
410 + aufs_modules=1
411 ;;
412 unionfs)
413 if [ ! -x /sbin/unionfs ]
414 @@ -447,14 +443,14 @@ then
415 # Setup the root filesystem
416 bootstrapFS
417
418 - if [ 1 = "$USE_AUFS_NORMAL" ]; then
419 + if [ 1 = "$aufs" ]; then
420 setup_aufs
421 - CHROOT=$UNION
422 + CHROOT=$aufs_union
423 else
424 CHROOT=${NEW_ROOT}
425 fi
426
427 - if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$USE_AUFS_NORMAL" ]; then
428 + if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ]; then
429 bootstrapCD
430 fi
431
432 @@ -704,7 +700,7 @@ then
433 FS_LOCATION='mnt/livecd'
434 elif [ "${LOOPTYPE}" = 'squashfs' ]
435 then
436 - if [ 1 != "$USE_AUFS_NORMAL" ]; then
437 + if [ 1 != "$aufs" ]; then
438 good_msg 'Mounting squashfs filesystem'
439 _CACHED_SQUASHFS_PATH="${NEW_ROOT}/mnt/${LOOP}"
440 _squashfs_path="${CDROOT_PATH}/${LOOPEXT}${LOOP}" # Default to uncached
441 @@ -766,10 +762,10 @@ then
442 fi
443 fi # if [ -n "${CRYPT_ROOT}" ]
444
445 - if [ 1 = "$USE_AUFS_NORMAL" ]; then
446 - union_insert_dir "$CHROOT" "$NEW_ROOT/$FS_LOCATION"
447 + if [ 1 = "$aufs" ]; then
448 + union_insert_dir "$CHROOT" "$aufs_ro_branch"
449
450 - # Function to handle the RC_NO_UMOUNTS variable in ${CHROOT}/etc/rc.conf
451 + # Function to handle the RC_NO_UMOUNTS variable in $CHROOT/etc/rc.conf
452 conf_rc_no_umounts
453
454 # Fstab changes for aufs
455 @@ -780,7 +776,7 @@ then
456
457 cat > "$CHROOT/etc/fstab" << FSTAB
458 ####################################################
459 -## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
460 +## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
461 ## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##
462 ####################################################
463 aufs / aufs defaults 0 0
464 @@ -790,14 +786,14 @@ distfiles /usr/portage/distfiles tmpfs defaults 0 0
465 FSTAB
466 fi
467
468 - if $AUFS_MODULES; then
469 - warn_msg "Adding all modules in $MODULESD/modules/"
470 + if [ 1 = "$aufs_modules" ]; then
471 + warn_msg "Adding all modules in $aufs_modules_dev/modules/"
472
473 - if [ -z "$MODULESD" ]; then
474 + if [ -z "$aufs_modules_dev" ]; then
475 union_insert_modules "$CDROOT_PATH"
476 else
477 mkdir "$NEW_ROOT/mnt/modulesd"
478 - mount "$MODULESD" "$NEW_ROOT/mnt/modulesd"
479 + mount "$aufs_modules_dev" "$NEW_ROOT/mnt/modulesd"
480 union_insert_modules "$NEW_ROOT/mnt/modulesd"
481 fi
482 fi
483 @@ -808,11 +804,13 @@ FSTAB
484 cp /etc/sysconfig/keyboard "$CHROOT/etc/sysconfig/"
485 fi
486
487 - # Create the directories for our new union mounts
488 + # Create the diuectories for our new union mounts
489 [ ! -d $CHROOT$NEW_ROOT ] && mkdir -p "$CHROOT$NEW_ROOT"
490
491 - if $AUFS_CHANGES && [ ! -d $CHROOT$NEW_ROOT/mnt/changesdev ]; then
492 - mkdir -p "$CHROOT$NEW_ROOT/mnt/changesdev"
493 + # Check to see if we successfully mounted $aufs_dev
494 + if [ -n "$aufs_dev" ] && grep $aufs_dev /etc/mtab 1>/dev/null; then
495 + [ ! -d $CHROOT$aufs_dev_mnt ] && mkdir -p "$CHROOT$aufs_dev_mnt"
496 + mount --move "$aufs_dev_mnt" "$CHROOT$aufs_dev_mnt"
497 fi
498 fi
499
500 @@ -833,31 +831,30 @@ FSTAB
501 fi
502
503
504 - if [ "${USE_UNIONFS_NORMAL}" = '1' ]
505 - then
506 + if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then
507 setup_unionfs ${NEW_ROOT} /${FS_LOCATION}
508 CHROOT=/union
509 - else
510 - #XXX Note to potential reviewers. diff formats this section very very oddly. Be sure to review this hunk after applied, do NOT simply read the diff
511 - if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
512 - then
513 - good_msg "Copying read-write image contents to tmpfs"
514 - # Copy over stuff that should be writable
515 - (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}") || {
516 - bad_msg "Copying failed, dropping into a shell."
517 - do_rundebugshell
518 - }
519 -
520 - # Now we do the links.
521 - for x in ${ROOT_LINKS}
522 - do
523 - if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
524 - then
525 - ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
526 - else
527 - # List all subdirectories of x
528 - find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
529 - do
530 + elif [ 1 != "$aufs" ]; then
531 + good_msg "Copying read-write image contents to tmpfs"
532 +
533 + # Copy over stuff that should be writable
534 + (
535 + cd "${NEW_ROOT}/${FS_LOCATION}"
536 + cp -a ${ROOT_TREES} "${NEW_ROOT}"
537 + ) ||
538 + {
539 + bad_msg "Copying failed, dropping into a shell."
540 + do_rundebugshell
541 + }
542 +
543 + # Now we do the links.
544 + for x in ${ROOT_LINKS}; do
545 + if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]; then
546 + ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
547 + else
548 + # List all subdirectories of x
549 + find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null |
550 + while read directory; do
551 # Strip the prefix of the FS_LOCATION
552 directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
553
554 @@ -869,11 +866,9 @@ FSTAB
555 fi
556 fi
557 # Test if the directory exists already
558 - if [ -e "/${NEW_ROOT}/${directory}" ]
559 - then
560 + if [ -e "/${NEW_ROOT}/${directory}" ]; then
561 # It does exist, link all the individual files
562 - for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
563 - do
564 + for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory}); do
565 if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
566 ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
567 fi
568 @@ -882,22 +877,24 @@ FSTAB
569 # It does not exist, make a link to the livecd
570 ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
571 current_parent="${directory}"
572 - fi # if [ -e "/${NEW_ROOT}/${directory}" ] ... else
573 - done # while read directory
574 - fi # if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ] ... else
575 - done # for x in ${ROOT_LINKS}
576 - mkdir -p initramfs proc tmp run sys 2>/dev/null
577 - chmod 1777 tmp
578 + fi
579 + done
580 + fi
581 + done
582
583 - fi # if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
584 - #XXX: end extremely confusing hunk
585 + mkdir -p initramfs proc tmp run sys 2>/dev/null
586 + chmod 1777 tmp
587
588 - # have handy /mnt/cdrom (CDROOT_PATH) as well
589 - _new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
590 - [ ! -d "${_new_cdroot}" ] && mkdir -p "${_new_cdroot}"
591 - mount --bind "${CDROOT_PATH}" "${_new_cdroot}"
592 + fi
593
594 - fi # if [ "${USE_UNIONFS_NORMAL}" = '1' ] ... else
595 + # Have handy /mnt/cdrom (CDROOT_PATH) as well
596 + if [ 1 = "$aufs" ]; then
597 + [ ! -d "$CHROOT$CDROOT_PATH" ] && mkdir "$CHROOT$CDROOT_PATH"
598 + mount --move "$CDROOT_PATH" "$CHROOT$CDROOT_PATH"
599 + else
600 + [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p "$NEW_ROOT$CDROOT_PATH"
601 + mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH"
602 + fi
603
604 #UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
605 #if [ "${UML}" = 'UML' ]
606 @@ -916,9 +913,9 @@ else
607 mount -t tmpfs tmpfs /union_changes
608 setup_unionfs /union_changes ${NEW_ROOT}
609 mkdir -p ${UNION}/tmp/.initrd
610 - elif [ 1 = "$USE_AUFS_NORMAL" ]; then
611 - union_insert_dir "$UNION" "$NEW_ROOT"
612 - mkdir -p "$UNION/tmp/.initrd"
613 + elif [ 1 = "$aufs" ]; then
614 + union_insert_dir "$aufs_union" "$NEW_ROOT"
615 + mkdir -p "$aufs_union/tmp/.initrd"
616 fi
617
618 fi # if [ "${CDROOT}" = '1' ]
619 @@ -965,20 +962,20 @@ fi
620
621 verbose_kmsg
622
623 -if [ 1 = "$USE_AUFS_NORMAL" ]; then
624 - UNION_MEMORY=$CHROOT/.unions/memory
625 +if [ 1 = "$aufs" ]; then
626 + aufs_union_memory=$CHROOT/.unions/memory
627
628 - mkdir -p "$UNION_MEMORY"
629 - mount --move "$MEMORY" "$UNION_MEMORY"
630 - test_success "Failed to move aufs /memory into the system root"
631 + mkdir -p "$aufs_union_memory"
632 + mount --move "$aufs_memory" "$aufs_union_memory"
633 + test_success "Failed to move aufs $aufs_memory into the system root"
634
635 - for dir in /mnt/gentoo $rw_branch $ro_branch $CDROOT_PATH; do
636 + for dir in /mnt/gentoo $aufs_rw_branch $aufs_ro_branch; do
637 mkdir -p "$CHROOT$dir"
638 chmod 755 "$CHROOT$dir"
639 done
640
641 - for dir in $CDROOT_PATH $rw_branch $ro_branch; do
642 - mount --move "$NEW_ROOT$dir" "$CHROOT$dir"
643 + for mount in $aufs_rw_branch $aufs_ro_branch; do
644 + mount --move "$mount" "$CHROOT$mount"
645 done
646 fi