summaryrefslogtreecommitdiff
diff options
authorRobert C Jennings <robert.jennings@canonical.com>2017-06-26 11:33:59 -0500
committerRobert C Jennings <robert.jennings@canonical.com>2017-06-26 11:33:59 -0500
commit5bb73fa03c1016b75f2bd049a1e479a5974ffd1d (patch)
treee87b36789159ae1857abc45416316e0d1d367d8a
parentbbd27b8f732b712b77e05b8c4b7390990f4f52e8 (diff)
Name, spelling, and doc cleanup
bzr-revno: 18.2.15
-rwxr-xr-xmfdiff73
1 files changed, 45 insertions, 28 deletions
diff --git a/mfdiff b/mfdiff
index fcb7376..2d4908a 100755
--- a/mfdiff
+++ b/mfdiff
@@ -1,4 +1,11 @@
#!/usr/bin/env python
+"""
+Given two manifest files for a particular release/arch, find the
+packages which have been added, removed, and changed. Print the
+changelog entries for the changed packages limited to changes between
+the two versions.
+"""
+
# vi:ts=4 expandtab
#
# Copyright (C) 2010, 2017 Canonical Ltd.
@@ -37,14 +44,17 @@ except ImportError:
class MissingChangelogError(Exception):
+ "The Changelog file could not be found on the server"
pass
class ChangelogMissingVersion(Exception):
+ "The Changelog is missing starting and/or ending versions for the search"
pass
class UnknownSourceVersionError(Exception):
+ "The binary package did not have a source version listed"
pass
@@ -66,63 +76,64 @@ def get_bin2src(packages, cache):
return ret
-def getchangelog(src, ver, cache_d):
+def getchangelog(source, version, cache_d):
"""
- Download changelog for src/ver and returns path to that
+ Download changelog for source / version and returns path to that
- :param str src: Source package name
- :param str ver: Source package version
+ :param str source: Source package name
+ :param str version: Source package version
:param str cache_d: apt cache path
:raises MissingChangelogError: If changelog file could not be downloaded
:return: changelog file for source package & version
:rtype: str
"""
- cache_f = "%s/changelog.%s_%s" % (cache_d, src, ver)
+ cache_f = "%s/changelog.%s_%s" % (cache_d, source, version)
if os.path.isfile(cache_f):
- logging.debug("Using cached changelog for %s:%s", src, ver)
+ logging.debug("Using cached changelog for %s:%s", source, version)
return cache_f
furls = []
num_colon_m = re.compile("[0-9]:")
- cache_tmp = "%s/.changelog.%s_%s" % (cache_d, src, ver)
+ cache_tmp = "%s/.changelog.%s_%s" % (cache_d, source, version)
for pile in ("main", "universe", "multiverse", "restricted"):
- pre = src[0:1]
+ pre = source[0:1]
# packages starting with 'lib' are special
- if src.startswith("lib"):
- pre = src[0:4]
+ if source.startswith("lib"):
+ pre = source[0:4]
# packages with '1:' versions have different paths
# update-manager at version 1:0.134.11.
# would be at main/u/update-manager/update-manager_1:0.134.11
# instead at main/u/update-manager/update-manager_0.134.11/
- xver = ver
- if num_colon_m.match(ver):
- xver = ver[2:]
+ url_version = version
+ if num_colon_m.match(version):
+ url_version = version[2:]
# Changelog URL example http://changelogs.ubuntu.com/changelogs/\
# pool/main/h/hal/hal_0.5.5.1-1ubuntu2/changelog
clog_url = "%s/%s/%s/%s/%s_%s/changelog" % \
("http://changelogs.ubuntu.com/changelogs/pool",
- pile, pre, src, src, xver)
+ pile, pre, source, source, url_version)
changelog = requests.get(clog_url)
if changelog.status_code == 200:
- logging.debug("Found changelog for %s in %s", src, pile)
+ logging.debug("Found changelog for %s in %s", source, pile)
with open(cache_tmp, "w") as cache_file:
cache_file.write(
changelog.text.encode('ascii', 'replace').decode('ascii'))
os.rename(cache_tmp, cache_f)
return cache_f
else:
- logging.error("missing %s: %s", src, clog_url)
+ logging.error("missing %s: %s", source, clog_url)
furls.append(clog_url)
if os.path.exists(cache_tmp):
os.unlink(cache_tmp)
raise MissingChangelogError("Failed to find changelog for %s at version "
- "%s.\n tried %s" % (src, ver, ' '.join(furls)))
+ "%s.\n tried %s" % (source, version,
+ ' '.join(furls)))
def hashmffile(filename):
@@ -222,14 +233,14 @@ def render_block(block):
for x in block.changes() if x])
-def print_blocks(blist):
+def print_blocks(block_list):
"""
- Print a Changelog blocklist
+ Print a Changelog block list
- :param list blist: List of :class:`debian.changelog.ChangeBlock`
+ :param list block_list: List of :class:`debian.changelog.ChangeBlock`
"""
- for block in blist:
+ for block in block_list:
print(render_block(block))
@@ -238,7 +249,7 @@ def kernel_fixups(manifest_from, manifest_to):
Fix up kernels so the pkg names match
Kernel package names change from release to release so that they are
- coinstallable, but we need to find matching package names in the
+ co-installable, but we need to find matching package names in the
two manifests to provide a list of changes between the versions of the
package in each manifest.
This function will return an altered version of manifest_from with kernel
@@ -348,8 +359,8 @@ def filter_changelog(changelog_path, version_start, version_end):
The range of changelog entries returned will include all entries
after version_start up to, and including, version_end.
If either the starting or ending version are not found in the
- list of changelog entries the result will be incoplete and
- a non-empty erorr message is returned to indicate the issue.
+ list of changelog entries the result will be incomplete and
+ a non-empty error message is returned to indicate the issue.
:param str changelog_path: File name of the changelog to process
@@ -378,7 +389,7 @@ def filter_changelog(changelog_path, version_start, version_end):
if not end:
if error_msg:
# Start and end were not found, put a newline between their
- # erorr messages
+ # error messages
error_msg += '\n'
error_msg += "Missing ending version {} in {}. " \
"Changelog output truncated".format(
@@ -389,7 +400,7 @@ def filter_changelog(changelog_path, version_start, version_end):
def parse_args():
"""
- Parse commandline arguments
+ Parse command line arguments
:returns: options and remaining arguments from OptionParser.parse_args()
:rtype list:
@@ -432,6 +443,13 @@ def setup_logging(loglevel=0):
def main():
+ """
+ Given two manifest files for a particular release/arch, find the
+ packages which have been added, removed, and changed. Print the
+ changelog entries for the changed packages limited to changes between
+ the two versions.
+ """
+
options, (arch, release, mf_from, mf_to) = parse_args()
setup_logging(options.loglevel)
@@ -453,7 +471,6 @@ def main():
src2bins = map_source_to_binary(cache, changed)
- # XXX RCJ Factor this out of main
# Generate changelog data per unique source package
for src in src2bins:
srcs[src] = {"changelog_file": "", "changeblocks": []}
@@ -508,7 +525,7 @@ def main():
srcs[src]["changeblocks"], incomplete = filter_changelog(
changelog_path, srcver_from, srcver_to)
if incomplete:
- raise(ChangelogMissingVersion(incomplete))
+ raise ChangelogMissingVersion(incomplete)
except ChangelogMissingVersion as exp:
exceptions.append(exp)
continue