1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 05:00:16 +00:00

Merge pull request #82067 from lucafavatella/androidenv-generate

androidenv: enhance script for the generated expressions
This commit is contained in:
Sander van der Burg 2020-03-16 22:48:17 +01:00 committed by GitHub
commit 52c89d0572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 25 deletions

View file

@ -235,5 +235,5 @@ package manager uses. To update the expressions run the `generate.sh` script
that is stored in the `pkgs/development/mobile/androidenv/` sub directory:
```bash
sh ./generate.sh
./generate.sh
```

View file

@ -28,7 +28,7 @@
{
<!-- Convert all remote packages -->
<xsl:for-each select="remotePackage"><xsl:sort select="@path" />
<xsl:for-each select="remotePackage[not(contains(@path, ';') and substring-after(@path, ';') = 'latest')]"><xsl:sort select="@path" />
<!-- Extract the package name from the path -->
<xsl:variable name="name">

View file

@ -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: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: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: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>

28
pkgs/development/mobile/androidenv/generate.sh Normal file → Executable file
View file

@ -1,16 +1,36 @@
#!/bin/sh -e
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl libxslt
set -e
die() {
echo "$1" >&2
exit 1
}
fetch() {
local url="https://dl.google.com/android/repository/$1"
echo "$url -> $2"
curl -s "$url" -o "$2" || die "Failed to fetch $url"
}
pushd "$(dirname "$0")" &>/dev/null || exit 1
mkdir -p xml
# Convert base packages
curl https://dl.google.com/android/repository/repository2-1.xml -o xml/repository2-1.xml
fetch repository2-1.xml xml/repository2-1.xml
xsltproc convertpackages.xsl xml/repository2-1.xml > generated/packages.nix
# Convert system images
for img in android android-tv android-wear android-wear-cn google_apis google_apis_playstore
do
curl https://dl.google.com/android/repository/sys-img/$img/sys-img2-1.xml -o xml/$img-sys-img2-1.xml
fetch sys-img/$img/sys-img2-1.xml xml/$img-sys-img2-1.xml
xsltproc --stringparam imageType $img convertsystemimages.xsl xml/$img-sys-img2-1.xml > generated/system-images-$img.nix
done
# Convert system addons
curl https://dl.google.com/android/repository/addon2-1.xml -o xml/addon2-1.xml
fetch addon2-1.xml xml/addon2-1.xml
xsltproc convertaddons.xsl xml/addon2-1.xml > generated/addons.nix
popd &>/dev/null