Debian Codegraph @

sdkmanager.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # PYTHON_ARGCOMPLETE_OK
3 #
4 # sdkmanager.py - part of the F-Droid tools
5 #
6 # Copyright (C) 2021, Hans-Christoph Steiner <[email protected]>
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17 #
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 import argparse
22 import base64
23 import configparser
24 import difflib
25 import gzip
26 import io
27 import json
28 import os
29 import re
30 import secrets
31 import shutil
32 import stat
33 import subprocess
34 import sys
35 import tempfile
36 import textwrap
37 import traceback
38 import zipfile
39 from pathlib import Path
40 from urllib.parse import urlparse
41
42 import requests
43 from requests.adapters import HTTPAdapter, Retry
44
45 try:
46 from looseversion import LooseVersion
47 except ImportError:
48 # distutils.version was removed in Python 3.12
49 import warnings
50 from distutils.version import LooseVersion
51
52 warnings.filterwarnings("ignore", category=DeprecationWarning)
53
54 COMPATIBLE_VERSION = '26.1.1'
55
56 # gitlab.com is disabled because it has Cloudflare blocking enabled and is therefore unreliable
57 CHECKSUMS_URLS = (
58 'https://f-droid.github.io/android-sdk-transparency-log/signed/checksums.json',
59 'https://fdroid.gitlab.io/android-sdk-transparency-log/checksums.json',
60 # 'https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/signed/checksums.json',
61 'https://raw.githubusercontent.com/f-droid/android-sdk-transparency-log/master/signed/checksums.json',
62 )
63
64 HTTP_HEADERS = {'User-Agent': 'F-Droid'}
65 BUILD_REGEX = re.compile(r'[1-9][0-9]{6}')
66 NDK_RELEASE_REGEX = re.compile(r'r[1-9][0-9]?[a-z]?(?:-(?:rc|beta)[0-9]+)?')
67 M2REPOSITORY_REVISION_REGEX = re.compile(r'android_m2repository_r([0-9]+)\.zip')
68
69 # The sub-directory to install a given package into, assumes ANDROID_HOME as root
70 # https://developer.android.com/studio/command-line/
71 #
72 # The base directories are hard coded:
73 # https://android.googlesource.com/platform/tools/base/+/2a5cb6330f399286bf193b7b0c098766e4701f8a/common/src/main/java/com/android/SdkConstants.java#508
74 # https://android.googlesource.com/platform/tools/base/+/2a5cb6330f399286bf193b7b0c098766e4701f8a/sdklib/src/main/java/com/android/sdklib/repository/meta/DetailsTypes.java#550
75 INSTALL_DIRS = {
76 'build-tools': 'build-tools/{revision}',
77 'cmake': 'cmake/{revision}',
78 'cmdline-tools': 'cmdline-tools/{revision}',
79 'emulator': 'emulator',
80 'ndk': 'ndk/{revision}',
81 'ndk-bundle': 'ndk-bundle',
82 'platforms': 'platforms/{revision}',
83 'platform-tools': 'platform-tools',
84 'skiaparser': 'skiaparser/{revision}',
85 'system-images': 'system-images/android-{apilevel}/{tag_id}/{abi}', # unused
86 'tools': 'tools',
87 'extras;android;m2repository': 'extras/android/m2repository',
88 }
89
90 # NDK releases are like r25b, revisions are like 25.1.8937393. Dir names use revisions.
91 NDK_REVISIONS = {}
92
93 # xsi:type="ns3:genericDetailsType
94 GENERIC_PACKAGE_XML_TEMPLATE = textwrap.dedent(
95 """
96 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
97 <ns2:repository
98 xmlns:ns2="http://schemas.android.com/repository/android/common/02"
99 xmlns:ns3="http://schemas.android.com/repository/android/common/01"
100 xmlns:ns4="http://schemas.android.com/repository/android/generic/01"
101 xmlns:ns5="http://schemas.android.com/repository/android/generic/02"
102 xmlns:ns6="http://schemas.android.com/sdk/android/repo/repository2/01"
103 xmlns:ns7="http://schemas.android.com/sdk/android/repo/repository2/02"
104 xmlns:ns8="http://schemas.android.com/sdk/android/repo/repository2/03"
105 xmlns:ns9="http://schemas.android.com/sdk/android/repo/addon2/01"
106 xmlns:ns10="http://schemas.android.com/sdk/android/repo/addon2/02"
107 xmlns:ns11="http://schemas.android.com/sdk/android/repo/addon2/03"
108 xmlns:ns12="http://schemas.android.com/sdk/android/repo/sys-img2/04"
109 xmlns:ns13="http://schemas.android.com/sdk/android/repo/sys-img2/03"
110 xmlns:ns14="http://schemas.android.com/sdk/android/repo/sys-img2/02"
111 xmlns:ns15="http://schemas.android.com/sdk/android/repo/sys-img2/01">
112 <license id="{license_id}" type="text">{license}</license>
113 <localPackage path="{path}" obsolete="false">
114 {type_details}
115 <revision>{revision}</revision>
116 <display-name>{display_name}</display-name>
117 <uses-license ref="{license_id}"/>
118 {dependencies}
119 </localPackage>
120 </ns2:repository>
121 """
122 ).strip()
123
124 GENERIC_TYPE_DETAILS = """<type-details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns5:genericDetailsType"/>"""
125
126 # this is needed for platforms 36+
127 PLATFORM_TYPE_DETAILS_TEMPLATE = """
128 <type-details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns8:platformDetailsType">
129 <api-level>{api_level}</api-level>
130 <codename>{codename}</codename>
131 {extension}
132 <layoutlib api="{layoutlib_api}"/>
133 </type-details>
134 """.strip()
135
136 SOURCE_TYPE_DETAILS_TEMPLATE = """
137 <type-details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns8:sourceDetailsType">
138 <api-level>{api_level}</api-level>
139 <codename>{codename}</codename>
140 {extension}
141 </type-details>
142 """.strip()
143
144 SYSTEM_IMAGES_TYPE_DETAILS_TEMPLATE = """
145 <type-details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns12:sysImgDetailsType">
146 <api-level>{api_level}</api-level>
147 {extension}
148 <tag>
149 <id>{tag_id}</id>
150 <display>{tag_display}</display>
151 </tag>
152 <abi>{abi}</abi>
153 <abis>{abi}</abis>
154 </type-details>
155 """.strip()
156
157 SYSTEM_IMAGES_DEPENDENCIES_TEMPLATE = """
158 <dependencies>
159 <dependency path="{dependency_path}">
160 <min-revision>
161 <major>{major}</major>
162 <minor>{minor}</minor>
163 <micro>{micro}</micro>
164 </min-revision>
165 </dependency>
166 </dependencies>
167 """.strip()
168
169 USAGE = """
170 Usage:
171 sdkmanager [--uninstall] [<common args>] [--package_file=<file>] [<packages>...]
172 sdkmanager --update [<common args>]
173 sdkmanager --list [<common args>]
174 sdkmanager --licenses [<common args>]
175 sdkmanager --version
176
177 With --install (optional), installs or updates packages.
178 By default, the listed packages are installed or (if already installed)
179 updated to the latest version.
180 With --uninstall, uninstall the listed packages.
181
182 <package> is a sdk-style path (e.g. "build-tools;23.0.0" or
183 "platforms;android-23").
184 <package-file> is a text file where each line is a sdk-style path
185 of a package to install or uninstall.
186 Multiple --package_file arguments may be specified in combination
187 with explicit paths.
188
189 With --update, all installed packages are updated to the latest version.
190
191 With --list, all installed and available packages are printed out.
192
193 With --licenses, show and offer the option to accept licenses for all
194 available packages that have not already been accepted.
195
196 With --version, prints the current version of sdkmanager.
197
198 Common Arguments:
199 --sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK
200 containing this tool
201
202 --channel=<channelId>: Include packages in channels up to <channelId>.
203 Common channels are:
204 0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
205
206 --include_obsolete: With --list, show obsolete packages in the
207 package listing. With --update, update obsolete
208 packages as well as non-obsolete.
209
210 --no_https: Force all connections to use http rather than https.
211
212 --proxy=<http | socks>: Connect via a proxy of the given type.
213
214 --proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
215
216 --proxy_port=<port #>: Proxy port to connect to.
217
218 --verbose: Enable verbose output.
219
220 * If the env var REPO_OS_OVERRIDE is set to "windows",
221 "macosx", or "linux", packages will be downloaded for that OS.
222 """
223
224 ANDROID_SDK_LICENSE = """Terms and Conditions
225
226 This is the Android Software Development Kit License Agreement
227
228 1. Introduction
229
230 1.1 The Android Software Development Kit (referred to in the License Agreement as the "SDK" and specifically including the Android system files, packaged APIs, and Google APIs add-ons) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the SDK.
231
232 1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.
233
234 1.3 A "compatible implementation" means any Android device that (i) complies with the Android Compatibility Definition document, which can be found at the Android compatibility website (http://source.android.com/compatibility) and which may be updated from time to time; and (ii) successfully passes the Android Compatibility Test Suite (CTS).
235
236 1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
237
238
239 2. Accepting the License Agreement
240
241 2.1 In order to use the SDK, you must first agree to the License Agreement. You may not use the SDK if you do not accept the License Agreement.
242
243 2.2 By clicking to accept, you hereby agree to the terms of the License Agreement.
244
245 2.3 You may not use the SDK and may not accept the License Agreement if you are a person barred from receiving the SDK under the laws of the United States or other countries, including the country in which you are resident or from which you use the SDK.
246
247 2.4 If you are agreeing to be bound by the License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the SDK on behalf of your employer or other entity.
248
249
250 3. SDK License from Google
251
252 3.1 Subject to the terms of the License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the SDK solely to develop applications for compatible implementations of Android.
253
254 3.2 You may not use this SDK to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this SDK is not used for that purpose.
255
256 3.3 You agree that Google or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
257
258 3.4 You may not use the SDK for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK.
259
260 3.5 Use, reproduction and distribution of components of the SDK licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement.
261
262 3.6 You agree that the form and nature of the SDK that Google provides may change without prior notice to you and that future versions of the SDK may be incompatible with applications developed on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) providing the SDK (or any features within the SDK) to you or to users generally at Google's sole discretion, without prior notice to you.
263
264 3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
265
266 3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the SDK.
267
268
269 4. Use of the SDK by You
270
271 4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the SDK, including any intellectual property rights that subsist in those applications.
272
273 4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) the License Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
274
275 4.3 You agree that if you use the SDK to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you permission to do so.
276
277 4.4 You agree that you will not engage in any activity with the SDK, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google or any mobile communications carrier.
278
279 4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
280
281 4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
282
283 5. Your Developer Credentials
284
285 5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
286
287 6. Privacy and Information
288
289 6.1 In order to continually innovate and improve the SDK, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the SDK are being used and how they are being used. Before any of this information is collected, the SDK will notify you and seek your consent. If you withhold consent, the information will not be collected.
290
291 6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in accordance with Google's Privacy Policy.
292
293
294 7. Third Party Applications
295
296 7.1 If you use the SDK to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
297
298 7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
299
300 7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, the License Agreement does not affect your legal relationship with these third parties.
301
302
303 8. Using Android APIs
304
305 8.1 Google Data APIs
306
307 8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
308
309 8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so. If you use the Android Recognition Service API, documented at the following URL: https://developer.android.com/reference/android/speech/RecognitionService, as updated from time to time, you acknowledge that the use of the API is subject to the Data Processing Addendum for Products where Google is a Data Processor, which is located at the following URL: https://privacy.google.com/businesses/gdprprocessorterms/, as updated from time to time. By clicking to accept, you hereby agree to the terms of the Data Processing Addendum for Products where Google is a Data Processor.
310
311
312 9. Terminating the License Agreement
313
314 9.1 The License Agreement will continue to apply until terminated by either you or Google as set out below.
315
316 9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the SDK and any relevant developer credentials.
317
318 9.3 Google may at any time, terminate the License Agreement with you if: (A) you have breached any provision of the License Agreement; or (B) Google is required to do so by law; or (C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the SDK to you; or (D) Google decides to no longer provide the SDK or certain parts of the SDK to users in the country in which you are resident or from which you use the service, or the provision of the SDK or certain SDK services to you by Google is, in Google's sole discretion, no longer commercially viable.
319
320 9.4 When the License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst the License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.
321
322
323 10. DISCLAIMER OF WARRANTIES
324
325 10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
326
327 10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.
328
329 10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
330
331
332 11. LIMITATION OF LIABILITY
333
334 11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
335
336
337 12. Indemnification
338
339 12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with the License Agreement.
340
341
342 13. Changes to the License Agreement
343
344 13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. When these changes are made, Google will make a new version of the License Agreement available on the website where the SDK is made available.
345
346
347 14. General Legal Terms
348
349 14.1 The License Agreement constitutes the whole legal agreement between you and Google and governs your use of the SDK (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the SDK.
350
351 14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
352
353 14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
354
355 14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
356
357 14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
358
359 14.6 The rights granted in the License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under the License Agreement without the prior written approval of the other party.
360
361 14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
362
363
364 January 16, 2019"""
365
366
367 # This is generated by doing:
368 # gpg --export-options export-minimal,export-clean \
369 # --export 37D2C98789D8311948394E3E41E7044E1DBA2E89 EE6620C7136B0D2C456C0A4DE9E28DEA00AA5556 \
370 # | gzip -9 \
371 # | base64 --wrap=88 \
372 # > keyring.gpg.gz.base64
373 KEYRING_GPG_GZ_BASE64 = """
374 H4sIAKZ8zGECA+17ZVBd3bblwd3d3d3dgrs7wd3d3Tn4wd3dLTjB3YIFD+6BQPAEaPK9e9+7P7pvdXd1VXdXfatq
375 7Tpn731kzj3GmHPJzAJHgtTikvgOhgro3ZvtvsfoLcH9FKUasYDhN0x17R0XU1HAAGHO1jEYxP2TrO6HlFalebEm
376 wQWwgYSF5lJgEZYUjtft2RxBQx3K80u2hp0ZSYXys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T36d/Xo/wfVo38X5v9dmP//W2H+
589 36tff69+/b369b+y+vXfAHPyA9GQRwAA
590 """
591
592 PACKAGES = {}
593 REVISIONS = {}
594 PLATFORM_VERSIONS = {}
595 SYSTEM_IMAGE_VERSIONS = {}
596 SOURCE_PROPERTIES = {}
597
598
599 def requests_retry_session(
600 retries=3,
601 backoff_factor=0.6,
602 status_forcelist=(500, 502, 504),
603 session=None,
604 ):
605 session = session or requests.Session()
606 retry = Retry(
607 total=retries,
608 read=retries,
609 connect=retries,
610 backoff_factor=backoff_factor,
611 status_forcelist=status_forcelist,
612 )
613 adapter = HTTPAdapter(max_retries=retry)
614 session.mount('http://', adapter)
615 session.mount('https://', adapter)
616 return session
617
618
619 def get_android_home():
620 """Get the pathlib.Path that is the base dir of the Android SDK home
621
622 This first tries the canonical ANDROID_HOME, then tries the
623 deprecated ANDROID_SDK_ROOT, then falls back to a sensible,
624 hard-coded default.
625
626 https://developer.android.com/studio/command-line/variables#envar
627
628 """
629 path = os.getenv('ANDROID_HOME', os.getenv('ANDROID_SDK_ROOT', '/opt/android-sdk'))
630 if not path:
631 print('ERROR: ANDROID_HOME is set to blank!')
632 sys.exit(1)
633
634 android_home = Path(path)
635 if not android_home.parent.exists():
636 raise FileNotFoundError('ANDROID_HOME "%s" does not exist!' % android_home)
637 android_home.mkdir(exist_ok=True)
638
639 return android_home
640
641
642 def get_cachedir():
643 cachedir = Path.home() / '.cache/sdkmanager'
644 cachedir.mkdir(mode=0o0700, parents=True, exist_ok=True)
645 return cachedir
646
647
648 def verify(filename):
649 cachedir = get_cachedir()
650 keyring = cachedir / 'keyring.gpg'
651 with io.BytesIO(base64.b64decode(KEYRING_GPG_GZ_BASE64)) as infp:
652 with gzip.GzipFile(fileobj=infp) as gzipfp:
653 with keyring.open('wb') as fp:
654 fp.write(gzipfp.read())
655
656 if isinstance(filename, str):
657 f = filename
658 else:
659 f = str(filename.resolve())
660 p = subprocess.run(
661 ['gpgv', '--keyring', str(keyring.resolve()), f + '.asc', f],
662 stdout=subprocess.PIPE,
663 stderr=subprocess.STDOUT,
664 check=False,
665 )
666 if p.returncode == 0:
667 return
668 print(p.stdout.decode())
669 os.remove(f)
670 os.remove(f + '.asc')
671 raise RuntimeError(f + " failed to verify!")
672
673
674 def download_file(url, local_filename=None):
675 """Download a file with some extra tricks for reliability
676
677 The stream=True parameter keeps memory usage low.
678 """
679 filename = os.path.basename(urlparse(url).path)
680 if local_filename is None:
681 local_filename = get_cachedir() / filename
682 print('Downloading', url, 'into', local_filename)
683 r = requests_retry_session().get(
684 url, stream=True, allow_redirects=True, headers=HTTP_HEADERS
685 )
686 r.raise_for_status()
687 if r.status_code == 304:
688 raise RuntimeError('304 Not Modified: ' + url)
689 with local_filename.open('wb') as f:
690 for chunk in r.iter_content(chunk_size=io.DEFAULT_BUFFER_SIZE):
691 if chunk: # filter out keep-alive new chunks
692 f.write(chunk)
693 f.flush()
694 return local_filename
695
696
697 def get_properties_dict(string):
698 config = configparser.ConfigParser(delimiters=('='), strict=False)
699 config.read_string('[DEFAULT]\n' + string)
700 return dict(config.items('DEFAULT'))
701
702
703 def _add_to_revisions(url, source_properties):
704 SOURCE_PROPERTIES[url] = source_properties
705 pkg_revision = source_properties.get('pkg.revision')
706 if pkg_revision:
707 REVISIONS[url] = tuple(LooseVersion(pkg_revision).version)
708
709
710 def _convert_source_properties_to_template(source_properties):
711 if not source_properties:
712 return {}
713 # example of Pkg.Dependencies: emulator#35.4.9
714 dependencies = source_properties.get('pkg.dependencies', '').split('#')
715 path = dependencies[0]
716 major = minor = micro = '0'
717 if len(dependencies) > 1:
718 v = dependencies[1].split('.')
719 major = v[0]
720 if len(v) > 1:
721 minor = v[1]
722 if len(v) > 2:
723 micro = v[2]
724
725 extension_level = source_properties.get('androidversion.extensionlevel')
726 is_base_sdk = source_properties.get('androidversion.isbasesdk', 'true')
727
728 extension = (
729 f"<extension-level>{extension_level}</extension-level>"
730 if extension_level
731 else ''
732 )
733 extension += f"<base-extension>{is_base_sdk}</base-extension>"
734
735 api_level = source_properties.get('androidversion.apilevel')
736 display_version = api_level
737 if is_base_sdk == 'false':
738 api_level += 'x'
739 display_version += f"-ext{extension_level}"
740
741 return {
742 'desc': source_properties.get('pkg.desc'),
743 'codename': source_properties.get('androidversion.codename', ''),
744 'layoutlib_api': source_properties.get('layoutlib.api'),
745 'abi': source_properties.get('systemimage.abi'),
746 'tag_id': source_properties.get('systemimage.tagid'),
747 'tag_display': source_properties.get('systemimage.tagdisplay'),
748 'dependency_path': path,
749 'major': major,
750 'minor': minor,
751 'micro': micro,
752 'extension': extension,
753 'api_level': api_level,
754 'display_version': display_version,
755 }
756
757
758 def parse_build_tools(url, d):
759 if 'source.properties' in d:
760 source_properties = get_properties_dict(d['source.properties'])
761 _add_to_revisions(url, source_properties)
762 revision = source_properties['pkg.revision'].replace(' ', '-')
763 key = ('build-tools', revision)
764 if key not in PACKAGES:
765 PACKAGES[key] = url
766
767
768 def parse_cmake(url, d):
769 if 'source.properties' in d:
770 source_properties = get_properties_dict(d['source.properties'])
771 _add_to_revisions(url, source_properties)
772 key = tuple(source_properties['pkg.path'].split(';'))
773 if key not in PACKAGES:
774 PACKAGES[key] = url
775
776
777 def parse_cmdline_tools(url, d):
778 """Set up cmdline-tools with versioned and 'latest' package name"""
779 if 'source.properties' in d:
780 source_properties = get_properties_dict(d['source.properties'])
781 _add_to_revisions(url, source_properties)
782 key = tuple(source_properties['pkg.path'].split(';'))
783 if key not in PACKAGES:
784 PACKAGES[key] = url
785
786 v = re.compile(r'^[0-9.]+$')
787 highest = None
788 for key, url in PACKAGES.items():
789 if key[0] != 'cmdline-tools' or len(key) < 2:
790 continue
791 version = key[-1]
792 if version == 'latest':
793 continue
794 if highest is None:
795 highest = version
796 elif v.match(version) and LooseVersion(version) > LooseVersion(highest):
797 highest = version
798 # TODO choose version for 'latest' based on --channel
799 # https://developer.android.com/studio/releases/cmdline-tools
800 PACKAGES[('cmdline-tools', 'latest')] = PACKAGES[('cmdline-tools', highest)]
801
802
803 def parse_emulator(url, d):
804 if 'source.properties' in d:
805 source_properties = get_properties_dict(d['source.properties'])
806 _add_to_revisions(url, source_properties)
807 key = tuple(source_properties['pkg.path'].split(';'))
808 if key not in PACKAGES:
809 PACKAGES[key] = url
810 versioned = (key[0], source_properties['pkg.revision'])
811 if versioned in PACKAGES:
812 PACKAGES[versioned] = sorted([url, PACKAGES[key]])[-1]
813 else:
814 PACKAGES[versioned] = url
815
816
817 def parse_m2repository(url, d):
818 if 'source.properties' in d:
819 source_properties = get_properties_dict(d['source.properties'])
820 _add_to_revisions(url, source_properties)
821 # source.properties does not reliably contain Pkg.Revision or the path info
822 m = M2REPOSITORY_REVISION_REGEX.search(url)
823 if m:
824 revision = m.group(1)
825 key = ('extras', 'android', 'm2repository')
826 PACKAGES[key] = url
827 versioned = key + tuple([revision])
828 if versioned not in PACKAGES:
829 PACKAGES[versioned] = url
830 noleading0 = key + tuple([revision.lstrip('0')])
831 if noleading0 not in PACKAGES:
832 PACKAGES[noleading0] = url
833
834
835 def parse_ndk(url, d):
836 revision = None
837 if 'source.properties' in d:
838 source_properties = get_properties_dict(d['source.properties'])
839 SOURCE_PROPERTIES[url] = source_properties
840 revision = source_properties.get(
841 'pkg.baserevision', source_properties.get('pkg.revision')
842 )
843 if revision:
844 REVISIONS[url] = tuple(LooseVersion(revision).version)
845 for k in ('ndk', 'ndk-bundle'):
846 key = (k, revision)
847 if key not in PACKAGES:
848 PACKAGES[key] = url
849 m = NDK_RELEASE_REGEX.search(url)
850 if m:
851 release = m.group()
852 if revision:
853 NDK_REVISIONS[release] = revision
854 PACKAGES[('ndk', release)] = url
855 PACKAGES[('ndk-bundle', release)] = url
856 # add fake revision for NDKs without source.properties
857 if url not in REVISIONS:
858 REVISIONS[url] = (1,)
859 vstring = re.search(r"android-ndk-r(\d*)([a-z])-linux", url)
860 if vstring:
861 REVISIONS[url] = (
862 int(vstring.group(1)),
863 ord(vstring.group(2)) - ord("a"),
864 )
865
866
867 def parse_platforms(url, d):
868 """Parse platforms and choose the URL with the highest release number
869
870 These packages are installed by API version,
871 e.g. platforms;android-29, but there are multiple releases
872 available, e.g. platform-29_r05.zip, platform-29_r04.zip, etc.
873
874 The build property ro.build.version.codename with the value of REL
875 means a full release, rather than preview/beta/etc. That value
876 was not always present, but those releases oly hve a single
877 package.
878
879 platform24_r01.zip was released twice, the first being a mistake
880 with a platform.version of 'N' in source.properties.
881
882 """
883 if 'source.properties' in d:
884 source_properties = get_properties_dict(d['source.properties'])
885 _add_to_revisions(url, source_properties)
886 apilevel = source_properties['androidversion.apilevel']
887 # TODO this should make all versions/revisions available, not only most recent
888 if source_properties.get('androidversion.isbasesdk') != 'false':
889 key = ('platforms', f'android-{apilevel}')
890 else:
891 ext = source_properties.get('androidversion.extensionlevel')
892 key = ('platforms', f'android-{apilevel}-ext{ext}')
893 vstring = '%s.%s' % (
894 source_properties.get('platform.version'),
895 source_properties.get('pkg.revision'),
896 )
897 if re.match(r'^[1-9].*', vstring):
898 if key not in PLATFORM_VERSIONS:
899 PLATFORM_VERSIONS[key] = []
900 platform_version = LooseVersion(vstring)
901 PLATFORM_VERSIONS[key].append(platform_version)
902 if key in PACKAGES:
903 if platform_version == sorted(PLATFORM_VERSIONS[key])[-1]:
904 PACKAGES[key] = url
905 else:
906 PACKAGES[key] = url
907
908
909 def parse_platform_tools(url, d):
910 """Find all platform-tools packages and set highest version as 'platform-tools'"""
911 if 'source.properties' in d:
912 source_properties = get_properties_dict(d['source.properties'])
913 _add_to_revisions(url, source_properties)
914 key = ('platform-tools', source_properties.get('pkg.revision'))
915 if key not in PACKAGES:
916 PACKAGES[key] = url
917
918 highest = '0'
919 for key, url in PACKAGES.items():
920 if key[0] != 'platform-tools' or len(key) < 2:
921 continue
922 version = key[-1]
923 if LooseVersion(version) > LooseVersion(highest):
924 highest = version
925 PACKAGES[('platform-tools',)] = PACKAGES[('platform-tools', highest)]
926
927
928 def parse_system_images(url, d):
929 """Parse system-images and choose the URL with the highest release number."""
930 if 'source.properties' in d:
931 source_properties = get_properties_dict(d['source.properties'])
932 _add_to_revisions(url, source_properties)
933 apilevel = source_properties['androidversion.apilevel']
934 revision = source_properties.get('pkg.revision')
935 abi = source_properties.get('systemimage.abi', 'armeabi-v7a')
936 tag_id = source_properties.get('systemimage.tagid', 'default')
937 # TODO this should make all versions/revisions available, not only most recent
938 key = ('system-images', f'android-{apilevel}', tag_id, abi)
939 vstring = '%s.%s' % (apilevel, revision)
940 if re.match(r'^[1-9].*', vstring):
941 if key not in SYSTEM_IMAGE_VERSIONS:
942 SYSTEM_IMAGE_VERSIONS[key] = []
943 system_image_version = LooseVersion(vstring)
944 SYSTEM_IMAGE_VERSIONS[key].append(system_image_version)
945 if key in PACKAGES:
946 if system_image_version == sorted(SYSTEM_IMAGE_VERSIONS[key])[-1]:
947 PACKAGES[key] = url
948 else:
949 PACKAGES[key] = url
950
951
952 def parse_tools(url, d):
953 """Find all tools packages and set highest version as 'tools'"""
954 if 'source.properties' in d:
955 source_properties = get_properties_dict(d['source.properties'])
956 _add_to_revisions(url, source_properties)
957 path = source_properties.get('pkg.path')
958 if not path:
959 path = 'tools'
960 key = (path, source_properties.get('pkg.revision'))
961 if key not in PACKAGES:
962 PACKAGES[key] = url
963
964 highest = '0'
965 for key, url in PACKAGES.items():
966 if key[0] != 'tools' or len(key) < 2:
967 continue
968 version = key[-1]
969 if LooseVersion(version) > LooseVersion(highest):
970 highest = version
971 PACKAGES[('tools',)] = PACKAGES[('tools', highest)]
972
973
974 def parse_skiaparser(url, d):
975 """Set up skiaparser with versioned and unversioned package name"""
976 if 'source.properties' in d:
977 source_properties = get_properties_dict(d['source.properties'])
978 _add_to_revisions(url, source_properties)
979 key = tuple(source_properties['pkg.path'].split(';'))
980 if key in PACKAGES:
981 PACKAGES[key] = sorted([url, PACKAGES[key]])[-1]
982 else:
983 PACKAGES[key] = url
984
985
986 def parse_repositories_cfg(f):
987 """Parse the supplied repositories.cfg and return a list of URLs"""
988 with Path(f).open() as fp:
989 data = get_properties_dict(fp.read())
990
991 disabled = set()
992 for k, v in data.items():
993 if k.startswith('@disabled@'):
994 if v == 'disabled':
995 url = k.split('@')[2]
996 disabled.add(url)
997
998 count = int(data.get('count', '0'))
999 i = 0
1000 repositories = []
1001 while i < count:
1002 d = {}
1003 for k in ('disp', 'dist', 'enabled', 'src'):
1004 key_i = '%s%02d' % (k, i)
1005 if data.get(key_i):
1006 d[k] = data[key_i]
1007 if d[k] not in disabled:
1008 repositories.append(d)
1009 i += 1
1010 enabled_repositories = []
1011 for d in repositories:
1012 v = d.get('enabled', 'true')
1013 if v == 'true':
1014 url = d.get('src', '').replace('\\', '')
1015 if url and url not in enabled_repositories:
1016 enabled_repositories.append(url)
1017 return enabled_repositories
1018
1019
1020 # TODO allow : and - as separator, e.g. ndk-22.1.7171670
1021 # only use android-sdk-transparency-log as source
1022 def build_package_list(use_net=False):
1023 cachedir = get_cachedir()
1024 cached_checksums = cachedir / 'checksums.json'
1025 cached_checksums_signature = cachedir / (cached_checksums.name + '.asc')
1026 if cached_checksums.exists() and cached_checksums_signature.exists():
1027 verify(cached_checksums)
1028 try:
1029 with cached_checksums.open() as fp:
1030 _process_checksums(json.load(fp))
1031 except Exception: # pylint: disable=broad-exception-caught
1032 print(traceback.format_exc())
1033 cached_checksums.unlink()
1034 cached_checksums_signature.unlink()
1035 else:
1036 use_net = True # need to fetch checksums.json, no cached version
1037
1038 etag_file = cached_checksums.parent / (cached_checksums.name + '.etag')
1039 if etag_file.exists():
1040 etag = etag_file.read_text()
1041 else:
1042 etag = None
1043
1044 if use_net:
1045 checksums_url = secrets.choice(CHECKSUMS_URLS)
1046 download_file(checksums_url + '.asc')
1047
1048 try:
1049 headers = HTTP_HEADERS.copy()
1050 if etag:
1051 headers['If-None-Match'] = etag
1052
1053 r = requests_retry_session().get(
1054 checksums_url, allow_redirects=True, headers=headers
1055 )
1056 except ValueError as e:
1057 if etag_file.exists():
1058 etag_file.unlink()
1059 print('ERROR:', e)
1060 sys.exit(1)
1061 r.raise_for_status()
1062
1063 if etag is None or etag != r.headers.get('etag'):
1064 print('Downloading', checksums_url, 'into', str(cached_checksums))
1065 cached_checksums.write_bytes(r.content)
1066 verify(cached_checksums)
1067 etag_file.write_text(r.headers['etag'])
1068 _process_checksums(r.json())
1069
1070
1071 def _process_checksums(checksums):
1072 for url in checksums.keys():
1073 if not url.endswith('.zip'):
1074 continue
1075
1076 basename = os.path.basename(url)
1077 if basename.startswith('build-tools'):
1078 for entry in checksums[url]:
1079 parse_build_tools(url, entry)
1080 elif basename.startswith('cmake'):
1081 for entry in checksums[url]:
1082 parse_cmake(url, entry)
1083 elif basename.startswith('cmdline-tools') or basename.startswith(
1084 'commandlinetools'
1085 ):
1086 for entry in checksums[url]:
1087 parse_cmdline_tools(url, entry)
1088 elif basename.startswith('emulator'):
1089 for entry in checksums[url]:
1090 parse_emulator(url, entry)
1091 elif basename.startswith('android_m2repository_r'):
1092 for entry in checksums[url]:
1093 parse_m2repository(url, entry)
1094 elif 'ndk-' in url:
1095 parse_ndk(url, checksums[url][0])
1096 elif basename.startswith('platform-tools'):
1097 for entry in checksums[url]:
1098 parse_platform_tools(url, entry)
1099 elif basename.startswith('android-') or basename.startswith('platform-'):
1100 for entry in checksums[url]:
1101 parse_platforms(url, entry)
1102 elif basename.startswith('skiaparser'):
1103 for entry in checksums[url]:
1104 parse_skiaparser(url, entry)
1105 elif basename.startswith('tools') or basename.startswith('sdk-tools-'):
1106 for entry in checksums[url]:
1107 parse_tools(url, entry)
1108 elif url.split('/')[5] == 'sys-img':
1109 for entry in checksums[url]:
1110 parse_system_images(url, entry)
1111
1112
1113 def licenses():
1114 """Prompt the user to accept the various licenses
1115
1116 TODO actually implement it, this largely fakes it.
1117
1118 https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:sdklib/src/main/java/com/android/sdklib/tool/sdkmanager/LicensesAction.java
1119 https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:repository/src/main/java/com/android/repository/api/License.java
1120
1121 """
1122 known_licenses = {
1123 'android-sdk-license': '\n8933bad161af4178b1185d1a37fbf41ea5269c55\n\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee',
1124 'android-sdk-preview-license': '\n84831b9409646a918e30573bab4c9c91346d8abd\n',
1125 'android-sdk-preview-license-old': '79120722343a6f314e0719f863036c702b0e6b2a\n\n84831b9409646a918e30573bab4c9c91346d8abd',
1126 'intel-android-extra-license': '\nd975f751698a77b662f1254ddbeed3901e976f5a\n',
1127 }
1128 known_license_hashes = set()
1129 for license_value in known_licenses.values():
1130 for license in license_value.strip().split('\n'):
1131 if license:
1132 known_license_hashes.add(license)
1133
1134 found_license_hashes = set()
1135 licenses_dir = get_android_home() / 'licenses'
1136 for f in licenses_dir.glob('*'):
1137 with f.open() as fp:
1138 for license in fp.read().strip().split('\n'):
1139 if license:
1140 found_license_hashes.add(license)
1141
1142 total = len(known_license_hashes)
1143 license_count = total - len(found_license_hashes)
1144 if license_count == 0:
1145 print('All SDK package licenses accepted.')
1146 return
1147 if license_count == 1:
1148 fl = ('1', '1', '', 's')
1149 else:
1150 fl = (license_count, total, 's', 've')
1151 msg = (
1152 "{0} of {1} SDK package license{2} not accepted.\n"
1153 "Review license{2} that ha{3} not been accepted (y/N)? "
1154 ).format(*fl)
1155 s = input(msg)
1156 print()
1157 if s.lower() in ('y', 'yes'):
1158 licenses_dir.mkdir(exist_ok=True)
1159 for h in known_license_hashes:
1160 if h not in found_license_hashes:
1161 for license_file, known in known_licenses.items():
1162 if h in known:
1163 with (licenses_dir / license_file).open('w') as fp:
1164 fp.write(known)
1165
1166
1167 def install(to_install, android_home=None):
1168 """Install specified packages, including downloading them as needed
1169
1170 Certain packages are installed into versioned sub-directories
1171 while others are always installed into the same location. These
1172 installed packages will at least always have 'source.properties'.
1173
1174 Parameters
1175 ----------
1176 to_install
1177 A single package or list of packages to install.
1178
1179 android_home
1180 Optionally provide the ANDROID_HOME path as the install location.
1181
1182 """
1183 if android_home is None:
1184 android_home = get_android_home()
1185 if isinstance(android_home, str):
1186 android_home = Path(android_home)
1187
1188 if isinstance(to_install, str):
1189 to_install = [to_install]
1190 for package in to_install:
1191 key = tuple(package.split(';'))
1192 if key not in PACKAGES:
1193 print("""Warning: Failed to find package '%s'""" % package)
1194 package_names = [';'.join(n) for n in PACKAGES]
1195 m = difflib.get_close_matches(package, package_names, 1)
1196 if m:
1197 print("""Did you mean '%s'?""" % m[0])
1198 sys.exit(1)
1199 url = PACKAGES[key]
1200
1201 if key[0] == 'extras' and len(key) in (3, 4):
1202 name = ';'.join(key[:3])
1203 else:
1204 name = key[0]
1205
1206 if name == 'system-images':
1207 install_dir = android_home / package.replace(';', '/')
1208 elif len(key) > 1:
1209 if key[0] == 'ndk':
1210 revision = NDK_REVISIONS.get(key[-1], key[-1])
1211 else:
1212 revision = key[-1]
1213 install_dir = android_home / INSTALL_DIRS[name].format(revision=revision)
1214 else:
1215 install_dir = android_home / INSTALL_DIRS[name]
1216 if install_dir.exists():
1217 continue
1218
1219 zipball = get_cachedir() / os.path.basename(url)
1220 if not zipball.exists():
1221 download_file(url, zipball)
1222
1223 install_dir.parent.mkdir(parents=True, exist_ok=True)
1224 _install_zipball_from_cache(zipball, install_dir)
1225 _generate_package_xml(install_dir, package, url)
1226
1227
1228 def _install_zipball_from_cache(zipball, install_dir):
1229 unzip_dir = Path(tempfile.mkdtemp(prefix='.sdkmanager-'))
1230
1231 print('Unzipping to %s' % unzip_dir)
1232 toplevels = set()
1233 try:
1234 with zipfile.ZipFile(str(zipball)) as zipfp:
1235 for info in zipfp.infolist():
1236 permbits = info.external_attr >> 16
1237 writefile = str(unzip_dir / info.filename)
1238 if stat.S_ISLNK(permbits):
1239 link = unzip_dir / info.filename
1240 link.parent.mkdir(0o755, parents=True, exist_ok=True)
1241 link_target = zipfp.read(info).decode()
1242 os.symlink(link_target, str(link))
1243
1244 try:
1245 link.resolve().relative_to(unzip_dir)
1246 except (FileNotFoundError, ValueError):
1247 link.unlink()
1248 trim_at = len(str(unzip_dir)) + 1
1249 print(
1250 'ERROR: Unexpected symlink target: {link} -> {target}'.format(
1251 link=str(link)[trim_at:], target=link_target
1252 )
1253 )
1254 elif stat.S_ISDIR(permbits) or stat.S_IXUSR & permbits:
1255 zipfp.extract(info.filename, path=str(unzip_dir))
1256 os.chmod(writefile, 0o755) # nosec bandit B103
1257 else:
1258 zipfp.extract(info.filename, path=str(unzip_dir))
1259 os.chmod(writefile, 0o644) # nosec bandit B103
1260 toplevels.update([p.split('/')[0] for p in zipfp.namelist()])
1261 except zipfile.BadZipFile as e:
1262 print('ERROR:', zipball, e)
1263 if zipball.exists():
1264 zipball.unlink()
1265 sys.exit(1)
1266
1267 print('Installing into', install_dir)
1268 if len(toplevels) == 1:
1269 extracted = [d for d in unzip_dir.iterdir()][0]
1270 shutil.move(str(extracted), str(install_dir))
1271 else:
1272 install_dir.mkdir(parents=True)
1273 for extracted in unzip_dir.iterdir():
1274 shutil.move(str(extracted), str(install_dir))
1275 if zipball.exists():
1276 zipball.unlink()
1277
1278
1279 def _generate_package_xml(install_dir, package, url):
1280 """Generate package.xml for an installed package
1281
1282 TODO: This does not yet work for all package types. Gradle Android
1283 Plugin work better with no package.xml than wrong one.
1284
1285 In a rational package system, all the required metadata would be
1286 embedded in the package itself. Android Tools did design that to
1287 some degree with source.properties, but for whatever reason, they
1288 just hacked <display-name> into the index file, e.g.
1289 repository2-3.xml. Pkg.Desc looks similar, but it is not. Luckily,
1290 in the upstream source, it is clear to see that the strings used in
1291 <display-name> are a fixed string format that is easy to reproduce.
1292
1293 """
1294 package_base = package.split(';')[0]
1295 if package_base == 'extras':
1296 return
1297
1298 source_properties = SOURCE_PROPERTIES.get(url)
1299 if source_properties:
1300 spt = _convert_source_properties_to_template(source_properties)
1301 else:
1302 spt = {}
1303
1304 revision = REVISIONS[url]
1305 revision_name = '.'.join((str(x) for x in revision))
1306
1307 type_details = GENERIC_TYPE_DETAILS
1308 display_name = ''
1309 if package_base == 'platforms':
1310 type_details = PLATFORM_TYPE_DETAILS_TEMPLATE.format(**spt)
1311 display_name = f'Android SDK Platform {spt["display_version"]}'
1312 elif package_base == 'sources':
1313 type_details = PLATFORM_TYPE_DETAILS_TEMPLATE.format(**spt)
1314 display_name = f'Sources for Android {spt["display_version"]}'
1315 elif package_base == 'system-images':
1316 type_details = SYSTEM_IMAGES_TYPE_DETAILS_TEMPLATE.format(**spt)
1317 display_name = 'System Image'
1318 elif package_base == 'ndk':
1319 package = f"ndk;{revision_name}"
1320 display_name = f'NDK (Side by side) {revision_name}'
1321 elif package_base == 'build-tools':
1322 display_name = f'Android SDK Build-Tools {revision_name}'
1323 elif package_base == 'cmdline-tools':
1324 display_name = 'Android SDK Command-line Tools'
1325 elif package_base == 'platform-tools':
1326 display_name = 'Android SDK Platform-Tools'
1327 elif package_base == 'skiaparser':
1328 display_name = spt["desc"]
1329
1330 # These packages should never have the version in the path.
1331 if package_base in ('emulator', 'ndk-bundle', 'tools'):
1332 package = package_base
1333
1334 if spt.get('dependency_path'):
1335 dependencies = SYSTEM_IMAGES_DEPENDENCIES_TEMPLATE.format(**spt)
1336 else:
1337 dependencies = ''
1338
1339 template = ('<major>{0}</major>', '<minor>{1}</minor>', '<micro>{2}</micro>')
1340 r = min(3, len(revision))
1341 d = {
1342 'dependencies': dependencies,
1343 'display_name': display_name,
1344 'license': ANDROID_SDK_LICENSE,
1345 'license_id': 'android-sdk-license',
1346 'path': package,
1347 'revision': ''.join(template[:r]).format(*revision),
1348 'type_details': type_details,
1349 }
1350 with (install_dir / 'package.xml').open('w') as fp:
1351 fp.write(GENERIC_PACKAGE_XML_TEMPLATE.format(**d))
1352
1353
1354 def _get_installed_packages():
1355 """Get the list of locally installed packages based on package.xml.
1356
1357 SDK package names are the same as the Pkg.Path value from
1358 source.properties, and are also the directory that the package is
1359 unzipped into.
1360
1361 This is inspired by LocalRepoLoaderImpl.getPackages(), but it might
1362 be worth it to actually implement the same algorithm.
1363
1364 """
1365 installed = []
1366 android_home = str(get_android_home().resolve())
1367 for root, dirs, files in os.walk(android_home):
1368 path = str(os.path.relpath(root, android_home))
1369 if len(path.split('/')) > 10:
1370 continue
1371 if 'package.xml' in files:
1372 installed.append(path.replace('/', ';'))
1373 return sorted(installed)
1374
1375
1376 def list():
1377 path_width = 0
1378 names = []
1379 for package in PACKAGES:
1380 name = ';'.join(package)
1381 if len(name) > path_width:
1382 path_width = len(name)
1383 names.append(name)
1384 print('Installed packages:')
1385 print(' ' + 'Path'.ljust(path_width) + ' | Version | Description | Location')
1386 print(
1387 ' ' + '-------'.ljust(path_width) + ' | ------- | ------- | -------'
1388 )
1389 for p in _get_installed_packages():
1390 print(
1391 f' {p.ljust(path_width)} | | | {p.replace(";", "/")}'
1392 )
1393 print()
1394 print('Available Packages:')
1395 print(' ' + 'Path'.ljust(path_width) + ' | Version | Description')
1396 print(' ' + '-------'.ljust(path_width) + ' | ------- | -------')
1397 for name in sorted(names):
1398 print(' %s | | ' % name.ljust(path_width))
1399
1400
1401 def main():
1402 parser = argparse.ArgumentParser()
1403 # commands
1404 parser.add_argument("--install", action="store_true")
1405 parser.add_argument("--licenses", action="store_true")
1406 parser.add_argument("--list", action="store_true")
1407 parser.add_argument("--uninstall", action="store_true")
1408 parser.add_argument("--update", action="store_true")
1409 parser.add_argument("--version", action="store_true")
1410
1411 # "common arguments"
1412 parser.add_argument("--channel")
1413 parser.add_argument("--include_obsolete")
1414 parser.add_argument("--no_https")
1415 parser.add_argument("--proxy")
1416 parser.add_argument("--proxy_host")
1417 parser.add_argument("--proxy_port")
1418 parser.add_argument("--sdk_root")
1419 parser.add_argument(
1420 "--verbose", action="store_true", help="increase output verbosity"
1421 )
1422
1423 parser.add_argument('packages', nargs='*')
1424
1425 # do not require argcomplete to keep the install profile light
1426 try:
1427 import argcomplete
1428
1429 argcomplete.autocomplete(parser)
1430 except ImportError:
1431 pass
1432
1433 args = parser.parse_args()
1434 command = None
1435 for k in ('install', 'licenses', 'list', 'uninstall', 'update', 'version'):
1436 if args.__dict__[k]:
1437 if command is not None:
1438 print(
1439 'Error: Only one of --uninstall, --install, --licenses, '
1440 '--update, --list, --version can be specified.'
1441 )
1442 print(USAGE)
1443 sys.exit(1)
1444 command = k
1445 if command is None:
1446 command = 'install'
1447 elif command == 'version':
1448 print('25.2.0')
1449 sys.exit()
1450
1451 method = globals().get(command)
1452 if not method:
1453 raise NotImplementedError('Command "--%s" not implemented' % command)
1454 if command in ('install', 'uninstall'):
1455 build_package_list(use_net=False)
1456 method(args.packages)
1457 else:
1458 build_package_list(use_net=True)
1459 method()
1460
1461
1462 if __name__ == "__main__":
1463 main()