~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
2
# Copyright 2004-2005 Canonical Ltd.  All rights reserved.
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
3
# This module uses relative imports.
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
4
# pylint: disable-msg=W0403
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
5
5883.1.2 by Curtis Hovey
Merge from RF. Resolved conflicts in confs.
6
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
7
"""
8
Gina launcher script. Handles commandline options and makes the proper
9
calls to the other classes and instances.
10
11
The callstack is essentially:
12
    main -> run_gina 
13
                -> import_sourcepackages -> do_one_sourcepackage
14
                -> import_binarypackages -> do_one_binarypackage
15
"""
16
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
17
18
__metaclass__ = type
19
20
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
21
# Set to non-zero if you'd like to be warned every so often
22
COUNTDOWN = 0
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
23
24
import _pythonpath
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
25
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
26
from optparse import OptionParser
2670 by Canonical.com Patch Queue Manager
[trivial] Gina love
27
import os
5821.10.4 by Celso Providelo
fixing gina tests.
28
import psycopg2
2670 by Canonical.com Patch Queue Manager
[trivial] Gina love
29
import sys
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
30
import time
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
31
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
32
from zope.component import getUtility
33
3691.348.2 by kiko
Only catch LockAlreadyAcquired, which is really what we are checking for in scripts.
34
from contrib.glock import GlobalLock, LockAlreadyAcquired
3691.348.1 by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests.
35
6555.7.35 by Stuart Bishop
Fix gina tests
36
from canonical import lp
5028.1.6 by David Murphy
Removed PackagePublishingPriority, PackagePublishingStatus, PackagePublishingPocket, PackageUploadStatus, & PackageUploadCustomFormat from canonical.lp.dbschema.
37
from canonical.lp import initZopeless
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
38
from canonical.config import config
5028.1.6 by David Murphy
Removed PackagePublishingPriority, PackagePublishingStatus, PackagePublishingPocket, PackageUploadStatus, & PackageUploadCustomFormat from canonical.lp.dbschema.
39
from canonical.launchpad.interfaces import (
40
    IComponentSet, PackagePublishingPocket)
3691.164.16 by Guilherme Salgado
Lots of fixes and tests suggested by Bjorn
41
from canonical.launchpad.scripts import (
42
    execute_zcml_for_scripts, logger_options, log)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
43
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
44
from canonical.launchpad.scripts.gina import ExecutionError
1716.1.213 by Christian Reis
Fix scripts/gina.py to cope with katie.py rename
45
from canonical.launchpad.scripts.gina.katie import Katie
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
46
from canonical.launchpad.scripts.gina.archive import (ArchiveComponentItems,
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
47
    PackagesMap, MangledArchiveError)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
48
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
49
from canonical.launchpad.scripts.gina.handlers import (ImporterHandler,
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
50
    MultiplePackageReleaseError, NoSourcePackageError, DataSetupError)
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
51
from canonical.launchpad.scripts.gina.packages import (SourcePackageData,
1716.1.229 by Christian Reis
Move encoding of person's displayname into packages. Add tests for version numbers for gcc-defaults, clean up code slightly. What remains: validating ensureBuild and _getBinary, and testing with multiple components, pockets and architectures
52
    BinaryPackageData, MissingRequiredArguments, DisplayNameDecodingError,
1716.1.239 by Christian Reis
Really fix get_dsc_path to properly grok archive paths (and sanitize callsites and a certain place where we were generating a filename without the string pool attached to it). Remove PackageFileProcessError, which was dead anyway, and update for it. Rename anything that was an archive_root to the right term. All tests now pass
53
    PoolFileNotFound, InvalidVersionError)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
54
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
55
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
56
def _get_keyring(keyrings_root):
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
57
    # XXX kiko 2005-10-23: untested
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
58
    keyrings = ""
59
    for keyring in os.listdir(keyrings_root):
60
        path = os.path.join(keyrings_root, keyring)
61
        keyrings += " --keyring=%s" % path
62
    if not keyrings:
63
        raise AttributeError("Keyrings not found in ./keyrings/")
64
    return keyrings
65
66
67
def main():
3691.164.16 by Guilherme Salgado
Lots of fixes and tests suggested by Bjorn
68
    execute_zcml_for_scripts()
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
69
    parser = OptionParser("Usage: %prog [OPTIONS] [target ...]")
70
    logger_options(parser)
71
72
    parser.add_option("-n", "--dry-run", action="store_true",
73
            help="Don't commit changes to the database",
74
            dest="dry_run", default=False)
75
76
    parser.add_option("-a", "--all", action="store_true",
77
            help="Run all sections defined in launchpad.conf (in order)",
78
            dest="all", default=False)
79
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
80
    parser.add_option( "-l", "--lockfile",
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
81
            default="/var/lock/launchpad-gina.lock",
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
82
            help="Ensure only one process is running that locks LOCKFILE",
83
            metavar="LOCKFILE"
84
            )
85
86
    (options, targets) = parser.parse_args()
87
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
88
    possible_targets = [target.category_and_section_names[1]
89
                        for target in config.getByCategory('gina_target')]
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
90
91
    if options.all:
92
        targets = possible_targets[:]
93
    else:
94
        if not targets:
95
            parser.error("Must specify at least one target to run, or --all")
96
97
        for target in targets:
98
            if target not in possible_targets:
99
                parser.error("No Gina target %s in config file" % target)
100
3691.348.1 by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests.
101
    lockfile = GlobalLock(options.lockfile, logger=log)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
102
    try:
103
        lockfile.acquire()
3691.348.2 by kiko
Only catch LockAlreadyAcquired, which is really what we are checking for in scripts.
104
    except LockAlreadyAcquired:
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
105
        log.info('Lockfile %s already locked. Exiting.', options.lockfile)
106
        sys.exit(1)
107
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
108
    ztm = initZopeless(dbuser=config.gina.dbuser)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
109
    try:
110
        for target in targets:
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
111
            target_section = config['gina_target.%s' % target]
112
            run_gina(options, ztm, target_section)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
113
    finally:
114
        lockfile.release()
115
116
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
117
def run_gina(options, ztm, target_section):
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
118
    package_root = target_section.root
119
    keyrings_root = target_section.keyrings
120
    distro = target_section.distro
5121.2.7 by Stuart Bishop
More required code changes
121
    # XXX kiko 2005-10-23: I honestly think having a separate distroseries
122
    # bit silly. Can't we construct this based on `distroseries-pocket`?
123
    pocket_distroseries = target_section.pocketrelease
124
    distroseries = target_section.distroseries
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
125
    components = [c.strip() for c in target_section.components.split(",")]
126
    archs = [a.strip() for a in target_section.architectures.split(",")]
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
127
    pocket = target_section.pocket
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
128
    component_override = target_section.componentoverride
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
129
    source_only = target_section.source_only
130
    spnames_only = target_section.sourcepackagenames_only
131
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
132
    dry_run = options.dry_run
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
133
6555.7.35 by Stuart Bishop
Fix gina tests
134
    LPDB = lp.dbname
135
    LPDB_HOST = lp.dbhost
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
136
    LPDB_USER = config.gina.dbuser
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
137
    KTDB = target_section.katie_dbname
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
138
139
    LIBRHOST = config.librarian.upload_host
140
    LIBRPORT = config.librarian.upload_port
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
141
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
142
    log.info("")
5121.2.7 by Stuart Bishop
More required code changes
143
    log.info("=== Processing %s/%s/%s ===" % (distro, distroseries, pocket))
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
144
    log.debug("Packages read from: %s" % package_root)
145
    log.debug("Keyrings read from: %s" % keyrings_root)
146
    log.info("Components to import: %s" % ", ".join(components))
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
147
    if component_override is not None:
148
        log.info("Override components to: %s" % component_override)
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
149
    log.info("Architectures to import: %s" % ", ".join(archs))
150
    log.debug("Launchpad database: %s" % LPDB)
151
    log.debug("Launchpad database host: %s" % LPDB_HOST)
152
    log.debug("Launchpad database user: %s" % LPDB_USER)
153
    log.info("Katie database: %s" % KTDB)
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
154
    log.info("SourcePackage Only: %s" % source_only)
155
    log.info("SourcePackageName Only: %s" % spnames_only)
156
    log.debug("Librarian: %s:%s" % (LIBRHOST, LIBRPORT))
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
157
    log.info("Dry run: %s" % (dry_run))
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
158
    log.info("")
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
159
5028.1.6 by David Murphy
Removed PackagePublishingPriority, PackagePublishingStatus, PackagePublishingPocket, PackageUploadStatus, & PackageUploadCustomFormat from canonical.lp.dbschema.
160
    if hasattr(PackagePublishingPocket, pocket.upper()):
161
        pocket = getattr(PackagePublishingPocket, pocket.upper())
1716.1.232 by Christian Reis
Set up an initial (empty) multiple-arch-component-pocket run, with a basic test. Also fix up my librarian query to not use selectOneBy. But I had to comment out the check, because staging and production are already polluted :-(
162
    else:
163
        log.error("Could not find a pocket schema for %s" % pocket)
164
        sys.exit(1)
165
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
166
    if component_override:
4753.4.2 by Julian Edwards
PEP-8 drives me NUTS.
167
        valid_components = [
168
            component.name for component in getUtility(IComponentSet)]
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
169
        if component_override not in valid_components:
170
            log.error("Could not find component %s" % component_override)
171
            sys.exit(1)
172
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
173
    kdb = None
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
174
    keyrings = None
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
175
    if KTDB:
5121.2.7 by Stuart Bishop
More required code changes
176
        kdb = Katie(KTDB, distroseries, dry_run)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
177
        keyrings = _get_keyring(keyrings_root)
178
179
    try:
6527.11.1 by Celso Providelo
go, gina, go ...
180
        arch_component_items = ArchiveComponentItems(
181
            package_root, pocket_distroseries, components, archs,
182
            source_only)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
183
    except MangledArchiveError:
5855.5.1 by Curtis Hovey
Migrate db configuration to lazr.config.
184
        log.exception(
185
            "Failed to analyze archive for %s" % pocket_distroseries)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
186
        sys.exit(1)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
187
188
    packages_map = PackagesMap(arch_component_items)
5121.2.7 by Stuart Bishop
More required code changes
189
    importer_handler = ImporterHandler(ztm, distro, distroseries,
2501 by Canonical.com Patch Queue Manager
Bring failed binary imports down from 472 to 6 by finding sources more aggressively. r=spiv
190
                                       dry_run, kdb, package_root, keyrings,
4753.4.1 by Julian Edwards
Allow gina to override the component (and thus the archive) when importing
191
                                       pocket, component_override)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
192
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
193
    if spnames_only:
194
        log.info('Running in SourcePackageName-only mode...')
195
        for source in packages_map.src_map.itervalues():
196
            log.info('Ensuring %s name' % source['Package'])
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
197
            importer_handler.ensure_sourcepackagename(source['Package'])
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
198
        log.info('done')
7224.3.1 by Celso Providelo
fixing gina batching mode.
199
        return
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
200
201
    import_sourcepackages(packages_map, kdb, package_root, keyrings,
202
                          importer_handler)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
203
    importer_handler.commit()
204
205
    if source_only:
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
206
        log.info('Source only mode... done')
7224.3.1 by Celso Providelo
fixing gina batching mode.
207
        return
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
208
6527.11.1 by Celso Providelo
go, gina, go ...
209
    for archtag in archs:
210
        try:
211
            importer_handler.ensure_archinfo(archtag)
212
        except DataSetupError:
213
            log.exception("Database setup required for run on %s" % archtag)
214
            sys.exit(1)
215
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
216
    import_binarypackages(packages_map, kdb, package_root, keyrings,
217
                          importer_handler)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
218
    importer_handler.commit()
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
219
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
220
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
221
def import_sourcepackages(packages_map, kdb, package_root,
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
222
                          keyrings, importer_handler):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
223
    # Goes over src_map importing the sourcepackages packages.
224
    count = 0
225
    npacks = len(packages_map.src_map)
1716.1.217 by Christian Reis
Fix up remaining SQL issues (manually tested by hacking up gina.py, improve gina.py logging and error output, some added language consistency
226
    log.info('%i Source Packages to be imported' % npacks)
1716.1.211 by Christian Reis
De-lintify and add better exceptions to gina.py
227
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
228
    for source in sorted(packages_map.src_map.values(),
229
                         key=lambda x: x.get("Package")):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
230
        count += 1
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
231
        package_name = source.get("Package", "unknown")
232
        try:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
233
            try:
234
                do_one_sourcepackage(source, kdb, package_root, keyrings,
235
                                     importer_handler)
5821.10.4 by Celso Providelo
fixing gina tests.
236
            except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
237
                log.exception("Database error: unable to create "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
238
                              "SourcePackage for %s. Retrying once.."
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
239
                              % package_name)
240
                importer_handler.abort()
241
                time.sleep(15)
242
                do_one_sourcepackage(source, kdb, package_root, keyrings,
243
                                     importer_handler)
1716.1.229 by Christian Reis
Move encoding of person's displayname into packages. Add tests for version numbers for gcc-defaults, clean up code slightly. What remains: validating ensureBuild and _getBinary, and testing with multiple components, pockets and architectures
244
        except (InvalidVersionError, MissingRequiredArguments,
245
                DisplayNameDecodingError):
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
246
            log.exception("Unable to create SourcePackageData for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
247
                          package_name)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
248
            continue
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
249
        except (PoolFileNotFound, ExecutionError):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
250
            # Problems with katie db stuff of opening files
251
            log.exception("Error processing package files for %s" %
252
                          package_name)
253
            continue
5821.10.4 by Celso Providelo
fixing gina tests.
254
        except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
255
            log.exception("Database errors made me give up: unable to create "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
256
                          "SourcePackage for %s" % package_name)
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
257
            importer_handler.abort()
258
            continue
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
259
        except MultiplePackageReleaseError:
260
            log.exception("Database duplication processing %s" %
261
                          package_name)
262
            continue
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
263
264
        if COUNTDOWN and count % COUNTDOWN == 0:
265
            log.warn('%i/%i sourcepackages processed' % (count, npacks))
1716.1.217 by Christian Reis
Fix up remaining SQL issues (manually tested by hacking up gina.py, improve gina.py logging and error output, some added language consistency
266
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
267
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
268
def do_one_sourcepackage(source, kdb, package_root, keyrings,
269
                         importer_handler):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
270
    source_data = SourcePackageData(**source)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
271
    if importer_handler.preimport_sourcecheck(source_data):
272
        # Don't bother reading package information if the source package
273
        # already exists in the database
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
274
        log.info('%s already exists in the archive' % source_data.package)
275
        return
276
    source_data.process_package(kdb, package_root, keyrings)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
277
    source_data.ensure_complete(kdb)
278
    importer_handler.import_sourcepackage(source_data)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
279
    importer_handler.commit()
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
280
281
1716.1.223 by Christian Reis
Checkpoint gina: the sourcepackage side is implemented and well-tested, over two releases, and over two runs of gina
282
def import_binarypackages(packages_map, kdb, package_root, keyrings,
283
                          importer_handler):
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
284
    nosource = []
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
285
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
286
    # Run over all the architectures we have
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
287
    for archtag in packages_map.bin_map.keys():
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
288
        count = 0
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
289
        npacks = len(packages_map.bin_map[archtag])
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
290
        log.info('%i Binary Packages to be imported for %s' %
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
291
                 (npacks, archtag))
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
292
        # Go over binarypackages importing them for this architecture
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
293
        for binary in sorted(packages_map.bin_map[archtag].values(),
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
294
                             key=lambda x: x.get("Package")):
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
295
            count += 1
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
296
            package_name = binary.get("Package", "unknown")
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
297
            try:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
298
                try:
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
299
                    do_one_binarypackage(binary, archtag, kdb, package_root,
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
300
                                         keyrings, importer_handler)
5821.10.4 by Celso Providelo
fixing gina tests.
301
                except psycopg2.Error:
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
302
                    log.exception("Database errors when importing a "
303
                                  "BinaryPackage for %s. Retrying once.."
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
304
                                  % package_name)
305
                    importer_handler.abort()
306
                    time.sleep(15)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
307
                    do_one_binarypackage(binary, archtag, kdb, package_root,
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
308
                                         keyrings, importer_handler)
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
309
            except (InvalidVersionError, MissingRequiredArguments):
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
310
                log.exception("Unable to create BinaryPackageData for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
311
                              package_name)
312
                continue
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
313
            except (PoolFileNotFound, ExecutionError):
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
314
                # Problems with katie db stuff of opening files
315
                log.exception("Error processing package files for %s" %
316
                              package_name)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
317
                continue
1716.1.226 by Christian Reis
Moving verification and parsing code over to packages.py, simplifying handlers.py. Also improved the way check_not_in_librarian communicates failures. Added some important XXXs that are a consequence of the use of Teri on the archive. All tests still pass
318
            except MultiplePackageReleaseError:
319
                log.exception("Database duplication processing %s" %
320
                              package_name)
321
                continue
5821.10.4 by Celso Providelo
fixing gina tests.
322
            except psycopg2.Error:
1716.1.255 by Christian Reis
Cope with intermittent postgres isolation errors when importing packages (caused one package to fail in breezy, growl). Also stop lowercasing package and version numbers, since they should be compared case-sensitively (right?)
323
                log.exception("Database errors made me give up: unable to "
1716.2.14 by Christian Reis
Cope better with source packages whose DSC refers to files not in the pool
324
                              "create BinaryPackage for %s" % package_name)
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
325
                importer_handler.abort()
326
                continue
327
            except NoSourcePackageError:
5883.1.1 by Curtis Hovey
Added gina_target and buildsequence_job to lazr schema.
328
                log.exception("Failed to create Binary Package for %s" %
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
329
                              package_name)
330
                nosource.append(binary)
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
331
                continue
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
332
333
            if COUNTDOWN and count % COUNTDOWN == 0:
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
334
                # XXX kiko 2005-10-23: untested
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
335
                log.warn('%i/%i binary packages processed' % (count, npacks))
336
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
337
        if nosource:
4664.1.1 by Curtis Hovey
Normalized comments for bug 3732.
338
            # XXX kiko 2005-10-23: untested
1716.1.241 by Christian Reis
Add support for locating license files that are prefixed with the binary package name (and add a package to test the feature with). Clean up changelog handling of package and version. Deal with the fact that selectOne* can raise an exception when encountering database corruption. Explicitly set SourcePackageRelease.format, and reorder the SPR attributes to check we are indeed sending in everything we should. Added a test for an invalid version. Refactor dsc and license handling so we don't do any more than we should in each of the calls to read_*.
339
            log.warn('%i source packages not found' % len(nosource))
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
340
            for pkg in nosource:
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
341
                log.warn(pkg)
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
342
343
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
344
def do_one_binarypackage(binary, archtag, kdb, package_root, keyrings,
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
345
                         importer_handler):
1716.1.219 by Christian Reis
One more step in the direction of gina testing: test the processing of a second distro release. Verify that no duplicate source packages are added. Check for mangled tagfile stanzas. Reorder classes in handlers.py to be more naturally sequenced. Centralize error checking in gina.py so that do_one_*package is what's tested for error raising. Add support files for testing Breezy. More test clauses. I'd estimate I'm 30% done
346
    binary_data = BinaryPackageData(**binary)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
347
    if importer_handler.preimport_binarycheck(archtag, binary_data):
1716.1.227 by Christian Reis
Order packages by name when processing them, to obtain stable test output. Add a host of binary packages to hoary to ensure I have enough to test with. Check before importing binary packages that they already exist (as we do for source packages) to optimize processing time and output. Reorganize tests to be a bit more self-contained.
348
        log.info('%s already exists in the archive' % binary_data.package)
349
        return
1716.1.225 by Christian Reis
First part of really testing binary packages. Add 14 binary package entries for hoary main. Change the librarian check to be a function so it can be unified between sources and binaries. Bulletproof the test to run under weird filesystem conditions. Make the config a bit less daft. Deal better with corrupt packages files (and entries). Fetch the licence for binary packages properly (the hard way). Clean up the creation of BinaryPackageData. Removed the catch-all except:s which only make my life harder (for now, at least).
350
    binary_data.process_package(kdb, package_root, keyrings)
1716.2.6 by Christian Reis
Move the check for processor to the start of run_gina so we ensure that all processors required are already preseeded in the database before doing /anything/. Clarifies issue in production where a processor for ia64 was missing
351
    importer_handler.import_binarypackage(archtag, binary_data)
1964 by Canonical.com Patch Queue Manager
[r=spiv] full gina refactor
352
    importer_handler.commit()
353
354
355
if __name__ == "__main__":
1716.1.218 by Christian Reis
Add more package data and update the gina doctest. Seriously whack packages.py and gina.py, with some trickle into handlers.py. The creation of source packages for Hoary is now minimally tested, with most important codepaths and error conditions being checked. Did work on validation and ensuring the source and binary package data we have is consistent. Added a ton of packages to the gina test archive so we can use them in our tests -- welcome them into rocketfuel :-)
356
    main()
2168 by Canonical.com Patch Queue Manager
[r=BjornT] More gina improvements.
357