emu_downloads: add ANDROID_REPOSITORY env var to override download base URL#411
Merged
jpcottin merged 2 commits intoMay 16, 2026
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Introduces an ANDROID_REPOSITORY environment variable, defaulting to https://dl.google.com, as the base URL for all system-image catalog fetches (sys-img2-5.xml), the emulator repo catalog (repository2-1.xml), per-package system-image zip downloads, and the platform-tools download. Lets users behind corporate proxies, in air-gapped environments, or in regions where Google's CDN is slow or unreachable point at a mirror instead. Original implementation by Greger Stolt Nilsen from google#359; cherry-picked onto current master with conflict resolutions to preserve current master's sys-img2-5.xml index version and the url_dir routing logic for 16KB-page sysimg URLs.
…ling slash The two modules disagreed on whether the default base URL had a trailing slash (`https://dl.google.com/` vs `https://dl.google.com`). Combined with format strings that start with `/android/...`, the slashed default produced double-slash URLs (`https://dl.google.com//android/...`). Servers usually tolerate this, but it's ugly in logs and breaks any exact-match logic downstream. Drop the trailing slash from both defaults, and `.rstrip("/")` the env-var value so user-supplied bases with a trailing slash also produce clean URLs.
4b8b0bb to
3c7ae13
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
All system-image and emulator-zip downloads are currently hardcoded to
https://dl.google.com/.... That breaks for users behind corporate proxies, air-gapped environments, or in regions where Google's CDN is slow/unreachable — most prominently the long-standing #240 ("China available mirror image"). It also makes it hard to test new emulator releases via a staged mirror without forking the script.Change
Two commits:
Add override of download location.(cherry-pick of @gregersn's commit from Custom naming and repository #359, authored 2021-10-11) — introduces anANDROID_REPOSITORYenv var, defaulted tohttps://dl.google.com, and uses it as the base for system-image catalogs (sys-img2-5.xml), the emulator repo catalog (repository2-1.xml), the per-package system-image zip URLs, and the platform-tools download.normalize ANDROID_REPOSITORY trailing slash(mine) — small follow-up. The two modules disagreed on whether the default had a trailing slash (https://dl.google.com/vshttps://dl.google.com), and combined with format strings starting/android/...this producedhttps://dl.google.com//android/...(double slash). Normalized both defaults to no trailing slash and added.rstrip("/")so user-supplied bases with a trailing slash also work cleanly.Conflict resolution notes
The original cherry-pick had two conflicts against current master, both resolved to keep HEAD's logic and apply the substitution:
SYSIMG_REPOS: kept HEAD's newersys-img2-5.xmlfilenames (Greger's commit predated the bump and still referencedsys-img2-1.xml), wrapped each in%s/...withANDROID_REPOSITORY.AndroidReleaseZip.urlconstruction: kept theurl_dir = sort_base or self.taglogic (added later for 16KB-page sysimg URL routing — see theis_16kwork), substitutedANDROID_REPOSITORYfor the hardcoded base.Credit
@gregersn opened the original feature in #359 (along with an unrelated
--nameflag). Splitting into two PRs (#410 for--name, this one forANDROID_REPOSITORY) for reviewability. Original authorship preserved on commit 1 via cherry-pick.Cross-link
Addresses #240 ("Requesting/Begging for a China available mirror image"). This PR provides the client-side override needed to point at any mirror; standing up the actual mirror is out of scope.
Test plan
pytest tests/ --ignore=tests/e2e)https://dl.google.com/android/repository/sys-img/android/sys-img2-5.xmlANDROID_REPOSITORY=https://my-mirror.example.com:https://my-mirror.example.com/android/repository/sys-img/android/sys-img2-5.xmlANDROID_REPOSITORY=https://my-mirror.example.com/(trailing slash): same as above — rstrip prevents double-slash