[csw-devel] [PATCH] checkpkg: allow collection of obsoletion info
Maciej Bliziński
maciej at opencsw.org
Sun Mar 27 16:22:26 CEST 2011
2011/3/27 Ben Walton <bwalton at opencsw.org>:
> Excerpts from Maciej Bliziński's message of Sun Mar 27 09:59:50 -0400 2011:
>
> Ok, here's the version I think is ready for commit...
>
> Thanks
> -Ben
>
> Index: package.py
> ===================================================================
> --- package.py (revision 13944)
> +++ package.py (working copy)
> @@ -358,6 +358,38 @@
> 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 tuple (bool, list) of (syntax_ok, obsoleted_by)
This bit needs updating.
> + 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
> + continue
> + pkgname, catalogname = fields[0:2]
> + obsoleted_by.append((pkgname, catalogname))
> + return { "syntax_ok": obsoleted_syntax_ok, "by": obsoleted_by }
> +
> def CheckPkgpathExists(self):
> if not os.path.isdir(self.directory):
> raise PackageError("%s does not exist or is not a directory"
Looks good!
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.
Maciej
More information about the devel
mailing list