mirror of
https://github.com/SinTan1729/ReVancedBuilder.git
synced 2024-12-26 12:48:36 -06:00
fix: Work with the changed download links for GmsCore, fixes #2
This commit is contained in:
parent
e2234078d9
commit
9195565385
4 changed files with 32 additions and 19 deletions
|
@ -50,5 +50,9 @@ root = true
|
||||||
output_name = YouTube_Music_ReVanced_root
|
output_name = YouTube_Music_ReVanced_root
|
||||||
keystore = revanced-ytm-root.keystore
|
keystore = revanced-ytm-root.keystore
|
||||||
|
|
||||||
|
[gmscore]
|
||||||
|
# If you use a Xiaomi or Huawei device, change the variant to alt
|
||||||
|
variant=regular
|
||||||
|
|
||||||
[post_script]
|
[post_script]
|
||||||
# file = ./post_script.sh
|
# file = ./post_script.sh
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import configparser as cp
|
import configparser as cp
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -45,7 +44,7 @@ def build_apps(appstate):
|
||||||
root = False
|
root = False
|
||||||
|
|
||||||
if root:
|
if root:
|
||||||
cmd += ' --mount -e microg-support'
|
cmd += ' --mount -e "GmsCore support"'
|
||||||
|
|
||||||
for item in included_patches:
|
for item in included_patches:
|
||||||
cmd += f" -i {item}"
|
cmd += f" -i {item}"
|
||||||
|
@ -58,14 +57,13 @@ def build_apps(appstate):
|
||||||
try:
|
try:
|
||||||
keystore = build_config[app]['keystore']
|
keystore = build_config[app]['keystore']
|
||||||
if not root:
|
if not root:
|
||||||
cmd += f" --keystore {keystore} --alias=alias --keystore-entry-password=ReVanced --keystore-password=ReVanced"
|
cmd += f" --keystore {keystore} --keystore-entry-alias=alias --keystore-entry-password=ReVanced --keystore-password=ReVanced"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
apk = build_config[app]['apk']
|
apk = build_config[app]['apk']
|
||||||
pretty_name = build_config[app]['pretty_name']
|
pretty_name = build_config[app]['pretty_name']
|
||||||
apkpure_appname = build_config[app]['apkpure_appname']
|
|
||||||
output_name = build_config[app]['output_name']
|
output_name = build_config[app]['output_name']
|
||||||
except:
|
except:
|
||||||
err_exit(f"Invalid config for {app} in build_config!", appstate)
|
err_exit(f"Invalid config for {app} in build_config!", appstate)
|
||||||
|
|
|
@ -28,7 +28,6 @@ def send_notif(appstate, error=False):
|
||||||
msg = msg.replace('cli', 'CLI')
|
msg = msg.replace('cli', 'CLI')
|
||||||
msg = msg.replace('integrations', 'Integrations')
|
msg = msg.replace('integrations', 'Integrations')
|
||||||
msg = msg.replace('patches', 'Patches')
|
msg = msg.replace('patches', 'Patches')
|
||||||
msg = msg.replace('VancedMicroG', 'Vanced microG')
|
|
||||||
|
|
||||||
for app in build_config:
|
for app in build_config:
|
||||||
if not build_config[app].getboolean('build'):
|
if not build_config[app].getboolean('build'):
|
||||||
|
@ -37,8 +36,8 @@ def send_notif(appstate, error=False):
|
||||||
build_config[app]['apk'], build_config[app]['pretty_name'])
|
build_config[app]['apk'], build_config[app]['pretty_name'])
|
||||||
|
|
||||||
msg += '\nTimestamp: ' + timestamp
|
msg += '\nTimestamp: ' + timestamp
|
||||||
if appstate['microg_updated']:
|
if appstate['gmscore_updated']:
|
||||||
msg += '\nVanced microG was updated.'
|
msg += '\nGmsCore was updated.'
|
||||||
|
|
||||||
config = appstate['notification_config']
|
config = appstate['notification_config']
|
||||||
for entry in config:
|
for entry in config:
|
||||||
|
|
|
@ -14,7 +14,7 @@ import requests as req
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ReVancedBuilder.APKPure_dl import apkpure_best_match, apkpure_dl, get_apks
|
from ReVancedBuilder.APKPure_dl import get_apks
|
||||||
from ReVancedBuilder.JAVABuilder import build_apps
|
from ReVancedBuilder.JAVABuilder import build_apps
|
||||||
from ReVancedBuilder.Notifications import send_notif
|
from ReVancedBuilder.Notifications import send_notif
|
||||||
from ReVancedBuilder.Cleanup import move_apps, err_exit
|
from ReVancedBuilder.Cleanup import move_apps, err_exit
|
||||||
|
@ -48,33 +48,45 @@ def update_tools(appstate):
|
||||||
|
|
||||||
return appstate
|
return appstate
|
||||||
|
|
||||||
# Update microG, if needed
|
# Update GmsCore, if needed
|
||||||
def update_microg(appstate):
|
def update_gmscore(appstate):
|
||||||
print('Checking updates for GmsCore...')
|
print('Checking updates for GmsCore...')
|
||||||
|
# Pull the latest information using the ReVanced API
|
||||||
try:
|
try:
|
||||||
data = req.get('https://api.github.com/repos/ReVanced/GmsCore/releases/latest').json()['tag_name']
|
data = req.get('https://api.revanced.app/v2/gmscore/releases/latest').json()['release']
|
||||||
latest_ver = Version(data)
|
|
||||||
except req.exceptions.RequestException as e:
|
except req.exceptions.RequestException as e:
|
||||||
err_exit(f"Error fetching info about GmsCore, {e}", appstate)
|
err_exit(f"Error fetching GmsCore information, {e}", appstate)
|
||||||
|
|
||||||
|
latest_ver = Version(data['metadata']['tag_name'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
present_ver = Version(appstate['present_vers']['GmsCore'])
|
present_ver = Version(appstate['present_vers']['GmsCore'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
present_ver = Version('0')
|
present_ver = Version('0')
|
||||||
|
|
||||||
if flag == 'force' or not os.path.isfile('microg.apk') or present_ver < latest_ver:
|
try:
|
||||||
|
variant = appstate['build_config']['gmscore']['variant']
|
||||||
|
except KeyError:
|
||||||
|
variant = "regular"
|
||||||
|
|
||||||
|
if variant == "alt":
|
||||||
|
gmscore_link = next(filter(lambda x: "-hw-" in x['name'], data['assets']))['browser_download_url']
|
||||||
|
else:
|
||||||
|
gmscore_link = next(filter(lambda x: "-hw-" not in x['name'], data['assets']))['browser_download_url']
|
||||||
|
|
||||||
|
if flag == 'force' or not os.path.isfile('GmsCore.apk') or present_ver < latest_ver:
|
||||||
appstate['up-to-date'] = False
|
appstate['up-to-date'] = False
|
||||||
print(f"GmsCore has an update ({str(present_ver)} -> {str(latest_ver)})")
|
print(f"GmsCore has an update ({str(present_ver)} -> {str(latest_ver)})")
|
||||||
if flag != 'checkonly':
|
if flag != 'checkonly':
|
||||||
print(f"Downloading GmsCore...")
|
print(f"Downloading GmsCore...")
|
||||||
res = req.get('https://github.com/ReVanced/GmsCore/releases/latest/download/microg.apk', stream=True)
|
res = req.get(gmscore_link, stream=True)
|
||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
with open('microg.apk', 'wb') as f:
|
with open('GmsCore.apk', 'wb') as f:
|
||||||
for chunk in res.iter_content(chunk_size=8192):
|
for chunk in res.iter_content(chunk_size=8192):
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
appstate['present_vers'].update({'GmsCore': str(latest_ver)})
|
appstate['present_vers'].update({'GmsCore': str(latest_ver)})
|
||||||
print("Done!")
|
print("Done!")
|
||||||
appstate['microg_updated'] = True
|
appstate['gmscore_updated'] = True
|
||||||
|
|
||||||
return appstate
|
return appstate
|
||||||
|
|
||||||
|
@ -130,7 +142,7 @@ if flag not in ['buildonly', 'checkonly', 'force', 'experimental', None]:
|
||||||
err_exit(f"Unknown flag: {flag}", appstate)
|
err_exit(f"Unknown flag: {flag}", appstate)
|
||||||
|
|
||||||
appstate['flag'] = flag
|
appstate['flag'] = flag
|
||||||
appstate['microg_updated'] = False
|
appstate['gmscore_updated'] = False
|
||||||
|
|
||||||
print(f"Started building ReVanced apps at {time.strftime('%d %B, %Y %H:%M:%S')}")
|
print(f"Started building ReVanced apps at {time.strftime('%d %B, %Y %H:%M:%S')}")
|
||||||
print('----------------------------------------------------------------------')
|
print('----------------------------------------------------------------------')
|
||||||
|
@ -163,7 +175,7 @@ appstate['up-to-date'] = True
|
||||||
# send_notif(appstate, error=False) # <,,,,,,,,<,,,,,,,,,,,,,
|
# send_notif(appstate, error=False) # <,,,,,,,,<,,,,,,,,,,,,,
|
||||||
if flag != 'buildonly':
|
if flag != 'buildonly':
|
||||||
appstate = update_tools(appstate)
|
appstate = update_tools(appstate)
|
||||||
appstate = update_microg(appstate)
|
appstate = update_gmscore(appstate)
|
||||||
if (not appstate['up-to-date'] and flag != 'checkonly') or flag == 'force':
|
if (not appstate['up-to-date'] and flag != 'checkonly') or flag == 'force':
|
||||||
appstate = get_apks(appstate)
|
appstate = get_apks(appstate)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue