def METHOD_NAME(v, opt, update_packages):
    v.do_downloads()
    clx = changelogs_xml()
    for xp in update_packages:
        try:
            f = v.get_downloaded_pkg(xp.name)
            log = extract_pkg_changelog(f)
        except ChangelogNeedsDependency as e:
            v.mark_pkg_download(e.pkgname)
            v.do_downloads()
            extra = v.get_downloaded_pkg(e.pkgname)
            log = extract_pkg_changelog(f, extra)
        clx.add_pkg_changelog(xp, log)
    clx.write(opt.changelogs)