summary refs log tree commit diff
path: root/pkgs/development/mobile/androidenv/convertsystemimages.xsl
blob: 42d19cb69651074b7893b77b5c712b9c2817750a (plain) (blame)
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
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sys-img="http://schemas.android.com/sdk/android/repo/sys-img2/01"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <xsl:param name="imageType" />

  <xsl:output omit-xml-declaration="yes" indent="no" />

  <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>
        https://dl.google.com/android/repository/sys-img/<xsl:value-of select="$imageType" />/<xsl:value-of select="$raw-url"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="/sys-img:sdk-sys-img">
{fetchurl}:

{
  <xsl:for-each select="remotePackage[starts-with(@path, 'system-images;')]">
    <xsl:variable name="revision">
      <xsl:value-of select="type-details/api-level" />-<xsl:value-of select="type-details/tag/id" />-<xsl:value-of select="type-details/abi" />
    </xsl:variable>

    "<xsl:value-of select="type-details/api-level" />".<xsl:value-of select="type-details/tag/id" />."<xsl:value-of select="type-details/abi" />" = {
      name = "system-image-<xsl:value-of select="$revision" />";
      path = "<xsl:value-of select="translate(@path, ';', '/')" />";
      revision = "<xsl:value-of select="$revision" />";
      displayName = "<xsl:value-of select="display-name" />";
      archives.all = fetchurl {
      <xsl:for-each select="archives/archive">
        url = <xsl:call-template name="repository-url"/>;
        sha1 = "<xsl:value-of select="complete/checksum" />";
      </xsl:for-each>
      };
  };
  </xsl:for-each>
}
  </xsl:template>
</xsl:stylesheet>