From 18bbeabe88712dbbd6e50c62099dc77c93b59d6e Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Fri, 12 Jun 2009 18:23:14 +0000 Subject: [PATCH] Add components.xml support.. pisi index will now need components.xml, else no component info will be added. Until we figure out some way to delete component.xml files, they will be used to find out the PartOf of the packages as before. --- pisi/component.py | 22 ++++++++++++++++++---- pisi/index.py | 16 +++++++++------- pisi/operations/build.py | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pisi/component.py b/pisi/component.py index ea536258..fcdcf99d 100644 --- a/pisi/component.py +++ b/pisi/component.py @@ -50,13 +50,11 @@ class Distribution(xmlfile.XmlFile): t_Obsoletes = [ [Obsolete], autoxml.optional, "Obsoletes/Package"] -class Component(xmlfile.XmlFile): +class Component: "representation for component declarations" __metaclass__ = autoxml.autoxml - tag = "PISI" - t_Name = [autoxml.String, autoxml.mandatory] # fully qualified name # component name in other languages, for instance in Turkish @@ -69,10 +67,26 @@ class Component(xmlfile.XmlFile): t_Summary = [autoxml.LocalText, autoxml.mandatory] t_Description = [autoxml.LocalText, autoxml.mandatory] t_Icon = [ autoxml.String, autoxml.optional] - t_VisibleTo = [autoxml.String, autoxml.optional] + t_Group = [ autoxml.LocalText, autoxml.optional ] # the parts of this component. # to be filled by the component database, thus it is optional. t_Packages = [ [autoxml.String], autoxml.optional, "Parts/Package"] t_Sources = [ [autoxml.String], autoxml.optional, "Parts/Source"] + +class Components(xmlfile.XmlFile): + "representation for component declarations" + + __metaclass__ = autoxml.autoxml + + tag = "PISI" + + t_Components = [ [Component], autoxml.optional, "Components/Component" ] + +# FIXME: there will be no component.xml only components.xml +class CompatComponent(Component, xmlfile.XmlFile): + + tag = "PISI" + + t_VisibleTo = [autoxml.String, autoxml.optional] diff --git a/pisi/index.py b/pisi/index.py index 53884493..c26b0f3a 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -93,9 +93,8 @@ class Index(xmlfile.XmlFile): elif fn.endswith(ctx.const.package_suffix): packages.append(os.path.join(root, fn)) - if fn == 'component.xml': - ctx.ui.info(_('Adding %s to component index') % fn) - self.add_component(os.path.join(root, fn)) + if fn == 'components.xml': + self.add_components(os.path.join(root, fn)) if fn == 'pspec.xml' and not skip_sources: self.add_spec(os.path.join(root, fn), repo_uri) if fn == 'distribution.xml': @@ -148,16 +147,19 @@ class Index(xmlfile.XmlFile): self.packages.append(md.package) - def add_component(self, path): - comp = component.Component() + def add_components(self, path): + ctx.ui.info("Adding components.xml to index...") + components_xml = component.Components() + components_xml.read(path) #try: - comp.read(path) - self.components.append(comp) + for comp in components_xml.components: + self.components.append(comp) #except: # raise Error(_('Component in %s is corrupt') % path) #ctx.ui.error(str(Error(*errs))) def add_distro(self, path): + ctx.ui.info("Adding distribution.xml to index...") distro = component.Distribution() #try: distro.read(path) diff --git a/pisi/operations/build.py b/pisi/operations/build.py index 4c8106f3..dcaf58bc 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -364,7 +364,7 @@ class Builder: if not os.path.exists(url): raise Exception(_('Cannot find component.xml in upper directory')) path = url - comp = component.Component() + comp = component.CompatComponent() comp.read(path) ctx.ui.info(_('Source is part of %s component') % comp.name) self.spec.source.partOf = comp.name