pixel: Remove hardcoded version from get-new-devices.py

Change-Id: I03af5fc9f270cc9dd4f4183095173096fe33dbc0
This commit is contained in:
Chirayu Desai
2023-05-01 23:58:23 +05:30
committed by Michael Bestas
parent c32092b849
commit 795e2a85dd
2 changed files with 8 additions and 7 deletions

View File

@@ -19,9 +19,9 @@ OTA_URL = "https://developers.google.com/android/ota"
COOKIE = {'Cookie': 'devsite_wall_acks=nexus-image-tos,nexus-ota-tos'}
PLATFORM_BUILD_URL = "https://android.googlesource.com/platform/build"
BUILD_ID_URL = "https://android.googlesource.com/platform/build/+/refs/tags/{}/core/build_id.mk?format=TEXT"
BUILD_ID_URL = "https://android.googlesource.com/platform/build/+/refs/{}/core/build_id.mk?format=TEXT"
BUILD_ID_FILTER = "BUILD_ID="
SECURITY_PATCH_URL = "https://android.googlesource.com/platform/build/+/refs/tags/{}/core/version_defaults.mk?format=TEXT"
SECURITY_PATCH_URL = "https://android.googlesource.com/platform/build/+/refs/{}/core/version_defaults.mk?format=TEXT"
SECURITY_PATCH_FILTER = "PLATFORM_SECURITY_PATCH :="
def handle_image(html_id):
@@ -54,7 +54,7 @@ def get_all_aosp_tags(tag_filter):
def get_aosp_tag_for_build_id(aosp_tags, wanted_build_id):
for aosp_tag in aosp_tags:
output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format(aosp_tag)).read()).decode()
output = base64.decodebytes(urllib.request.urlopen(BUILD_ID_URL.format("tags/" + aosp_tag)).read()).decode()
for line in output.split('\n'):
if BUILD_ID_FILTER in line:
found_build_id = line.split("=")[1]
@@ -66,7 +66,7 @@ def get_aosp_tag_for_build_id(aosp_tags, wanted_build_id):
def get_security_patch_for_aosp_tag(aosp_tag):
try:
output = base64.decodebytes(urllib.request.urlopen(SECURITY_PATCH_URL.format(aosp_tag)).read()).decode()
output = base64.decodebytes(urllib.request.urlopen(SECURITY_PATCH_URL.format("tags/" + aosp_tag)).read()).decode()
except:
print('new_security_patch=unknown')
return
@@ -81,12 +81,12 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('-b', '--build_id', help="Build ID", type=str, required=True)
parser.add_argument('-d', '--device', help="Device codename", type=str, required=True)
parser.add_argument('-v', '--version', default="13.0", help='Android version', type=str)
parser.add_argument('-t', '--tags_match', default="android-13.0", help='Android version tag to match', type=str)
args = parser.parse_args()
html_id = "{0}{1}".format(args.device, args.build_id.lower())
handle_image(html_id)
handle_ota(html_id)
aosp_tag = get_aosp_tag_for_build_id(get_all_aosp_tags("android-{0}*".format(args.version)), args.build_id.upper())
aosp_tag = get_aosp_tag_for_build_id(get_all_aosp_tags("{0}*".format(args.tags_match)), args.build_id.upper())
get_security_patch_for_aosp_tag(aosp_tag)
if __name__ == "__main__":

View File

@@ -32,6 +32,7 @@ readonly vars_path="${script_path}/../../../vendor/lineage/vars"
readonly tmp_dir="${TMPDIR:-/tmp}/pixel"
source "${vars_path}/pixels"
source "${vars_path}/common"
## HELP MESSAGE (USAGE INFO)
# TODO
@@ -66,7 +67,7 @@ main() {
local tmp=$(mktemp "${tmp_dir}/${d}.XXXXXXXXXX")
local dv="${vars_path}/${d}"
source "${dv}"
${script_path}/get-new-device-vars.py -b "${build_id}" -d "${d}"> "${tmp}"
${script_path}/get-new-device-vars.py -b "${build_id}" -d "${d}" -t ${aosp_tag_match}> "${tmp}"
source "${tmp}"
if [[ "${new_aosp_tag}" != "${aosp_tag}" ]]; then
sed -i "/ prev_aosp_tag=/c\readonly prev_aosp_tag=\"$aosp_tag\"" "${dv}"