From 6b11373d4ae91b10ce4745e380ee3d4b440fbde6 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 1 Jan 2018 20:32:24 -0700 Subject: [PATCH 1/3] update-binary: Change how we handle modules As of Oreo, Google is requiring that kernel modules be used whenever possible and that their location be in /vendor. With Lineage 15.1, devices without a separate /vendor partition will use /system/vendor, which symlinked to /vendor. To make this more flexible and future proof, allow developers to specify where each module needs to go by setting the path in the modules folder. If a module needs to go to /system/vendor/lib/modules, then the module should be placed in modules/system/vendor/lib/modules. Contexts and permissions will still be updated automatically. Android documentation: https://source.android.com/devices/architecture/kernel/modular-kernels Lineage 15.1 commit: https://github.com/LineageOS/android_vendor_lineage/commit/bf38db2a5e358a5449458b3dee2dd9d4015b8147 Signed-off-by: Nathan Chancellor --- META-INF/com/google/android/update-binary | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index d18a101..50d27cb 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -13,14 +13,6 @@ ui_print() { done; } show_progress() { echo "progress $1 $2" > $OUTFD; } -set_perm_recursive() { - dirs=$(echo $* | $bb awk '{ print substr($0, index($0,$5)) }'); - for i in $dirs; do - $bb chown -R $1:$2 $i; - $bb find "$i" -type d -exec chmod $3 {} +; - $bb find "$i" -type f -exec chmod $4 {} +; - done; -} file_getprop() { grep "^$2=" "$1" | cut -d= -f2; } getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; } cleanup() { rm -rf /tmp/anykernel; } @@ -63,6 +55,7 @@ ui_print "AnyKernel2 by osm0sis @ xda-developers"; ui_print " "; umount /system 2>/dev/null; mount -o ro -t auto /system; +mount -o ro -t auto /vendor 2>/dev/null; mount /data 2>/dev/null; test -f /system/system/build.prop && root=/system; @@ -97,10 +90,21 @@ if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then ui_print " "; ui_print "Pushing modules..."; mount -o rw,remount -t auto /system; - $bb cp -rLf /tmp/anykernel/modules/* $root/system/lib/modules/; - set_perm_recursive 0 0 0755 0644 $root/system/lib/modules; - chcon -R 'u:object_r:system_file:s0' $root/system/lib/modules; + mount -o rw,remount -t auto /vendor 2>/dev/null; + cd /tmp/anykernel/modules; + for module in $(find . -name '*.ko'); do + $bb cp -rLf $module /$module; + $bb chown 0:0 /$module; + $bb chmod 644 /$module; + case $module in + */vendor/*) mod=vendor;; + *) mod=system;; + esac; + chcon "u:object_r:${mod}_file:s0" /$module; + done; + cd /tmp/anykernel; mount -o ro,remount -t auto /system; + mount -o ro,remount -t auto /vendor 2>/dev/null; fi; debugging; From 218b5774d26f1ff1c0acd3bec273153f5b529cb2 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 1 Jan 2018 20:32:24 -0700 Subject: [PATCH 2/3] README: Update documentation for modules Signed-off-by: Nathan Chancellor --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c4d61eb..62d43ac 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ramdisk_compression=auto; __do.devicecheck=1__ specified requires at least device.name1 to be present. This should match ro.product.device or ro.build.product for your device. There is support for up to 5 device.name# properties. -__do.modules=1__ will push the contents of the module directory to /system/lib/modules/ and apply 644 permissions. +__do.modules=1__ will push the contents of the module directory to the same location relative to root (/) and apply 644 permissions. __do.cleanup=0__ will keep the zip from removing it's working directory in /tmp/anykernel - this can be useful if trying to debug in adb shell whether the patches worked correctly. @@ -97,7 +97,7 @@ Optional supported binaries which may be placed in /tools to enable built-in exp 1. Place zImage in the root (dtb and/or dtbo should also go here for devices that require custom ones, each will fallback to the original if not included) -2. Place any required ramdisk files in /ramdisk, and modules in /modules +2. Place any required ramdisk files in /ramdisk and modules in /modules (with the full path like /modules/system/lib/modules) 3. Place any required patch files (generally partial files which go with commands) in /patch From a0b6db2784a3cd121a4af768a68ec88fc97c550a Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 2 Jan 2018 06:45:40 -0700 Subject: [PATCH 3/3] example: Update modules folder for new location handling Signed-off-by: Nathan Chancellor --- modules/{ => system/lib/modules}/placeholder | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/{ => system/lib/modules}/placeholder (100%) diff --git a/modules/placeholder b/modules/system/lib/modules/placeholder similarity index 100% rename from modules/placeholder rename to modules/system/lib/modules/placeholder