aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Reyes (likewhoa) <design@missionaccomplish.com>2014-06-25 18:12:11 +0200
committerRick Farina (Zero_Chaos) <zerochaos@gentoo.org>2015-08-11 14:21:16 -0400
commit5070080b5bef3ee5c0231f11833f227e3e055520 (patch)
tree5fe81ddcd770b780da96619ca00750d5bc17a533 /defaults/linuxrc
parentReverting back old mknod permission settings for netboot compatibility (diff)
downloadgenkernel-5070080b5bef3ee5c0231f11833f227e3e055520.tar.gz
genkernel-5070080b5bef3ee5c0231f11833f227e3e055520.tar.bz2
genkernel-5070080b5bef3ee5c0231f11833f227e3e055520.zip
This is commit contains several changes summarized below.
1. Changed renaming of RC_NO_UMOUNTS directories 2. Upper to lowercase variables because this is the year 2014 3. Renamed aufs related variables for better readability 4. Fixed a typo in mke2fs command which was missing an "&" 5. Cleaned up setup_squashfs_aufs() function 6. Fixed an issue with legacy squashfs implementation which caused /mnt/cdrom to be shown twice in 'mount' and removed the --bind and replaced this with --move 7. Restructured the union_* functions so that we don't parse 'ls' and enabled globbing 8. Coding style changes - rid of the unnecessary braces - fix a missing & for mke2fs on livecd.aufs - renamed variables for more readabilit 9. Better error handling for changesfs() 10. Removed aufs.persistent since 'aufs' already mounts a tmpfs which uses half the available ram, and since this feature is not true persistent we remove it in favor of aufs=<DEV>
Diffstat (limited to 'defaults/linuxrc')
-rw-r--r--defaults/linuxrc151
1 files changed, 74 insertions, 77 deletions
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 5a341af..276f150 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -251,26 +251,22 @@ do
keymap=${x#*=}
;;
aufs)
- USE_AUFS_NORMAL=1
+ aufs=1
;;
aufs\=*)
- USE_AUFS_NORMAL=1
+ aufs=1
if echo "${x#*=}" | grep , &>/dev/null; then
- UID=${x#*,}
- AUFS=${x%,*}
+ aufs_dev_uid=${x#*,}
+ aufs_dev=${x%,*}
else
- AUFS=${x#*=}
+ aufs_dev=${x#*=}
fi
;;
- aufs.persistent)
- USE_AUFS_NORMAL=1
- AUFS=detect
- ;;
# Allow user to specify the modules location
aufs.modules\=*)
- MODULESD=${x#*=}
- AUFS_MODULES=true
+ aufs_modules_dev=${x#*=}
+ aufs_modules=1
;;
unionfs)
if [ ! -x /sbin/unionfs ]
@@ -447,14 +443,14 @@ then
# Setup the root filesystem
bootstrapFS
- if [ 1 = "$USE_AUFS_NORMAL" ]; then
+ if [ 1 = "$aufs" ]; then
setup_aufs
- CHROOT=$UNION
+ CHROOT=$aufs_union
else
CHROOT=${NEW_ROOT}
fi
- if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$USE_AUFS_NORMAL" ]; then
+ if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ]; then
bootstrapCD
fi
@@ -704,7 +700,7 @@ then
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'squashfs' ]
then
- if [ 1 != "$USE_AUFS_NORMAL" ]; then
+ if [ 1 != "$aufs" ]; then
good_msg 'Mounting squashfs filesystem'
_CACHED_SQUASHFS_PATH="${NEW_ROOT}/mnt/${LOOP}"
_squashfs_path="${CDROOT_PATH}/${LOOPEXT}${LOOP}" # Default to uncached
@@ -766,10 +762,10 @@ then
fi
fi # if [ -n "${CRYPT_ROOT}" ]
- if [ 1 = "$USE_AUFS_NORMAL" ]; then
- union_insert_dir "$CHROOT" "$NEW_ROOT/$FS_LOCATION"
+ if [ 1 = "$aufs" ]; then
+ union_insert_dir "$CHROOT" "$aufs_ro_branch"
- # Function to handle the RC_NO_UMOUNTS variable in ${CHROOT}/etc/rc.conf
+ # Function to handle the RC_NO_UMOUNTS variable in $CHROOT/etc/rc.conf
conf_rc_no_umounts
# Fstab changes for aufs
@@ -780,7 +776,7 @@ then
cat > "$CHROOT/etc/fstab" << FSTAB
####################################################
-## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
+## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##
####################################################
aufs / aufs defaults 0 0
@@ -790,14 +786,14 @@ distfiles /usr/portage/distfiles tmpfs defaults 0 0
FSTAB
fi
- if $AUFS_MODULES; then
- warn_msg "Adding all modules in $MODULESD/modules/"
+ if [ 1 = "$aufs_modules" ]; then
+ warn_msg "Adding all modules in $aufs_modules_dev/modules/"
- if [ -z "$MODULESD" ]; then
+ if [ -z "$aufs_modules_dev" ]; then
union_insert_modules "$CDROOT_PATH"
else
mkdir "$NEW_ROOT/mnt/modulesd"
- mount "$MODULESD" "$NEW_ROOT/mnt/modulesd"
+ mount "$aufs_modules_dev" "$NEW_ROOT/mnt/modulesd"
union_insert_modules "$NEW_ROOT/mnt/modulesd"
fi
fi
@@ -808,11 +804,13 @@ FSTAB
cp /etc/sysconfig/keyboard "$CHROOT/etc/sysconfig/"
fi
- # Create the directories for our new union mounts
+ # Create the diuectories for our new union mounts
[ ! -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"
+ # Check to see if we successfully mounted $aufs_dev
+ if [ -n "$aufs_dev" ] && grep $aufs_dev /etc/mtab 1>/dev/null; then
+ [ ! -d $CHROOT$aufs_dev_mnt ] && mkdir -p "$CHROOT$aufs_dev_mnt"
+ mount --move "$aufs_dev_mnt" "$CHROOT$aufs_dev_mnt"
fi
fi
@@ -833,31 +831,30 @@ FSTAB
fi
- if [ "${USE_UNIONFS_NORMAL}" = '1' ]
- then
+ if [ "${USE_UNIONFS_NORMAL}" = '1' ]; 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
+ elif [ 1 != "$aufs" ]; 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}/}"
@@ -869,11 +866,9 @@ FSTAB
fi
fi
# Test if the directory exists already
- if [ -e "/${NEW_ROOT}/${directory}" ]
- then
+ if [ -e "/${NEW_ROOT}/${directory}" ]; then
# It does exist, link all the individual files
- for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
- do
+ 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
@@ -882,22 +877,24 @@ FSTAB
# 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
+ done
+ fi
+ done
- fi # if [ ! "${USE_AUFS_NORMAL}" -eq '1' ]
- #XXX: end extremely confusing hunk
+ mkdir -p initramfs proc tmp run sys 2>/dev/null
+ chmod 1777 tmp
- # 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
- fi # if [ "${USE_UNIONFS_NORMAL}" = '1' ] ... else
+ # Have handy /mnt/cdrom (CDROOT_PATH) as well
+ if [ 1 = "$aufs" ]; then
+ [ ! -d "$CHROOT$CDROOT_PATH" ] && mkdir "$CHROOT$CDROOT_PATH"
+ mount --move "$CDROOT_PATH" "$CHROOT$CDROOT_PATH"
+ else
+ [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p "$NEW_ROOT$CDROOT_PATH"
+ mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH"
+ fi
#UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
#if [ "${UML}" = 'UML' ]
@@ -916,9 +913,9 @@ else
mount -t tmpfs tmpfs /union_changes
setup_unionfs /union_changes ${NEW_ROOT}
mkdir -p ${UNION}/tmp/.initrd
- elif [ 1 = "$USE_AUFS_NORMAL" ]; then
- union_insert_dir "$UNION" "$NEW_ROOT"
- mkdir -p "$UNION/tmp/.initrd"
+ elif [ 1 = "$aufs" ]; then
+ union_insert_dir "$aufs_union" "$NEW_ROOT"
+ mkdir -p "$aufs_union/tmp/.initrd"
fi
fi # if [ "${CDROOT}" = '1' ]
@@ -965,20 +962,20 @@ fi
verbose_kmsg
-if [ 1 = "$USE_AUFS_NORMAL" ]; then
- UNION_MEMORY=$CHROOT/.unions/memory
+if [ 1 = "$aufs" ]; then
+ aufs_union_memory=$CHROOT/.unions/memory
- mkdir -p "$UNION_MEMORY"
- mount --move "$MEMORY" "$UNION_MEMORY"
- test_success "Failed to move aufs /memory into the system root"
+ mkdir -p "$aufs_union_memory"
+ mount --move "$aufs_memory" "$aufs_union_memory"
+ test_success "Failed to move aufs $aufs_memory into the system root"
- for dir in /mnt/gentoo $rw_branch $ro_branch $CDROOT_PATH; do
+ for dir in /mnt/gentoo $aufs_rw_branch $aufs_ro_branch; do
mkdir -p "$CHROOT$dir"
chmod 755 "$CHROOT$dir"
done
- for dir in $CDROOT_PATH $rw_branch $ro_branch; do
- mount --move "$NEW_ROOT$dir" "$CHROOT$dir"
+ for mount in $aufs_rw_branch $aufs_ro_branch; do
+ mount --move "$mount" "$CHROOT$mount"
done
fi