From d296e2765968e2e677f6885ea1668c0c72ca1c0e Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Fri, 16 Sep 2022 16:22:45 +0800 Subject: [PATCH 1/3] Fix Play Services SElinux Policy close #55 --- scripts/build.sh | 2 +- scripts/generateGappsLink.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 3369bd9..7a8c458 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -628,7 +628,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then sudo patchelf --replace-needed libdl.so "../linker/$HOST_ARCH/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort sudo patchelf --set-interpreter "../linker/$HOST_ARCH/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort - sudo "$WORK_DIR"/magisk/magiskpolicy --load "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --save "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" || abort + sudo "$WORK_DIR"/magisk/magiskpolicy --load "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --save "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" "allow gmscore_app system_server_tmpfs filesystem getattr" "allow gmscore_app gpu_device dir search" || abort echo -e "Integrate GApps done\n" fi diff --git a/scripts/generateGappsLink.py b/scripts/generateGappsLink.py index d1d7b47..cdaf6ff 100644 --- a/scripts/generateGappsLink.py +++ b/scripts/generateGappsLink.py @@ -45,7 +45,6 @@ if brand == "OpenGApps": j = json.loads(res.content) link = {i["name"]: i for i in j["archs"][abi_map[arch]] ["apis"][release]["variants"]}[variant]["zip"] - # print(f"JSON={j}", flush=True) DATE=j["archs"][abi_map[arch]]["date"] print(f"DATE={DATE}", flush=True) except Exception: From 2a86e252a20770f45002dd9746c92df45d3ee31e Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:32:04 +0800 Subject: [PATCH 2/3] Minor change --- scripts/build.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 7a8c458..a7d257e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -359,6 +359,11 @@ if [ -f "$MAGISK_PATH" ]; then CLEAN_DOWNLOAD_MAGISK=1 abort fi + sudo patchelf --replace-needed libc.so "../linker/$HOST_ARCH/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort + sudo patchelf --replace-needed libm.so "../linker/$HOST_ARCH/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort + sudo patchelf --replace-needed libdl.so "../linker/$HOST_ARCH/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort + sudo patchelf --set-interpreter "../linker/$HOST_ARCH/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort + chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort elif [ -z "${CUSTOM_MAGISK+x}" ]; then echo "The Magisk zip package does not exist, is the download incomplete?" exit 1 @@ -476,11 +481,7 @@ EOF sudo find "$MOUNT_DIR"/sbin -type f -exec chmod 0755 {} \; sudo find "$MOUNT_DIR"/sbin -type f -exec chown root:root {} \; sudo find "$MOUNT_DIR"/sbin -type f -exec chcon --reference "$MOUNT_DIR"/product {} \; - sudo patchelf --replace-needed libc.so "../linker/$HOST_ARCH/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --replace-needed libm.so "../linker/$HOST_ARCH/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --replace-needed libdl.so "../linker/$HOST_ARCH/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --set-interpreter "../linker/$HOST_ARCH/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort - chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort + TMP_PATH=$(Gen_Rand_Str 8) echo "/dev/$TMP_PATH(/.*)? u:object_r:magisk_file:s0" | sudo tee -a "$MOUNT_DIR"/vendor/etc/selinux/vendor_file_contexts echo '/data/adb/magisk(/.*)? u:object_r:magisk_file:s0' | sudo tee -a "$MOUNT_DIR"/vendor/etc/selinux/vendor_file_contexts @@ -623,11 +624,6 @@ if [ "$GAPPS_BRAND" != 'none' ]; then find "$WORK_DIR"/gapps/system_ext/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/priv-app/dir -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app/Settings/Settings.apk {} \; fi - sudo patchelf --replace-needed libc.so "../linker/$HOST_ARCH/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --replace-needed libm.so "../linker/$HOST_ARCH/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --replace-needed libdl.so "../linker/$HOST_ARCH/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort - sudo patchelf --set-interpreter "../linker/$HOST_ARCH/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort - chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort sudo "$WORK_DIR"/magisk/magiskpolicy --load "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy --save "$MOUNT_DIR"/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" "allow gmscore_app system_server_tmpfs filesystem getattr" "allow gmscore_app gpu_device dir search" || abort echo -e "Integrate GApps done\n" fi From 823f1895d0c8e408b6f481967ea900230a0ede9c Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Sat, 17 Sep 2022 00:57:15 +0800 Subject: [PATCH 3/3] Fix stupid mistake --- scripts/extractWSA.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/extractWSA.py b/scripts/extractWSA.py index 9da9204..12da132 100644 --- a/scripts/extractWSA.py +++ b/scripts/extractWSA.py @@ -29,11 +29,11 @@ warnings.filterwarnings("ignore") arch = sys.argv[1] -if not os.path.exists(Path.cwd().parent / sys.argv[2] / "wsa"): - os.makedirs(Path.cwd().parent / sys.argv[2] / "wsa") zip_name = "" wsa_zip_path= Path(sys.argv[2]).resolve() workdir = Path.cwd().parent / sys.argv[3] / "wsa" +if not os.path.exists(workdir): + os.makedirs(workdir) with zipfile.ZipFile(wsa_zip_path) as zip: for f in zip.filelist: if arch in f.filename.lower():