Support presubmit build ids
Bug: 72552006
Test: ./update_current.py -s P5326255
Change-Id: I829954d702e24cf19d213c5a1a63d5eebea2c8a3
diff --git a/update_current.py b/update_current.py
index 7607f55..ff2c968 100755
--- a/update_current.py
+++ b/update_current.py
@@ -15,6 +15,7 @@
support_dir = os.path.join(current_path, 'support')
extras_dir = os.path.join(current_path, 'extras')
buildtools_dir = 'tools'
+jetifier_dir = os.path.join(buildtools_dir, 'jetifier')
# See go/fetch_artifact for details on this script.
FETCH_ARTIFACT = '/google/data/ro/projects/android/fetch_artifact'
@@ -329,7 +330,7 @@
try:
subprocess.check_output(fetch_cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
- print_e('FAIL: Unable to retrieve %s artifact for build ID %d' % (artifact_path, build_id))
+ print_e('FAIL: Unable to retrieve %s artifact for build ID %s' % (artifact_path, build_id))
print_e('Please make sure you are authenticated for build server access!')
return None
return artifact_path
@@ -351,8 +352,8 @@
def update_support(target, build_id):
- repo_file = 'top-of-tree-m2repository-%s.zip' % build_id
- repo_dir = fetch_and_extract(target, build_id, repo_file)
+ repo_file = 'top-of-tree-m2repository-%s.zip' % build_id.fs_id
+ repo_dir = fetch_and_extract(target, build_id.url_id, repo_file)
if not repo_dir:
print_e('Failed to extract Support Library repository')
return False
@@ -360,9 +361,8 @@
# Transform the repo archive into a Makefile-compatible format.
return transform_maven_repo([repo_dir], support_dir)
-
def update_toolkit(target, build_id):
- repo_dir = fetch_and_extract(target, build_id, 'top-of-tree-m2repository-%s.zip' % build_id)
+ repo_dir = fetch_and_extract(target, build_id.url_id, 'top-of-tree-m2repository-%s.zip' % build_id.fs_id)
if not repo_dir:
print_e('Failed to extract App Toolkit repository')
return False
@@ -372,10 +372,10 @@
def update_constraint(target, build_id):
- layout_dir = fetch_and_extract(target, build_id,
- 'com.android.support.constraint-constraint-layout-%s.zip' % build_id)
- solver_dir = fetch_and_extract(target, build_id,
- 'com.android.support.constraint-constraint-layout-solver-%s.zip' % build_id)
+ layout_dir = fetch_and_extract(target, build_id.url_id,
+ 'com.android.support.constraint-constraint-layout-%s.zip' % build_id.fs_id)
+ solver_dir = fetch_and_extract(target, build_id.url_id,
+ 'com.android.support.constraint-constraint-layout-solver-%s.zip' % build_id.fs_id)
if not layout_dir or not solver_dir:
print_e('Failed to extract Constraint Layout repositories')
return False
@@ -407,7 +407,7 @@
def update_sdk_repo(target, build_id):
platform = 'darwin' if 'mac' in target else 'linux'
artifact_path = fetch_artifact(
- target, build_id, 'sdk-repo-%s-platforms-%s.zip' % (platform, build_id))
+ target, build_id.url_id, 'sdk-repo-%s-platforms-%s.zip' % (platform, build_id.fs_id))
if not artifact_path:
return False
@@ -427,13 +427,13 @@
def update_system(target, build_id):
- artifact_path = fetch_artifact(target, build_id, 'android_system.jar')
+ artifact_path = fetch_artifact(target, build_id.url_id, 'android_system.jar')
if not artifact_path:
return False
mv(artifact_path, path(system_path, 'android.jar'))
- artifact_path = fetch_artifact(target, build_id, 'android.test.mock.stubs_system.jar')
+ artifact_path = fetch_artifact(target, build_id.url_id, 'android.test.mock.stubs_system.jar')
if not artifact_path:
return False
@@ -443,8 +443,8 @@
def update_buildtools(target, arch, build_id):
- artifact_path = fetch_and_extract(target, build_id,
- "sdk-repo-%s-build-tools-%s.zip" % (arch, build_id))
+ artifact_path = fetch_and_extract(target, build_id.url_id,
+ "sdk-repo-%s-build-tools-%s.zip" % (arch, build_id.fs_id))
if not artifact_path:
return False
@@ -474,13 +474,29 @@
return more_text
+class buildId(object):
+ def __init__(self, url_id, fs_id):
+ # id when used in build server urls
+ self.url_id = url_id
+ # id when used in build commands
+ self.fs_id = fs_id
+
def getBuildId(args):
+ # must be in the format 12345 or P12345
source = args.source
- if source.isnumeric():
- args.file = False
- return int(args.source)
- else:
- raise Exception('Updating this set of prebuilts requires <source> to be a numeric build id, not "' + source + '"')
+ number_text = source[:]
+ presubmit = False
+ if number_text.startswith("P"):
+ presubmit = True
+ number_text = number_text[1:]
+ if not number_text.isnumeric():
+ raise Exception('Updating this set of prebuilts requires <source> to be a build id, not "' + source + '"')
+ url_id = source
+ fs_id = url_id
+ if presubmit:
+ fs_id = "0"
+ args.file = False
+ return buildId(url_id, fs_id)
parser = argparse.ArgumentParser(
description=('Update current prebuilts'))
@@ -578,7 +594,7 @@
if args.file:
src_msg = "local Maven ZIP"
else:
- src_msg = "build %s" % (getBuildId(args))
+ src_msg = "build %s" % (getBuildId(args).url_id)
msg = "Import %s from %s\n\n%s" % (components, src_msg, flatten(sys.argv))
subprocess.check_call(['git', 'commit', '-m', msg])
print('Remember to test this change before uploading it to Gerrit!')