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

add generic config checker to avoid code reuse, add check in a few more places

 defaults/initrd.defaults |  2 --
 defaults/initrd.scripts  | 14 ++++++++++++++
 defaults/linuxrc         | 26 ++++++--------------------
 3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index e83f6fe..32bffc0 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -72,13 +72,11 @@ 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'

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9424f5d..73e9bac 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1782,3 +1782,17 @@ strip_mount_options()
                -e 's/(,|^)(no)?auto(,|$)/,/g' \
                 -e 's/(,|^)iversion(,|$)/,/g'
 }
+
+checkzconfig() {
+  if [ -r "/proc/config.gz ]; then
+    if zcat /proc/config.gz | grep -E 'CONFIG_${1}=(m|y)' 1>/dev/null;
+    then
+     return 0
+    fi
+  fi
+
+  warn_msg "No CONFIG_${1} support"
+  warn_msg "${1} is not guarantee to work on this medium"
+
+  return 1
+}

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 7edf8d5..6464280 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -261,18 +261,11 @@ do
     ;;
     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
+      checkzconfig AUFS_FS
     ;;
                aufs\=*)
+      aufs=1
+      checkzconfig AUFS_FS
                        if echo "${x#*=}" | grep , &>/dev/null; then
                                aufs_dev_uid=${x#*,}
                                aufs_dev=${x%,*}
@@ -287,18 +280,11 @@ do
                ;;
     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
+      checkzconfig OVERLAY_FS
     ;;
   overlayfs\=*)
+    overlayfs=1
+    checkzconfig OVERLAY_FS
     if echo "${x#*=}" | grep , &>/dev/null; then
       overlayfs_dev_uid=${x#*,}
       overlayfs_dev=${x%,*}

Reply via email to