android-sdk improvements

* Returns all matched versions to support list options
* Don't hard-code the host OS
* Document the default of `channel`
This commit is contained in:
Chih-Hsuan Yen 2021-12-04 18:58:34 +08:00
parent c6ed37ada1
commit c15e9b7576
No known key found for this signature in database
GPG Key ID: F98EF2A7B0A098AE
3 changed files with 38 additions and 3 deletions

View File

@ -731,7 +731,12 @@ 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``.
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``. The default is ``stable``.
host_os
Choose the target OS for the tracked package from one of ``linux``, ``macosx``, ``windows``. The default is ``linux``. For OS-independent packages (e.g., Java JARs), this field is ignored.
This source supports :ref:`list options`.
Check Sparkle framework
~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -38,6 +38,8 @@ async def get_version(name, conf, *, cache, **kwargs):
repo_manifest = await cache.get(repo, _get_repo_manifest)
versions = []
for pkg in repo_manifest.findall('.//remotePackage'):
if not pkg.attrib['path'].startswith(pkg_path_prefix):
continue
@ -46,7 +48,7 @@ async def get_version(name, conf, *, cache, **kwargs):
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':
if host_os is not None and host_os.text != conf.get('host_os', 'linux'):
continue
archive_url = archive.find('./complete/url').text
# revision
@ -62,4 +64,8 @@ async def get_version(name, conf, *, cache, **kwargs):
mobj = re.match(r'r\d+', rel_str)
if mobj:
rev_strs.append(rel_str)
return '.'.join(rev_strs)
versions.append('.'.join(rev_strs))
# A package suitable for the target host OS is found - skip remaining
break
return versions

View File

@ -27,3 +27,27 @@ async def test_android_package_channel(get_version):
"repo": "package",
"channel": "beta,dev,canary",
}) == "3.22.1"
async def test_android_list(get_version):
assert await get_version("android-sdk-cmake-older", {
"source": "android_sdk",
"android_sdk": "cmake;",
"repo": "package",
"include_regex": "3\.10.*",
}) == "3.10.2"
async def test_android_package_os(get_version):
await get_version("android-usb-driver", {
"source": "android_sdk",
"android_sdk": "extras;google;usb_driver",
"repo": "addon",
"host_os": "windows"
}) == "13"
async def test_android_package_os_missing(get_version):
await get_version("android-usb-driver", {
"source": "android_sdk",
"android_sdk": "extras;google;usb_driver",
"repo": "addon",
"host_os": "linux"
}) == None