From 37b59237d74915d34ebe8a7d4608b41e0dd9763d Mon Sep 17 00:00:00 2001 From: Syuugo Date: Sat, 10 Sep 2022 15:40:21 +0900 Subject: [PATCH] Build x86_64 with MindTheGappsBuilder (#94) Co-authored-by: Howard Wu <40033067+Howard20181@users.noreply.github.com> --- scripts/build.sh | 4 ++-- scripts/generateGappsLink.py | 42 +++++++++++++++++++++++------------- scripts/run.sh | 18 ++++++---------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index d428c45..5d78fdb 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -306,8 +306,8 @@ if [ -z "${OFFLINE+x}" ]; then if [ -z "${CUSTOM_MAGISK+x}" ]; then python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort fi - if [ "$GAPPS_BRAND" = "OpenGApps" ]; then - python3 generateGappsLink.py "$ARCH" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort + if [ "$GAPPS_BRAND" != "none" ]; then + python3 generateGappsLink.py "$ARCH" "$GAPPS_BRAND" "$GAPPS_VARIANT" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort fi echo "Download Artifacts" diff --git a/scripts/generateGappsLink.py b/scripts/generateGappsLink.py index 06cc559..d3350c0 100644 --- a/scripts/generateGappsLink.py +++ b/scripts/generateGappsLink.py @@ -27,31 +27,43 @@ import re from pathlib import Path arch = sys.argv[1] -variant = sys.argv[2] -download_dir = Path.cwd().parent / "download" if sys.argv[3] == "" else Path(sys.argv[3]).resolve() -tempScript = sys.argv[4] -print(f"Generating OpenGApps download link: arch={arch} variant={variant}", flush=True) +brand = sys.argv[2] +variant = sys.argv[3] +download_dir = Path.cwd().parent / \ + "download" if sys.argv[4] == "" else Path(sys.argv[4]).resolve() +tempScript = sys.argv[5] +print( + f"Generating {brand} download link: arch={arch} variant={variant}", flush=True) abi_map = {"x64": "x86_64", "arm64": "arm64"} # TODO: keep it 11.0 since opengapps does not support 12+ yet # As soon as opengapps is available for 12+, we need to get the sdk/release from build.prop and # download the corresponding version release = "11.0" -try: - res = requests.get(f"https://api.opengapps.org/list") - j = json.loads(res.content) - link = {i["name"]: i for i in j["archs"][abi_map[arch]] - ["apis"][release]["variants"]}[variant]["zip"] -except Exception: - print("Failed to fetch from OpenGApps API, fallbacking to SourceForge RSS...") +if brand == "OpenGApps": + try: + res = requests.get(f"https://api.opengapps.org/list") + j = json.loads(res.content) + link = {i["name"]: i for i in j["archs"][abi_map[arch]] + ["apis"][release]["variants"]}[variant]["zip"] + except Exception: + print("Failed to fetch from OpenGApps API, fallbacking to SourceForge RSS...") + res = requests.get( + f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100') + link = re.search(f'https://.*{abi_map[arch]}/.*{release}.*{variant}.*\.zip/download', res.text).group().replace( + '.zip/download', '.zip').replace('sourceforge.net/projects/opengapps/files', 'downloads.sourceforge.net/project/opengapps') +elif brand == "MindTheGapps": res = requests.get( - f'https://sourceforge.net/projects/opengapps/rss?path=/{abi_map[arch]}&limit=100') - link = re.search(f'https://.*{abi_map[arch]}/.*{release}.*{variant}.*\.zip/download', res.text).group().replace( - '.zip/download', '.zip').replace('sourceforge.net/projects/opengapps/files', 'downloads.sourceforge.net/project/opengapps') + f'https://sourceforge.net/projects/wsa-mtg/rss?path=/{abi_map[arch]}&limit=100') + link = re.search(f'https://.*{abi_map[arch]}/.*\.zip/download', res.text).group().replace( + '.zip/download', '.zip').replace('sourceforge.net/projects/wsa-mtg/files', 'downloads.sourceforge.net/project/wsa-mtg') print(f"download link: {link}", flush=True) with open(download_dir/tempScript, 'a') as f: f.writelines(f'{link}\n') f.writelines(f' dir={download_dir}\n') - f.writelines(f' out=OpenGApps-{arch}-{variant}.zip\n') + if brand == "OpenGApps": + f.writelines(f' out={brand}-{arch}-{variant}.zip\n') + elif brand == "MindTheGapps": + f.writelines(f' out={brand}-{arch}.zip\n') f.close diff --git a/scripts/run.sh b/scripts/run.sh index 7f4cfd8..212dbcc 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -145,17 +145,13 @@ else fi if (YesNoBox '([title]="Install GApps" [text]="Do you want to install GApps?")'); then - if [ -f "$DOWNLOAD_DIR"/MindTheGapps-"$ARCH".zip ]; then - GAPPS_BRAND=$( - Radiolist '([title]="Which GApps do you want to install?" - [default]="OpenGApps")' \ - \ - 'OpenGApps' "" 'on' \ - 'MindTheGapps' "" 'off' - ) - else - GAPPS_BRAND="OpenGApps" - fi + GAPPS_BRAND=$( + Radiolist '([title]="Which GApps do you want to install?" + [default]="OpenGApps")' \ + \ + 'OpenGApps' "" 'on' \ + 'MindTheGapps' "" 'off' + ) else GAPPS_BRAND="none" fi