AK2: introduce cmdline patching function, misc cleanup

- use proper variable for ramdisk in mkbootfs support

patch_cmdline:
- if match not present, appends to the end of the current commandline
- if match is present, expands to full string (to allow for item=value entries), and optionally replaces with a second string, or just removes the entry, then cleans up doublespaces and trailing whitespace
This commit is contained in:
osm0sis committed 2017-04-22 08:59:52 -03:00
1 parent b89e3fd164
commit 6fedeb5dc4
1 file changed
+13 -1
+13 -1
View File
@@ -116,7 +116,7 @@ write_boot() {
dtb="--dt $split_img/$dtb";
fi;
if [ -f "$bin/mkbootfs" ]; then
$bin/mkbootfs /tmp/anykernel/ramdisk | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
$bin/mkbootfs $ramdisk | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
else
cd $ramdisk;
find . | cpio -H newc -o | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
@@ -280,5 +280,17 @@ patch_fstab() {
fi;
}
# patch_cmdline <cmdline match string> [<replacement string>]
patch_cmdline() {
cmdfile=`ls $split_img/*-cmdline`;
if [ -z "$(grep "$1" $cmdfile)" ]; then
cmdtmp=`cat $cmdfile`;
echo "$cmdtmp $1" > $cmdfile;
else
match=$(grep -o "$1.*$" $cmdfile | cut -d\ -f1);
sed -i -e "s;${match};${2};" -e 's; ; ;' -e 's;[ \t]*$;;' $cmdfile;
fi;
}
## end methods