Merge pull request #163 from yan12125/android-sdk-channel
Add `channel` for Android SDK packages
This commit is contained in:
commit
8d1a079703
|
@ -591,6 +591,9 @@ android_sdk
|
|||
repo
|
||||
Should be one of ``addon`` or ``package``. Packages in ``addon2-1.xml`` use ``addon`` and packages in ``repository2-1.xml`` use ``package``.
|
||||
|
||||
channel
|
||||
Choose the target channel from one of ``stable``, ``beta``, ``dev`` or ``canary``. This option also accepts a comma-seperated list to pick from multiple channels. For example, the latest unstable version is picked with ``beta,dev,canary``.
|
||||
|
||||
Check Sparkle framework
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
::
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2020 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||
# Copyright (c) 2017 Chih-Hsuan Yen <yan12125 at gmail dot com>
|
||||
# Copyright (c) 2017,2020 Chih-Hsuan Yen <yan12125 at gmail dot com>
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -13,6 +13,14 @@ _ANDROID_REPO_MANIFESTS = {
|
|||
'package': 'https://dl.google.com/android/repository/repository2-1.xml',
|
||||
}
|
||||
|
||||
# See <channel> tags in Android SDK XML manifests
|
||||
_CHANNEL_MAP = {
|
||||
'stable': 'channel-0',
|
||||
'beta': 'channel-1',
|
||||
'dev': 'channel-2',
|
||||
'canary': 'channel-3',
|
||||
}
|
||||
|
||||
async def _get_repo_manifest(repo):
|
||||
repo_xml_url = _ANDROID_REPO_MANIFESTS[repo]
|
||||
|
||||
|
@ -25,12 +33,17 @@ async def _get_repo_manifest(repo):
|
|||
async def get_version(name, conf, *, cache, **kwargs):
|
||||
repo = conf['repo']
|
||||
pkg_path_prefix = conf['android_sdk']
|
||||
channels = [_CHANNEL_MAP[channel]
|
||||
for channel in conf.get('channel', 'stable').split(',')]
|
||||
|
||||
repo_manifest = await cache.get(repo, _get_repo_manifest)
|
||||
|
||||
for pkg in repo_manifest.findall('.//remotePackage'):
|
||||
if not pkg.attrib['path'].startswith(pkg_path_prefix):
|
||||
continue
|
||||
channelRef = pkg.find('./channelRef')
|
||||
if channelRef.attrib['ref'] not in channels:
|
||||
continue
|
||||
for archive in pkg.findall('./archives/archive'):
|
||||
host_os = archive.find('./host-os')
|
||||
if host_os is not None and host_os.text != 'linux':
|
||||
|
|
|
@ -17,4 +17,13 @@ async def test_android_package(get_version):
|
|||
"source": "android_sdk",
|
||||
"android_sdk": "cmake;",
|
||||
"repo": "package",
|
||||
}) == "3.6.4111459"
|
||||
|
||||
|
||||
async def test_android_package_channel(get_version):
|
||||
assert await get_version("android-sdk-cmake", {
|
||||
"source": "android_sdk",
|
||||
"android_sdk": "cmake;",
|
||||
"repo": "package",
|
||||
"channel": "beta,dev,canary",
|
||||
}) == "3.18.1"
|
||||
|
|
Loading…
Reference in New Issue