From: Seth Vidal Date: Tue, 22 Jan 2008 17:44:19 +0000 (-0500) Subject: add changelog-limit option to restrict the number of changelogs we add, by default X-Git-Tag: upstream/0.9.9~147 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be282761d79dab9d02b8cfd2ce5985cb3f215596;p=tools%2Fcreaterepo.git add changelog-limit option to restrict the number of changelogs we add, by default --- diff --git a/createrepo/__init__.py b/createrepo/__init__.py index 7d1e5e1..eaa79b8 100644 --- a/createrepo/__init__.py +++ b/createrepo/__init__.py @@ -85,6 +85,8 @@ class MetaDataConfig(object): self.mdtimestamp = 0 self.directory = None self.directories = [] + self.changelog_limit = None # needs to be an int or None + class SimpleMDCallBack(object): def errorlog(self, thing): @@ -367,6 +369,9 @@ class MetaDataGenerator: po = yumbased.CreateRepoPackage(self.ts, rpmfile) except Errors.MiscError, e: raise MDError, "Unable to open package: %s" % e + # if we're going to add anything in from outside, here is where + # you can do it + po.crp_changelog_limit = self.conf.changelog_limit po.crp_cachedir = self.conf.cachedir return po diff --git a/createrepo/yumbased.py b/createrepo/yumbased.py index 816df6c..ac03bdc 100644 --- a/createrepo/yumbased.py +++ b/createrepo/yumbased.py @@ -372,7 +372,11 @@ class CreateRepoPackage(YumLocalPackage): if not self.changelog: return "" msg = "\n" - for (ts, author, content) in self.changelog: + clog_count = 0 + for (ts, author, content) in reversed(sorted(self.changelog)): + if self.crp_changelog_limit and clog_count >= self.crp_changelog_limit: + break + clog_count += 1 c = self.xml_node.newChild(None, "changelog", None) c.addContent(utils.utf8String(content)) c.newProp('author', utils.utf8String(author)) diff --git a/genpkgmetadata.py b/genpkgmetadata.py index a43b281..e46b0a7 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -81,6 +81,8 @@ def parseArgs(args, conf): parser.add_option("-S", "--skip-symlinks", dest="skip_symlinks", default=False, action="store_true", help="ignore symlinks of packages") + parser.add_option("--changelog-limit", dest="changelog_limit", + default=None, help="only import the last N changelog entries") (opts, argsleft) = parser.parse_args() if len(argsleft) > 1 and not opts.split: @@ -121,6 +123,9 @@ def parseArgs(args, conf): conf.pkglist = lst + if conf.changelog_limit: # make sure it is an int, not a string + conf.changelog_limit = int(conf.changelog_limit) + return conf class MDCallBack(object):