Skip to content

Commit

Permalink
qitoolchain: Add sub package feed parsing.
Browse files Browse the repository at this point in the history
In the toolchain xml file, a 'package' tag contained in an other
'package' tag is not taken into account. This patch adds a feature that
look for 'package' tags inside 'package' tags.

Now, this kind of xml file is valid:
<toolchain strict_metadata="false">
  <package name="meta-package" ...>
    <package name="sub-pkg1" version="..."/>
    <package name="sub-pkg2" version="..."/>
    <package name="sub-pkg3" version="..."/>
  </package>
</toolchain>

This is needed when a package (eg. yocto-sdk) provides several
sub-packages that need to appear as qitoolchain packages.

The xml sub package tag should not contain 'directory' or 'url'
attributes as 'directory' attribute will be set to the parent package
'directory' attribute.

Change-Id: Ib7b1f22a065c30c9d9616383fbd7629f73b051e2
Reviewed-on: http://gerrit.aldebaran.lan/79917
Reviewed-by: nrubinstein <[email protected]>
Tested-by: plemagourou <[email protected]>
  • Loading branch information
plemagourou committed Feb 10, 2017
1 parent 1c26e5a commit c8f4c4e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/source/changes/3.11.13.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
v3.11.13
========

qitoolchain
-----------

* In the toolchain xml file, a 'package' tag can now contain other 'package' tags::

<toolchain strict_metadata="false">
<package name="meta-package" ...>
<package name="sub-pkg1" version="..."/>
<package name="sub-pkg2" version="..."/>
<package name="sub-pkg3" version="..."/>
</package>
</toolchain>

This is needed when a package (eg. yocto-sdk) provides several
sub-packages that need to appear as qitoolchain packages.

The xml sub package tag should not contain 'directory' or 'url'
attributes as 'directory' attribute will be set to the parent package
'directory' attribute.
8 changes: 8 additions & 0 deletions python/qitoolchain/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def parse(self, feed, branch=None, name=None, first_pass=True):
""" Recursively parse the feed, filling the self.packages
"""
tc_path = qisys.sh.get_share_path("qi", "toolchains", self.name)
if branch and name:
feed_path = open_git_feed(self.name, feed, branch=branch, name=name,
first_pass=first_pass)
Expand All @@ -135,6 +136,13 @@ def parse(self, feed, branch=None, name=None, first_pass=True):
for package_tree in package_trees:
package_tree.set("feed", feed)
self.append_package(package_tree)
subpkg_trees = package_tree.findall("package")
for subpkg_tree in subpkg_trees:
subpkg_tree.set("feed", feed)
subpkg_tree.set("directory",
os.path.join(tc_path, package_tree.get("name")))
self.append_package(subpkg_tree)

feeds = tree.findall("feed")
for feed_tree in feeds:
feed_url = feed_tree.get("url")
Expand Down
27 changes: 27 additions & 0 deletions python/qitoolchain/test/test_subpackages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

import qisys
import qitoolchain.toolchain

def test_subpackage_parsing(tmpdir):
tmp = tmpdir.mkdir("feed")
subpackage_xml = tmp.join("subpackage.xml")
subpackage_xml.write("""
<toolchain>
<package name="rootpkg" directory="." version="1.0">
<package name="subpkg1" version="2.3"/>
<package name="subpkg2" version="0.2"/>
</package>
</toolchain>""")
parser = qitoolchain.feed.ToolchainFeedParser("test_subpackage")
parser.parse(subpackage_xml.strpath)
pkgs = parser.get_packages()

toolchain_path = qisys.sh.get_share_path("qi", "toolchains", parser.name, "rootpkg")
assert len(pkgs)== 3
assert pkgs[0].name == "rootpkg"
assert pkgs[1].name == "subpkg1"
assert pkgs[2].name == "subpkg2"
assert pkgs[1].directory == toolchain_path
assert pkgs[2].directory == toolchain_path

0 comments on commit c8f4c4e

Please sign in to comment.