From 3c7be0aa1c9de2770029d84b76e7d1d5ebfa32c6 Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:27:06 +0800 Subject: [PATCH] Get WSA version before extract --- scripts/build.sh | 10 +++------ scripts/getWSAMainVersion.py | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 scripts/getWSAMainVersion.py diff --git a/scripts/build.sh b/scripts/build.sh index 1ed31a8..310b911 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -375,7 +375,7 @@ if [ -z "${OFFLINE+x}" ]; then # shellcheck disable=SC1091 source "${WORK_DIR:?}/ENV" || abort else - DOWN_WSA_MAIN_VERSION=2211 + DOWN_WSA_MAIN_VERSION=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") fi if [[ "$DOWN_WSA_MAIN_VERSION" -lt 2211 ]]; then ANDROID_API=32 @@ -394,8 +394,8 @@ if [ -z "${OFFLINE+x}" ]; then exit 1 fi else # Offline mode - # TODO: Removed after Android 13 was released to the retail channel - if [ "$RELEASE_TYPE" = "retail" ]; then + DOWN_WSA_MAIN_VERSION=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") + if [[ "$DOWN_WSA_MAIN_VERSION" -lt 2211 ]]; then ANDROID_API=32 update_gapps_zip_name fi @@ -429,10 +429,6 @@ if [ -f "$WSA_ZIP_PATH" ]; then echo -e "Extract done\n" # shellcheck disable=SC1091 source "${WORK_DIR:?}/ENV" || abort - if [[ "$WSA_MAIN_VER" -ge 2211 ]]; then - ANDROID_API=33 - update_gapps_zip_name - fi else echo "The WSA zip package does not exist, is the download incomplete?" exit 1 diff --git a/scripts/getWSAMainVersion.py b/scripts/getWSAMainVersion.py new file mode 100644 index 0000000..68f3768 --- /dev/null +++ b/scripts/getWSAMainVersion.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# +# This file is part of MagiskOnWSALocal. +# +# MagiskOnWSALocal is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# MagiskOnWSALocal is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with MagiskOnWSALocal. If not, see . +# +# Copyright (C) 2023 LSPosed Contributors +# + +import sys + +import zipfile +from pathlib import Path + +arch = sys.argv[1] + +zip_name = "" +wsa_zip_path= Path(sys.argv[2]).resolve() + +with zipfile.ZipFile(wsa_zip_path) as zip: + for f in zip.filelist: + if arch in f.filename.lower(): + zip_name = f.filename + ver_no = zip_name.split("_") + long_ver = ver_no[1] + ver = long_ver.split(".") + main_ver = ver[0] + print(main_ver)