diff options
author | Nicolas Vigier <boklm@mageia.org> | 2011-01-11 00:35:59 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2011-01-11 00:35:59 +0000 |
commit | ad7fb7807ceaee96521d779993a5e1b28650723f (patch) | |
tree | 2ece42aa7e83b7fdb51702b298aa3eec95da3573 /MgaRepo/commands/rpmlog.py | |
parent | 715e125cc8d0b3fc4a79752e28a8b76a4ce97d5a (diff) | |
download | mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.gz mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.bz2 mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.xz mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.zip |
rename repsys to mgarepo, RepSys to MgaRepo, and update docs and examples for Mageia
Diffstat (limited to 'MgaRepo/commands/rpmlog.py')
-rw-r--r-- | MgaRepo/commands/rpmlog.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/MgaRepo/commands/rpmlog.py b/MgaRepo/commands/rpmlog.py new file mode 100644 index 0000000..ae8997d --- /dev/null +++ b/MgaRepo/commands/rpmlog.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# +# This program will convert the output of "svn log" to be suitable +# for usage in an rpm %changelog session. +# +from MgaRepo import Error, layout, disable_mirror +from MgaRepo.command import * +from MgaRepo.svn import SVN +from MgaRepo.log import get_changelog, split_spec_changelog +from cStringIO import StringIO +import getopt +import os +import sys + +HELP = """\ +Usage: mgarepo rpmlog [OPTIONS] REPPKGDIRURL + +Prints the RPM changelog of a given package. + +Options: + -r REV Collect logs from given revision to revision 0 + -n NUM Output only last NUM entries + -T FILE %changelog template file to be used + -o Append old package changelog + -p Append changelog found in .spec file + -s Sort changelog entries, even from the old log + -M Do not use the mirror (use the main repository) + -h Show this message + +Examples: + mgarepo rpmlog python + mgarepo rpmlog http://svn.mandriva.com/svn/packages/cooker/python +""" + +def parse_options(): + parser = OptionParser(help=HELP) + parser.add_option("-r", dest="revision") + parser.add_option("-n", dest="size", type="int") + parser.add_option("-T", "--template", dest="template", type="string") + parser.add_option("-o", dest="oldlog", default=False, + action="store_true") + parser.add_option("-p", dest="usespec", default=False, + action="store_true") + parser.add_option("-s", dest="sort", default=False, + action="store_true") + parser.add_option("-M", "--no-mirror", action="callback", + callback=disable_mirror) + opts, args = parser.parse_args() + if len(args) != 1: + raise Error, "invalid arguments" + opts.pkgdirurl = layout.package_url(args[0]) + return opts + +def rpmlog(pkgdirurl, revision, size, template, oldlog, usespec, sort): + another = None + if usespec: + svn = SVN() + specurl = layout.package_spec_url(pkgdirurl) + rawspec = svn.cat(specurl, rev=revision) + spec, another = split_spec_changelog(StringIO(rawspec)) + newlog = get_changelog(pkgdirurl, another=another, rev=revision, + size=size, sort=sort, template=template, oldlog=oldlog) + sys.stdout.writelines(newlog) + +def main(): + do_command(parse_options, rpmlog) + +# vim:sw=4:ts=4:et |