commit:     c81f01fd8561844a9fc9f9b7a2d8cd2b98910fae
Author:     Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  7 19:03:29 2017 +0000
Commit:     Richard Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Mon Aug  7 19:03:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c81f01fd

initialize overlayfs and aufs variables properly, enable unconditionally and 
warn if checks fail

 defaults/initrd.defaults |   6 ++
 defaults/linuxrc         | 239 ++++++++++++++++++++++++-----------------------
 2 files changed, 129 insertions(+), 116 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index b028f72..e83f6fe 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -72,9 +72,15 @@ VERIFY=0
 
 # AUFS variables
 aufs=0
+aufs_detected=0
 aufs_union_file=/livecd.aufs
 aufs_modules_dir=mnt/cdrom
 
+# Overlayfs variables
+overlayfs=0
+overlayfs_detected=0
+overlayfs_modules_dir=mnt/cdrom
+
 LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop'
 
 DEFAULT_NFSOPTIONS="ro,nolock,rsize=1024,wsize=1024"

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 6bb1b98..7edf8d5 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -256,18 +256,22 @@ do
                keymap=*)
                        keymap=${x#*=}
                ;;
-                locale=*)
-                        locale=${x#*=}
-                ;;
-               aufs)
-                       if [ -f /proc/config.gz ]; then
-                                zcat /proc/config.gz | grep -E 
'CONFIG_AUFS_FS=(m|y)' 1>/dev/null && aufs=1
-                        else
-                                warn_msg "No CONFIG_IKCONFIG support"
-                                warn_msg "AUFS is not guarantee to work on 
this medium"
-                                aufs=1
-                        fi
-               ;;
+    locale=*)
+      locale=${x#*=}
+    ;;
+    aufs)
+      aufs=1
+      if [ -f /proc/config.gz ]; then
+        if zcat /proc/config.gz | grep -E 'CONFIG_AUFS_FS=(m|y)' 1>/dev/null;
+        then
+          aufs_detected=1
+        fi
+      fi
+      if [ "1" != "$aufs_detected" ]; then
+        warn_msg "No CONFIG_IKCONFIG support"
+        warn_msg "AUFS is not guarantee to work on this medium"
+      fi
+    ;;
                aufs\=*)
                        if echo "${x#*=}" | grep , &>/dev/null; then
                                aufs_dev_uid=${x#*,}
@@ -281,24 +285,27 @@ do
                        aufs_modules_dir=${x#*=}
                         aufs_modules=1
                ;;
-
-                overlayfs)
-                        if [ -f /proc/config.gz ]; then
-                                zcat /proc/config.gz | grep -E 
'CONFIG_OVERLAY_FS=(m|y)' 1>/dev/null && overlayfs=1
-                        else
-                                warn_msg "No CONFIG_IKCONFIG support"
-                                warn_msg "OVERLAYFS is not guarantee to work 
on this medium"
-                                overlayfs=1
-                        fi
-                ;;
-                overlayfs\=*)
-                        if echo "${x#*=}" | grep , &>/dev/null; then
-                                overlayfs_dev_uid=${x#*,}
-                                overlayfs_dev=${x%,*}
-                        else
-                                overlayfs_dev=${x#*=}
-                       fi
-               ;;
+    overlayfs)
+      overlayfs=1
+      if [ -f /proc/config.gz ]; then
+        if zcat /proc/config.gz | grep -E 'CONFIG_OVERLAY_FS=(m|y)' 
1>/dev/null;
+        then
+          overlayfs_detected=1
+        fi
+      fi
+      if [ "1" != "$overlayfs_detected" ]; then
+        warn_msg "No CONFIG_IKCONFIG support"
+        warn_msg "OVERLAYFS is not guarantee to work on this medium"
+      fi
+    ;;
+  overlayfs\=*)
+    if echo "${x#*=}" | grep , &>/dev/null; then
+      overlayfs_dev_uid=${x#*,}
+      overlayfs_dev=${x%,*}
+    else
+      overlayfs_dev=${x#*=}
+    fi
+    ;;
                # Allow user to specify the modules location
                overlayfs.modules\=*)
                        overlayfs_modules_dir=${x#*=}
@@ -877,94 +884,94 @@ FSTAB
        fi
 
 
-       if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then
-               setup_unionfs ${NEW_ROOT} /${FS_LOCATION}
-               CHROOT=/union
-        elif [ 1 != "$aufs"  ] && [ 1 != "$overlayfs" ]; 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
-                                        done
-                        fi
-                done
-
-                mkdir -p initramfs proc tmp run sys 2>/dev/null
-                chmod 1777 tmp
-
-        fi
-
-        # 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"
+  if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then
+    setup_unionfs ${NEW_ROOT} /${FS_LOCATION}
+    CHROOT=/union
+  elif [ 1 != "$aufs"  ] && [ 1 != "$overlayfs" ]; 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
-                [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p 
"$NEW_ROOT$CDROOT_PATH"
-                mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH"
+          # 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
+          done
         fi
-
-       #UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
-       #if [ "${UML}" = 'UML' ]
-       #then
-       #       # UML Fixes
-       #       good_msg 'Updating for uml system'
-       #fi
-
-       # Let Init scripts know that we booted from CD
-       export CDBOOT
-       CDBOOT=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
-       elif [ 1 = "$aufs" ]; then
-               aufs_insert_dir "$aufs_union" "$NEW_ROOT"
-               mkdir -p "$aufs_union/tmp/.initrd"
-       fi
-
-fi # if [ "${CDROOT}" = '1' ]
+      done
+
+      mkdir -p initramfs proc tmp run sys 2>/dev/null
+      chmod 1777 tmp
+
+    fi
+
+    # 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' ]
+    #then
+    #  # UML Fixes
+    #  good_msg 'Updating for uml system'
+    #fi
+
+    # Let Init scripts know that we booted from CD
+    export CDBOOT
+    CDBOOT=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
+    elif [ 1 = "$aufs" ]; then
+      aufs_insert_dir "$aufs_union" "$NEW_ROOT"
+      mkdir -p "$aufs_union/tmp/.initrd"
+    fi
+
+  fi # if [ "${CDROOT}" = '1' ]
 
 # Mount the additional things as required by udev & systemd
 if [ -f ${NEW_ROOT}/etc/initramfs.mounts ]; then

Reply via email to