~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to scripts/ftpmaster-tools/sync-source.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-03 05:05:39 UTC
  • mfrom: (14514.3.5 new-python-apt)
  • Revision ID: launchpad@pqm.canonical.com-20120103050539-y6ipuo5e9illcrsr
[r=benji][bug=551510] Port to new python-apt API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
            is_debian_changelog = 1
123
123
            if previous_version is None:
124
124
                previous_version = "9999:9999"
125
 
            elif apt_pkg.VersionCompare(
 
125
            elif apt_pkg.version_compare(
126
126
                match.group('version'), previous_version) > 0:
127
127
                urgency = max(
128
128
                    urgency_to_numeric(match.group('urgency')), urgency)
193
193
        raise LaunchpadScriptFailure(
194
194
            "debian/control not found in extracted source.")
195
195
    control_filehandle = open(control_filename)
196
 
    Control = apt_pkg.ParseTagFile(control_filehandle)
197
 
    while Control.Step():
198
 
        source = Control.Section.Find("Source")
199
 
        package = Control.Section.Find("Package")
200
 
        section = Control.Section.Find("Section")
201
 
        priority = Control.Section.Find("Priority")
202
 
        description = Control.Section.Find("Description")
 
196
    control = apt_pkg.TagFile(control_filehandle)
 
197
    for control_section in control:
 
198
        source = control_section.find("Source")
 
199
        package = control_section.find("Package")
 
200
        section = control_section.find("Section")
 
201
        priority = control_section.find("Priority")
 
202
        description = control_section.find("Description")
203
203
        if source is not None:
204
204
            if section is not None:
205
205
                source_section = section
399
399
        if pkg not in S:
400
400
            S[pkg] = [version, component]
401
401
        else:
402
 
            if apt_pkg.VersionCompare(S[pkg][0], version) < 0:
 
402
            if apt_pkg.version_compare(S[pkg][0], version) < 0:
403
403
                Log.warning(
404
404
                    "%s: skipping because %s is < %s" % (
405
405
                    pkg, version, S[pkg][0]))
435
435
    #             if pkg not in B:
436
436
    #                 B[pkg] = [version, component]
437
437
    #             else:
438
 
    #                 if apt_pkg.VersionCompare(B[pkg][0], version) < 0:
 
438
    #                 if apt_pkg.version_compare(B[pkg][0], version) < 0:
439
439
    #                     B[pkg] = [version, component]
440
440
 
441
441
    # XXX James Troup 2006-02-22: so... let's fall back on raw SQL
463
463
        if pkg not in B:
464
464
            B[pkg] = [version, component]
465
465
        else:
466
 
            if apt_pkg.VersionCompare(B[pkg][0], version) < 0:
 
466
            if apt_pkg.version_compare(B[pkg][0], version) < 0:
467
467
                B[pkg] = [version, component]
468
468
    return B
469
469
 
480
480
 
481
481
    filename = "%s%s%s_%s" % (origin["name"], suite, component, filename)
482
482
    sources_filehandle = open(filename)
483
 
    Sources = apt_pkg.ParseTagFile(sources_filehandle)
484
 
    while Sources.Step():
485
 
        pkg = Sources.Section.Find("Package")
486
 
        version = Sources.Section.Find("Version")
 
483
    sources = apt_pkg.TagFile(sources_filehandle)
 
484
    for sources_section in sources:
 
485
        pkg = sources_section.find("Package")
 
486
        version = sources_section.find("Version")
487
487
 
488
 
        if pkg in S and apt_pkg.VersionCompare(
 
488
        if pkg in S and apt_pkg.version_compare(
489
489
            S[pkg]["version"], version) > 0:
490
490
            continue
491
491
 
492
492
        S[pkg] = {}
493
493
        S[pkg]["version"] = version
494
494
 
495
 
        directory = Sources.Section.Find("Directory", "")
 
495
        directory = sources_section.find("Directory", "")
496
496
        files = {}
497
 
        for line in Sources.Section.Find("Files").split('\n'):
 
497
        for line in sources_section.find("Files").split('\n'):
498
498
            (md5sum, size, filename) = line.strip().split()
499
499
            files[filename] = {}
500
500
            files[filename]["md5sum"] = md5sum
578
578
 
579
579
        source_version = Sources[pkg]["version"]
580
580
        if (dest_version is None
581
 
                or apt_pkg.VersionCompare(dest_version, source_version) < 0):
 
581
                or apt_pkg.version_compare(dest_version, source_version) < 0):
582
582
            if (dest_version is not None
583
583
                    and (not Options.force
584
584
                        and dest_version.find("ubuntu") != -1)):