From 8ce334422a31f7209a21a5d2b42d46c6fbf47ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 31 Oct 2005 22:24:58 +0000 Subject: [PATCH] * a few minor, fixes, make specfilenewtests complete successfully --- pisi/specfilenew.py | 44 +++++++++++++++++---------------------- pisi/xmlfile.py | 4 ++-- tests/specfilenewtests.py | 4 ++-- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/pisi/specfilenew.py b/pisi/specfilenew.py index 9fcda5b6..32e68b7a 100644 --- a/pisi/specfilenew.py +++ b/pisi/specfilenew.py @@ -160,6 +160,8 @@ class Source: t_Archive = [Archive, xmlfile.mandatory ] t_Patches = [ [Patch], xmlfile.optional] t_BuildDependencies = [ [Dependency], xmlfile.optional] + t_Version = [ xmlfile.String, xmlfile.optional] + t_Release = [ xmlfile.String, xmlfile.optional] class Package: @@ -207,20 +209,12 @@ class SpecFile(XmlFile): self.merge_tags() self.override_tags() - #FIXME: copy only needed information - # no need to keep full history with comments in metadata.xml - self.source.history = self.history - for p in self.packages: - p.history = self.history - self.unlink() errs = self.check() if errs: - e = "" - for x in errs: - e += x + "\n" - raise Error(_("File '%s' has errors:\n%s") % (filename, e)) + errs.append(_("File '%s' has errors") % filename) + raise Error(*errs) def override_tags(self): """Override tags from Source in Packages. Some tags in Packages @@ -229,41 +223,41 @@ class SpecFile(XmlFile): tmp = [] for pkg in self.packages: - if not pkg.summary: pkg.summary = self.source.summary - if not pkg.description: pkg.description = self.source.description - if not pkg.partOf: pkg.partOf = self.source.partOf - if not pkg.license: pkg.license = self.source.license - if not pkg.icon: pkg.icon = self.source.icon - tmp.append(pkg) - self.packages = tmp - + def merge_tags(self): """Merge tags from Source in Packages. Some tags in Packages merged with the tags from Source. There is a more detailed description in documents.""" + # FIXME: copy only needed information + # no need to keep full history with comments in metadata.xml + self.source.history = self.history + + # To avoid tag duplication in PSPEC we need to get + # the last version and release information + # from the most recent History/Update. + if not self.source.version: + self.source.version = self.history[0].version + if not self.source.release: + self.source.release = self.history[0].release + tmp = [] for pkg in self.packages: - - if pkg.isA and self.source.isA: - pkg.isA.append(self.source.isA) - elif not pkg.isA and self.source.isA: - pkg.isA = self.source.isA - + pkg.isA.extend(self.source.isA) + pkg.history = self.history tmp.append(pkg) - self.packages = tmp def write(self, filename): diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py index 5fced6b8..cc3a0cc2 100644 --- a/pisi/xmlfile.py +++ b/pisi/xmlfile.py @@ -391,7 +391,7 @@ class autoxml(oo.autosuper): errs = [] if hasattr(self, name): value = getattr(self,name) - errs.extend(check_a(value, unicode("%s: " %name))) + errs.extend(check_a(value, where + name + ': ' )) else: if req == mandatory: errs.append(where + _('Mandatory variable %s not available') % name) @@ -595,7 +595,7 @@ class autoxml(oo.autosuper): def check(l, where): errs = [] for ix in range(len(l)): - errs.extend(check_item(l[ix], unicode(ix))) + errs.extend(check_item(l[ix], where + '[%s]' % ix)) return errs def format(l, f, errs): diff --git a/tests/specfilenewtests.py b/tests/specfilenewtests.py index 922cb759..4ed6611f 100644 --- a/tests/specfilenewtests.py +++ b/tests/specfilenewtests.py @@ -31,7 +31,7 @@ class SpecFileNewTestCase(testcase.TestCase): self.assertEqual(self.spec.source.release, "3") - self.assertEqual(self.spec.source.archiveSHA1, + self.assertEqual(self.spec.source.archive.sha1sum, "66f3c77b87a160951b180447f4a6dce68ad2f71b") patches = self.spec.source.patches @@ -47,7 +47,7 @@ class SpecFileNewTestCase(testcase.TestCase): # search for a path in package.paths pn = "/usr/lib" - matched = [p for p in package.paths if p.pathname == pn] + matched = [p for p in package.files if p.path == pn] if not matched: self.fail("Failed to match pathname: %s" %pn)