Merge pull request #82067 from lucafavatella/androidenv-generate
androidenv: enhance script for the generated expressions
This commit is contained in:
commit
52c89d0572
@ -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
|
||||
```
|
||||
|
@ -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">
|
||||
|
@ -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
28
pkgs/development/mobile/androidenv/generate.sh
Normal file → Executable 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
|
||||
|
Loading…
Reference in New Issue
Block a user