Skip to content

Commit

Permalink
Get WSA version before extract
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 committed Jan 11, 2023
1 parent d41bee3 commit 3c7be0a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions scripts/getWSAMainVersion.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
#
# 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)

0 comments on commit 3c7be0a

Please sign in to comment.