]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
anbox: Add kernel patcher based on halium config checker
authorErfan Abdi <erfangplus@gmail.com>
Mon, 14 Jun 2021 06:06:28 +0000 (10:36 +0430)
committerErfan Abdi <erfangplus@gmail.com>
Wed, 16 Jun 2021 20:50:09 +0000 (01:20 +0430)
README.md
scripts/check-kernel-config.sh [new file with mode: 0755]

index 1782bf3fcd50112632539127ec357fbffcad8331..83156a69d39745fe6ed204fe67eadd7958cac471 100644 (file)
--- a/README.md
+++ b/README.md
@@ -43,3 +43,15 @@ Execute command blew:
 wget -O - https://github.com/Anbox-halium/anbox-halium/raw/lineage-17.1/scripts/install.sh | bash
 ```
 Note: Run installer on the user you are willing to install anbox on 
+
+Patching kernel
+---------------
+Running anbox requires: 
+* Veth for networking
+* Ashmem
+* Specific binder nodes (anbox-binder anbox-hwbinder anbox-vndbinder)
+Checkout defconfig kernel patcher [script](https://github.com/Anbox-halium/anbox-halium/blob/lineage-17.1/scripts/check-kernel-config.sh) for patching halium devices kernel.
+```
+check-kernel-config.sh halium_device_defconfig -w 
+```
+On mainline devices it is highly recommanded to use needed drivers as module. (binder_linux and ashmem_linux)
diff --git a/scripts/check-kernel-config.sh b/scripts/check-kernel-config.sh
new file mode 100755 (executable)
index 0000000..7e38ef3
--- /dev/null
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+FILE=$1
+
+[ -f "$FILE" ] || {
+       echo "Provide a config file as argument"
+       exit
+}
+
+write=false
+
+if [ "$2" = "-w" ]; then
+       write=true
+fi
+
+CONFIGS_ON="
+CONFIG_SW_SYNC_USER
+CONFIG_NET_CLS_CGROUP
+CONFIG_CGROUP_NET_CLASSID
+CONFIG_VETH
+"
+
+CONFIGS_OFF="
+"
+
+CONFIGS_EQ="
+CONFIG_ANDROID_BINDER_DEVICES=\"binder,hwbinder,vndbinder,anbox-binder,anbox-hwbinder,anbox-vndbinder\"
+"
+ered() {
+       echo -e "\033[31m" $@
+}
+
+egreen() {
+       echo -e "\033[32m" $@
+}
+
+ewhite() {
+       echo -e "\033[37m" $@
+}
+
+echo -e "\n\nChecking config file for Halium specific config options.\n\n"
+
+errors=0
+fixes=0
+
+for c in $CONFIGS_ON $CONFIGS_OFF;do
+       cnt=`grep -w -c $c $FILE`
+       if [ $cnt -gt 1 ];then
+               ered "$c appears more than once in the config file, fix this"
+               errors=$((errors+1))
+       fi
+
+       if [ $cnt -eq 0 ];then
+               if $write ; then
+                       ewhite "Creating $c"
+                       echo "# $c is not set" >> "$FILE"
+                       fixes=$((fixes+1))
+               else
+                       ered "$c is neither enabled nor disabled in the config file"
+                       errors=$((errors+1))
+               fi
+       fi
+done
+
+for c in $CONFIGS_ON;do
+       if grep "$c=y\|$c=m" "$FILE" >/dev/null;then
+               egreen "$c is already set"
+       else
+               if $write ; then
+                       ewhite "Setting $c"
+                       sed  -i "s,# $c is not set,$c=y," "$FILE"
+                       fixes=$((fixes+1))
+               else
+                       ered "$c is not set, set it"
+                       errors=$((errors+1))
+               fi
+       fi
+done
+
+for c in $CONFIGS_EQ;do
+       lhs=$(awk -F= '{ print $1 }' <(echo $c))
+       rhs=$(awk -F= '{ print $2 }' <(echo $c))
+       if grep "^$c" "$FILE" >/dev/null;then
+               egreen "$c is already set correctly."
+               continue
+       elif grep "^$lhs" "$FILE" >/dev/null;then
+               cur=$(awk -F= '{ print $2 }' <(grep "$lhs" "$FILE"))
+               ered "$lhs is set, but to $cur not $rhs."
+               if $write ; then
+                       egreen "Setting $c correctly"
+                       sed -i 's,^'"$lhs"'.*,# '"$lhs"' was '"$cur"'\n'"$c"',' "$FILE"
+                       fixes=$((fixes+1))
+               fi
+       else
+               if $write ; then
+                       ewhite "Setting $c"
+                       echo  "$c" >> "$FILE"
+                       fixes=$((fixes+1))
+               else
+                       ered "$c is not set"
+                       errors=$((errors+1))
+               fi
+       fi
+done
+
+for c in $CONFIGS_OFF;do
+       if grep "$c=y\|$c=m" "$FILE" >/dev/null;then
+               if $write ; then
+                       ewhite "Unsetting $c"
+                       sed  -i "s,$c=.*,# $c is not set," $FILE
+                       fixes=$((fixes+1))
+               else
+                       ered "$c is set, unset it"
+                       errors=$((errors+1))
+               fi
+       else
+               egreen "$c is already unset"
+       fi
+done
+
+if [ $errors -eq 0 ];then
+       egreen "\n\nConfig file checked, found no errors.\n\n"
+else
+       ered "\n\nConfig file checked, found $errors errors that I did not fix.\n\n"
+fi
+
+if [ $fixes -gt 0 ];then
+       egreen "Made $fixes fixes.\n\n"
+fi
+
+ewhite " "