android13(T) 增加开机启动脚本

修改清单

system/core/rootdir/init.rc
system/sepolicy/private/file_contexts_asan
system/sepolicy/private/wallpaper.te
system/sepolicy/private/compat/31.0/31.0.ignore.cil
system/sepolicy/private/compat/32.0/32.0.ignore.cil
system/sepolicy/public/wallpaper.te
system/sepolicy/prebuilts/api/33.0/private/file_contexts_asan
system/sepolicy/prebuilts/api/33.0/private/wallpaper.te
system/sepolicy/prebuilts/api/33.0/private/compat/31.0/31.0.ignore.cil
system/sepolicy/prebuilts/api/33.0/private/compat/32.0/32.0.ignore.cil
system/sepolicy/prebuilts/api/33.0/public/wallpaper.te

一上来按照之前经验增加 wallpaper.te 文件,编译直接报错

错误一

ermediates/built_28.0_plat_sepolicy -o out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/built_28.0_plat_sepolicy -f /dev/null )"
system/sepolicy/prebuilts/api/28.0/public/wallpaper.te:4:ERROR 'attribute system_file_type is not declared' at token ';' on line 17448:
type wallpaper_exec, system_file_type, exec_type, file_type;
type wallpaper, domain;
checkpolicy:  error(s) encountered while parsing configuration
16:45:14 ninja failed with: exit status 1

和文件格式之类的有关系

在 file_contexts 中发现了一个例子 extra_free_kbytes.sh 看着靠谱,就直接复用它来

grep extra_free_kbytes_exec ./system/sepolicy/ -nir
./system/sepolicy/private/file_contexts:233:/system/bin/extra_free_kbytes.sh u:object_r:extra_free_kbytes_exec:s0
./system/sepolicy/private/compat/31.0/31.0.ignore.cil:19: extra_free_kbytes_exec
./system/sepolicy/private/compat/32.0/32.0.ignore.cil:29: extra_free_kbytes_exec
./system/sepolicy/public/extra_free_kbytes.te:3:type extra_free_kbytes_exec, system_file_type, exec_type, file_type;
./system/sepolicy/prebuilts/api/33.0/private/file_contexts:233:/system/bin/extra_free_kbytes.sh u:object_r:extra_free_kbytes_exec:s0
./system/sepolicy/prebuilts/api/33.0/private/compat/31.0/31.0.ignore.cil:19: extra_free_kbytes_exec
./system/sepolicy/prebuilts/api/33.0/private/compat/32.0/32.0.ignore.cil:29: extra_free_kbytes_exec
./system/sepolicy/prebuilts/api/33.0/public/extra_free_kbytes.te:3:type extra_free_kbytes_exec, system_file_type, exec_type, file_type;

错误二

[ 76% 19/25] build out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0
FAILED: out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0
/bin/bash -c "(out/host/linux-x86/bin/treble_sepolicy_tests  -f out/target/product/qssi/system/etc/selinux/plat_file_contexts  -f out/target/product/qssi/vendor/etc/selinux/vendor_file_contexts  -f out/target/product/qssi/system_ext/etc/selinux/system_ext_file_contexts  -f out/target/product/qssi/product/etc/selinux/product_file_contexts                 -b out/target/product/qssi/obj/ETC/base_plat_sepolicy_intermediates/base_plat_sepolicy -m out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/28.0_mapping.combined.cil                 -o out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/built_28.0_plat_sepolicy -p out/target/product/qssi/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy                 -u out/target/product/qssi/obj/ETC/base_plat_pub_policy.cil_intermediates/base_plat_pub_policy.cil                 --fake-treble ) && (touch out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0 )"
/home/LA.QSSI.13.0.R1/out/soong/.temp/Soong.python_cq0z3hcd/treble_sepolicy_tests.py:23: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils.ccompiler
Unrecognized entrypoint for wallpaper at /oem/bin/wallpaper\.sh
SELinux: The following public types were found added to the policy without an entry into the compatibility mapping file(s) found in private/compat/V.v/V.v[.ignore].cil, where V.v is the latest API level.
wallpaper wallpaper_exec

See examples of how to fix this:
https://android-review.googlesource.com/c/platform/system/sepolicy/+/781036
https://android-review.googlesource.com/c/platform/system/sepolicy/+/852612

解决办法在 31.0.ignore.cil 和 32.0.ignore.cil 中增加 wallpaper wallpaper_exec

错误三

[ 76% 19/25] build out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0
FAILED: out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0
/bin/bash -c "(out/host/linux-x86/bin/treble_sepolicy_tests  -f out/target/product/qssi/system/etc/selinux/plat_file_contexts  -f out/target/product/qssi/vendor/etc/selinux/vendor_file_contexts  -f out/target/product/qssi/system_ext/etc/selinux/system_ext_file_contexts  -f out/target/product/qssi/product/etc/selinux/product_file_contexts                 -b out/target/product/qssi/obj/ETC/base_plat_sepolicy_intermediates/base_plat_sepolicy -m out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/28.0_mapping.combined.cil                 -o out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/built_28.0_plat_sepolicy -p out/target/product/qssi/obj/ETC/precompiled_sepolicy_intermediates/precompiled_sepolicy                 -u out/target/product/qssi/obj/ETC/base_plat_pub_policy.cil_intermediates/base_plat_pub_policy.cil                 --fake-treble ) && (touch out/target/product/qssi/obj/FAKE/treble_sepolicy_tests_28.0_intermediates/treble_sepolicy_tests_28.0 )"
/home/LA.QSSI.13.0.R1/out/soong/.temp/Soong.python_cq0z3hcd/treble_sepolicy_tests.py:23: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils.ccompiler
Unrecognized entrypoint for wallpaper at /oem/bin/wallpaper\.sh

最坑就是这个错误,一直查不到原因,隔了两天看了错误二中有 See examples of how to fix this 网址提示,去看了看,发现了一个文件 file_contexts_asan

把 /oem/bin/wallpaper.sh u:object_r:wallpaper_exec:s0 从 file_contexts 移动到 file_contexts_asan 中,编译错误解决。

system/core/rootdir/init.rc

on property:persist.test.wallpaper=1
    start  setwallpaper

service setwallpaper /system/bin/sh /oem/bin/wallpaper.sh
    class main
    oneshot
    seclabel u:object_r:wallpaper_exec:s0

system/sepolicy/private/file_contexts_asan

/oem/bin/wallpaper\.sh u:object_r:wallpaper_exec:s0

system/sepolicy/private/wallpaper.te

typeattribute wallpaper coredomain;

init_daemon_domain(wallpaper)

system/sepolicy/private/compat/31.0/31.0.ignore.cil
system/sepolicy/private/compat/32.0/32.0.ignore.cil

    extra_free_kbytes
    extra_free_kbytes_exec
    wallpaper
    wallpaper_exec
    framework_status_prop

system/sepolicy/public/wallpaper.te

# The wallpaper.sh script run by init.
type wallpaper, domain;
type wallpaper_exec, system_file_type, exec_type, file_type;

猜你喜欢

转载自blog.csdn.net/u012932409/article/details/130420651