From 89f23006de51a9eda68f84cd8011d4fcf2c0448c Mon Sep 17 00:00:00 2001 From: Syuugo Date: Thu, 25 Aug 2022 03:16:13 +0900 Subject: [PATCH 01/15] Fixed some text OpenG "A "pps, etc. --- scripts/run.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 82a5f93764..0a1aa83b05 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -117,24 +117,24 @@ MAGISK_VER=$( 'debug' "Canary Channel Debug Build" 'off' ) -if (YesNoBox '([title]="Install Gapps" [text]="Do you want to install gapps?")'); then +if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then if [ -f "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip ]; then GAPPS_BRAND=$( - Radiolist '([title]="Which gapps do you want to install?" + Radiolist '([title]="Which GApps do you want to install?" [default]="OpenGapps")' \ \ - 'OpenGapps' "" 'on' \ + 'OpenGApps' "" 'on' \ 'MindTheGapps' "" 'off' ) else - GAPPS_BRAND="OpenGapps" + GAPPS_BRAND="OpenGApps" fi else GAPPS_VARIANT="none" fi -if [ $GAPPS_BRAND = "OpenGapps" ]; then +if [ $GAPPS_BRAND = "OpenGApps" ]; then GAPPS_VARIANT=$( - Radiolist '([title]="Variants of gapps" + Radiolist '([title]="Variants of GApps" [default]="pico")' \ \ 'super' "" 'off' \ @@ -151,7 +151,7 @@ else GAPPS_VARIANT=$GAPPS_BRAND fi -if (YesNoBox '([title]="Remove Amazon AppStore" [text]="Do you want to keep amazon appStore?")'); then +if (YesNoBox '([title]="Remove Amazon AppStore" [text]="Do you want to keep Amazon AppStore?")'); then REMOVE_AMAZON="keep" else REMOVE_AMAZON="remove" @@ -207,7 +207,7 @@ echo -e "done\n" if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then echo "Extract GApps" mkdir -p "$WORK_DIR"/gapps || abort - if [ $GAPPS_BRAND = "OpenGapps" ]; then + if [ $GAPPS_BRAND = "OpenGApps" ]; then unzip -p "$DOWNLOAD_DIR"/gapps.zip {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common' || abort else unzip "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps || abort @@ -432,7 +432,7 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; - if [ $GAPPS_BRAND = "OpenGapps" ]; then + if [ $GAPPS_BRAND = "OpenGApps" ]; then ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chmod 0644 {} \; ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; From 08638400bdbd244f3040b31c4c66f98fbbe2d2ba Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Thu, 25 Aug 2022 02:32:55 +0800 Subject: [PATCH 02/15] Fix some missing strings --- scripts/run.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 0a1aa83b05..8588ddeef6 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -121,7 +121,7 @@ if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")') if [ -f "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip ]; then GAPPS_BRAND=$( Radiolist '([title]="Which GApps do you want to install?" - [default]="OpenGapps")' \ + [default]="OpenGApps")' \ \ 'OpenGApps' "" 'on' \ 'MindTheGapps' "" 'off' @@ -178,7 +178,7 @@ echo "Generate Download Links" python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then - if [ $GAPPS_BRAND = "OpenGapps" ]; then + if [ $GAPPS_BRAND = "OpenGApps" ]; then # TODO: Keep it pico since other variants of opengapps are unable to boot successfully python3 generateGappsLink.py "$ARCH" "pico" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort # python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort @@ -587,8 +587,8 @@ fi if [[ "$GAPPS_VARIANT" = "none" || "$GAPPS_VARIANT" = "" ]]; then name2="-NoGApps" else - if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGapps" ]; then - echo ":warning: Since OpenGapps doesn't officially support Android 12.1 yet, lock the variant to pico!" + if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ]; then + echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!" fi name2="-GApps-${GAPPS_VARIANT}" fi From e5b9f3b9e3f4adecd76de22957d7604ef4890387 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Thu, 25 Aug 2022 14:05:05 +0800 Subject: [PATCH 03/15] Some permissions are pre-set to remove warnings before copying. --- scripts/run.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 8588ddeef6..f738e2fc9f 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -377,10 +377,10 @@ sed -i -zE "s//\n$(cat "$WORK_DIR"/wsa/xml/* | echo -e "Merge Language Resources done\n" echo "Add extra packages" -sudo cp -r ../"$ARCH"/system/* "$MOUNT_DIR" || abort -sudo find "$MOUNT_DIR"/system/priv-app -type d -exec chmod 0755 {} \; -sudo find "$MOUNT_DIR"/system/priv-app -type f -exec chmod 0644 {} \; -sudo find "$MOUNT_DIR"/system/priv-app -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; +sudo find ../"$ARCH"/system/system/priv-app -type d -exec chmod 0755 {} \; +sudo find ../"$ARCH"/system/system/priv-app -type f -exec chmod 0644 {} \; +sudo find ../"$ARCH"/system/system/priv-app -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; +sudo cp --preserve=a -r ../"$ARCH"/system/* "$MOUNT_DIR" || abort echo -e "Add extra packages done\n" if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then @@ -402,40 +402,42 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then sudo chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml "$f" done shopt -s extglob + + sudo find "$WORK_DIR"/gapps/{app,etc,framework,priv-app} -exec chown root:root {} \; + sudo find "$WORK_DIR"/gapps/product/overlay -exec chown root:root {} \; + sudo cp --preserve=a -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort sudo rm -rf "${WORK_DIR:?}"/gapps/product || abort if [ $GAPPS_BRAND = "MindTheGapps" ]; then mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort sudo cp --preserve=a -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chmod 0644 {} \; - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; + ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chmod 0644 {} \; + ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; + ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; if [ -e "$MOUNT_DIR"/system_ext/priv-app/SetupWizard ] ; then rm -rf "${MOUNT_DIR:?}/system_ext/priv-app/Provision" fi sudo rm -rf "${WORK_DIR:?}"/gapps/system_ext || abort fi - sudo cp --preserve=a -r "$WORK_DIR"/gapps/* "$MOUNT_DIR"/system || abort - sudo find "$MOUNT_DIR"/system/{app,etc,framework,priv-app} -exec chown root:root {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -exec chown root:root {} \; + sudo cp --preserve=a -r "$WORK_DIR"/gapps/* "$MOUNT_DIR"/system || abort sudo find "$MOUNT_DIR"/system/{app,etc,framework,priv-app} -type d -exec chmod 0755 {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type d -exec chmod 0755 {} \; + sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type d -exec chmod 0755 {} \; sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chmod 0644 {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type f -exec chmod 0644 {} \; + sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type f -exec chmod 0644 {} \; sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; + sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; + sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; if [ $GAPPS_BRAND = "OpenGApps" ]; then - ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chmod 0644 {} \; - ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; - ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; + ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chmod 0644 {} \; + ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; + ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; else sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -exec chown root:root {} \; sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type d -exec chmod 0755 {} \; From 5c59ac539cdcf0621af87f8b539eba665082e87a Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Thu, 25 Aug 2022 14:38:44 +0800 Subject: [PATCH 04/15] Fix MindTheGapps build --- scripts/run.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f738e2fc9f..dffb90261f 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -403,13 +403,16 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then done shopt -s extglob - sudo find "$WORK_DIR"/gapps/{app,etc,framework,priv-app} -exec chown root:root {} \; + if [ $GAPPS_BRAND = "OpenGApps" ]; then + sudo find "$WORK_DIR"/gapps/{app,etc,framework} -exec chown root:root {} \; + fi + sudo find "$WORK_DIR"/gapps/priv-app -exec chown root:root {} \; sudo find "$WORK_DIR"/gapps/product/overlay -exec chown root:root {} \; sudo cp --preserve=a -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort sudo rm -rf "${WORK_DIR:?}"/gapps/product || abort if [ $GAPPS_BRAND = "MindTheGapps" ]; then - mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort + sudo mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort sudo cp --preserve=a -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chmod 0644 {} \; ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; @@ -597,8 +600,11 @@ fi artifact_name="WSA${name1}${name2}_${WSA_VER}_${ARCH}_${WSA_REL}" echo "$artifact_name" echo -e "\nFinishing building...." +if [ -f "$OUTPUT_DIR" ]; then + sudo rm -rf "${OUTPUT_DIR:?}" +fi if [ ! -d "$OUTPUT_DIR" ]; then - mkdir "$OUTPUT_DIR" + mkdir -p "$OUTPUT_DIR" fi if [ "$COMPRESS_OUTPUT" = "yes" ]; then rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort From 3fb9ef1e773e5b8979bea80ecdd7b79bddf52e1c Mon Sep 17 00:00:00 2001 From: Syuugo Date: Thu, 25 Aug 2022 18:46:37 +0900 Subject: [PATCH 05/15] Fix some strings --- scripts/generateGappsLink.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/generateGappsLink.py b/scripts/generateGappsLink.py index cdb1d08042..d7734883da 100644 --- a/scripts/generateGappsLink.py +++ b/scripts/generateGappsLink.py @@ -31,7 +31,7 @@ variant = sys.argv[2] download_dir = Path.cwd().parent / "download" if sys.argv[3] == "" else Path(sys.argv[3]).resolve() tempScript = sys.argv[4] -print(f"Generating OpenGapps download link: arch={arch} variant={variant}", flush=True) +print(f"Generating OpenGApps download link: arch={arch} variant={variant}", flush=True) abi_map = {"x64": "x86_64", "arm64": "arm64"} # TODO: keep it 11.0 since opengapps does not support 12+ yet # As soon as opengapps is available for 12+, we need to get the sdk/release from build.prop and @@ -43,7 +43,7 @@ link = {i["name"]: i for i in j["archs"][abi_map[arch]] ["apis"][release]["variants"]}[variant]["zip"] except Exception: - print("Failed to fetch from opengapps api, fallbacking to sourceforge rss...") + print("Failed to fetch from OpenGApps API, fallbacking to SourceForge RSS...") res = requests.get( f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100') link = re.search(f'https://.*{abi_map[arch]}/.*{release}.*{variant}.*\.zip/download', res.text).group().replace( From 111fd20c1811a7ec42cb3a20204120e2a9d4f6e2 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 00:20:49 +0800 Subject: [PATCH 06/15] Rewrite Integrate GApps --- scripts/extractMagisk.py | 5 +- scripts/extractWSA.py | 10 +- scripts/fixGappsProp.py | 3 +- scripts/generateGappsLink.py | 5 +- scripts/generateMagiskLink.py | 5 +- scripts/generateWSALinks.py | 5 +- scripts/run.sh | 168 ++++++++++++++++++---------------- 7 files changed, 101 insertions(+), 100 deletions(-) diff --git a/scripts/extractMagisk.py b/scripts/extractMagisk.py index 741ffa8531..8d2bd11019 100644 --- a/scripts/extractMagisk.py +++ b/scripts/extractMagisk.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify @@ -17,8 +18,6 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/usr/bin/python - import sys import zipfile diff --git a/scripts/extractWSA.py b/scripts/extractWSA.py index 995bf68f47..2c2b10cf64 100644 --- a/scripts/extractWSA.py +++ b/scripts/extractWSA.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify @@ -17,18 +18,11 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/usr/bin/python - import sys -import requests -from xml.dom import minidom -import html import warnings -import re import zipfile import os -import urllib.request from pathlib import Path warnings.filterwarnings("ignore") diff --git a/scripts/fixGappsProp.py b/scripts/fixGappsProp.py index a033131404..0bd7dcee03 100644 --- a/scripts/fixGappsProp.py +++ b/scripts/fixGappsProp.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify diff --git a/scripts/generateGappsLink.py b/scripts/generateGappsLink.py index d7734883da..09623348d3 100644 --- a/scripts/generateGappsLink.py +++ b/scripts/generateGappsLink.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify @@ -17,8 +18,6 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/usr/bin/python - import sys import requests diff --git a/scripts/generateMagiskLink.py b/scripts/generateMagiskLink.py index 6b0fc74c92..6c541ceedb 100644 --- a/scripts/generateMagiskLink.py +++ b/scripts/generateMagiskLink.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify @@ -17,8 +18,6 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/usr/bin/python - import sys import os diff --git a/scripts/generateWSALinks.py b/scripts/generateWSALinks.py index d503aeb4b6..8d6dd177f5 100644 --- a/scripts/generateWSALinks.py +++ b/scripts/generateWSALinks.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/python +# # This file is part of MagiskOnWSALocal. # # MagiskOnWSALocal is free software: you can redistribute it and/or modify @@ -17,8 +18,6 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/usr/bin/python - import sys import requests diff --git a/scripts/run.sh b/scripts/run.sh index dffb90261f..f6b7b037cf 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # This file is part of MagiskOnWSALocal. # @@ -17,7 +18,6 @@ # Copyright (C) 2022 LSPosed Contributors # -#!/bin/bash if [ ! "$BASH_VERSION" ] ; then echo "Please do not use sh to run this script, just execute it directly" 1>&2 exit 1 @@ -28,32 +28,35 @@ if [ "$HOST_ARCH" != "x86_64" ] && [ "$HOST_ARCH" != "aarch64" ]; then exit 1 fi cd "$(dirname "$0")" || exit 1 -trap 'rm -rf -- "${WORK_DIR:?}"' EXIT +trap umount_clean EXIT WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1 DOWNLOAD_DIR=../download DOWNLOAD_CONF_NAME=download.list OUTPUT_DIR=../output MOUNT_DIR="$WORK_DIR"/system - +CLEAN_DOWNLOAD=1 +umount_clean(){ + echo "Cleanup Work Directory" + if [ -d "$MOUNT_DIR" ]; then + if [ -d "$MOUNT_DIR/vendor" ]; then + sudo umount "$MOUNT_DIR"/vendor + fi + if [ -d "$MOUNT_DIR/product" ]; then + sudo umount "$MOUNT_DIR"/product + fi + if [ -d "$MOUNT_DIR/system_ext" ]; then + sudo umount "$MOUNT_DIR"/system_ext + fi + sudo umount "$MOUNT_DIR" + fi + sudo rm -rf "${WORK_DIR:?}" +} abort() { echo "An error has occurred, exit" if [ -d "$WORK_DIR" ]; then - echo "Cleanup Work Directory" - if [ -d "$MOUNT_DIR" ]; then - if [ -d "$MOUNT_DIR/vendor" ]; then - sudo umount "$MOUNT_DIR"/vendor - fi - if [ -d "$MOUNT_DIR/product" ]; then - sudo umount "$MOUNT_DIR"/product - fi - if [ -d "$MOUNT_DIR/system_ext" ]; then - sudo umount "$MOUNT_DIR"/system_ext - fi - sudo umount "$MOUNT_DIR" - fi - sudo rm -rf "${WORK_DIR:?}" + umount_clean fi - if [ -d "$DOWNLOAD_DIR" ]; then + if [ -d "$DOWNLOAD_DIR" ] && [ $CLEAN_DOWNLOAD = "1" ]; then echo "Cleanup Download Directory" sudo rm -rf "${DOWNLOAD_DIR:?}" fi @@ -85,7 +88,7 @@ function Gen_Rand_Str { echo "Dependencies" sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf whiptail e2fsprogs python3-pip aria2 -sudo python3 -m pip install requests +python3 -m pip install requests cp -r ../wine/.cache/* ~/.cache winetricks msxml6 || abort @@ -188,8 +191,10 @@ trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT echo "Download Artifacts" if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then - echo "We have encountered an error while downloading files." - exit 1 + echo "We have encountered an error while downloading files." + exit 1 +else + CLEAN_DOWNLOAD=0 fi echo "Extract WSA" @@ -198,7 +203,7 @@ if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi export WSA_WORK_ENV python3 extractWSA.py "$ARCH" "$WORK_DIR" || abort echo -e "Extract done\n" -source "${WORK_DIR:?}/ENV" +source "${WORK_DIR:?}/ENV" || abort echo "Extract Magisk" python3 extractMagisk.py "$ARCH" "$DOWNLOAD_DIR/magisk.zip" "$WORK_DIR" || abort @@ -212,7 +217,12 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then else unzip "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps || abort mv "$WORK_DIR"/gapps/system/* "$WORK_DIR"/gapps || abort - sudo rm -rf "${WORK_DIR:?}"/gapps/system || abort + rm -rf "${WORK_DIR:?}"/gapps/system || abort + fi + cp -r ../"$ARCH"/gapps/* "$WORK_DIR"/gapps || abort + if [ $GAPPS_BRAND = "MindTheGapps" ]; then + mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort + rm -rf "${WORK_DIR:?}"/gapps/priv-app || abort fi echo -e "Extract done\n" fi @@ -247,6 +257,9 @@ fi if [ -f "$DOWNLOAD_DIR"/magisk.zip ]; then SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$DOWNLOAD_DIR"/magisk.zip | cut -f1) )) fi +if [ -d "../$ARCH/system" ]; then + SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "../$ARCH/system" | cut -f1) )) +fi resize2fs "$WORK_DIR"/wsa/"$ARCH"/system.img "$SYSTEM_SIZE"s || abort e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort @@ -377,76 +390,73 @@ sed -i -zE "s//\n$(cat "$WORK_DIR"/wsa/xml/* | echo -e "Merge Language Resources done\n" echo "Add extra packages" -sudo find ../"$ARCH"/system/system/priv-app -type d -exec chmod 0755 {} \; -sudo find ../"$ARCH"/system/system/priv-app -type f -exec chmod 0644 {} \; -sudo find ../"$ARCH"/system/system/priv-app -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; -sudo cp --preserve=a -r ../"$ARCH"/system/* "$MOUNT_DIR" || abort +sudo cp -r ../"$ARCH"/system/* "$MOUNT_DIR" || abort +find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -type d -exec chmod 0755 {} \; +find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -type f -exec chmod 0644 {} \; +find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -exec chown root:root {} \; +find ../"$ARCH"/system/system/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; +find ../"$ARCH"/system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/etc/permissions/file -type f -exec chmod 0644 {} \; +find ../"$ARCH"/system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/etc/permissions/file -exec chown root:root {} \; +find ../"$ARCH"/system/system/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/etc/permissions/file -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions/platform.xml {} \; echo -e "Add extra packages done\n" if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then echo "Integrate GApps" - cp -r ../"$ARCH"/gapps/* "$WORK_DIR"/gapps || abort - for d in $(find "$WORK_DIR"/gapps -mindepth 1 -type d -type d); do - sudo chmod 0755 "$d" - sudo chown root:root "$d" - done - for f in $(find "$WORK_DIR"/gapps -type f); do - type=$(echo "$f" | sed 's/.*\.//') - if [ "$type" == "sh" ] || [ "$type" == "$f" ]; then - sudo chmod 0755 "$f" - else - sudo chmod 0644 "$f" - fi - sudo chown root:root "$f" - sudo chcon -h --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml "$f" - sudo chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml "$f" + + find "$WORK_DIR/gapps/" -mindepth 1 -type d -exec sudo chmod 0755 {} \; + find "$WORK_DIR/gapps/" -mindepth 1 -type d -exec sudo chown root:root {} \; + file_list="$(find "$WORK_DIR/gapps/" -mindepth 1 -type f | cut -d/ -f5-)" + for file in $file_list; do + sudo chown root:root "$WORK_DIR/gapps/${file}" + sudo chmod 0644 "$WORK_DIR/gapps/${file}" done - shopt -s extglob if [ $GAPPS_BRAND = "OpenGApps" ]; then - sudo find "$WORK_DIR"/gapps/{app,etc,framework} -exec chown root:root {} \; - fi - sudo find "$WORK_DIR"/gapps/priv-app -exec chown root:root {} \; - sudo find "$WORK_DIR"/gapps/product/overlay -exec chown root:root {} \; - - sudo cp --preserve=a -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort - sudo rm -rf "${WORK_DIR:?}"/gapps/product || abort - if [ $GAPPS_BRAND = "MindTheGapps" ]; then - sudo mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort - sudo cp --preserve=a -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chmod 0644 {} \; - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; - ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions {} \; + # cp --preserve=all -r "$WORK_DIR"/gapps/!(product) "$MOUNT_DIR"/system || abort + find "$WORK_DIR"/gapps/ -maxdepth 1 -mindepth 1 -type d -not -path '*product' -exec sudo cp --preserve=all -r {} "$MOUNT_DIR"/system \; || abort + elif [ $GAPPS_BRAND = "MindTheGapps" ]; then + sudo cp --preserve=all -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort if [ -e "$MOUNT_DIR"/system_ext/priv-app/SetupWizard ] ; then rm -rf "${MOUNT_DIR:?}/system_ext/priv-app/Provision" fi - sudo rm -rf "${WORK_DIR:?}"/gapps/system_ext || abort fi + sudo cp --preserve=all -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort - sudo cp --preserve=a -r "$WORK_DIR"/gapps/* "$MOUNT_DIR"/system || abort - - sudo find "$MOUNT_DIR"/system/{app,etc,framework,priv-app} -type d -exec chmod 0755 {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type d -exec chmod 0755 {} \; - - sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chmod 0644 {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type f -exec chmod 0644 {} \; - - sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; - - sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; - sudo find "$MOUNT_DIR"/product/{app,etc,overlay,priv-app,lib64,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; + # sudo find "$MOUNT_DIR"/product/overlay -type f -exec chcon --reference="$MOUNT_DIR"/product/overlay/FontNotoSerifSource/FontNotoSerifSourceOverlay.apk {} \; + find "$WORK_DIR"/gapps/product/overlay -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/overlay/file -type f -exec chcon --reference="$MOUNT_DIR"/product/overlay/FontNotoSerifSource/FontNotoSerifSourceOverlay.apk {} \; if [ $GAPPS_BRAND = "OpenGApps" ]; then - ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chmod 0644 {} \; - ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; - ls "$WORK_DIR"/gapps/etc/ | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; + # sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; + # sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; + find "$WORK_DIR"/gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/app/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; + find "$WORK_DIR"/gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/framework/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/framework {} \; + find "$WORK_DIR"/gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; + find "$WORK_DIR"/gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/app/file -type f -exec chcon --reference="$MOUNT_DIR"/system/app/KeyChain/KeyChain.apk {} \; + find "$WORK_DIR"/gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/framework/file -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; + find "$WORK_DIR"/gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system/priv-app/file -type f -exec chcon --reference="$MOUNT_DIR"/system/priv-app/Shell/Shell.apk {} \; + find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; + find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; else - sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -exec chown root:root {} \; - sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type d -exec chmod 0755 {} \; - sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type f -exec chmod 0644 {} \; - sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; - sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions/com.android.settings.xml {} \; + # sudo find "$MOUNT_DIR"/product/{app,etc,priv-app,framework} -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; + find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/app/item -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; + find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/etc/item -type d -exec chcon --reference="$MOUNT_DIR"/product/etc {} \; + find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/priv-app/item -type d -exec chcon --reference="$MOUNT_DIR"/product/priv-app {} \; + find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/framework/item -type d -exec chcon --reference="$MOUNT_DIR"/product/framework {} \; + + # sudo find "$MOUNT_DIR"/product/{app,etc,priv-app,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; + find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/app/item -type f -exec chcon --reference="$MOUNT_DIR"/product/app/HomeApp/HomeApp.apk {} \; + find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/etc/item -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; + find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/priv-app/item -type f -exec chcon --reference="$MOUNT_DIR"/product/priv-app/SettingsIntelligence/SettingsIntelligence.apk {} \; + find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/framework/item -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; + find "$WORK_DIR"/gapps/system_ext/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system_ext/etc/permissions/file -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions/com.android.systemui.xml {} \; + + find "$WORK_DIR"/gapps/product/lib/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib/file -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; + find "$WORK_DIR"/gapps/product/lib64/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib64/file -type f -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; + # sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; + 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 d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; + find "$WORK_DIR"/gapps/system_ext/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc {} \; + # sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions/com.android.settings.xml {} \; + 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 @@ -520,7 +530,7 @@ elseif ((\$args.Count -eq 1) -and (\$args[0] -eq "EVAL")) { exit } -if (((Test-Path -Path $(ls -Q "$WORK_DIR"/wsa/"$ARCH" | paste -sd "," -)) -eq \$false).Count) { +if (((Test-Path -Path $(find "$WORK_DIR"/wsa/"$ARCH" -maxdepth 1 -mindepth 1 -printf "\"%P\"\n" | paste -sd "," -)) -eq \$false).Count) { Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist" \$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') exit 1 From cd138840d897d41d1d0b7ab3a16a1d08f2761b2a Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 00:33:22 +0800 Subject: [PATCH 07/15] Cleanup --- scripts/run.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f6b7b037cf..9a4b89784f 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -412,7 +412,6 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then done if [ $GAPPS_BRAND = "OpenGApps" ]; then - # cp --preserve=all -r "$WORK_DIR"/gapps/!(product) "$MOUNT_DIR"/system || abort find "$WORK_DIR"/gapps/ -maxdepth 1 -mindepth 1 -type d -not -path '*product' -exec sudo cp --preserve=all -r {} "$MOUNT_DIR"/system \; || abort elif [ $GAPPS_BRAND = "MindTheGapps" ]; then sudo cp --preserve=all -r "$WORK_DIR"/gapps/system_ext/* "$MOUNT_DIR"/system_ext/ || abort @@ -422,12 +421,9 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then fi sudo cp --preserve=all -r "$WORK_DIR"/gapps/product/* "$MOUNT_DIR"/product || abort - # sudo find "$MOUNT_DIR"/product/overlay -type f -exec chcon --reference="$MOUNT_DIR"/product/overlay/FontNotoSerifSource/FontNotoSerifSourceOverlay.apk {} \; find "$WORK_DIR"/gapps/product/overlay -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/overlay/file -type f -exec chcon --reference="$MOUNT_DIR"/product/overlay/FontNotoSerifSource/FontNotoSerifSourceOverlay.apk {} \; if [ $GAPPS_BRAND = "OpenGApps" ]; then - # sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; - # sudo find "$MOUNT_DIR"/system/{app,framework,priv-app} -type f -exec chcon --reference="$MOUNT_DIR"/system/framework/ext.jar {} \; find "$WORK_DIR"/gapps/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/app/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/app {} \; find "$WORK_DIR"/gapps/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/framework/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/framework {} \; find "$WORK_DIR"/gapps/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/priv-app/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/priv-app {} \; @@ -437,13 +433,11 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; find "$WORK_DIR"/gapps/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system/etc/dir -type f -exec chcon --reference="$MOUNT_DIR"/system/etc/permissions {} \; else - # sudo find "$MOUNT_DIR"/product/{app,etc,priv-app,framework} -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/app/item -type d -exec chcon --reference="$MOUNT_DIR"/product/app {} \; find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/etc/item -type d -exec chcon --reference="$MOUNT_DIR"/product/etc {} \; find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/priv-app/item -type d -exec chcon --reference="$MOUNT_DIR"/product/priv-app {} \; find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/framework/item -type d -exec chcon --reference="$MOUNT_DIR"/product/framework {} \; - # sudo find "$MOUNT_DIR"/product/{app,etc,priv-app,framework} -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; find "$WORK_DIR"/gapps/product/app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/app/item -type f -exec chcon --reference="$MOUNT_DIR"/product/app/HomeApp/HomeApp.apk {} \; find "$WORK_DIR"/gapps/product/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/etc/item -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; find "$WORK_DIR"/gapps/product/priv-app/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/priv-app/item -type f -exec chcon --reference="$MOUNT_DIR"/product/priv-app/SettingsIntelligence/SettingsIntelligence.apk {} \; @@ -452,10 +446,8 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then find "$WORK_DIR"/gapps/product/lib/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib/file -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; find "$WORK_DIR"/gapps/product/lib64/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib64/file -type f -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; - # sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; 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 d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; find "$WORK_DIR"/gapps/system_ext/etc/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I dir sudo find "$MOUNT_DIR"/system_ext/etc/dir -type d -exec chcon --reference="$MOUNT_DIR"/system_ext/etc {} \; - # sudo find "$MOUNT_DIR"/system_ext/{priv-app,etc} -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions/com.android.settings.xml {} \; 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 From b996fda4760d5cc52c6b73ec987f8d565d5911af Mon Sep 17 00:00:00 2001 From: Syuugo Date: Fri, 26 Aug 2022 02:06:14 +0900 Subject: [PATCH 08/15] Update README.md --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2774656837..79771ad590 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ - Keep each build up to date - Support both ARM64 and x64 - Support all OpenGApps variants except for aroma (aroma does not support x86_64, please use super instead) +- Remove Amazon AppStore - Fix VPN dialog not showing (use our [VpnDialogs app](https://github.com/LSPosed/VpnDialogs)) +- Add device management feature - Unattended installation - Automatically activates developers mode in Windows 11 - Update to the new version while preserving data with a one-click script @@ -73,12 +75,6 @@ - How can I get rid of Magisk? Choose `none` as the root solution. -- Github script is updated, how can I synchronize it? - - 1. In your fork repository, click `fetch upstream` - ![fetch](https://docs.github.com/assets/cb-33284/images/help/repository/fetch-upstream-drop-down.png) - 1. Then click `fetch and merge` - ![merge](https://docs.github.com/assets/cb-128489/images/help/repository/fetch-and-merge-button.png) ## Credits From f6a348a59637d4e227b1b14af8f25a56ef7ba6fa Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 02:33:27 +0800 Subject: [PATCH 09/15] Download on demand Delete only when files are corrupted Download only when a new version of a file is available close #39 --- scripts/extractWSA.py | 5 +- scripts/generateGappsLink.py | 14 ++--- scripts/generateMagiskLink.py | 27 +++++----- scripts/generateWSALinks.py | 21 ++++---- scripts/run.sh | 98 ++++++++++++++++++++++++----------- 5 files changed, 98 insertions(+), 67 deletions(-) diff --git a/scripts/extractWSA.py b/scripts/extractWSA.py index 2c2b10cf64..9da9204e6e 100644 --- a/scripts/extractWSA.py +++ b/scripts/extractWSA.py @@ -32,8 +32,9 @@ if not os.path.exists(Path.cwd().parent / sys.argv[2] / "wsa"): os.makedirs(Path.cwd().parent / sys.argv[2] / "wsa") zip_name = "" -workdir = Path.cwd().parent / sys.argv[2] / "wsa" -with zipfile.ZipFile(Path.cwd().parent / "download/wsa.zip") as zip: +wsa_zip_path= Path(sys.argv[2]).resolve() +workdir = Path.cwd().parent / sys.argv[3] / "wsa" +with zipfile.ZipFile(wsa_zip_path) as zip: for f in zip.filelist: if arch in f.filename.lower(): zip_name = f.filename diff --git a/scripts/generateGappsLink.py b/scripts/generateGappsLink.py index 09623348d3..06cc5598cb 100644 --- a/scripts/generateGappsLink.py +++ b/scripts/generateGappsLink.py @@ -50,12 +50,8 @@ print(f"download link: {link}", flush=True) -out_file = download_dir / "gapps.zip" - -if not os.path.isfile(out_file): - # urllib.request.urlretrieve(link, out_file) - with open(download_dir/tempScript, 'a') as f: - f.writelines(f'{link}\n') - f.writelines(f' dir={download_dir}\n') - f.writelines(f' out=gapps.zip\n') - f.close +with open(download_dir/tempScript, 'a') as f: + f.writelines(f'{link}\n') + f.writelines(f' dir={download_dir}\n') + f.writelines(f' out=OpenGApps-{arch}-{variant}.zip\n') + f.close diff --git a/scripts/generateMagiskLink.py b/scripts/generateMagiskLink.py index 6c541ceedb..0578c4be11 100644 --- a/scripts/generateMagiskLink.py +++ b/scripts/generateMagiskLink.py @@ -25,21 +25,18 @@ import requests from pathlib import Path -magisk_apk = sys.argv[1] +magisk_ver = sys.argv[1] download_dir = Path.cwd().parent / "download" if sys.argv[2] == "" else Path(sys.argv[2]).resolve() tempScript = sys.argv[3] -print(f"Generating Magisk download link: release type={magisk_apk}", flush=True) -if not magisk_apk: - magisk_apk = "stable" -if magisk_apk == "stable" or magisk_apk == "beta" or magisk_apk == "canary" or magisk_apk == "debug": - magisk_apk = json.loads(requests.get( - f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_apk}.json").content)['magisk']['link'] -print(f"download link: {magisk_apk}", flush=True) -out_file = download_dir / "magisk.zip" +print(f"Generating Magisk download link: release type={magisk_ver}", flush=True) +if not magisk_ver: + magisk_ver = "stable" +if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug": + magisk_link = json.loads(requests.get( + f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_ver}.json").content)['magisk']['link'] +print(f"download link: {magisk_link}", flush=True) -if not os.path.isfile(out_file): - # urllib.request.urlretrieve(magisk_apk, out_file) - with open(download_dir/tempScript, 'a') as f: - f.writelines(f'{magisk_apk}\n') - f.writelines(f' dir={download_dir}\n') - f.writelines(f' out=magisk.zip\n') +with open(download_dir/tempScript, 'a') as f: + f.writelines(f'{magisk_link}\n') + f.writelines(f' dir={download_dir}\n') + f.writelines(f' out=magisk-{magisk_ver}.zip\n') diff --git a/scripts/generateWSALinks.py b/scripts/generateWSALinks.py index 8d6dd177f5..4d761c4581 100644 --- a/scripts/generateWSALinks.py +++ b/scripts/generateWSALinks.py @@ -36,6 +36,7 @@ "insider slow": "WIS", "insider fast": "WIF"} release_type = release_type_map[sys.argv[2]] if sys.argv[2] != "" else "Retail" download_dir = Path.cwd().parent / "download" if sys.argv[3] == "" else Path(sys.argv[3]).resolve() +download_dir tempScript = sys.argv[4] cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8' print(f"Generating WSA download link: arch={arch} release_type={release_type}", flush=True) @@ -85,14 +86,14 @@ tmpdownlist = open(download_dir/tempScript, 'a') for i, v, f in identities: if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", f): - out_file = download_dir / "xaml.appx" - out_file_name = "xaml.appx" + out_file_name = f"xaml-{arch}.appx" + out_file = download_dir / out_file_name # elif re.match(f"Microsoft\.VCLibs\..+\.UWPDesktop_.*_{arch}_.*\.appx", f): # out_file = download_dir / "vclibs.appx" # out_file_name = "vclibs.appx" elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", f): - out_file = download_dir / "wsa.zip" - out_file_name = "wsa.zip" + out_file_name = f"wsa-{arch}-{release_type}.zip" + out_file = download_dir / out_file_name else: continue out = requests.post( @@ -105,13 +106,11 @@ for l in doc.getElementsByTagName("FileLocation"): url = l.getElementsByTagName("Url")[0].firstChild.nodeValue if len(url) != 99: - if not os.path.isfile(out_file): - print(f"download link: {url} to {out_file}", flush=True) - # urllib.request.urlretrieve(url, out_file) - tmpdownlist.writelines(url + '\n') - tmpdownlist.writelines(f' dir={download_dir}\n') - tmpdownlist.writelines(f' out={out_file_name}\n') + print(f"download link: {url} to {out_file}", flush=True) + tmpdownlist.writelines(url + '\n') + tmpdownlist.writelines(f' dir={download_dir}\n') + tmpdownlist.writelines(f' out={out_file_name}\n') tmpdownlist.writelines(f'https://aka.ms/Microsoft.VCLibs.{arch}.14.00.Desktop.appx\n') tmpdownlist.writelines(f' dir={download_dir}\n') -tmpdownlist.writelines(f' out=vclibs.appx\n') +tmpdownlist.writelines(f' out=vclibs-{arch}.appx\n') tmpdownlist.close diff --git a/scripts/run.sh b/scripts/run.sh index 9a4b89784f..ae94eae1ad 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -34,7 +34,6 @@ DOWNLOAD_DIR=../download DOWNLOAD_CONF_NAME=download.list OUTPUT_DIR=../output MOUNT_DIR="$WORK_DIR"/system -CLEAN_DOWNLOAD=1 umount_clean(){ echo "Cleanup Work Directory" if [ -d "$MOUNT_DIR" ]; then @@ -51,19 +50,26 @@ umount_clean(){ fi sudo rm -rf "${WORK_DIR:?}" } +clean_download(){ + if [ -d "$DOWNLOAD_DIR" ]; then + echo "Cleanup Download Directory" + if [ "$CLEAN_DOWNLOAD_WSA" = "1" ]; then + rm -f "${WSA_ZIP_PATH:?}" + fi + if [ "$CLEAN_DOWNLOAD_MAGISK" = "1" ]; then + rm -f "${MAGISK_PATH:?}" + fi + if [ "$CLEAN_DOWNLOAD_GAPPS" = "1" ]; then + rm -f "${GAPPS_PATH:?}" + fi + fi +} abort() { echo "An error has occurred, exit" if [ -d "$WORK_DIR" ]; then umount_clean fi - if [ -d "$DOWNLOAD_DIR" ] && [ $CLEAN_DOWNLOAD = "1" ]; then - echo "Cleanup Download Directory" - sudo rm -rf "${DOWNLOAD_DIR:?}" - fi - if [ -d "$OUTPUT_DIR" ]; then - echo "Cleanup Output Directory" - sudo rm -rf "${OUTPUT_DIR:?}" - fi + clean_download exit 1 } trap abort INT TERM @@ -121,7 +127,7 @@ MAGISK_VER=$( ) if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then - if [ -f "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip ]; then + if [ -f "$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip ]; then GAPPS_BRAND=$( Radiolist '([title]="Which GApps do you want to install?" [default]="OpenGApps")' \ @@ -176,7 +182,8 @@ fi clear echo -e "ARCH=$ARCH\nRELEASE_TYPE=$RELEASE_TYPE\nMAGISK_VER=$MAGISK_VER\nGAPPS_VARIANT=$GAPPS_VARIANT\nREMOVE_AMAZON=$REMOVE_AMAZON\nROOT_SOL=$ROOT_SOL\nCOMPRESS_OUTPUT=$COMPRESS_OUTPUT" - +declare -A RELEASE_TYPE_MAP=(["retail"]="Retail" ["release preview"]="RP" ["insider slow"]="WIS" ["insider fast"]="WIF") +trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT echo "Generate Download Links" python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort @@ -187,35 +194,65 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then # python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort fi fi -trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT echo "Download Artifacts" -if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then +if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 --allow-overwrite=true --conditional-get=true -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR"/"$DOWNLOAD_CONF_NAME"; then echo "We have encountered an error while downloading files." exit 1 -else - CLEAN_DOWNLOAD=0 fi +WSA_ZIP_PATH=$DOWNLOAD_DIR/wsa-$ARCH-${RELEASE_TYPE_MAP[$RELEASE_TYPE]}.zip +MAGISK_PATH=$DOWNLOAD_DIR/magisk-$MAGISK_VER.zip +GAPPS_PATH="$DOWNLOAD_DIR"/OpenGApps-$ARCH-$GAPPS_VARIANT.zip echo "Extract WSA" -WSA_WORK_ENV="${WORK_DIR:?}"/ENV -if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi -export WSA_WORK_ENV -python3 extractWSA.py "$ARCH" "$WORK_DIR" || abort -echo -e "Extract done\n" -source "${WORK_DIR:?}/ENV" || abort - +if [ -f "$WSA_ZIP_PATH" ]; then + WSA_WORK_ENV="${WORK_DIR:?}"/ENV + if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi + export WSA_WORK_ENV + if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR"; then + echo "Unzip WSA failed, is the download incomplete?" + CLEAN_DOWNLOAD_WSA=1 + abort + fi + echo -e "Extract done\n" + source "${WORK_DIR:?}/ENV" || abort +else + echo "The WSA zip package does not exist, is the download incomplete?" + exit 1 +fi echo "Extract Magisk" -python3 extractMagisk.py "$ARCH" "$DOWNLOAD_DIR/magisk.zip" "$WORK_DIR" || abort + +if [ -f "$MAGISK_PATH" ]; then + if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then + echo "Unzip Magisk failed, is the download incomplete?" + CLEAN_DOWNLOAD_MAGISK=1 + abort + fi +else + echo "The Magisk zip package does not exist, is the download incomplete?" + exit 1 +fi echo -e "done\n" if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then echo "Extract GApps" mkdir -p "$WORK_DIR"/gapps || abort if [ $GAPPS_BRAND = "OpenGApps" ]; then - unzip -p "$DOWNLOAD_DIR"/gapps.zip {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common' || abort + if [ -f "$GAPPS_PATH" ]; then + if ! unzip -p "$GAPPS_PATH" {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common'; then + echo "Unzip GApps failed, is the download incomplete?" + CLEAN_DOWNLOAD_GAPPS=1 + abort + fi + else + echo "The WSA zip package does not exist, is the download incomplete?" + exit 1 + fi else - unzip "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps || abort + if ! unzip "$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps; then + echo "Unzip MindTheGapps failed, package is corrupted?" + abort + fi mv "$WORK_DIR"/gapps/system/* "$WORK_DIR"/gapps || abort rm -rf "${WORK_DIR:?}"/gapps/system || abort fi @@ -444,6 +481,7 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then find "$WORK_DIR"/gapps/product/framework/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I item sudo find "$MOUNT_DIR"/product/framework/item -type f -exec chcon --reference="$MOUNT_DIR"/product/etc/permissions/com.android.settings.intelligence.xml {} \; find "$WORK_DIR"/gapps/system_ext/etc/permissions/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/system_ext/etc/permissions/file -type f -exec chcon --reference="$MOUNT_DIR"/system_ext/etc/permissions/com.android.systemui.xml {} \; + sudo chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so "$MOUNT_DIR"/product/lib find "$WORK_DIR"/gapps/product/lib/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib/file -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; find "$WORK_DIR"/gapps/product/lib64/ -maxdepth 1 -mindepth 1 -printf '%P\n' | xargs -I file sudo find "$MOUNT_DIR"/product/lib64/file -type f -exec chcon --reference="$MOUNT_DIR"/product/lib64/libjni_eglfence.so {} \; 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 d -exec chcon --reference="$MOUNT_DIR"/system_ext/priv-app {} \; @@ -487,7 +525,7 @@ echo -e "Shrink images done\n" echo "Remove signature and add scripts" sudo rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR"/wsa/"$ARCH"/AppxBlockMap.xml "$WORK_DIR"/wsa/"$ARCH"/AppxSignature.p7x "$WORK_DIR"/wsa/"$ARCH"/AppxMetadata || abort -cp "$DOWNLOAD_DIR"/vclibs.appx "$DOWNLOAD_DIR"/xaml.appx "$WORK_DIR"/wsa/"$ARCH" || abort +cp "$DOWNLOAD_DIR"/vclibs-"$ARCH".appx "$DOWNLOAD_DIR"/xaml-"$ARCH".appx "$WORK_DIR"/wsa/"$ARCH" || abort tee "$WORK_DIR"/wsa/"$ARCH"/Install.ps1 < Date: Fri, 26 Aug 2022 02:38:57 +0800 Subject: [PATCH 10/15] Minor Changes --- scripts/generateWSALinks.py | 1 - scripts/run.sh | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/generateWSALinks.py b/scripts/generateWSALinks.py index 4d761c4581..2c2038ab64 100644 --- a/scripts/generateWSALinks.py +++ b/scripts/generateWSALinks.py @@ -36,7 +36,6 @@ "insider slow": "WIS", "insider fast": "WIF"} release_type = release_type_map[sys.argv[2]] if sys.argv[2] != "" else "Retail" download_dir = Path.cwd().parent / "download" if sys.argv[3] == "" else Path(sys.argv[3]).resolve() -download_dir tempScript = sys.argv[4] cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8' print(f"Generating WSA download link: arch={arch} release_type={release_type}", flush=True) diff --git a/scripts/run.sh b/scripts/run.sh index ae94eae1ad..84b3ecfa35 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -34,6 +34,9 @@ DOWNLOAD_DIR=../download DOWNLOAD_CONF_NAME=download.list OUTPUT_DIR=../output MOUNT_DIR="$WORK_DIR"/system +CLEAN_DOWNLOAD_WSA=0 +CLEAN_DOWNLOAD_MAGISK=0 +CLEAN_DOWNLOAD_GAPPS=0 umount_clean(){ echo "Cleanup Work Directory" if [ -d "$MOUNT_DIR" ]; then @@ -240,12 +243,12 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then if [ $GAPPS_BRAND = "OpenGApps" ]; then if [ -f "$GAPPS_PATH" ]; then if ! unzip -p "$GAPPS_PATH" {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common'; then - echo "Unzip GApps failed, is the download incomplete?" + echo "Unzip OpenGApps failed, is the download incomplete?" CLEAN_DOWNLOAD_GAPPS=1 abort fi else - echo "The WSA zip package does not exist, is the download incomplete?" + echo "The OpenGApps zip package does not exist, is the download incomplete?" exit 1 fi else From 312dfd680c7c57b62baac49b2fe1d653dd5bfef9 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 02:45:32 +0800 Subject: [PATCH 11/15] Update artifact name --- scripts/run.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/run.sh b/scripts/run.sh index 84b3ecfa35..0cf101f669 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -638,7 +638,11 @@ else if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ]; then echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!" fi - name2="-GApps-${GAPPS_VARIANT}" + if [ $GAPPS_BRAND = "OpenGApps" ]; then + name2="-$GAPPS_BRAND-${GAPPS_VARIANT}" + else + name2="-$GAPPS_BRAND" + fi fi artifact_name="WSA${name1}${name2}_${WSA_VER}_${ARCH}_${WSA_REL}" echo "$artifact_name" From a3c9842d68fd2840a5fc949e9cd9abe01b99ee91 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 02:52:16 +0800 Subject: [PATCH 12/15] Fix Magisk file path error. --- scripts/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 0cf101f669..f11ea04531 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -294,8 +294,8 @@ fi if [ -d "$WORK_DIR"/magisk ]; then SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/magisk/magisk | cut -f1) )) fi -if [ -f "$DOWNLOAD_DIR"/magisk.zip ]; then - SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$DOWNLOAD_DIR"/magisk.zip | cut -f1) )) +if [ -f "$MAGISK_PATH" ]; then + SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$MAGISK_PATH" | cut -f1) )) fi if [ -d "../$ARCH/system" ]; then SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "../$ARCH/system" | cut -f1) )) @@ -328,7 +328,7 @@ if [ "$ROOT_SOL" = 'magisk' ] || [ "$ROOT_SOL" = '' ]; then sudo chown root:root "$MOUNT_DIR"/sbin sudo chmod 0700 "$MOUNT_DIR"/sbin sudo cp "$WORK_DIR"/magisk/magisk/* "$MOUNT_DIR"/sbin/ - sudo cp "$DOWNLOAD_DIR"/magisk.zip "$MOUNT_DIR"/sbin/magisk.apk + sudo cp "$MAGISK_PATH" "$MOUNT_DIR"/sbin/magisk.apk sudo tee -a "$MOUNT_DIR"/sbin/loadpolicy.sh < Date: Fri, 26 Aug 2022 03:28:43 +0800 Subject: [PATCH 13/15] Add an easy way to skip OpenGApps variant locking Now all but the pico variant will bootloops. --- scripts/run.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f11ea04531..0163ff9906 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -17,7 +17,7 @@ # # Copyright (C) 2022 LSPosed Contributors # - +# DEBUG=1 if [ ! "$BASH_VERSION" ] ; then echo "Please do not use sh to run this script, just execute it directly" 1>&2 exit 1 @@ -145,6 +145,8 @@ else GAPPS_VARIANT="none" fi if [ $GAPPS_BRAND = "OpenGApps" ]; then + # TODO: Keep it pico since other variants of opengapps are unable to boot successfully + if [ "$DEBUG" = "1" ]; then GAPPS_VARIANT=$( Radiolist '([title]="Variants of GApps" [default]="pico")' \ @@ -159,6 +161,9 @@ if [ $GAPPS_BRAND = "OpenGApps" ]; then 'tvstock' "" 'off' \ 'tvmini' "" 'off' ) + else + GAPPS_VARIANT=pico + fi else GAPPS_VARIANT=$GAPPS_BRAND fi @@ -192,9 +197,7 @@ python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_C python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then if [ $GAPPS_BRAND = "OpenGApps" ]; then - # TODO: Keep it pico since other variants of opengapps are unable to boot successfully - python3 generateGappsLink.py "$ARCH" "pico" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort - # python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort + python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort fi fi @@ -635,14 +638,14 @@ fi if [[ "$GAPPS_VARIANT" = "none" || "$GAPPS_VARIANT" = "" ]]; then name2="-NoGApps" else - if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ]; then - echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!" - fi if [ $GAPPS_BRAND = "OpenGApps" ]; then name2="-$GAPPS_BRAND-${GAPPS_VARIANT}" else name2="-$GAPPS_BRAND" fi + if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ] && [ "$DEBUG" != "1" ]; then + echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!" + fi fi artifact_name="WSA${name1}${name2}_${WSA_VER}_${ARCH}_${WSA_REL}" echo "$artifact_name" From 646417b9da6049e97497df8d5e657f94df76b340 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 03:32:41 +0800 Subject: [PATCH 14/15] Show OpenGApps variant warning message --- scripts/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run.sh b/scripts/run.sh index 0163ff9906..e6c675dd4e 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -643,7 +643,7 @@ else else name2="-$GAPPS_BRAND" fi - if [ "$GAPPS_VARIANT" != "pico" ] && [ $GAPPS_BRAND = "OpenGApps" ] && [ "$DEBUG" != "1" ]; then + if [ $GAPPS_BRAND = "OpenGApps" ] && [ "$DEBUG" != "1" ]; then echo ":warning: Since OpenGApps doesn't officially support Android 12.1 yet, lock the variant to pico!" fi fi From bc4664ded8cff07cbbbd62e0310e834502943b95 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Fri, 26 Aug 2022 03:54:13 +0800 Subject: [PATCH 15/15] Easy way to install self-build Magisk. --- scripts/run.sh | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index e6c675dd4e..c5950ec154 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -18,6 +18,7 @@ # Copyright (C) 2022 LSPosed Contributors # # DEBUG=1 +# CUSTOM_MAGISK=1 if [ ! "$BASH_VERSION" ] ; then echo "Please do not use sh to run this script, just execute it directly" 1>&2 exit 1 @@ -118,16 +119,19 @@ RELEASE_TYPE=$( 'insider slow' "Beta Channel" 'off' \ 'insider fast' "Dev Channel" 'off' ) - -MAGISK_VER=$( - Radiolist '([title]="Magisk version" - [default]="stable")' \ - \ - 'stable' "Stable Channel" 'on' \ - 'beta' "Beta Channel" 'off' \ - 'canary' "Canary Channel" 'off' \ - 'debug' "Canary Channel Debug Build" 'off' -) +if [ "$CUSTOM_MAGISK" != "1" ]; then + MAGISK_VER=$( + Radiolist '([title]="Magisk version" + [default]="stable")' \ + \ + 'stable' "Stable Channel" 'on' \ + 'beta' "Beta Channel" 'off' \ + 'canary' "Canary Channel" 'off' \ + 'debug' "Canary Channel Debug Build" 'off' + ) +else + MAGISK_VER=debug +fi if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then if [ -f "$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip ]; then @@ -194,7 +198,9 @@ declare -A RELEASE_TYPE_MAP=(["retail"]="Retail" ["release preview"]="RP" ["insi trap 'rm -f -- "${DOWNLOAD_DIR:?}/${DOWNLOAD_CONF_NAME}"' EXIT echo "Generate Download Links" python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort -python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort +if [ "$CUSTOM_MAGISK" != "1" ]; then + python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort +fi if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then if [ $GAPPS_BRAND = "OpenGApps" ]; then python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort @@ -234,9 +240,12 @@ if [ -f "$MAGISK_PATH" ]; then CLEAN_DOWNLOAD_MAGISK=1 abort fi -else +elif [ "$CUSTOM_MAGISK" != "1" ]; then echo "The Magisk zip package does not exist, is the download incomplete?" exit 1 +else + echo "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder." + exit 1 fi echo -e "done\n"