[yum-commits] 4 commits - docs/repodiff.1 repodiff.py
James Antill
james at osuosl.org
Tue Nov 8 21:07:24 UTC 2011
docs/repodiff.1 | 12 +++-
repodiff.py | 152 +++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 117 insertions(+), 47 deletions(-)
New commits:
commit 4d03ffee567a11862dbb3ecc5faed77b6f08c6c5
Author: James Antill <james at and.org>
Date: Tue Nov 8 16:06:31 2011 -0500
Add mirror: and --simple and --downgrade to repodiff docs.
diff --git a/docs/repodiff.1 b/docs/repodiff.1
index fdfa88b..ef2a373 100644
--- a/docs/repodiff.1
+++ b/docs/repodiff.1
@@ -11,9 +11,11 @@ repositories. \fBNote\fP that by default only source packages are compared.
.PP
.SH "GENERAL OPTIONS"
.IP "\fB\-\-old, -o\fP"
-Add a repo. as an old repo.
+Add a repo. as an old repo. Note that if you prefix the url with "mirror:" then
+the following url is treated as a mirror and not a baseurl.
.IP "\fB\-\-new, -n\fP"
-Add a repo. as an new repo.
+Add a repo. as an new repo. Note that if you prefix the url with "mirror:" then
+the following url is treated as a mirror and not a baseurl.
.IP "\fB\-\-archlist, -a\fP"
Add architectures to change the default from just comparing source packages.
Note that if you want the same as a native
@@ -25,6 +27,10 @@ Output additional data about the size of the changes.
.IP "\fB\-\-compare-arch\fP"
Normally packages are just compared based on their name, this flag makes the
comparison also use the arch. So foo.i386 and foo.x86_64 are different.
+.IP "\fB\-\-simple\fP"
+Output a simple one line message for modified packages.
+.IP "\fB\-\-downgrade\fP"
+Split the data for modified packages between upgraded and downgraded packages.
.SH "EXAMPLES"
.IP "Compare source pkgs in two local repos:"
\fBrepodiff --old=/tmp/repo-old --new=/tmp/repo-new\fP
@@ -32,6 +38,8 @@ comparison also use the arch. So foo.i386 and foo.x86_64 are different.
\fBrepodiff -a x86_64 --old=http://example.com/repo1-old --old=/tmp/repo-old --new=http://example.com/repo1-new --new=/tmp/repo-new\fP
.IP "Compare x86_64 compat. binary pkgs, but also compare arch:"
\fBrepodiff -a x86_64 --compare-arch --old=http://example.com/repo1-old --old=/tmp/repo-old --new=http://example.com/repo1-new --new=/tmp/repo-new\fP
+.IP "Compare two releases of Fedora (15 => 16):"
+\fBrepodiff --old='mirror:https://mirrors.fedoraproject.org/metalink?repo=fedora-source-15&arch=i386' --new='mirror:https://mirrors.fedoraproject.org/metalink?repo=fedora-source-16&arch=i386' --size --simple --downgrade\fP
.PP
.SH "SEE ALSO"
commit 0a3072dc3122df5557bc00bdb64a5b9a6681d929
Author: James Antill <james at and.org>
Date: Tue Nov 8 15:58:48 2011 -0500
Add downgrade option. Add format_number() output for size.
diff --git a/repodiff.py b/repodiff.py
index 6652dd1..51b3132 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -22,8 +22,16 @@ import locale
import rpmUtils.arch
from yum.i18n import to_unicode
+from urlgrabber.progress import format_number
+
from optparse import OptionParser
+def bkMG(num):
+ ''' Call format_number() but deals with negative numbers. '''
+ if num >= 0:
+ return format_number(num)
+ return '-' + format_number(-num)
+
class DiffYum(yum.YumBase):
def __init__(self):
yum.YumBase.__init__(self)
@@ -160,6 +168,8 @@ def parseArgs(args):
help="When comparing binary repos. also compare the arch of packages, to see if they are different")
parser.add_option("-s", "--size", default=False, action='store_true',
help="Output size changes for any new->old packages")
+ parser.add_option("--downgrade", default=False, action='store_true',
+ help="Output upgrade/downgrade separately")
parser.add_option("--simple", default=False, action='store_true',
help="output simple format")
(opts, argsleft) = parser.parse_args()
@@ -265,8 +275,11 @@ def main(args):
total_sizechange = 0
add_sizechange = 0
remove_sizechange = 0
+ mod_sizechange = 0
up_sizechange = 0
down_sizechange = 0
+ upgraded_pkgs = 0
+ downgraded_pkgs = 0
if ygh.add:
for pkg in sorted(ygh.add):
if opts.compare_arch:
@@ -289,11 +302,30 @@ def main(args):
if ygh.modified:
print '\nUpdated Packages:\n'
for (pkg, oldpkg) in sorted(ygh.modified):
+ if opts.downgrade and pkg.verLT(oldpkg):
+ continue
+
+ upgraded_pkgs += 1
if opts.size:
sizechange = int(pkg.size) - int(oldpkg.size)
- total_sizechange += sizechange
- _out_mod(opts, olgpkg, pkd)
-
+ if opts.downgrade:
+ up_sizechange += sizechange
+ else:
+ mod_sizechange += sizechange
+ _out_mod(opts, oldpkg, pkg)
+
+ if opts.downgrade:
+ print '\nDowngraded Packages:\n'
+ for (pkg, oldpkg) in sorted(ygh.modified):
+ if pkg.verGT(oldpkg):
+ continue
+
+ downgraded_pkgs += 1
+ if opts.size:
+ sizechange = int(pkg.size) - int(oldpkg.size)
+ down_sizechange += sizechange
+ _out_mod(opts, oldpkg, pkg)
+
if (not ygh.add and not ygh.remove and not ygh.modified and
not my.pkgSack.searchNevra(arch='src')):
@@ -302,11 +334,33 @@ def main(args):
print '\nSummary:'
print 'Added Packages: %s' % len(ygh.add)
print 'Removed Packages: %s' % len(ygh.remove)
- print 'Modified Packages: %s' % len(ygh.modified)
+ if not opts.downgrade:
+ print 'Upgraded Packages: %s' % upgraded_pkgs
+ else:
+ print 'Downgraded Packages: %s' % downgraded_pkgs
if opts.size:
- print 'Size of added packages: %s' % add_sizechange
- print 'Size change of modified packages: %s' % total_sizechange
- print 'Size of removed packages: %s' % remove_sizechange
+ print 'Size of added packages: %s (%s)' % (add_sizechange,
+ bkMG(add_sizechange))
+
+ if not opts.downgrade:
+ msg = 'Size change of modified packages: %s (%s)'
+ print msg % (mod_sizechange, bkMG(mod_sizechange))
+
+ total_sizechange = add_sizechange +mod_sizechange -remove_sizechange
+ else:
+ msg = 'Size change of upgraded packages: %s (%s)'
+ print msg % (up_sizechange, bkMG(up_sizechange))
+ msg = 'Size change of downgraded packages: %s (%s)'
+ print msg % (down_sizechange, bkMG(down_sizechange))
+
+ total_sizechange = (add_sizechange +
+ up_sizechange + down_sizechange -
+ remove_sizechange)
+
+ msg = 'Size of removed packages: %s (%s)'
+ print msg % (remove_sizechange, bkMG(remove_sizechange))
+ msg = 'Size change: %s (%s)'
+ print msg % (total_sizechange, bkMG(total_sizechange))
if __name__ == "__main__":
commit 66e34bef3cc6dd23dba9862227924e291c01f891
Author: James Antill <james at and.org>
Date: Tue Nov 8 15:36:25 2011 -0500
Move output of modified packages to a function.
diff --git a/repodiff.py b/repodiff.py
index daa457b..6652dd1 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -180,6 +180,47 @@ def parseArgs(args):
return opts
+def _out_mod(opts, oldpkg, pkg):
+ if opts.simple:
+ if opts.compare_arch:
+ msg = "%s: %s -> %s" % (pkg.name, oldpkg, pkg)
+ else:
+ msg = "%s: %s-%s-%s -> %s-%s-%s" % (pkg.name, oldpkg.name,
+ oldpkg.ver, oldpkg.rel,
+ pkg.name, pkg.ver,
+ pkg.rel)
+ else:
+ if opts.compare_arch:
+ msg = "%s" % pkg
+ else:
+ msg = "%s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
+ dashes = "-" * len(msg)
+ msg += "\n%s\n" % dashes
+ # get newest clog time from the oldpkg
+ # for any newer clog in pkg
+ # print it
+ oldlogs = oldpkg.changelog
+ if len(oldlogs):
+ # Don't sort as that can screw the order up when time is the
+ # same.
+ oldtime = oldlogs[0][0]
+ oldauth = oldlogs[0][1]
+ oldcontent = oldlogs[0][2]
+ for (t, author, content) in pkg.changelog:
+ if t < oldtime:
+ break
+ if ((t == oldtime) and (author == oldauth) and
+ (content == oldcontent)):
+ break
+ tm = datetime.date.fromtimestamp(int(t))
+ tm = tm.strftime("%a %b %d %Y")
+ msg += "* %s %s\n%s\n\n" % (tm, to_unicode(author),
+ to_unicode(content))
+ if opts.size:
+ msg += "\nSize Change: %s bytes\n" % sizechange
+
+ print msg
+
def main(args):
opts = parseArgs(args)
@@ -224,6 +265,8 @@ def main(args):
total_sizechange = 0
add_sizechange = 0
remove_sizechange = 0
+ up_sizechange = 0
+ down_sizechange = 0
if ygh.add:
for pkg in sorted(ygh.add):
if opts.compare_arch:
@@ -249,46 +292,8 @@ def main(args):
if opts.size:
sizechange = int(pkg.size) - int(oldpkg.size)
total_sizechange += sizechange
+ _out_mod(opts, olgpkg, pkd)
- if opts.simple:
- if opts.compare_arch:
- msg = "%s: %s -> %s" % (pkg.name, oldpkg, pkg)
- else:
- msg = "%s: %s-%s-%s -> %s-%s-%s" % (pkg.name, oldpkg.name,
- oldpkg.ver, oldpkg.rel,
- pkg.name, pkg.ver,
- pkg.rel)
- else:
- if opts.compare_arch:
- msg = "%s" % pkg
- else:
- msg = "%s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
- dashes = "-" * len(msg)
- msg += "\n%s\n" % dashes
- # get newest clog time from the oldpkg
- # for any newer clog in pkg
- # print it
- oldlogs = oldpkg.changelog
- if len(oldlogs):
- # Don't sort as that can screw the order up when time is the
- # same.
- oldtime = oldlogs[0][0]
- oldauth = oldlogs[0][1]
- oldcontent = oldlogs[0][2]
- for (t, author, content) in pkg.changelog:
- if t < oldtime:
- break
- if ((t == oldtime) and (author == oldauth) and
- (content == oldcontent)):
- break
- tm = datetime.date.fromtimestamp(int(t))
- tm = tm.strftime("%a %b %d %Y")
- msg += "* %s %s\n%s\n\n" % (tm, to_unicode(author),
- to_unicode(content))
- if opts.size:
- msg += "\nSize Change: %s bytes\n" % sizechange
-
- print msg
if (not ygh.add and not ygh.remove and not ygh.modified and
not my.pkgSack.searchNevra(arch='src')):
commit 6c16e5deb222c69817c2f94ee05896ae35ecdf14
Author: James Antill <james at and.org>
Date: Tue Nov 8 12:45:47 2011 -0500
Allow repodiff to use a mirror/metalink url.
diff --git a/repodiff.py b/repodiff.py
index 67c162e..daa457b 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -43,7 +43,10 @@ class DiffYum(yum.YumBase):
# make our new repo obj
newrepo = yum.yumRepo.YumRepository(repoid)
newrepo.name = repoid
- newrepo.baseurl = [baseurl]
+ if baseurl.startswith("mirror:"):
+ newrepo.mirrorlist = baseurl[len("mirror:"):]
+ else:
+ newrepo.baseurl = [baseurl]
newrepo.basecachedir = self.dy_basecachedir
newrepo.metadata_expire = 0
newrepo.timestamp_check = False
More information about the Yum-commits
mailing list