summary refs log tree commit diff
diff options
context:
space:
mode:
authorTad Fisher <tadfisher@gmail.com>2019-03-22 10:44:48 -0700
committerLuca Favatella <lucafavatella@users.noreply.github.com>2020-03-09 03:43:19 +0000
commitd574ea45a2d3ef49e78d915b119b8d59de5d6a66 (patch)
treeed687ad558896dec864b6d1747fcf812835b788b
parent6f809839633ab4e3434df7eb125cc4d5d0b406b7 (diff)
downloadnixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar.gz
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar.bz2
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar.lz
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar.xz
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.tar.zst
nixpkgs-d574ea45a2d3ef49e78d915b119b8d59de5d6a66.zip
androidenv: fix system images xsl used in generate.sh
Updated with fixes for `convertsystemimages.xsl`:
- Use `type-details/codename` if it exists, falling back to
  `type-details/api-level`: this results in "Q" rather than "28" for
  preview images
- Use `<xsl:text>` elements to control whitespace in the output.

This is extracted from https://github.com/NixOS/nixpkgs PR 58131.
-rw-r--r--pkgs/development/mobile/androidenv/convertsystemimages.xsl69
1 files changed, 49 insertions, 20 deletions
diff --git a/pkgs/development/mobile/androidenv/convertsystemimages.xsl b/pkgs/development/mobile/androidenv/convertsystemimages.xsl
index 42d19cb6965..de57041f192 100644
--- a/pkgs/development/mobile/androidenv/convertsystemimages.xsl
+++ b/pkgs/development/mobile/androidenv/convertsystemimages.xsl
@@ -6,7 +6,7 @@
 
   <xsl:param name="imageType" />
 
-  <xsl:output omit-xml-declaration="yes" indent="no" />
+  <xsl:output method="text" omit-xml-declaration="yes" indent="no" />
 
   <xsl:template name="repository-url">
     <xsl:variable name="raw-url" select="complete/url"/>
@@ -15,33 +15,62 @@
         <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:text>https://dl.google.com/android/repository/sys-img/</xsl:text><xsl:value-of select="$imageType" /><xsl:text>/</xsl:text><xsl:value-of select="$raw-url"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
 
+  <xsl:template mode="revision" match="type-details[codename]">
+    <xsl:value-of select="codename" />-<xsl:value-of select="tag/id" />-<xsl:value-of select="abi" />
+  </xsl:template>
+
+  <xsl:template mode="revision" match="type-details[not(codename)]">
+    <xsl:value-of select="api-level" />-<xsl:value-of select="tag/id" />-<xsl:value-of select="abi" />
+  </xsl:template>
+
+  <xsl:template mode="attrkey" match="type-details[codename]">
+    <xsl:text>"</xsl:text>
+    <xsl:value-of select="codename" />
+    <xsl:text>".</xsl:text>
+    <xsl:value-of select="tag/id" />
+    <xsl:text>."</xsl:text>
+    <xsl:value-of select="abi" />
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
+  <xsl:template mode="attrkey" match="type-details[not(codename)]">
+    <xsl:text>"</xsl:text>
+    <xsl:value-of select="api-level" />
+    <xsl:text>".</xsl:text>
+    <xsl:value-of select="tag/id" />
+    <xsl:text>."</xsl:text>
+    <xsl:value-of select="abi" />
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
   <xsl:template match="/sys-img:sdk-sys-img">
-{fetchurl}:
+<xsl:text>{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:text><xsl:for-each select="remotePackage[starts-with(@path, 'system-images;')]">
+  <xsl:variable name="revision"><xsl:apply-templates mode="revision" select="type-details" /></xsl:variable>
+
+  <xsl:variable name="attrkey"><xsl:apply-templates mode="attrkey" select="type-details" /></xsl:variable>
+
+  <xsl:text>  </xsl:text><xsl:value-of select="$attrkey" /><xsl:text> = {
+    name = "system-image-</xsl:text><xsl:value-of select="$revision" /><xsl:text>";
+    path = "</xsl:text><xsl:value-of select="translate(@path, ';', '/')" /><xsl:text>";
+    revision = "</xsl:text><xsl:value-of select="$revision" /><xsl:text>";
+    displayName = "</xsl:text><xsl:value-of select="display-name" /><xsl:text>";
+    archives.all = fetchurl {</xsl:text>
+    <xsl:for-each select="archives/archive"><xsl:text>
+      url = </xsl:text><xsl:call-template name="repository-url"/><xsl:text>;
+      sha1 = "</xsl:text><xsl:value-of select="complete/checksum" /><xsl:text>";</xsl:text>
+    </xsl:for-each><xsl:text>
+    };
   };
+</xsl:text>
   </xsl:for-each>
-}
+<xsl:text>}</xsl:text>
   </xsl:template>
 </xsl:stylesheet>