Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created September 4, 2014 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxandersen/5b256eeb2dc8856f5a0b to your computer and use it in GitHub Desktop.
Save maxandersen/5b256eeb2dc8856f5a0b to your computer and use it in GitHub Desktop.
Creates a p2 update repo from content.jars piped to this command.
Usage:
cd <dir with p2 repos under it>
find . -name content.jar | python gencomposite.py
It will generate the necessary xml files for a composite repo and you
can now use the directory as an updatesite.
from lxml import etree
import fileinput
repos = []
for line in fileinput.input():
repos.append(line)
repository = etree.Element("repository", name="Auto-generated repo", type="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository", version="1.0.0")
properties = etree.SubElement(repository,"properties")
children = etree.SubElement(repository, "children")
for rep in repos:
etree.SubElement(children,"child", location=rep.replace("content.jar\n",''))
children.attrib["size"]=str(len(repos))
s = etree.tostring(repository, pretty_print=True)
print "Writing compositeContent.xml"
file = open("compositeContent.xml", "w")
file.write(s)
file.close()
repository.attrib["type"] = "org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository"
s = etree.tostring(repository, pretty_print=True)
print "Writing compositeArtifacts.xml"
file = open("compositeArtifacts.xml", "w")
file.write(s)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment