1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
|
#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
#
# sdkmanager.py - part of the F-Droid tools
#
# Copyright (C) 2021, Hans-Christoph Steiner <hans@eds.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import base64
import configparser
import difflib
import gzip
import io
import json
import os
import random
import re
import shutil
import stat
import subprocess
import sys
import tempfile
import textwrap
import traceback
import zipfile
from pathlib import Path
from urllib.parse import urlparse
import requests
from requests.adapters import HTTPAdapter, Retry
try:
from looseversion import LooseVersion
except ImportError:
# distutils.version was removed in Python 3.12
import warnings
from distutils.version import LooseVersion
warnings.filterwarnings("ignore", category=DeprecationWarning)
COMPATIBLE_VERSION = '26.1.1'
# gitlab.com is disabled because it has Cloudflare blocking enabled and is therefore unreliable
CHECKSUMS_URLS = (
'https://f-droid.github.io/android-sdk-transparency-log/signed/checksums.json',
'https://fdroid.gitlab.io/android-sdk-transparency-log/checksums.json',
# 'https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/signed/checksums.json',
'https://raw.githubusercontent.com/f-droid/android-sdk-transparency-log/master/signed/checksums.json',
)
HTTP_HEADERS = {'User-Agent': 'F-Droid'}
BUILD_REGEX = re.compile(r'[1-9][0-9]{6}')
NDK_RELEASE_REGEX = re.compile(r'r[1-9][0-9]?[a-z]?(?:-(?:rc|beta)[0-9]+)?')
M2REPOSITORY_REVISION_REGEX = re.compile(r'android_m2repository_r([0-9]+)\.zip')
# The sub-directory to install a given package into, assumes ANDROID_SDK_ROOT as root
# https://developer.android.com/studio/command-line/
INSTALL_DIRS = {
'build-tools': 'build-tools/{revision}',
'cmake': 'cmake/{revision}',
'cmdline-tools': 'cmdline-tools/{revision}',
'emulator': 'emulator',
'ndk': 'ndk/{revision}',
'ndk-bundle': 'ndk-bundle',
'platforms': 'platforms/{revision}',
'platform-tools': 'platform-tools',
'skiaparser': 'skiaparser/{revision}',
'tools': 'tools',
'extras;android;m2repository': 'extras/android/m2repository',
}
# NDK releases are like r25b, revisions are like 25.1.8937393. Dir names use revisions.
NDK_REVISIONS = {}
# xsi:type="ns3:genericDetailsType
GENERIC_PACKAGE_XML_TEMPLATE = textwrap.dedent(
"""
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:repository
xmlns:ns2="http://schemas.android.com/repository/android/common/01"
xmlns:ns3="http://schemas.android.com/repository/android/generic/01"
xmlns:ns4="http://schemas.android.com/sdk/android/repo/addon2/01"
xmlns:ns5="http://schemas.android.com/sdk/android/repo/repository2/01"
xmlns:ns6="http://schemas.android.com/sdk/android/repo/sys-img2/01">
<license id="{license_id}" type="text">{license}</license>
<localPackage path="{path}">
<type-details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:genericDetailsType"/>
<revision>{revision}</revision>
<display-name>PLACEHOLDER</display-name>
<uses-license ref="{license_id}"/>
</localPackage>
</ns2:repository>
"""
).strip()
USAGE = """
Usage:
sdkmanager [--uninstall] [<common args>] [--package_file=<file>] [<packages>...]
sdkmanager --update [<common args>]
sdkmanager --list [<common args>]
sdkmanager --licenses [<common args>]
sdkmanager --version
With --install (optional), installs or updates packages.
By default, the listed packages are installed or (if already installed)
updated to the latest version.
With --uninstall, uninstall the listed packages.
<package> is a sdk-style path (e.g. "build-tools;23.0.0" or
"platforms;android-23").
<package-file> is a text file where each line is a sdk-style path
of a package to install or uninstall.
Multiple --package_file arguments may be specified in combination
with explicit paths.
With --update, all installed packages are updated to the latest version.
With --list, all installed and available packages are printed out.
With --licenses, show and offer the option to accept licenses for all
available packages that have not already been accepted.
With --version, prints the current version of sdkmanager.
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK
containing this tool
--channel=<channelId>: Include packages in channels up to <channelId>.
Common channels are:
0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
--include_obsolete: With --list, show obsolete packages in the
package listing. With --update, update obsolete
packages as well as non-obsolete.
--no_https: Force all connections to use http rather than https.
--proxy=<http | socks>: Connect via a proxy of the given type.
--proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
--proxy_port=<port #>: Proxy port to connect to.
--verbose: Enable verbose output.
* If the env var REPO_OS_OVERRIDE is set to "windows",
"macosx", or "linux", packages will be downloaded for that OS.
"""
ANDROID_SDK_LICENSE = """Terms and Conditions
This is the Android Software Development Kit License Agreement
1. Introduction
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.
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.
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).
1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
2. Accepting the License Agreement
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.
2.2 By clicking to accept, you hereby agree to the terms of the License Agreement.
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.
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.
3. SDK License from Google
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.
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.
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.
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.
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.
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.
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.
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.
4. Use of the SDK by You
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.
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).
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.
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.
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.
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.
5. Your Developer Credentials
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.
6. Privacy and Information
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.
6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in accordance with Google's Privacy Policy.
7. Third Party Applications
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.
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.
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.
8. Using Android APIs
8.1 Google Data APIs
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.
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.
9. Terminating the License Agreement
9.1 The License Agreement will continue to apply until terminated by either you or Google as set out below.
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.
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.
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.
10. DISCLAIMER OF WARRANTIES
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.
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.
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.
11. LIMITATION OF LIABILITY
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.
12. Indemnification
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.
13. Changes to the License Agreement
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.
14. General Legal Terms
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.
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.
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.
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.
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.
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.
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.
January 16, 2019"""
# This is generated by doing:
# gpg --export-options export-minimal,export-clean \
# --export 37D2C98789D8311948394E3E41E7044E1DBA2E89 EE6620C7136B0D2C456C0A4DE9E28DEA00AA5556 \
# | gzip -9 \
# | base64 --wrap=88 \
# > keyring.gpg.gz.base64
KEYRING_GPG_GZ_BASE64 = """
H4sIAKZ8zGECA+17ZVBd3bblwd3d3d3dgrs7wd3d3Tn4wd3dLTjB3YIFD+6BQPAEaPK9e9+7P7pvdXd1VXdXfatq
7Tpn731kzj3GmHPJzAJHgtTikvgOhgro3ZvtvsfoLcH9FKUasYDhN0x17R0XU1HAAGHO1jEYxP2TrO6HlFalebEm
wQWwgYSF5lJgEZYUjtft2RxBQx3K80u2hp0ZSYXys0dTaa8XTr+Nxh2tDTTVMfJgQwim9hFEwotVOtMV2w93A6wH
OE333lJ357Ues7punukqoytSUbjhutPUQuHJqE4JdLVZ1BIxzt8B3h2ZYSkB1eJa5C56wyu9VVhXppa5YqzmP0Jy
41UkcZEOjRQEcliaDZZG6EJjFZWxJ7a5XNrlowocqMKXR8+p143rpsNDxtELFB22qc6PB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Vh32fuRS4AhLfQJsb
aQxogkfeFpbQX2slNVJ6axUVFMMFIkPreLxa2ZNmFMZJcFfOsdP5sx7oyyJtXB07TpDaZtHQKEYXYKTxOazWN3BR
yYf8qgG5ObNV6QlZWo0gnWxOKp51KeXXujlEarbKjHU64q9WGWlVwvjZOiYlTz9hIKUUMJo3MDDDoFTxBhOvuK+b
BJ0kd2ZSYONjjld0WBhYNvRMFsZeIdg8BhaSa1HuP1/mEKlGSS5WlmkuaLHinynHEVdP4OzdjiSslGSS1EGPEZ0E
zilSOEKfTKQYOzKmBeWlFAntb2HKf/Cxm7TFgYATMQ818K03KTueueNJXvicsyA7efjozGR5LKyDr2KRB3V/r2sd
UeoNaY215eCZI12lp5pySjqSVt2rcJb1dzXp39Wk/1pN+nfJ098lT/+vlzz9XT36d/Xo/wfVo38X5v9dmP//W2H+
36tff69+/b369b+y+vXfAHPyA9GQRwAA
"""
packages = {}
revisions = {}
platform_versions = {}
def requests_retry_session(
retries=3,
backoff_factor=0.6,
status_forcelist=(500, 502, 504),
session=None,
):
session = session or requests.Session()
retry = Retry(
total=retries,
read=retries,
connect=retries,
backoff_factor=backoff_factor,
status_forcelist=status_forcelist,
)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)
return session
def get_android_home():
"""Get the pathlib.Path that is the base dir of the Android SDK home
This first tries the canonical ANDROID_HOME, then tries the
deprecated ANDROID_SDK_ROOT, then falls back to a sensible,
hard-coded default.
https://developer.android.com/studio/command-line/variables#envar
"""
path = os.getenv('ANDROID_HOME', os.getenv('ANDROID_SDK_ROOT', '/opt/android-sdk'))
if not path:
print('ERROR: ANDROID_HOME is set to blank!')
sys.exit(1)
android_home = Path(path)
if not android_home.parent.exists():
raise FileNotFoundError('ANDROID_HOME "%s" does not exist!' % android_home)
android_home.mkdir(exist_ok=True)
return android_home
def get_cachedir():
cachedir = Path.home() / '.cache/sdkmanager'
cachedir.mkdir(mode=0o0700, parents=True, exist_ok=True)
return cachedir
def verify(filename):
cachedir = get_cachedir()
keyring = cachedir / 'keyring.gpg'
with io.BytesIO(base64.b64decode(KEYRING_GPG_GZ_BASE64)) as infp:
with gzip.GzipFile(fileobj=infp) as gzipfp:
with keyring.open('wb') as fp:
fp.write(gzipfp.read())
if isinstance(filename, str):
f = filename
else:
f = str(filename.resolve())
p = subprocess.run(
['gpgv', '--keyring', str(keyring.resolve()), f + '.asc', f],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=False,
)
if p.returncode == 0:
return
print(p.stdout.decode())
os.remove(f)
os.remove(f + '.asc')
raise RuntimeError(f + " failed to verify!")
def download_file(url, local_filename=None):
"""Download a file with some extra tricks for reliability
The stream=True parameter keeps memory usage low.
"""
filename = os.path.basename(urlparse(url).path)
if local_filename is None:
local_filename = get_cachedir() / filename
print('Downloading', url, 'into', local_filename)
r = requests_retry_session().get(
url, stream=True, allow_redirects=True, headers=HTTP_HEADERS
)
r.raise_for_status()
if r.status_code == 304:
raise RuntimeError('304 Not Modified: ' + url)
with local_filename.open('wb') as f:
for chunk in r.iter_content(chunk_size=io.DEFAULT_BUFFER_SIZE):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return local_filename
def get_properties_dict(string):
config = configparser.ConfigParser(delimiters=('='), strict=False)
config.read_string('[DEFAULT]\n' + string)
return dict(config.items('DEFAULT'))
def _add_to_revisions(url, source_properties):
pkg_revision = source_properties.get('pkg.revision')
if pkg_revision:
revisions[url] = tuple(LooseVersion(pkg_revision).version)
def parse_build_tools(url, d):
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
revision = source_properties['pkg.revision'].replace(' ', '-')
key = ('build-tools', revision)
if key not in packages:
packages[key] = url
def parse_cmake(url, d):
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
key = tuple(source_properties['pkg.path'].split(';'))
if key not in packages:
packages[key] = url
def parse_cmdline_tools(url, d):
"""Set up cmdline-tools with versioned and 'latest' package name"""
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
key = tuple(source_properties['pkg.path'].split(';'))
if key not in packages:
packages[key] = url
v = re.compile(r'^[0-9.]+$')
highest = None
for key, url in packages.items():
if key[0] != 'cmdline-tools' or len(key) < 2:
continue
version = key[-1]
if version == 'latest':
continue
if highest is None:
highest = version
elif v.match(version) and LooseVersion(version) > LooseVersion(highest):
highest = version
# TODO choose version for 'latest' based on --channel
# https://developer.android.com/studio/releases/cmdline-tools
packages[('cmdline-tools', 'latest')] = packages[('cmdline-tools', highest)]
def parse_emulator(url, d):
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
key = tuple(source_properties['pkg.path'].split(';'))
if key not in packages:
packages[key] = url
versioned = (key[0], source_properties['pkg.revision'])
if versioned in packages:
packages[versioned] = sorted([url, packages[key]])[-1]
else:
packages[versioned] = url
def parse_m2repository(url, d):
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
# source.properties does not reliably contain Pkg.Revision or the path info
m = M2REPOSITORY_REVISION_REGEX.search(url)
if m:
revision = m.group(1)
key = ('extras', 'android', 'm2repository')
packages[key] = url
versioned = key + tuple([revision])
if versioned not in packages:
packages[versioned] = url
noleading0 = key + tuple([revision.lstrip('0')])
if noleading0 not in packages:
packages[noleading0] = url
def parse_ndk(url, d):
revision = None
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
revision = source_properties.get(
'pkg.baserevision', source_properties.get('pkg.revision')
)
if revision:
revisions[url] = tuple(LooseVersion(revision).version)
for k in ('ndk', 'ndk-bundle'):
key = (k, revision)
if key not in packages:
packages[key] = url
m = NDK_RELEASE_REGEX.search(url)
if m:
release = m.group()
if revision:
NDK_REVISIONS[release] = revision
packages[('ndk', release)] = url
packages[('ndk-bundle', release)] = url
# add fake revision for NDKs without source.properties
if url not in revisions:
revisions[url] = (1,)
vstring = re.search(r"android-ndk-r(\d*)([a-z])-linux", url)
if vstring:
revisions[url] = (
int(vstring.group(1)),
ord(vstring.group(2)) - ord("a"),
)
def parse_platforms(url, d):
"""Parse platforms and choose the URL with the highest release number
These packages are installed by API version,
e.g. platforms;android-29, but there are multiple releases
available, e.g. platform-29_r05.zip, platform-29_r04.zip, etc.
The build property ro.build.version.codename with the value of REL
means a full release, rather than preview/beta/etc. That value
was not always present, but those releases oly hve a single
package.
platform24_r01.zip was released twice, the first being a mistake
with a platform.version of 'N' in source.properties.
"""
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
apilevel = source_properties['androidversion.apilevel']
# TODO this should make all versions/revisions available, not only most recent
key = ('platforms', 'android-%s' % apilevel)
vstring = '%s.%s' % (
source_properties.get('platform.version'),
source_properties.get('pkg.revision'),
)
if re.match(r'^[1-9].*', vstring):
if key not in platform_versions:
platform_versions[key] = []
platform_version = LooseVersion(vstring)
platform_versions[key].append(platform_version)
if key in packages:
if platform_version == sorted(platform_versions[key])[-1]:
packages[key] = url
else:
packages[key] = url
def parse_platform_tools(url, d):
"""Find all platform-tools packages and set highest version as 'platform-tools'"""
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
key = ('platform-tools', source_properties.get('pkg.revision'))
if key not in packages:
packages[key] = url
highest = '0'
for key, url in packages.items():
if key[0] != 'platform-tools' or len(key) < 2:
continue
version = key[-1]
if LooseVersion(version) > LooseVersion(highest):
highest = version
packages[('platform-tools',)] = packages[('platform-tools', highest)]
def parse_tools(url, d):
"""Find all tools packages and set highest version as 'tools'"""
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
path = source_properties.get('pkg.path')
if not path:
path = 'tools'
key = (path, source_properties.get('pkg.revision'))
if key not in packages:
packages[key] = url
highest = '0'
for key, url in packages.items():
if key[0] != 'tools' or len(key) < 2:
continue
version = key[-1]
if LooseVersion(version) > LooseVersion(highest):
highest = version
packages[('tools',)] = packages[('tools', highest)]
def parse_skiaparser(url, d):
"""Set up skiaparser with versioned and unversioned package name"""
if 'source.properties' in d:
source_properties = get_properties_dict(d['source.properties'])
_add_to_revisions(url, source_properties)
key = tuple(source_properties['pkg.path'].split(';'))
if key in packages:
packages[key] = sorted([url, packages[key]])[-1]
else:
packages[key] = url
def parse_repositories_cfg(f):
"""Parse the supplied repositories.cfg and return a list of URLs"""
with Path(f).open() as fp:
data = get_properties_dict(fp.read())
disabled = set()
for k, v in data.items():
if k.startswith('@disabled@'):
if v == 'disabled':
url = k.split('@')[2]
disabled.add(url)
count = int(data.get('count', '0'))
i = 0
repositories = []
while i < count:
d = {}
for k in ('disp', 'dist', 'enabled', 'src'):
key_i = '%s%02d' % (k, i)
if data.get(key_i):
d[k] = data[key_i]
if d[k] not in disabled:
repositories.append(d)
i += 1
enabled_repositories = []
for d in repositories:
v = d.get('enabled', 'true')
if v == 'true':
url = d.get('src', '').replace('\\', '')
if url and url not in enabled_repositories:
enabled_repositories.append(url)
return enabled_repositories
# TODO allow : and - as separator, e.g. ndk-22.1.7171670
# only use android-sdk-transparency-log as source
def build_package_list(use_net=False):
cachedir = get_cachedir()
cached_checksums = cachedir / 'checksums.json'
cached_checksums_signature = cachedir / (cached_checksums.name + '.asc')
if cached_checksums.exists() and cached_checksums_signature.exists():
verify(cached_checksums)
try:
with cached_checksums.open() as fp:
_process_checksums(json.load(fp))
except Exception: # pylint: disable=broad-exception-caught
print(traceback.format_exc())
cached_checksums.unlink()
cached_checksums_signature.unlink()
else:
use_net = True # need to fetch checksums.json, no cached version
etag_file = cached_checksums.parent / (cached_checksums.name + '.etag')
if etag_file.exists():
etag = etag_file.read_text()
else:
etag = None
if use_net:
checksums_url = CHECKSUMS_URLS[random.randint(0, len(CHECKSUMS_URLS) - 1)]
download_file(checksums_url + '.asc')
try:
headers = HTTP_HEADERS.copy()
if etag:
headers['If-None-Match'] = etag
r = requests_retry_session().get(
checksums_url, allow_redirects=True, headers=headers
)
except ValueError as e:
if etag_file.exists():
etag_file.unlink()
print('ERROR:', e)
sys.exit(1)
r.raise_for_status()
if etag is None or etag != r.headers.get('etag'):
print('Downloading', checksums_url, 'into', str(cached_checksums))
cached_checksums.write_bytes(r.content)
verify(cached_checksums)
etag_file.write_text(r.headers['etag'])
_process_checksums(r.json())
def _process_checksums(checksums):
for url in checksums.keys():
if not url.endswith('.zip'):
continue
basename = os.path.basename(url)
if basename.startswith('build-tools'):
for entry in checksums[url]:
parse_build_tools(url, entry)
elif basename.startswith('cmake'):
for entry in checksums[url]:
parse_cmake(url, entry)
elif basename.startswith('cmdline-tools') or basename.startswith(
'commandlinetools'
):
for entry in checksums[url]:
parse_cmdline_tools(url, entry)
elif basename.startswith('emulator'):
for entry in checksums[url]:
parse_emulator(url, entry)
elif basename.startswith('android_m2repository_r'):
for entry in checksums[url]:
parse_m2repository(url, entry)
elif 'ndk-' in url:
parse_ndk(url, checksums[url][0])
elif basename.startswith('platform-tools'):
for entry in checksums[url]:
parse_platform_tools(url, entry)
elif basename.startswith('android-') or basename.startswith('platform-'):
for entry in checksums[url]:
parse_platforms(url, entry)
elif basename.startswith('skiaparser'):
for entry in checksums[url]:
parse_skiaparser(url, entry)
elif basename.startswith('tools') or basename.startswith('sdk-tools-'):
for entry in checksums[url]:
parse_tools(url, entry)
def licenses():
"""Prompt the user to accept the various licenses
TODO actually implement it, this largely fakes it.
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:sdklib/src/main/java/com/android/sdklib/tool/sdkmanager/LicensesAction.java
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:repository/src/main/java/com/android/repository/api/License.java
"""
known_licenses = {
'android-sdk-license': '\n8933bad161af4178b1185d1a37fbf41ea5269c55\n\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee',
'android-sdk-preview-license': '\n84831b9409646a918e30573bab4c9c91346d8abd\n',
'android-sdk-preview-license-old': '79120722343a6f314e0719f863036c702b0e6b2a\n\n84831b9409646a918e30573bab4c9c91346d8abd',
'intel-android-extra-license': '\nd975f751698a77b662f1254ddbeed3901e976f5a\n',
}
known_license_hashes = set()
for license_value in known_licenses.values():
for license in license_value.strip().split('\n'):
if license:
known_license_hashes.add(license)
found_license_hashes = set()
licenses_dir = get_android_home() / 'licenses'
for f in licenses_dir.glob('*'):
with f.open() as fp:
for license in fp.read().strip().split('\n'):
if license:
found_license_hashes.add(license)
total = len(known_license_hashes)
license_count = total - len(found_license_hashes)
if license_count == 0:
print('All SDK package licenses accepted.')
return
if license_count == 1:
fl = ('1', '1', '', 's')
else:
fl = (license_count, total, 's', 've')
msg = (
"{0} of {1} SDK package license{2} not accepted.\n"
"Review license{2} that ha{3} not been accepted (y/N)? "
).format(*fl)
s = input(msg)
print()
if s.lower() in ('y', 'yes'):
licenses_dir.mkdir(exist_ok=True)
for h in known_license_hashes:
if h not in found_license_hashes:
for license_file, known in known_licenses.items():
if h in known:
with (licenses_dir / license_file).open('w') as fp:
fp.write(known)
def install(to_install, android_home=None):
"""Install specified packages, including downloading them as needed
Certain packages are installed into versioned sub-directories
while others are always installed into the same location. These
installed packages will at least always have 'source.properties'.
Parameters
----------
to_install
A single package or list of packages to install.
android_home
Optionally provide the ANDROID_HOME path as the install location.
"""
global packages
if android_home is None:
android_home = get_android_home()
if isinstance(android_home, str):
android_home = Path(android_home)
if isinstance(to_install, str):
to_install = [to_install]
for package in to_install:
key = tuple(package.split(';'))
if key not in packages:
print("""Warning: Failed to find package '%s'""" % package)
package_names = [';'.join(n) for n in packages]
m = difflib.get_close_matches(package, package_names, 1)
if m:
print("""Did you mean '%s'?""" % m[0])
sys.exit(1)
url = packages[key]
if key[0] == 'extras' and len(key) in (3, 4):
name = ';'.join(key[:3])
else:
name = key[0]
if len(key) > 1:
if key[0] == 'ndk':
revision = NDK_REVISIONS.get(key[-1], key[-1])
else:
revision = key[-1]
install_dir = android_home / INSTALL_DIRS[name].format(revision=revision)
else:
install_dir = android_home / INSTALL_DIRS[name]
if install_dir.exists():
continue
zipball = get_cachedir() / os.path.basename(url)
if not zipball.exists():
download_file(url, zipball)
install_dir.parent.mkdir(parents=True, exist_ok=True)
_install_zipball_from_cache(zipball, install_dir)
_generate_package_xml(install_dir, package, url)
def _install_zipball_from_cache(zipball, install_dir):
unzip_dir = Path(tempfile.mkdtemp(prefix='.sdkmanager-'))
print('Unzipping to %s' % unzip_dir)
toplevels = set()
try:
with zipfile.ZipFile(str(zipball)) as zipfp:
for info in zipfp.infolist():
permbits = info.external_attr >> 16
writefile = str(unzip_dir / info.filename)
if stat.S_ISLNK(permbits):
link = unzip_dir / info.filename
link.parent.mkdir(0o755, parents=True, exist_ok=True)
link_target = zipfp.read(info).decode()
os.symlink(link_target, str(link))
try:
link.resolve().relative_to(unzip_dir)
except (FileNotFoundError, ValueError):
link.unlink()
trim_at = len(str(unzip_dir)) + 1
print(
'ERROR: Unexpected symlink target: {link} -> {target}'.format(
link=str(link)[trim_at:], target=link_target
)
)
elif stat.S_ISDIR(permbits) or stat.S_IXUSR & permbits:
zipfp.extract(info.filename, path=str(unzip_dir))
os.chmod(writefile, 0o755) # nosec bandit B103
else:
zipfp.extract(info.filename, path=str(unzip_dir))
os.chmod(writefile, 0o644) # nosec bandit B103
toplevels.update([p.split('/')[0] for p in zipfp.namelist()])
except zipfile.BadZipFile as e:
print('ERROR:', e)
if zipball.exists():
zipball.unlink()
return
print('Installing into', install_dir)
if len(toplevels) == 1:
extracted = [d for d in unzip_dir.iterdir()][0]
shutil.move(str(extracted), str(install_dir))
else:
install_dir.mkdir(parents=True)
for extracted in unzip_dir.iterdir():
shutil.move(str(extracted), str(install_dir))
if zipball.exists():
zipball.unlink()
def _generate_package_xml(install_dir, package, url):
"""Generate package.xml for an installed package
TODO: This does not yet work for all package types. Gradle Android
Plugin work better with no package.xml than wrong one.
"""
package_base = package.split(';')[0]
if package_base in ('extras', 'platforms', 'sources', 'system-images'):
return
# These packages should never have the version in the path.
if package_base in ('emulator', 'ndk-bundle', 'tools'):
package = package_base
revision = revisions[url]
if package_base == 'ndk':
package = f"ndk;{'.'.join((str(x) for x in revision))}"
template = ('<major>{0}</major>', '<minor>{1}</minor>', '<micro>{2}</micro>')
r = min(3, len(revision))
d = {
'license': ANDROID_SDK_LICENSE,
'license_id': 'android-sdk-license',
'path': package,
'revision': ''.join(template[:r]).format(*revision),
}
with (install_dir / 'package.xml').open('w') as fp:
fp.write(GENERIC_PACKAGE_XML_TEMPLATE.format(**d))
def list():
global packages
path_width = 0
names = []
for package in packages:
name = ';'.join(package)
if len(name) > path_width:
path_width = len(name)
names.append(name)
print('Installed Packages:')
print(' ' + 'Path'.ljust(path_width) + ' | Version | Description | Location')
print(
' ' + '-------'.ljust(path_width) + ' | ------- | ------- | -------'
)
print()
print('Available Packages:')
print(' ' + 'Path'.ljust(path_width) + ' | Version | Description')
print(' ' + '-------'.ljust(path_width) + ' | ------- | -------')
for name in sorted(names):
print(' %s | | ' % name.ljust(path_width))
def main():
parser = argparse.ArgumentParser()
# commands
parser.add_argument("--install", action="store_true")
parser.add_argument("--licenses", action="store_true")
parser.add_argument("--list", action="store_true")
parser.add_argument("--uninstall", action="store_true")
parser.add_argument("--update", action="store_true")
parser.add_argument("--version", action="store_true")
# "common arguments"
parser.add_argument("--channel")
parser.add_argument("--include_obsolete")
parser.add_argument("--no_https")
parser.add_argument("--proxy")
parser.add_argument("--proxy_host")
parser.add_argument("--proxy_port")
parser.add_argument("--sdk_root")
parser.add_argument(
"--verbose", action="store_true", help="increase output verbosity"
)
parser.add_argument('packages', nargs='*')
# do not require argcomplete to keep the install profile light
try:
import argcomplete
argcomplete.autocomplete(parser)
except ImportError:
pass
args = parser.parse_args()
command = None
for k in ('install', 'licenses', 'list', 'uninstall', 'update', 'version'):
if args.__dict__[k]:
if command is not None:
print(
'Error: Only one of --uninstall, --install, --licenses, '
'--update, --list, --version can be specified.'
)
print(USAGE)
sys.exit(1)
command = k
if command is None:
command = 'install'
elif command == 'version':
print('25.2.0')
sys.exit()
method = globals().get(command)
if not method:
raise NotImplementedError('Command "--%s" not implemented' % command)
if command in ('install', 'uninstall'):
build_package_list(use_net=False)
method(args.packages)
else:
build_package_list(use_net=True)
method()
if __name__ == "__main__":
main()
|