forked from iotbzh/agl-manifest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo2manifest
executable file
·42 lines (34 loc) · 1.75 KB
/
repo2manifest
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
#!/bin/sh
xsl='<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template name="get-branch">
<xsl:param name="branch"/>
<xsl:choose>
<xsl:when test="string-length($branch) = 0">origin/<xsl:value-of select="/manifest/default/@revision"/></xsl:when>
<xsl:when test="string-length($branch) = 40"><xsl:value-of select="substring($branch,1,7)"/></xsl:when>
<xsl:otherwise>origin/<xsl:value-of select="$branch"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="get-fetch">
<xsl:param name="remote"/>
<xsl:if test="string-length($remote) = 0">
<xsl:variable name="remote" select="/manifest/default/@remote"/>
</xsl:if>
<xsl:choose>
<xsl:when test="string-length($remote) = 0"><xsl:value-of select="/manifest/remote[@name=/manifest/default/@remote]/@fetch"/></xsl:when>
<xsl:otherwise><xsl:value-of select="/manifest/remote[@name=$remote]/@fetch"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="project">
<xsl:variable name="xxx"><xsl:call-template name="get-branch"><xsl:with-param name="branch"><xsl:value-of select="@revision"/></xsl:with-param></xsl:call-template></xsl:variable>
<xsl:variable name="yyy"><xsl:call-template name="get-fetch"><xsl:with-param name="remote"><xsl:value-of select="@remote"/></xsl:with-param></xsl:call-template></xsl:variable>
<xsl:value-of select="$xxx"/>=iotbzh <xsl:value-of select="@path"/> origin=<xsl:value-of select="$yyy"/><xsl:value-of select="@name"/> EOL
</xsl:template>
<xsl:template match="/manifest">
<xsl:apply-templates select="project">
<xsl:sort select="@path" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>'
echo "$xsl" | xsltproc - "$@" | sed 's: EOL$::'