diff --git a/README.md b/README.md index c8199cee6d..3416665af7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,6 @@ # Magisk on WSA (with Google Apps) -:warning: For fork developers: Please [use the GitHub Support virtual assistant chatbot](https://support.github.com/contact?flow=detach_fork&subject=Detach%20Fork&tags=rr-forks) to detach your fork from [upstream](https://github.com/LSPosed/MagiskOnWSALocal) before building with GitHub Actions, as GitHub will count your forked GitHub Actions usage against this upstream repository, which may cause this upstream repository gets disabled by GitHub staff because of numerous forks building GitHub Actions, and counting the forks' Action usage against this upstream repository. - -We are not against forks, but please detach them from our repository. If you do not make changes one day after receiving the detachment request, our organization will ban you. - -
- How to detach your fork from this upstream repository (a visual guide): -

- -

-
+:warning: For fork developers: Please don't build using GitHub Actions, as GitHub will count your forked GitHub Actions usage against this upstream repository, which may cause this upstream repository gets disabled by GitHub staff like [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA) because of numerous forks building GitHub Actions, and counting the forks' Action usage against this upstream repository. ## Support for generating from these systems @@ -62,10 +53,11 @@ We are not against forks, but please detach them from our repository. If you do 1. Star (if you like) 1. Clone the repo to local - - Run `build.sh --help` to get the usage if you want to use CLI. -1. Run `scripts/run.sh` -1. Select the WSA version and its architecture (mostly x64) -1. Select the version of Magisk + - Run `cd scripts` + - Then run `./build.sh --help` (optional) to get the usage if you want to use CLI. +1. Run `./run.sh` under scripts directory. +1. Select the WSA version and its architecture (mostly x64). +1. Select the version of Magisk. 1. Choose which brand of GApps you want to install - OpenGApps @@ -74,7 +66,7 @@ We are not against forks, but please detach them from our repository. If you do There is no other variant we can choose. 1. Select the root solution (none means no root) -1. If you are running the script for the first time, it will take some time to complete. After the script completes, two new folders named `output` and `download` will be generated in the `MagiskOnWSALocal` folder. Go to the `output` folder. While running the ./run.sh script in the last step, if you selected `Yes` for `Do you want to compress the output?` then in `output` folder you will see a compressed file called `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`or else there will be folder with the `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`. If there is a folder open it and skip to step 10. NOTE: The name of compressed file or the folder generated in the `output` folder may be different for you. It will be dependent on the choices made when executing `./run.sh` +1. If you are running the script for the first time, it will take some time to complete. After the script completes, two new folders named `output` and `download` will be generated in the `MagiskOnWSALocal` folder. Go to the `output` folder. While running the `./run.sh` script in the step 3, if you selected `Yes` for `Do you want to compress the output?` then in `output` folder you will see a compressed file called `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`or else there will be folder with the `WSA-with-magisk-stable-MindTheGapps_2207.40000.8.0_x64_Release-Nightly`. If there is a folder open it and skip to step 10. NOTE: The name of compressed file or the folder generated in the `output` folder may be different for you. It will be dependent on the choices made when executing `./run.sh` 1. Extract the compressed file and open the folder created after the extraction of the file. 1. Here look for file `Run.bat` and run it. - If you previously have a MagiskOnWSA installation, it will automatically uninstall the previous one while **preserving all user data** and install the new one, so don't worry about your data. diff --git a/scripts/build.sh b/scripts/build.sh index a27674dc17..a353c17d85 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -124,6 +124,7 @@ MAGISK_VER_MAP=( "beta" "canary" "debug" + "release" ) GAPPS_BRAND_MAP=( @@ -148,6 +149,13 @@ ROOT_SOL_MAP=( "magisk" "none" ) + +COMPRESS_FORMAT_MAP=( + "7z" + "xz" + "zip" +) + ARR_TO_STR() { local arr=("$@") local joined @@ -190,9 +198,15 @@ usage() { Possible values: $(ARR_TO_STR "${ROOT_SOL_MAP[@]}") Default: $ROOT_SOL + --compress-format + Compress format of output file. + If this option is not specified and --compress is not specified, the generated file will not be compressed + + Possible values: $(ARR_TO_STR "${COMPRESS_FORMAT_MAP[@]}") + Additional Options: --remove-amazon Remove Amazon Appstore from the system - --compress Compress the WSA + --compress Compress the WSA, The default format is 7z, you can use the format specified by --compress-format --offline Build WSA offline --magisk-custom Install custom Magisk --debug Debug build mode @@ -213,6 +227,7 @@ ARGUMENT_LIST=( "gapps-brand:" "gapps-variant:" "root-sol:" + "compress-format:" "remove-amazon" "compress" "offline" @@ -236,14 +251,15 @@ while [[ $# -gt 0 ]]; do case "$1" in --arch ) ARCH="$2"; shift 2 ;; --release-type ) RELEASE_TYPE="$2"; shift 2 ;; - --magisk-ver ) MAGISK_VER="$2"; shift 2 ;; --gapps-brand ) GAPPS_BRAND="$2"; shift 2 ;; --gapps-variant ) GAPPS_VARIANT="$2"; shift 2 ;; --root-sol ) ROOT_SOL="$2"; shift 2 ;; + --compress-format ) COMPRESS_FORMAT="$2"; shift 2 ;; --remove-amazon ) REMOVE_AMAZON="remove"; shift ;; --compress ) COMPRESS_OUTPUT="yes"; shift ;; --offline ) OFFLINE="on"; shift ;; --magisk-custom ) CUSTOM_MAGISK="debug"; MAGISK_VER=$CUSTOM_MAGISK; shift ;; + --magisk-ver ) MAGISK_VER="$2"; shift 2 ;; --debug ) DEBUG="on"; shift ;; --help ) usage; exit 0 ;; -- ) shift; break;; @@ -252,20 +268,22 @@ done check_list() { local input=$1 - local name=$2 - shift - local arr=("$@") - local list_count=${#arr[@]} - for i in "${arr[@]}"; do - if [ "$input" == "$i" ]; then - echo "INFO: $name: $input" - break - fi - ((list_count--)) - if (("$list_count" <= 0)); then - exit_with_message "Invalid $name: $input" - fi - done + if [ -n "$input" ]; then + local name=$2 + shift + local arr=("$@") + local list_count=${#arr[@]} + for i in "${arr[@]}"; do + if [ "$input" == "$i" ]; then + echo "INFO: $name: $input" + break + fi + ((list_count--)) + if (("$list_count" <= 0)); then + exit_with_message "Invalid $name: $input" + fi + done + fi } check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}" @@ -274,6 +292,7 @@ check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}" check_list "$GAPPS_BRAND" "GApps Brand" "${GAPPS_BRAND_MAP[@]}" check_list "$GAPPS_VARIANT" "GApps Variant" "${GAPPS_VARIANT_MAP[@]}" check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}" +check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}" if [ "$DEBUG" ]; then set -x @@ -296,11 +315,18 @@ echo -e "Build: RELEASE_TYPE=$RELEASE_NAME" WSA_ZIP_PATH=$DOWNLOAD_DIR/wsa-$ARCH-$RELEASE_TYPE.zip vclibs_PATH=$DOWNLOAD_DIR/Microsoft.VCLibs."$ARCH".14.00.Desktop.appx xaml_PATH=$DOWNLOAD_DIR/Microsoft.UI.Xaml_"$ARCH".appx -MAGISK_PATH=$DOWNLOAD_DIR/magisk-$MAGISK_VER.zip +MAGISK_ZIP=magisk-$MAGISK_VER.zip +MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP if [ "$CUSTOM_MAGISK" ]; then if [ ! -f "$MAGISK_PATH" ]; then - echo "Custom Magisk not found, please rename it to magisk-debug.zip and put it in $DOWNLOAD_DIR" - abort + echo "Custom Magisk $MAGISK_ZIP not found" + MAGISK_ZIP=app-$MAGISK_VER.apk + echo "Fallback to $MAGISK_ZIP" + MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP + if [ ! -f "$MAGISK_PATH" ]; then + echo -e "Custom Magisk $MAGISK_ZIP not found\nPlease put custom Magisk in $DOWNLOAD_DIR" + abort + fi fi fi if [ "$GAPPS_BRAND" = "OpenGApps" ]; then @@ -489,6 +515,7 @@ if [ "$ROOT_SOL" = 'magisk' ] || [ "$ROOT_SOL" = '' ]; then #!/system/bin/sh mkdir -p /data/adb/magisk cp /sbin/* /data/adb/magisk/ +sync chmod -R 755 /data/adb/magisk restorecon -R /data/adb/magisk for module in \$(ls /data/adb/modules); do @@ -530,8 +557,9 @@ on post-fs-data mkdir /dev/$TMP_PATH/.magisk/mirror 700 mkdir /dev/$TMP_PATH/.magisk/block 700 copy /sbin/magisk.apk /dev/$TMP_PATH/stub.apk + chmod 0644 /dev/$TMP_PATH/stub.apk rm /dev/.magisk_unblock - start $SERVER_NAME1 + exec_start $SERVER_NAME1 start $SERVER_NAME2 wait /dev/.magisk_unblock 40 rm /dev/.magisk_unblock @@ -836,13 +864,35 @@ fi if [ ! -d "$OUTPUT_DIR" ]; then mkdir -p "$OUTPUT_DIR" fi -if [ "$COMPRESS_OUTPUT" ]; then - rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort +OUTPUT_PATH="${OUTPUT_DIR:?}/$artifact_name" +if [ "$COMPRESS_OUTPUT" ] || [ -n "$COMPRESS_FORMAT" ]; then mv "$WORK_DIR/wsa/$ARCH" "$WORK_DIR/wsa/$artifact_name" - 7z a "$OUTPUT_DIR"/"$artifact_name.7z" "$WORK_DIR/wsa/$artifact_name" || abort + if [ -z "$COMPRESS_FORMAT" ]; then + COMPRESS_FORMAT="7z" + fi + if [ -n "$COMPRESS_FORMAT" ]; then + FILE_EXT=".$COMPRESS_FORMAT" + if [ "$FILE_EXT" = ".xz" ]; then + FILE_EXT=".tar$FILE_EXT" + fi + OUTPUT_PATH="$OUTPUT_PATH$FILE_EXT" + fi + rm -f "${OUTPUT_PATH:?}" || abort + if [ "$COMPRESS_FORMAT" = "7z" ]; then + echo "Compressing with 7z" + 7z a "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort + elif [ "$COMPRESS_FORMAT" = "xz" ]; then + echo "Compressing with tar xz" + if ! (tar -cP -I 'xz -9 -T0' -f "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name"); then + echo "Out of memory? Trying again with single threads..." + tar -cPJvf "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort + fi + elif [ "$COMPRESS_FORMAT" = "zip" ]; then + 7z -tzip a "${OUTPUT_PATH:?}" "$WORK_DIR/wsa/$artifact_name" || abort + fi else - rm -rf "${OUTPUT_DIR:?}/${artifact_name}" || abort - cp -r "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_DIR/$artifact_name" || abort + rm -rf "${OUTPUT_PATH:?}" || abort + cp -r "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_PATH" || abort fi echo -e "done\n" diff --git a/scripts/run.sh b/scripts/run.sh index 8f6de5e4d5..bce55471f1 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -52,6 +52,8 @@ check_dependencies() { command -v aria2c >/dev/null 2>&1 || NEED_INSTALL+=("aria2") command -v 7z > /dev/null 2>&1 || NEED_INSTALL+=("p7zip-full") command -v setfattr > /dev/null 2>&1 || NEED_INSTALL+=("attr") + command -v xz > /dev/null 2>&1 || NEED_INSTALL+=("xz-utils") + command -v unzip > /dev/null 2>&1 || NEED_INSTALL+=("unzip") } check_dependencies osrel=$(sed -n '/^ID_LIKE=/s/^.*=//p' /etc/os-release); @@ -103,8 +105,12 @@ if [ -n "${NEED_INSTALL[*]}" ]; then else if [ "$PM" = "zypper" ]; then NEED_INSTALL_FIX=${NEED_INSTALL[*]} - NEED_INSTALL_FIX=${NEED_INSTALL_FIX//setools/setools-console} >> /dev/null 2>&1 - NEED_INSTALL_FIX=${NEED_INSTALL_FIX//whiptail/dialog} >> /dev/null 2>&1 + { + NEED_INSTALL_FIX=${NEED_INSTALL_FIX//setools/setools-console} 2>&1 + NEED_INSTALL_FIX=${NEED_INSTALL_FIX//whiptail/dialog} 2>&1 + NEED_INSTALL_FIX=${NEED_INSTALL_FIX//xz-utils/xz} 2>&1 + } >> /dev/null + readarray -td ' ' NEED_INSTALL <<<"$NEED_INSTALL_FIX "; unset 'NEED_INSTALL[-1]'; elif [ "$PM" = "apk" ]; then NEED_INSTALL_FIX=${NEED_INSTALL[*]} @@ -142,8 +148,9 @@ if [ GAPPS_VARIANT != "none" ]; then fi COMPRESS_OUTPUT="--compress" +COMPRESS_FORMAT="7z" declare -A RELEASE_TYPE_MAP=(["retail"]="retail" ["release preview"]="RP" ["insider slow"]="WIS" ["insider fast"]="WIF") -COMMAND_LINE=(--arch "$ARCH" --release-type "${RELEASE_TYPE_MAP[$RELEASE_TYPE]}" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VARIANT" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$COMPRESS_OUTPUT" "$OFFLINE" "$DEBUG" "$CUSTOM_MAGISK" --debug) +COMMAND_LINE=(--arch "$ARCH" --release-type "${RELEASE_TYPE_MAP[$RELEASE_TYPE]}" --magisk-ver "$MAGISK_VER" --gapps-brand "$GAPPS_BRAND" --gapps-variant "$GAPPS_VARIANT" "$REMOVE_AMAZON" --root-sol "$ROOT_SOL" "$COMPRESS_OUTPUT" "$OFFLINE" "$DEBUG" "$CUSTOM_MAGISK" --debug --compress-format "$COMPRESS_FORMAT") echo "COMMAND_LINE=${COMMAND_LINE[*]}" ./build.sh "${COMMAND_LINE[@]}" \ No newline at end of file