瀏覽代碼

remove the cmdline reference in initramfs, this isn't actually possible
added occur function for future use, as I found it useful while debugging

Hal Emmerich 4 年之前
父節點
當前提交
c1d0a3e621
共有 1 個文件被更改,包括 14 次插入5 次删除
  1. 14 5
      resources/BuildResources/initramfs-init

+ 14 - 5
resources/BuildResources/initramfs-init

@@ -45,6 +45,19 @@ rootpartuuid() {
     [ "${value}" != "" ] && echo "${value}"
 }
 
+# a clever portable shell script to detect occurances of a substring in a string
+# occur <string> <substring> (optional count)
+# if optional count is not provided:
+# returns 1 if substring is not in string
+# returns 0 otherwise
+# if optional count is provided:
+# returns 1 if substring occurs in string < optional count
+# returns 0 otherwise
+occur() while case "$1" in (*"$2"*) set -- \
+        "${1#*"$2"}" "$2" "${3:-0}" "$((${4:-0}+1))";;
+        (*) return "$((${4:-0}<${3:-1}))";;esac
+        do : "${_occur:+$((_occur=$4))}";done
+
 # mount the bare necesities
 mount -n -t proc     proc      /proc
 mount -n -t sysfs    sysfs     /sys
@@ -62,10 +75,6 @@ ROOT_DEV="${BLKID%1:*}"
 
 echo ${ROOT_DEV} > /dev/tty1
 
-# we can use this to change what cmdline options get passed into
-# the next boot stage
-CMDLINE='cat /proc/cmdline'
-
 # label any partition on the system with RESCUESHELL to enter the initramfs rescue shell before mount and root_switch.
 # you can do this with "cgpt add -i 1 -l RESCUESHELL /dev/sda" for example to label the first partiton of a usb drive.
 if [ -n "$(blkid | grep RESCUESHELL)" ]
@@ -91,4 +100,4 @@ umount /sys
 umount /proc
 
 #switch to the new rootfs
-exec switch_root /newroot /sbin/init ${CMDLINE}
+exec switch_root /newroot /sbin/init