Justin Yun | 9d2e85e | 2022-11-25 15:18:11 +0900 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (C) 2022 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | import argparse |
| 19 | import logging |
| 20 | |
| 21 | import update |
| 22 | import utils |
| 23 | |
| 24 | VNDK_SNAPSHOT_SOURCE_BRANCHES = { |
| 25 | 29: 'qt-gsi-release', |
| 26 | 30: 'android11-gsi', |
| 27 | 31: 'android12-gsi', |
| 28 | 32: 'android12L-gsi', |
| 29 | 33: 'android13-gsi', |
| 30 | } |
| 31 | |
| 32 | def fetch_and_update_snapshots(versions, args): |
| 33 | for version in versions: |
| 34 | if version not in VNDK_SNAPSHOT_SOURCE_BRANCHES: |
| 35 | raise ValueError ('Unknown VNDK version: {}'.format(version)) |
| 36 | logging.info('Updating snapshot version {}'.format(version)) |
| 37 | branch = VNDK_SNAPSHOT_SOURCE_BRANCHES[version] |
| 38 | bid = utils.get_latest_vndk_bid(branch) |
| 39 | |
| 40 | update.run(version, branch, bid, None, args.use_current_branch, |
| 41 | args.remote, args.verbose) |
| 42 | |
| 43 | def get_args(parser): |
| 44 | parser.add_argument( |
| 45 | 'versions', |
| 46 | metavar='vndk_version', |
| 47 | type=int, |
| 48 | nargs='*', |
| 49 | help='list of versions to fetch and update') |
| 50 | parser.add_argument( |
| 51 | '--all', |
| 52 | action='store_true', |
| 53 | help='fetch all vndk snapshots') |
| 54 | parser.add_argument( |
| 55 | '--use-current-branch', |
| 56 | action='store_true', |
| 57 | help='Perform the update in the current branch. Do not repo start.') |
| 58 | parser.add_argument( |
| 59 | '--remote', |
| 60 | default='aosp', |
| 61 | help=('Remote name to fetch and check if the revision of VNDK snapshot ' |
| 62 | 'is included in the source to conform GPL license. default=aosp')) |
| 63 | parser.add_argument( |
| 64 | '-v', |
| 65 | '--verbose', |
| 66 | action='count', |
| 67 | default=0, |
| 68 | help='Increase output verbosity, e.g. "-v", "-vv"') |
| 69 | return parser.parse_args() |
| 70 | |
| 71 | def main(): |
| 72 | parser = argparse.ArgumentParser() |
| 73 | args = get_args(parser) |
| 74 | utils.set_logging_config(args.verbose) |
| 75 | |
| 76 | if args.all: |
| 77 | versions = VNDK_SNAPSHOT_SOURCE_BRANCHES.keys() |
| 78 | fetch_and_update_snapshots(versions, args) |
| 79 | return |
| 80 | |
| 81 | if not args.versions: |
| 82 | parser.print_help() |
| 83 | return |
| 84 | |
| 85 | fetch_and_update_snapshots(args.versions, args) |
| 86 | |
| 87 | if __name__ == '__main__': |
| 88 | main() |