diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl')
-rw-r--r-- | nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl b/nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl new file mode 100644 index 000000000000..9623e01abcd7 --- /dev/null +++ b/nixpkgs/pkgs/development/mobile/androidenv/convertpackages.xsl @@ -0,0 +1,116 @@ +<?xml version="1.0"?> + +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:common="http://schemas.android.com/repository/android/common/01" + xmlns:generic="http://schemas.android.com/repository/android/generic/01" + xmlns:sdk="http://schemas.android.com/sdk/android/repo/repository2/01" + xmlns:sdk-common="http://schemas.android.com/sdk/android/repo/common/01" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <xsl:output omit-xml-declaration="yes" indent="no" /> + + <!-- Template that puts a google HTTP prefix in front of relative URLs --> + <xsl:template name="repository-url"> + <xsl:variable name="raw-url" select="complete/url"/> + <xsl:choose> + <xsl:when test="starts-with($raw-url, 'http')"> + <xsl:value-of select="$raw-url"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>https://dl.google.com/android/repository/</xsl:text> + <xsl:value-of select="$raw-url"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="/sdk:sdk-repository"> +{fetchurl}: + +{ + <!-- Convert all remote packages --> + <xsl:for-each select="remotePackage"><xsl:sort select="@path" /> + + <!-- Extract the package name from the path --> + <xsl:variable name="name"> + <xsl:choose> + <xsl:when test="contains(@path, ';')"> + <xsl:value-of select="substring-before(@path, ';')" /> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@path" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- Compose version string from version attributes --> + <xsl:variable name="revision"> + <xsl:choose> + <!-- Compose revision for a generic package from the revision attributes --> + <xsl:when test="type-details/@xsi:type='generic:genericDetailsType'"> + <xsl:choose> + <xsl:when test="revision/major"> + <xsl:value-of select="revision/major" /> + </xsl:when> + </xsl:choose> + <xsl:choose> + <xsl:when test="revision/minor">.<xsl:value-of select="revision/minor" /> + </xsl:when> + </xsl:choose> + <xsl:choose> + <xsl:when test="revision/micro">.<xsl:value-of select="revision/micro" /> + </xsl:when> + </xsl:choose> + <xsl:choose> + <xsl:when test="revision/preview">-rc<xsl:value-of select="revision/preview" /> + </xsl:when> + </xsl:choose> + </xsl:when> + <!-- Compose revision of a platform SDK from the API-level or codename if the latter exists --> + <xsl:when test="type-details/@xsi:type='sdk:platformDetailsType'"> + <xsl:choose> + <xsl:when test="not(type-details/codename='')"> + <xsl:value-of select="type-details/codename" /> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="type-details/api-level" /> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <!-- Compose revision of a source SDK from the API-level --> + <xsl:when test="type-details/@xsi:type='sdk:sourceDetailsType'"> + <xsl:value-of select="type-details/api-level" /> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="@path='emulator'"> <!-- An emulator package provides one archive per operating system but the same versions --> + "<xsl:value-of select="$name" />"."<xsl:value-of select="$revision" />".<xsl:value-of select="archives/archive/host-os" /> = { + </xsl:when> + <xsl:otherwise> + "<xsl:value-of select="$name" />"."<xsl:value-of select="$revision" />" = { + </xsl:otherwise> + </xsl:choose> + name = "<xsl:value-of select="$name" />"; + path = "<xsl:value-of select="translate(@path, ';', '/')" />"; + revision = "<xsl:value-of select="$revision" />"; + displayName = "<xsl:value-of select="display-name" />"; + archives = { + <xsl:for-each select="archives/archive[not(host-os)]"> + all = fetchurl { + url = <xsl:call-template name="repository-url"/>; + sha1 = "<xsl:value-of select="complete/checksum" />"; + }; + </xsl:for-each> + <xsl:for-each select="archives/archive[host-os and not(host-os = 'windows')]"> + <xsl:value-of select="host-os" /> = fetchurl { + url = <xsl:call-template name="repository-url"/>; + sha1 = "<xsl:value-of select="complete/checksum" />"; + }; + </xsl:for-each> + }; + }; + </xsl:for-each> +} + </xsl:template> +</xsl:stylesheet> |