From dcc6dcd9bea4a0064010cfbb665c99282ad31fd3 Mon Sep 17 00:00:00 2001 From: orariley70 <96967473+orariley70@users.noreply.github.com> Date: Sat, 8 Oct 2022 20:27:27 +0700 Subject: [PATCH 1/2] Improve wording and provide tutorial to detach fork (#170) Co-authored-by: Howard Wu <40033067+Howard20181@users.noreply.github.com> --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c5ffa6..c8199ce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ # Magisk on WSA (with Google Apps) -:warning: For fork developers: Please detach the fork from [upstream](https://github.com/LSPosed/MagiskOnWSALocal) before building with Actions, Github will count the forked Actions usage to the upstream repository, which means if a forked repository abuses Actions, the repository that gets disabled will be upstream. 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. +: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): +

+ +

+
## Support for generating from these systems From 1fc795b7fe1d63e3af4a07756112f425bd42e5a3 Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:03:02 +0800 Subject: [PATCH 2/2] Supports compression using xz format Close #203 --- scripts/build.sh | 63 ++++++++++++++++++++++++++++++++++-------------- scripts/run.sh | 21 +++++++++++++--- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 8b143f4..7c62025 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -148,6 +148,12 @@ ROOT_SOL_MAP=( "magisk" "none" ) + +COMPRESS_FORMAT_MAP=( + "7z" + "xz" +) + ARR_TO_STR() { local arr=("$@") local joined @@ -190,9 +196,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 +225,7 @@ ARGUMENT_LIST=( "gapps-brand:" "gapps-variant:" "root-sol:" + "compress-format:" "remove-amazon" "compress" "offline" @@ -240,6 +253,7 @@ while [[ $# -gt 0 ]]; do --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 ;; @@ -252,20 +266,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 +290,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 @@ -836,10 +853,20 @@ fi if [ ! -d "$OUTPUT_DIR" ]; then mkdir -p "$OUTPUT_DIR" fi -if [ "$COMPRESS_OUTPUT" ]; then - rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort +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 [ "$COMPRESS_FORMAT" = "7z" ]; then + rm -f "${OUTPUT_DIR:?}"/"$artifact_name.7z" || abort + echo "Compressing with 7z" + 7z a "$OUTPUT_DIR"/"$artifact_name.7z" "$WORK_DIR/wsa/$artifact_name" || abort + elif [ "$COMPRESS_FORMAT" = "xz" ]; then + rm -f "${OUTPUT_DIR:?}"/"$artifact_name.tar.xz" || abort + echo "Compressing with tar xz" + if ! (tar -cP -I 'xz -9 -T0' -f "$OUTPUT_DIR"/"$artifact_name.tar.xz" "$WORK_DIR/wsa/$artifact_name"); then + echo "Out of memory? Trying again with single threads..." + tar -cPJvf "$OUTPUT_DIR"/"$artifact_name.tar.xz" "$WORK_DIR/wsa/$artifact_name" || abort + fi + fi else rm -rf "${OUTPUT_DIR:?}/${artifact_name}" || abort cp -r "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_DIR/$artifact_name" || abort diff --git a/scripts/run.sh b/scripts/run.sh index ff2bfca..1cc078f 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -52,6 +52,7 @@ 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") } check_dependencies osrel=$(sed -n '/^ID_LIKE=/s/^.*=//p' /etc/os-release); @@ -103,8 +104,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[*]} @@ -223,7 +228,15 @@ if (YesNoBox '([title]="Compress output" [text]="Do you want to compress the out else COMPRESS_OUTPUT="" fi - +if [ "$COMPRESS_OUTPUT" = "--compress" ]; then + COMPRESS_FORMAT=$( + Radiolist '([title]="Compress format" + [default]="7z")' \ + \ + '7z' "7-Zip" 'on' \ + 'xz' "tar.xz" 'off' + ) +fi # if ! (YesNoBox '([title]="Off line mode" [text]="Do you want to enable off line mode?")'); then # OFFLINE="--offline" # else @@ -232,6 +245,6 @@ fi # OFFLINE="--offline" clear 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") +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" --compress-format "$COMPRESS_FORMAT") echo "COMMAND_LINE=${COMMAND_LINE[*]}" ./build.sh "${COMMAND_LINE[@]}"