[csw-devel] [PATCH] checkpkg: allow collection of obsoletion info
Ben Walton
bwalton at opencsw.org
Sun Mar 27 16:49:26 CEST 2011
Excerpts from Maciej Bliziński's message of Sun Mar 27 10:22:26 -0400 2011:
> > + def GetObsoletedBy(self):
> > + """Collects obsolescence information from the package if it
> > exists
> > +
> > + Documentation:
> > + http://wiki.opencsw.org/obsoleting-packages
> > +
> > + Returns:
> > + a tuple (bool, list) of (syntax_ok, obsoleted_by)
>
> This bit needs updating.
Ah yes. Good catch.
Index: package.py
===================================================================
--- package.py (revision 13944)
+++ package.py (working copy)
@@ -358,6 +358,39 @@
fd.close()
return depends
+ def GetObsoletedBy(self):
+ """Collects obsolescence information from the package if it
exists
+
+ Documentation:
+ http://wiki.opencsw.org/obsoleting-packages
+
+ Returns:
+ a dict { syntax_ok: bool, obsoleted_by: [[pkg,cat], [pkg2,cat2], ...] }
^^ I'm not sure if I'm describing the data structure in the proper
python way here. Should the [] be ()?
+
+ If the package has not been obsoleted or the package predates the
+ implementation of this mechanism, the list is empty. If the
+ package provides obsolescence information but the format of the
+ information is invalid, syntax_ok will be False and the list will
+ be empty.
+ """
+
+ obsoleted_syntax_ok = True
+ obsoleted_by = []
+ obsoleted_by_path = os.path.join(self.directory, "install", "obsolete")
+ if not os.path.exists(obsoleted_by_path):
+ return obsoleted_by
+
+ with open(obsoleted_by_path, "r") as fd:
+ for line in fd:
+ fields = re.split(c.WS_RE, line)
+ if len(fields) < 2:
+ obsoleted_syntax_ok = False
+ logging.warning("Bad line in obsolete file: %s", repr(line))
+ continue
+ pkgname, catalogname = fields[0:2]
+ obsoleted_by.append((pkgname, catalogname))
+ return { "syntax_ok": obsoleted_syntax_ok, "obsoleted_by": obsoleted_by }
+
> Incrementing of the data structure version doesn't need to be done
> in this change, if it only adds this function. It will need to be
> in the change in the code creating pkg_stats in package_stats.py.
Right. And I'll do my best to keeps the commits atomic in the 'git
way' where each change is as self contained as possible, newer
building on older.
Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302
More information about the devel
mailing list