Merge lp:~pfalcon/linaro-android-build-tools/manifest-descr into lp:linaro-android-build-tools

Proposed by Paul Sokolovsky
Status: Merged
Merged at revision: 660
Proposed branch: lp:~pfalcon/linaro-android-build-tools/manifest-descr
Merge into: lp:linaro-android-build-tools
Diff against target: 190 lines (+172/-0)
3 files modified
build-scripts/build-android (+2/-0)
utils/manifest-descriptions/make.sh (+15/-0)
utils/manifest-descriptions/manifest-annotate (+155/-0)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-build-tools/manifest-descr
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Amit Pundir Pending
Review via email: mp+178534@code.launchpad.net

Description of the change

This implements needed functionality for lp:1194801 / LAVA-567. This yet needs to be tested.

It's also clear that JSON format as currently present in http://android.git.linaro.org/git-ro/platform/manifest-descriptions.git is not ideal, but I rehash it into needed shape in the script, so would like to land this first, and then think if it's worth to change format.

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

<pundiramit_> pfalcon, MP looks good to me. Do you need anything from my side?

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build-scripts/build-android'
2--- build-scripts/build-android 2013-04-22 09:51:50 +0000
3+++ build-scripts/build-android 2013-08-05 11:13:29 +0000
4@@ -160,3 +160,5 @@
5 if [ -f out/kernel_config ]; then
6 (cd out/; ${BUILD_SCRIPT_ROOT}/create-user-kernel-script)
7 fi
8+
9+${BUILD_SCRIPT_ROOT}/../utils/manifest-descriptions/make.sh out/source-manifest.xml out/pinned-manifest.xml
10
11=== added directory 'utils/manifest-descriptions'
12=== added file 'utils/manifest-descriptions/make.sh'
13--- utils/manifest-descriptions/make.sh 1970-01-01 00:00:00 +0000
14+++ utils/manifest-descriptions/make.sh 2013-08-05 11:13:29 +0000
15@@ -0,0 +1,15 @@
16+#!/bin/sh
17+
18+dir=manifest-descriptions
19+
20+#rm -rf $dir
21+
22+if [ -d $dir ]; then
23+ cd $dir
24+ git pull
25+ cd ..
26+else
27+ git clone http://android.git.linaro.org/git-ro/platform/manifest-descriptions.git
28+fi
29+
30+$(dirname $0)/manifest-annotate $*
31
32=== added file 'utils/manifest-descriptions/manifest-annotate'
33--- utils/manifest-descriptions/manifest-annotate 1970-01-01 00:00:00 +0000
34+++ utils/manifest-descriptions/manifest-annotate 2013-08-05 11:13:29 +0000
35@@ -0,0 +1,155 @@
36+#!/usr/bin/env python
37+import sys
38+import json
39+import optparse
40+from xml.dom import minidom
41+from pprint import pprint
42+
43+
44+JSON_DATA_PATH = "manifest-descriptions/"
45+
46+
47+class Manifest:
48+
49+ def __init__(self):
50+ self.remote_list = []
51+ self.project_list = []
52+ # (project name, remote) -> revision
53+ self.project_revision_map = {}
54+ self.default_node = None
55+
56+ @staticmethod
57+ def compare_attr_wise(node1, node2):
58+ if node1.attributes.length != node2.attributes.length:
59+ return False
60+ for i in xrange(node1.attributes.length):
61+ a1 = node1.attributes.item(i)
62+ if a1.value != node2.attributes[a1.name].value:
63+ return False
64+ return True
65+
66+ def add_default(self, default_node):
67+ if self.default_node:
68+ if not self.compare_attr_wise(default_node, self.default_node):
69+ raise ValueError("default collision: %s vs %s" % (default_node.toxml(), self.default_node.toxml()))
70+ return
71+ self.default_node = default_node
72+
73+ def add_remote(self, remote_node):
74+ self.remote_list.append(remote_node)
75+ return True
76+
77+ def add_project(self, project_node):
78+ remote = project_node.getAttribute("remote")
79+ name = project_node.getAttribute("name")
80+ revision = project_node.getAttribute("revision")
81+ path = project_node.getAttribute("path")
82+ self.project_list.append(project_node)
83+ self.project_revision_map[(name, remote)] = revision
84+ return True
85+
86+ def get_default(self):
87+ return self.default_node
88+
89+ def get_remotes(self):
90+ return self.remote_list
91+
92+ def get_projects(self):
93+ return self.project_list
94+
95+ def get_revision(self, project_name, remote):
96+ return self.project_revision_map[(project_name, remote)]
97+
98+
99+def parse(manifest_file):
100+ manifest = Manifest()
101+ print >>sys.stderr, "Processing: %s" % manifest_file
102+ dom = minidom.parse(manifest_file)
103+ default = dom.getElementsByTagName("default")
104+ assert len(default) == 1
105+ manifest.add_default(default[0])
106+ for r in dom.getElementsByTagName("remote"):
107+ manifest.add_remote(r)
108+ for p in dom.getElementsByTagName("project"):
109+ manifest.add_project(p)
110+
111+ return manifest
112+
113+
114+def dump(manifest, out, revision_ref_manifest=None):
115+
116+ def sort_by_name(n1, n2):
117+ return cmp(n1.getAttribute("name"), n2.getAttribute("name"))
118+
119+ out.write("""\
120+<?xml version="1.0" encoding="UTF-8"?>
121+<manifest>
122+
123+""")
124+ for r in manifest.get_remotes():
125+ out.write(r.toxml())
126+ out.write("\n")
127+ out.write("\n")
128+
129+ out.write(manifest.get_default().toxml())
130+ out.write("\n\n")
131+
132+ for p in manifest.get_projects():
133+ name = p.getAttribute("name")
134+ remote = p.getAttribute("remote")
135+ if revision_ref_manifest:
136+ # For pinned manifest, we look up branch name for
137+ # this project in source manifest
138+ revision = revision_ref_manifest.get_revision(name, remote)
139+ else:
140+ revision = p.getAttribute("revision")
141+ if not remote:
142+ remote = manifest.get_default().getAttribute("remote")
143+ if (name, remote) in descr_map:
144+ descr = descr_map[(name, remote)]
145+ pd = descr.get("description")
146+ if pd:
147+ out.write("<!-- Project: %s -->\n" % pd)
148+ bd = descr["branches"].get(revision)
149+ if bd:
150+ out.write("<!-- Branch %s: %s -->\n" % (revision, bd))
151+ out.write(p.toxml())
152+ out.write("\n")
153+ out.write("""\
154+
155+</manifest>
156+""")
157+
158+optparser = optparse.OptionParser(usage="%prog <source-manifest.xml> <pinned-manifest.xml>")
159+options, args = optparser.parse_args(sys.argv[1:])
160+if len(args) != 2:
161+ optparser.error("Wrong number of arguments")
162+
163+FILE_MAP = [
164+ ("git_description_aglo.json", "aosp"),
165+ ("git_description_glo.json", "linaro-other"),
166+ ("git_description_hglo.json", "linaro-landing-team-hisilicon"),
167+ ("git_description_lpglo.json", "linaro-private"),
168+]
169+
170+descr_map = {}
171+for fname, remote in FILE_MAP:
172+ descrs_js = json.load(open(JSON_DATA_PATH + fname))
173+ for p in descrs_js["project"]:
174+ name = p["name"]
175+ description = None
176+ branches_js = p["branch"]
177+ branches = {}
178+ for b in branches_js:
179+ if "name" in b:
180+ branches[b["name"]] = b["description"]
181+ else:
182+ description = b["description"]
183+ descr_map[(name, remote)] = { "description": description, "branches": branches}
184+
185+#pprint(descr_map)
186+
187+source_manifest = parse(args[0])
188+pinned_manifest = parse(args[1])
189+dump(source_manifest, open(args[0] + ".ann", "w"))
190+dump(pinned_manifest, open(args[1] + ".ann", "w"), source_manifest)

Subscribers

People subscribed via source and target branches