~ubuntu-on-ec2/vmbuilder/jenkins_kvm-add-azure-cc

« back to all changes in this revision

Viewing changes to should_build.py

  • Committer: Daniel Watkins
  • Date: 2016-08-01 15:30:35 UTC
  • mto: This revision was merged to the branch mainline in revision 756.
  • Revision ID: daniel.watkins@canonical.com-20160801153035-gojbwsuvv7ju3juc
Use dpkg for all should_build.py version comparisons

Prior to this commit, we were using dpkg to compare the archive version against
the manifest version.  However, we weren't using it to compare versions from
different archive pockets, which meant that once precise-updates' kernel ticked
up to 3.2.0.100.something, it started comparing lower than the release's
3.2.0.23.something, meaning automated promotion stopped happening.

This should address that issue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
logger.setLevel(logging.DEBUG)
50
50
 
51
51
 
 
52
def dpkg_version_greater_than(a, b):
 
53
    """
 
54
    Use dpkg to check if a > b
 
55
    """
 
56
    return_code = subprocess.call(
 
57
        ['dpkg', '--compare-versions', a, 'gt', b])
 
58
    return return_code == 0
 
59
 
 
60
 
52
61
def get_suite_version(suite):
53
62
    with open("/usr/share/distro-info/ubuntu.csv") as f:
54
63
        for line in f.readlines():
197
206
            if pkg_name and pkg_ver:
198
207
                count += 1
199
208
                found_ver = archive_content.get(pkg_name)
200
 
                if not found_ver or pkg_ver > found_ver:
 
209
                if not found_ver or dpkg_version_greater_than(pkg_ver,
 
210
                                                              found_ver):
201
211
                    archive_content[pkg_name] = pkg_ver
202
212
 
203
213
                (pkg_name, pkg_ver) = (None, None)
271
281
            if not aver or aver in iver:
272
282
                continue
273
283
 
274
 
            return_code = subprocess.call(
275
 
                ['dpkg', '--compare-versions', aver, 'gt', iver])
276
 
            aver_gt_iver = return_code == 0
277
 
            if aver_gt_iver:
 
284
            if dpkg_version_greater_than(aver, iver):
278
285
                diff_msgs.append("{}:{} (MAN: {}) (ARCHIVE: {})".format(
279
286
                                 ipkg, arch, iver, aver))
280
287
                diffs[arch][ipkg] = (manfst_v, arch_v)