From: "Richard Farina" <zerochaos@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:aufs commit in: defaults/
Date: Fri, 5 Sep 2014 16:09:52 +0000 (UTC) [thread overview]
Message-ID: <1403565075.5d4766cd1b811a525f5b624fc1e8daf1207acac0.zerochaos@gentoo> (raw)
commit: 5d4766cd1b811a525f5b624fc1e8daf1207acac0
Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
AuthorDate: Mon Jun 23 17:58:33 2014 +0000
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Mon Jun 23 23:11:15 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=5d4766cd
Coding style changes throughout all the AUFS related code.
---
defaults/initrd.defaults | 4 +-
defaults/initrd.scripts | 179 ++++++++++++++++++-------------------
defaults/linuxrc | 227 +++++++++++++++++++++--------------------------
3 files changed, 188 insertions(+), 222 deletions(-)
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index d0efa28..67b0d28 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -58,7 +58,7 @@ KSUFF='.ko'
REAL_ROOT=''
CONSOLE='/dev/console'
NEW_ROOT='/newroot'
-RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/overlay|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"
+RC_NO_UMOUNTS="/newroot|/newroot/mnt/changesdev|/mnt/rw_branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino"
CDROOT='0'
CDROOT_DEV=''
CDROOT_TYPE='auto'
@@ -71,7 +71,7 @@ CDROOT_MARKER='/livecd'
USE_AUFS_NORMAL=0
AUFS_MODULES=false
AUFS_CHANGES=false
-AUFS_CHANGESFILE=livecd.aufs
+AUFS_CHANGESFILE=/livecd.aufs
LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop'
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 52b18b3..5ca1203 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -314,8 +314,7 @@ union_insert_modules() {
# This should really go into /etc/init.d/localmounts but until then we manually set this here
conf_rc_no_umounts() {
local conf nomount fnd
- conf="${CHROOT}/etc/rc.conf"
- fnd=0
+ conf=$CHROOT/etc/rc.conf fnd=0
if nomount=$(grep -n '^[[:blank:]]*RC_NO_UMOUNTS=' $conf); then
local i n data cmd IFS
@@ -350,33 +349,28 @@ conf_rc_no_umounts() {
create_changefs() {
local size
- while [ 1 ]
- do
+ while :; do
read -p '<< Size of file (Press Enter for default 256 Mb): ' size
- if [ -z "${size}" ]; then
- size=256
- fi
- size="${size}"
- if [ ${size} -lt 16 ]
- then
- bad_msg "Please give a size of at least 16 Mb"
+ [ -n "$size" ] || size=256
+
+ size=$size
+
+ if [ 15 -ge "$size" ]; then
+ bad_msg "Please give a size of at least 16 Megabytes"
else
- dd if=/dev/zero of=${CHANGESMNT}/${AUFS_CHANGESFILE} bs=1M count=${size} &>/dev/null
- if [ $? = '0' ]
- then
- good_msg "Creation of ${AUFS_CHANGESFILE}, ${size} Mb on ${CHANGESDEV} successful, formatting it ext2"
- mke2fs -F ${CHANGESMNT}/${AUFS_CHANGESFILE} &>/dev/null
+ if dd if=/dev/zero "of=$CHANGESMNT$AUFS_CHANGESFILE" bs=1M count="$size" &>/dev/null; then
+ good_msg "Creation of $AUFS_CHANGESFILE, ${size}Mb on $CHANGESDEV successful, formatting it ext2"
+ mke2fs -F "$CHANGESMNT$AUFS_CHANGESFILE" >/dev/null
AUFS_CHANGES=true
break
else
- rm -f ${CHANGESMNT}/${AUFS_CHANGESFILE}
- bad_msg "Unable to create ${AUFS_CHANGESFILE} on ${CHANGESDEV} of ${size} Mb"
+ rm -f "$CHANGESMNT$AUFS_CHANGESFILE"
+ bad_msg "Unable to create ${AUFS_CHANGESFILE#*/} on $CHANGESDEV of ${size}Mb"
bad_msg "Ensure your disk is not full or read-only"
+
read -p '<< Type "a" to abort, anything else to continue : ' doabort
- if [ "${doabort}" = "a" ]; then
- return 1
- fi
+ if [ a = "$doabort" ]; then return 1; fi
fi
fi
done
@@ -386,87 +380,80 @@ create_changefs() {
setup_aufs() {
bootstrapCD
- if [ -n "${AUFS}" ]
- then
- if [ "${AUFS}" = "detect" ]
- then
- CHANGESMNT="${NEW_ROOT}${CDROOT_PATH}"
- CHANGESDEV=${REAL_ROOT}
+ if [ -n "$AUFS" ]; then
+ if [ detect = "$AUFS" ]; then
+ CHANGESMNT=$NEW_ROOT$CDROOT_PATH
+ CHANGESDEV=$REAL_ROOT
else
- CHANGESDEV=${AUFS}
- good_msg "Mounting ${CHANGESDEV} to ${MEMORY} for aufs support"
- mount -t auto ${CHANGESDEV} ${CHANGESMNT} &>/dev/null
- ret=$?
- if [ "${ret}" -ne 0 ]
- then
- bad_msg "Mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
+ CHANGESDEV=$AUFS
+ good_msg "Mounting $CHANGESDEV to $MEMORY for aufs support"
+
+ if ! mount -t auto "$CHANGESDEV" "$CHANGESMNT" &>/dev/null; then
+ bad_msg "Mount of $CHANGESDEV failed, falling back to ramdisk based aufs"
unset AUFS
fi
fi
+
# Check and attempt to create the changesfile
- if [ ! -e ${CHANGESMNT}/${AUFS_CHANGESFILE} ] && [ -n "${AUFS}" ]
- then
+ if [ ! -e $CHANGESMNT$AUFS_CHANGESFILE ] && [ -n "$AUFS" ]; then
create_changefs
- mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
- elif [ -n "${AUFS}" ]
- then
- local nbpass=0
- while [ 1 ]
- do
- mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
- ret=$?
- if [ "${ret}" -ne 0 ]
- then
- if [ ${nbpass} -eq 0 ]
- then
- bad_msg "Mounting of changes file failed, Running e2fsck"
- e2fsck ${CHANGESMNT}/${AUFS_CHANGESFILE}
- nbpass=$((${nbpass} + 1))
- else
- bad_msg "Mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
- bad_msg "your ${AUFS_CHANGESFILE} might be messed up, and I couldn't fix it"
- bad_msg "moving ${AUFS_CHANGESFILE} to ${AUFS_CHANGESFILE}.bad"
- mv ${CHANGESMNT}/${AUFS_CHANGESFILE} ${CHANGESMNT}/${AUFS_CHANGESFILE}.bad
- bad_msg "Try to fix it yourself with e2fsck"
+ mount -t auto "$CHANGESMNT$AUFS_CHANGESFILE" "$MEMORY"
+ elif [ -n "$AUFS" ]; then
+ while :; do
+ if mount -t auto "$CHANGESMNT$AUFS_CHANGESFILE" "$MEMORY" &>/dev/null; then
+ break
+ else
+ bad_msg "Mounting of changes file failed, Running e2fsck"
+
+ if ! hash e2fsck &>/dev/null; then
+ bad_msg "/sbin/e2fsck not found! aborting filesystem check"
+ bad_msg "Moving ${AUFS_CHANGESFILE#*/} to ${AUFS_CHANGESFILE#*/}.bad"
+
+ mv "$CHANGESMNT$AUFS_CHANGESFILE" "$CHANGESMNT$AUFS_CHANGESFILE.bad"
+ break
+
+ fi
+
+ if e2fsck "$CHANGESMNT$AUFS_CHANGESFILE" &>/dev/null; then
+ good_msg "e2fsck ran successfully. Please verify data after bootup"
+ else
+ bad_msg "Your ${AUFS_CHANGESFILE#*/} image might be corrupted"
+ bad_msg "moving ${AUFS_CHANGESFILE#*/} to ${AUFS_CHANGESFILE#*/}.bad"
+
+ mv "$CHANGESMNT$AUFS_CHANGESFILE" "$CHANGESMNT$AUFS_CHANGESFILE.bad"
break
fi
- else
- if [ ${nbpass} -eq 1 ]
- then
- good_msg "e2fsck ran successfully. Please check your files after bootup"
- fi
- break
fi
done
fi
# mount tmpfs only in the case when changes= boot parameter was
# empty or we were not able to mount the storage device
- if [ "${CDROOT}" -eq '1' -a ! -f ${CHANGESMNT}/${AUFS_CHANGESFILE} ]
- then
- XINO=${MEMORY}
- umount ${MEMORY} &>/dev/null
- bad_msg "Failed to find ${AUFS_CHANGESFILE} file on ${CHANGESDEV}"
- bad_msg "Create an ext2 ${AUFS_CHANGESFILE} file on this device if you wish to use it for aufs"
- bad_msg "Falling back to ramdisk based aufs for safety"
+ if [ 1 = "$CDROOT" ] && [ ! -f "$CHANGESMNT$AUFS_CHANGESFILE" ]; then
+ XINO=$MEMORY
+ umount "$MEMORY" &>/dev/null
+
+ bad_msg "Create an extfs ${AUFS_CHANGESFILE#*/} file on this device"
+ bad_msg "if you wish to have aufs data persistency on reboots"
+ bad_msg "Falling back to ramdisk based aufs"
good_msg "Mounting ramdisk to $MEMORY for aufs support"
- mount -t tmpfs tmpfs ${MEMORY}
+
+ mount -t tmpfs tmpfs "$MEMORY"
else
- XINO=${MEMORY}/xino
- mkdir -p ${XINO}
- mount -t tmpfs tmpfs ${XINO}
+ XINO=$MEMORY/xino
+
+ mkdir -p "$XINO"
+ mount -t tmpfs aufs-xino "$XINO"
fi
else
- good_msg "Mounting ramdisk to $MEMORY for aufs support"
- mount -t tmpfs tmpfs ${MEMORY}
- XINO=${MEMORY}
+ XINO=$MEMORY
+
+ good_msg "Mounting ramdisk to $MEMORY for aufs support"
+ mount -t tmpfs tmpfs "$MEMORY"
fi
- mkdir -p ${CHANGES}
- mount -t aufs -n -o nowarn_perm,udba=none,xino=${XINO}/.aufs.xino,br:${CHANGES}=rw aufs ${UNION}
- ret=$?
- if [ "${ret}" -ne 0 ]
- then
- bad_msg "Can't setup union ${UNION} in directory!"
+ mkdir -p "$CHANGES"
+ if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=$XINO/.aufs.xino,br:$CHANGES=rw" aufs "$UNION"; then
+ bad_msg "Can't setup union $UNION in directory!"
USE_AUFS_NORMAL=0
fi
}
@@ -1420,22 +1407,24 @@ getdvhoff() {
setup_squashfs_aufs() {
# Setup aufs directories and vars
- overlay=/mnt/overlay
- static=/mnt/livecd
+ rw_branch=/mnt/rw_branch ro_branch=/mnt/livecd
- for i in "${overlay}" "${static}"; do
- [ ! -d "${i}" ] && mkdir -p "${i}"
+ for dir in $rw_branch $ro_branch; do
+ [ ! -d $dir ] && mkdir -p "$dir"
done
- good_msg "Loading aufs"
- modprobe aufs > /dev/null 2>&1
- mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${static}"
- mount -t tmpfs none "${overlay}"
- mount -t aufs -o br:${overlay}:${static} aufs "${NEW_ROOT}"
+ good_msg "Loading aufs module ..."
+ modprobe aufs &>/dev/null
- [ ! -d "${NEW_ROOT}${overlay}" ] && mkdir -p "${NEW_ROOT}${overlay}"
- [ ! -d "${NEW_ROOT}${static}" ] && mkdir -p "${NEW_ROOT}${static}"
- for i in "${overlay}" "${static}"; do mount --move "${i}" "${NEW_ROOT}${i}"; done
+ mount -t squashfs -o loop,ro "$CDROOT_PATH/$LOOPEXT$LOOP" "$ro_branch"
+ mount -t tmpfs none "$rw_branch"
+ mount -t aufs -o "br:$rw_branch:$ro_branch" aufs "$NEW_ROOT"
+
+ [ ! -d $NEW_ROOT$rw_branch ] && mkdir -p "$NEW_ROOT$rw_branch"
+ [ ! -d $NEW_ROOT$ro_branch ] && mkdir -p "$NEW_ROOT$ro_branch"
+ for mount in $rw_branch $ro_branch; do
+ mount --move "$mount" "$NEW_ROOT$mount"
+ done
}
setup_unionfs() {
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 8b3ff87..5a341af 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -255,31 +255,17 @@ do
;;
aufs\=*)
USE_AUFS_NORMAL=1
- echo ${x#*=} | grep , &>/dev/null
- if [ "$?" -eq '0' ]
- then
+ if echo "${x#*=}" | grep , &>/dev/null; then
UID=${x#*,}
AUFS=${x%,*}
else
AUFS=${x#*=}
fi
;;
- aufs.changes\=*)
- USE_AUFS_NORMAL=1
- echo ${x#*=} | grep , &>/dev/null
-
- if [ "$?" -eq '0' ]
- then
- UID=${x#*,}
- AUFS=${x%,*}
- else
- AUFS=${x#*=}
- fi
- ;;
aufs.persistent)
USE_AUFS_NORMAL=1
- AUFS="detect"
+ AUFS=detect
;;
# Allow user to specify the modules location
aufs.modules\=*)
@@ -461,16 +447,14 @@ then
# Setup the root filesystem
bootstrapFS
- if [ "${USE_AUFS_NORMAL}" -eq '1' ]
- then
+ if [ 1 = "$USE_AUFS_NORMAL" ]; then
setup_aufs
- CHROOT=${UNION}
+ CHROOT=$UNION
else
CHROOT=${NEW_ROOT}
fi
- if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ] && [ "${USE_AUFS_NORMAL}" != '1' ]
- then
+ if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$USE_AUFS_NORMAL" ]; then
bootstrapCD
fi
@@ -502,7 +486,7 @@ then
fi
# Determine root device
-good_msg 'Determining root device...'
+good_msg 'Determining root device ...'
while true
do
while [ "${got_good_root}" != '1' ]
@@ -720,7 +704,7 @@ then
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'squashfs' ]
then
- if [ "${USE_AUFS_NORMAL}" != '1' ]; then
+ if [ 1 != "$USE_AUFS_NORMAL" ]; then
good_msg 'Mounting squashfs filesystem'
_CACHED_SQUASHFS_PATH="${NEW_ROOT}/mnt/${LOOP}"
_squashfs_path="${CDROOT_PATH}/${LOOPEXT}${LOOP}" # Default to uncached
@@ -782,25 +766,23 @@ then
fi
fi # if [ -n "${CRYPT_ROOT}" ]
- if [ "${USE_AUFS_NORMAL}" -eq '1' ]
- then
- union_insert_dir ${CHROOT} ${NEW_ROOT}/${FS_LOCATION}
-
- # Make sure fstab notes livecd is mounted ro. Makes system skip remount which fails on aufs dirs.
- # TODO: remounting all tmpfs as RO seems weird, can we be more specific?
- #sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' /${UNION}/etc/fstab > /${UNION}/etc/fstab.new
- #mv /${UNION}/etc/fstab.new /${UNION}/etc/fstab
+ if [ 1 = "$USE_AUFS_NORMAL" ]; then
+ union_insert_dir "$CHROOT" "$NEW_ROOT/$FS_LOCATION"
# Function to handle the RC_NO_UMOUNTS variable in ${CHROOT}/etc/rc.conf
conf_rc_no_umounts
# Fstab changes for aufs
- if ! grep -q '^aufs' "${CHROOT}"/etc/fstab 2>/dev/null; then
- for i in /var/tmp /tmp /usr/portage/distfiles; do
- [ ! -d "${CHROOT}${i}" ] && mkdir -p "${CHROOT}${i}"
+ if ! grep -q '^aufs' "$CHROOT/etc/fstab" 2>/dev/null; then
+ for dir in /var/tmp /tmp /usr/portage/distfiles; do
+ [ ! -d $CHROOT$dir ] && mkdir -p "$CHROOT$dir"
done
- cat > "${CHROOT}"/etc/fstab << FSTAB
+ cat > "$CHROOT/etc/fstab" << FSTAB
+####################################################
+## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
+## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##
+####################################################
aufs / aufs defaults 0 0
vartmp /var/tmp tmpfs defaults 0 0
tmp /tmp tmpfs defaults 0 0
@@ -808,30 +790,29 @@ distfiles /usr/portage/distfiles tmpfs defaults 0 0
FSTAB
fi
- if ${AUFS_MODULES}; then
+ if $AUFS_MODULES; then
warn_msg "Adding all modules in $MODULESD/modules/"
- if [ -z "${MODULESD}" ]
- then
- union_insert_modules ${CDROOT_PATH}
+ if [ -z "$MODULESD" ]; then
+ union_insert_modules "$CDROOT_PATH"
else
- mkdir ${NEW_ROOT}/mnt/modulesd
- mount "${MODULESD}" ${NEW_ROOT}/mnt/modulesd
- union_insert_modules ${NEW_ROOT}/mnt/modulesd
+ mkdir "$NEW_ROOT/mnt/modulesd"
+ mount "$MODULESD" "$NEW_ROOT/mnt/modulesd"
+ union_insert_modules "$NEW_ROOT/mnt/modulesd"
fi
fi
# Copy user keymap file
if [ -e /etc/sysconfig/keyboard ]; then
- [ ! -d ${CHROOT}/etc/sysconfig ] && mkdir -p ${CHROOT}/etc/sysconfig
- cp /etc/sysconfig/keyboard ${CHROOT}/etc/sysconfig/
+ [ ! -d $CHROOT/etc/sysconfig ] && mkdir -p "$CHROOT/etc/sysconfig"
+ cp /etc/sysconfig/keyboard "$CHROOT/etc/sysconfig/"
fi
# Create the directories for our new union mounts
- test ! -d "${CHROOT}${NEW_ROOT}" && mkdir -p "${CHROOT}${NEW_ROOT}"
+ [ ! -d $CHROOT$NEW_ROOT ] && mkdir -p "$CHROOT$NEW_ROOT"
- if ${AUFS_CHANGES} && [ ! -d "${CHROOT}${NEW_ROOT}/mnt/changesdev" ]; then
- mkdir -p "${CHROOT}${NEW_ROOT}/mnt/changesdev"
+ if $AUFS_CHANGES && [ ! -d $CHROOT$NEW_ROOT/mnt/changesdev ]; then
+ mkdir -p "$CHROOT$NEW_ROOT/mnt/changesdev"
fi
fi
@@ -856,67 +837,67 @@ FSTAB
then
setup_unionfs ${NEW_ROOT} /${FS_LOCATION}
CHROOT=/union
- else
- #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
- if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
- then
- good_msg "Copying read-write image contents to tmpfs"
- # Copy over stuff that should be writable
- (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}") || {
- bad_msg "Copying failed, dropping into a shell."
- do_rundebugshell
- }
-
- # Now we do the links.
- for x in ${ROOT_LINKS}
- do
- if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
- then
- ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
- else
- # List all subdirectories of x
- find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
- do
- # Strip the prefix of the FS_LOCATION
- directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
-
- # Skip this directory if we already linked a parent directory
- if [ "${current_parent}" != '' ]; then
- var=$(echo "${directory}" | grep "^${current_parent}")
- if [ "${var}" != '' ]; then
- continue
- fi
- fi
- # Test if the directory exists already
- if [ -e "/${NEW_ROOT}/${directory}" ]
- then
- # It does exist, link all the individual files
- for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
- do
- if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
- ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
- fi
- done
- else
- # It does not exist, make a link to the livecd
- ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
- current_parent="${directory}"
- fi # if [ -e "/${NEW_ROOT}/${directory}" ] ... else
- done # while read directory
- fi # if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ] ... else
- done # for x in ${ROOT_LINKS}
- mkdir -p initramfs proc tmp run sys 2>/dev/null
- chmod 1777 tmp
-
- fi # if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
- #XXX: end extremely confusing hunk
-
- # have handy /mnt/cdrom (CDROOT_PATH) as well
- _new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
- [ ! -d "${_new_cdroot}" ] && mkdir -p "${_new_cdroot}"
- mount --bind "${CDROOT_PATH}" "${_new_cdroot}"
-
- fi # if [ "${USE_UNIONFS_NORMAL}" = '1' ] ... else
+ else
+ #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
+ if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
+ then
+ good_msg "Copying read-write image contents to tmpfs"
+ # Copy over stuff that should be writable
+ (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}") || {
+ bad_msg "Copying failed, dropping into a shell."
+ do_rundebugshell
+ }
+
+ # Now we do the links.
+ for x in ${ROOT_LINKS}
+ do
+ if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
+ then
+ ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
+ else
+ # List all subdirectories of x
+ find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
+ do
+ # Strip the prefix of the FS_LOCATION
+ directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
+
+ # Skip this directory if we already linked a parent directory
+ if [ "${current_parent}" != '' ]; then
+ var=$(echo "${directory}" | grep "^${current_parent}")
+ if [ "${var}" != '' ]; then
+ continue
+ fi
+ fi
+ # Test if the directory exists already
+ if [ -e "/${NEW_ROOT}/${directory}" ]
+ then
+ # It does exist, link all the individual files
+ for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
+ do
+ if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
+ ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
+ fi
+ done
+ else
+ # It does not exist, make a link to the livecd
+ ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
+ current_parent="${directory}"
+ fi # if [ -e "/${NEW_ROOT}/${directory}" ] ... else
+ done # while read directory
+ fi # if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ] ... else
+ done # for x in ${ROOT_LINKS}
+ mkdir -p initramfs proc tmp run sys 2>/dev/null
+ chmod 1777 tmp
+
+ fi # if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
+ #XXX: end extremely confusing hunk
+
+ # have handy /mnt/cdrom (CDROOT_PATH) as well
+ _new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
+ [ ! -d "${_new_cdroot}" ] && mkdir -p "${_new_cdroot}"
+ mount --bind "${CDROOT_PATH}" "${_new_cdroot}"
+
+ fi # if [ "${USE_UNIONFS_NORMAL}" = '1' ] ... else
#UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
#if [ "${UML}" = 'UML' ]
@@ -928,18 +909,16 @@ FSTAB
# Let Init scripts know that we booted from CD
export CDBOOT
CDBOOT=1
-else # if [ "${CDROOT}" = '1' ]
+else
if [ "${USE_UNIONFS_NORMAL}" = '1' ]
then
mkdir /union_changes
mount -t tmpfs tmpfs /union_changes
setup_unionfs /union_changes ${NEW_ROOT}
mkdir -p ${UNION}/tmp/.initrd
- fi
- if [ "${USE_AUFS_NORMAL}" -eq '1' ]
- then
- union_insert_dir ${UNION} ${NEW_ROOT}
- mkdir -p ${UNION}/tmp/.initrd
+ elif [ 1 = "$USE_AUFS_NORMAL" ]; then
+ union_insert_dir "$UNION" "$NEW_ROOT"
+ mkdir -p "$UNION/tmp/.initrd"
fi
fi # if [ "${CDROOT}" = '1' ]
@@ -986,22 +965,20 @@ fi
verbose_kmsg
-if [ "${USE_AUFS_NORMAL}" -eq '1' ]
-then
- UNION_MEMORY=${CHROOT}/.unions/memory
+if [ 1 = "$USE_AUFS_NORMAL" ]; then
+ UNION_MEMORY=$CHROOT/.unions/memory
- mkdir -p "${UNION_MEMORY}"
- mount --move "${MEMORY}" "${UNION_MEMORY}"
+ mkdir -p "$UNION_MEMORY"
+ mount --move "$MEMORY" "$UNION_MEMORY"
test_success "Failed to move aufs /memory into the system root"
- for i in /mnt/gentoo /mnt/livecd /mnt/overlay ${CDROOT_PATH}
- do
- mkdir -p "${CHROOT}${i}"
- chmod 755 "${CHROOT}${i}"
+ for dir in /mnt/gentoo $rw_branch $ro_branch $CDROOT_PATH; do
+ mkdir -p "$CHROOT$dir"
+ chmod 755 "$CHROOT$dir"
done
- for i in ${CDROOT_PATH} ${overlay} ${static}; do
- mount --move ${NEW_ROOT}${i} ${CHROOT}${i}
+ for dir in $CDROOT_PATH $rw_branch $ro_branch; do
+ mount --move "$NEW_ROOT$dir" "$CHROOT$dir"
done
fi
next reply other threads:[~2014-09-05 16:10 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 16:09 Richard Farina [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-04-29 19:04 [gentoo-commits] proj/genkernel:aufs commit in: defaults/ Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2015-04-29 19:04 Richard Farina
2014-09-23 0:21 Richard Farina
2014-09-23 0:21 Richard Farina
2014-09-05 16:11 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-09-05 16:09 Richard Farina
2014-05-24 21:35 Richard Farina
2014-05-24 21:35 Richard Farina
2014-05-24 21:35 Richard Farina
2014-05-22 20:28 Richard Farina
2014-05-22 20:28 Richard Farina
2014-05-22 20:28 Richard Farina
2014-05-22 20:28 Richard Farina
2014-03-17 19:38 Robin H. Johnson
2014-03-17 19:32 Robin H. Johnson
2014-03-17 19:20 Robin H. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403565075.5d4766cd1b811a525f5b624fc1e8daf1207acac0.zerochaos@gentoo \
--to=zerochaos@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox