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)