~launchpad-pqm/launchpad/devel

10637.3.1 by Guilherme Salgado
Use the default python version instead of a hard-coded version
1
#!/usr/bin/python -S
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
2
# pylint: disable-msg=W0403
3
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
4
# Copyright 2010 Canonical Ltd.  This software is licensed under the
5
# GNU Affero General Public License version 3 (see the file LICENSE).
6
#
7
# This code is based on William Grant's make-ubuntu-sane.py script, but
8
# reorganized to fit Launchpad coding guidelines, and extended.  The
9
# code is included under Canonical copyright with his permission
10
# (2010-02-24).
11
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
12
"""Clean up sample data so it will allow Soyuz to run locally.
13
14
DO NOT RUN ON PRODUCTION SYSTEMS.  This script deletes lots of
15
Ubuntu-related data.
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
16
17
This script creates a user "ppa-user" (email ppa-user@example.com,
18
password test) who is able to create PPAs.
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
19
"""
20
21
__metaclass__ = type
22
23
import _pythonpath
24
25
from optparse import OptionParser
26
import re
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
27
import os
28
import subprocess
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
29
import sys
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
30
from textwrap import dedent
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
31
import transaction
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
32
33
from zope.component import getUtility
34
from zope.event import notify
35
from zope.lifecycleevent import ObjectCreatedEvent
36
from zope.security.proxy import removeSecurityProxy
37
38
from storm.store import Store
39
40
from canonical.lp import initZopeless
41
13130.1.21 by Curtis Hovey
Fixed cronscript imports.
42
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
43
from canonical.launchpad.scripts import execute_zcml_for_scripts
44
from canonical.launchpad.scripts.logger import logger, logger_options
45
from canonical.launchpad.webapp.interfaces import (
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
46
    IStoreSelector, MAIN_STORE, MASTER_FLAVOR, SLAVE_FLAVOR)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
47
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
48
from lp.registry.interfaces.codeofconduct import ISignedCodeOfConductSet
10427.4.6 by Jeroen Vermeulen
Final polish. I hope.
49
from lp.registry.interfaces.person import IPersonSet
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
50
from lp.registry.interfaces.series import SeriesStatus
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
51
from lp.registry.model.codeofconduct import SignedCodeOfConduct
11411.6.11 by Julian Edwards
Move SourcePackageFormat
52
from lp.soyuz.enums import SourcePackageFormat
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
53
from lp.soyuz.interfaces.component import IComponentSet
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
54
from lp.soyuz.interfaces.processor import IProcessorFamilySet
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
55
from lp.soyuz.interfaces.section import ISectionSet
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
56
from lp.soyuz.interfaces.sourcepackageformat import (
11411.6.11 by Julian Edwards
Move SourcePackageFormat
57
    ISourcePackageFormatSelectionSet,
58
    )
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
59
from lp.soyuz.model.section import SectionSelection
60
from lp.soyuz.model.component import ComponentSelection
11258.1.13 by Steve Kowalik
Call InitialiseDistroSeries.initialise(), rather than .initialiseFromParent().
61
from lp.soyuz.scripts.initialise_distroseries import InitialiseDistroSeries
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
62
from lp.testing.factory import LaunchpadObjectFactory
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
63
64
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
65
user_name = 'ppa-user'
66
default_email = '%s@example.com' % user_name
67
68
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
69
class DoNotRunOnProduction(Exception):
70
    """Error: do not run this script on production (-like) systems."""
71
72
73
def get_max_id(store, table_name):
74
    """Find highest assigned id in given table."""
75
    max_id = store.execute("SELECT max(id) FROM %s" % table_name).get_one()
76
    if max_id is None:
77
        return None
78
    else:
79
        return max_id[0]
80
81
10373.3.11 by Jeroen Vermeulen
Merge devel
82
def get_store(flavor=MASTER_FLAVOR):
83
    """Obtain an ORM store."""
84
    return getUtility(IStoreSelector).get(MAIN_STORE, flavor)
85
86
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
87
def check_preconditions(options):
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
88
    """Try to ensure that it's safe to run.
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
89
90
    This script must not run on a production server, or anything
91
    remotely like it.
92
    """
10373.3.11 by Jeroen Vermeulen
Merge devel
93
    store = get_store(SLAVE_FLAVOR)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
94
95
    # Just a guess, but dev systems aren't likely to have ids this high
96
    # in this table.  Production data does.
97
    real_data = (get_max_id(store, "TranslationMessage") >= 1000000)
98
    if real_data and not options.force:
99
        raise DoNotRunOnProduction(
100
            "Refusing to delete Ubuntu data unless you --force me.")
101
102
    # For some configs it's just absolutely clear this script shouldn't
103
    # run.  Don't even accept --force there.
104
    forbidden_configs = re.compile('(edge|lpnet|production)')
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
105
    current_config = os.getenv('LPCONFIG', 'an unknown config')
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
106
    if forbidden_configs.match(current_config):
107
        raise DoNotRunOnProduction(
108
            "I won't delete Ubuntu data on %s and you can't --force me."
109
            % current_config)
110
111
112
def parse_args(arguments):
113
    """Parse command-line arguments.
114
115
    :return: (options, args, logger)
116
    """
117
    parser = OptionParser(
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
118
        description="Set up fresh Ubuntu series and %s identity." % user_name)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
119
    parser.add_option('-f', '--force', action='store_true', dest='force',
120
        help="DANGEROUS: run even if the database looks production-like.")
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
121
    parser.add_option('-e', '--email', action='store', dest='email',
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
122
        default=default_email,
123
        help=(
124
            "Email address to use for %s.  Should match your GPG key."
125
            % user_name))
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
126
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
127
    logger_options(parser)
128
129
    options, args = parser.parse_args(arguments)
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
130
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
131
    return options, args, logger(options)
132
133
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
134
def get_person_set():
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
135
    """Return `IPersonSet` utility."""
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
136
    return getUtility(IPersonSet)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
137
138
139
def retire_series(distribution):
140
    """Mark all `DistroSeries` for `distribution` as obsolete."""
141
    for series in distribution.series:
142
        series.status = SeriesStatus.OBSOLETE
143
144
145
def retire_active_publishing_histories(histories, requester):
146
    """Retire all active publishing histories in the given collection."""
147
    # Avoid circular import.
148
    from lp.soyuz.interfaces.publishing import active_publishing_status
149
    for history in histories(status=active_publishing_status):
150
        history.requestDeletion(
151
            requester, "Cleaned up because of missing Librarian files.")
152
153
154
def retire_distro_archives(distribution, culprit):
155
    """Retire all items in `distribution`'s archives."""
156
    for archive in distribution.all_distro_archives:
157
        retire_active_publishing_histories(
158
            archive.getPublishedSources, culprit)
159
        retire_active_publishing_histories(
160
            archive.getAllPublishedBinaries, culprit)
161
162
163
def retire_ppas(distribution):
164
    """Disable all PPAs for `distribution`."""
165
    for ppa in distribution.getAllPPAs():
166
        removeSecurityProxy(ppa).publish = False
167
168
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
169
def add_architecture(distroseries, architecture_name):
170
    """Add a DistroArchSeries for the given architecture to `distroseries`."""
171
    # Avoid circular import.
172
    from lp.soyuz.model.distroarchseries import DistroArchSeries
173
10373.3.11 by Jeroen Vermeulen
Merge devel
174
    store = get_store(MASTER_FLAVOR)
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
175
    family = getUtility(IProcessorFamilySet).getByName(architecture_name)
176
    archseries = DistroArchSeries(
177
        distroseries=distroseries, processorfamily=family,
178
        owner=distroseries.owner, official=True,
179
        architecturetag=architecture_name)
180
    store.add(archseries)
181
182
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
183
def create_sections(distroseries):
184
    """Set up some sections for `distroseries`."""
185
    section_names = (
186
        'admin', 'cli-mono', 'comm', 'database', 'devel', 'debug', 'doc',
187
        'editors', 'electronics', 'embedded', 'fonts', 'games', 'gnome',
188
        'graphics', 'gnu-r', 'gnustep', 'hamradio', 'haskell', 'httpd',
189
        'interpreters', 'java', 'kde', 'kernel', 'libs', 'libdevel', 'lisp',
190
        'localization', 'mail', 'math', 'misc', 'net', 'news', 'ocaml',
191
        'oldlibs', 'otherosfs', 'perl', 'php', 'python', 'ruby', 'science',
192
        'shells', 'sound', 'tex', 'text', 'utils', 'vcs', 'video', 'web',
193
        'x11', 'xfce', 'zope')
194
    store = Store.of(distroseries)
195
    for section_name in section_names:
196
        section = getUtility(ISectionSet).ensure(section_name)
197
        if section not in distroseries.sections:
198
            store.add(
199
                SectionSelection(distroseries=distroseries, section=section))
200
201
202
def create_components(distroseries, uploader):
203
    """Set up some components for `distroseries`."""
204
    component_names = ('main', 'restricted', 'universe', 'multiverse')
205
    store = Store.of(distroseries)
206
    main_archive = distroseries.distribution.main_archive
207
    for component_name in component_names:
208
        component = getUtility(IComponentSet).ensure(component_name)
209
        if component not in distroseries.components:
210
            store.add(
211
                ComponentSelection(
212
                    distroseries=distroseries, component=component))
213
        main_archive.newComponentUploader(uploader, component)
214
        main_archive.newQueueAdmin(uploader, component)
215
216
217
def create_series(parent, full_name, version, status):
218
    """Set up a `DistroSeries`."""
219
    distribution = parent.distribution
7675.1070.6 by Raphael Badin
Fixed tests.
220
    registrant = parent.owner
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
221
    name = full_name.split()[0].lower()
222
    title = "The " + full_name
223
    displayname = full_name.split()[0]
224
    new_series = distribution.newSeries(name=name, title=title,
225
        displayname=displayname, summary='Ubuntu %s is good.' % version,
226
        description='%s is awesome.' % version, version=version,
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
227
        previous_series=None, registrant=registrant)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
228
    new_series.status = status
229
    notify(ObjectCreatedEvent(new_series))
230
13117.2.15 by Raphael Badin
Fix test failure.
231
    ids = InitialiseDistroSeries(new_series, [parent.id])
11258.1.13 by Steve Kowalik
Call InitialiseDistroSeries.initialise(), rather than .initialiseFromParent().
232
    ids.initialise()
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
233
    return new_series
234
235
236
def create_sample_series(original_series, log):
237
    """Set up sample `DistroSeries`.
238
239
    :param original_series: The parent for the first new series to be
240
        created.  The second new series will have the first as a parent,
241
        and so on.
242
    """
243
    series_descriptions = [
244
        ('Dapper Drake', SeriesStatus.SUPPORTED, '6.06'),
245
        ('Edgy Eft', SeriesStatus.OBSOLETE, '6.10'),
246
        ('Feisty Fawn', SeriesStatus.OBSOLETE, '7.04'),
247
        ('Gutsy Gibbon', SeriesStatus.OBSOLETE, '7.10'),
248
        ('Hardy Heron', SeriesStatus.SUPPORTED, '8.04'),
12473.2.2 by William Grant
Add Natty and Onerous, and allow 3.0 formats in Karmic and later.
249
        ('Intrepid Ibex', SeriesStatus.OBSOLETE, '8.10'),
250
        ('Jaunty Jackalope', SeriesStatus.OBSOLETE, '9.04'),
11091.5.2 by Aaron Bentley
Update soyuz sample data
251
        ('Karmic Koala', SeriesStatus.SUPPORTED, '9.10'),
12473.2.2 by William Grant
Add Natty and Onerous, and allow 3.0 formats in Karmic and later.
252
        ('Lucid Lynx', SeriesStatus.SUPPORTED, '10.04'),
253
        ('Maverick Meerkat', SeriesStatus.CURRENT, '10.10'),
254
        ('Natty Narwhal', SeriesStatus.DEVELOPMENT, '11.04'),
255
        ('Onerous Ocelot', SeriesStatus.FUTURE, '11.10'),
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
256
        ]
257
258
    parent = original_series
259
    for full_name, status, version in series_descriptions:
260
        log.info('Creating %s...' % full_name)
261
        parent = create_series(parent, full_name, version, status)
12473.2.2 by William Grant
Add Natty and Onerous, and allow 3.0 formats in Karmic and later.
262
        # Karmic is the first series in which the 3.0 formats are
263
        # allowed. Subsequent series will inherit them.
264
        if version == '9.10':
265
            spfss = getUtility(ISourcePackageFormatSelectionSet)
266
            spfss.add(parent, SourcePackageFormat.FORMAT_3_0_QUILT)
267
            spfss.add(parent, SourcePackageFormat.FORMAT_3_0_NATIVE)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
268
269
12473.2.3 by William Grant
Add a component to grumpy to placate the publisher.
270
def add_series_component(series):
271
    """Permit a component in the given series."""
272
    component = getUtility(IComponentSet)['main']
273
    get_store(MASTER_FLAVOR).add(
274
        ComponentSelection(
275
            distroseries=series, component=component))
276
277
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
278
def clean_up(distribution, log):
279
    # First we eliminate all active publishings in the Ubuntu main archives.
280
    # None of the librarian files exist, so it kills the publisher.
281
282
    # Could use IPublishingSet.requestDeletion() on the published sources to
283
    # get rid of the binaries too, but I don't trust that there aren't
284
    # published binaries without corresponding sources.
285
286
    log.info("Deleting all items in official archives...")
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
287
    retire_distro_archives(distribution, get_person_set().getByName('name16'))
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
288
289
    # Disable publishing of all PPAs, as they probably have broken
290
    # publishings too.
291
    log.info("Disabling all PPAs...")
292
    retire_ppas(distribution)
293
294
    retire_series(distribution)
295
12473.2.3 by William Grant
Add a component to grumpy to placate the publisher.
296
    # grumpy has no components, which upsets the publisher.
297
    add_series_component(distribution['grumpy'])
298
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
299
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
300
def set_source_package_format(distroseries):
301
    """Register a series' source package format selection."""
302
    utility = getUtility(ISourcePackageFormatSelectionSet)
303
    format = SourcePackageFormat.FORMAT_1_0
304
    if utility.getBySeriesAndFormat(distroseries, format) is None:
305
        utility.add(distroseries, format)
306
307
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
308
def populate(distribution, previous_series_name, uploader_name, options, log):
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
309
    """Set up sample data on `distribution`."""
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
310
    previous_series = distribution.getSeries(previous_series_name)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
311
312
    log.info("Configuring sections...")
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
313
    create_sections(previous_series)
314
    add_architecture(previous_series, 'amd64')
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
315
316
    log.info("Configuring components and permissions...")
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
317
    uploader = get_person_set().getByName(uploader_name)
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
318
    create_components(previous_series, uploader)
319
320
    set_source_package_format(previous_series)
321
322
    create_sample_series(previous_series, log)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
323
324
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
325
def sign_code_of_conduct(person, log):
326
    """Sign Ubuntu Code of Conduct for `person`, if necessary."""
327
    if person.is_ubuntu_coc_signer:
328
        # Already signed.
329
        return
330
331
    log.info("Signing Ubuntu code of conduct.")
332
    signedcocset = getUtility(ISignedCodeOfConductSet)
333
    person_id = person.id
334
    if signedcocset.searchByUser(person_id).count() == 0:
335
        fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person)
336
        Store.of(person).add(SignedCodeOfConduct(
337
            owner=person, signingkey=fake_gpg_key,
338
            signedcode="Normally a signed CoC would go here.", active=True))
339
340
341
def create_ppa_user(username, options, approver, log):
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
342
    """Create new user, with password "test," and sign code of conduct."""
343
    person = get_person_set().getByName(username)
344
    if person is None:
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
345
        have_email = (options.email != default_email)
346
        command_line = [
12494.1.98 by Gavin Panella
Fix almost all test failures. Most were due to the extra required argument to the InitialiseDistroSeries constructor.
347
            'utilities/make-lp-user', username, 'ubuntu-team']
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
348
        if have_email:
349
            command_line += ['--email', options.email]
350
351
        pipe = subprocess.Popen(command_line, stderr=subprocess.PIPE)
352
        stdout, stderr = pipe.communicate()
353
        if stderr != '':
354
            print stderr
355
        if pipe.returncode != 0:
356
            sys.exit(2)
357
358
    transaction.commit()
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
359
10427.4.6 by Jeroen Vermeulen
Final polish. I hope.
360
    person = getUtility(IPersonSet).getByName(username)
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
361
    sign_code_of_conduct(person, log)
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
362
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
363
    return person
364
365
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
366
def create_ppa(distribution, person, name):
367
    """Create a PPA for `person`."""
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
368
    ppa = LaunchpadObjectFactory().makeArchive(
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
369
        distribution=distribution, owner=person, name=name, virtualized=False,
370
        description="Automatically created test PPA.")
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
371
    ppa.external_dependencies = (
12473.2.1 by William Grant
An archive's external dependencies can have a series variable. Use it.
372
        "deb http://archive.ubuntu.com/ubuntu %(series)s "
373
        "main restricted universe multiverse\n")
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
374
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
375
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
376
def main(argv):
377
    options, args, log = parse_args(argv[1:])
378
379
    execute_zcml_for_scripts()
380
    txn = initZopeless(dbuser='launchpad')
381
382
    check_preconditions(options.force)
383
384
    ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
385
    clean_up(ubuntu, log)
386
387
    # Use Hoary as the root, as Breezy and Grumpy are broken.
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
388
    populate(ubuntu, 'hoary', 'ubuntu-team', options, log)
389
390
    admin = get_person_set().getByName('name16')
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
391
    person = create_ppa_user(user_name, options, admin, log)
392
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
393
    create_ppa(ubuntu, person, 'test-ppa')
10303.1.9 by Gary Poster
merge with devel; it has been awhile!
394
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
395
    txn.commit()
10373.3.8 by Jeroen Vermeulen
Moved instructions to the very end again.
396
    log.info("Done.")
397
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
398
    print dedent("""
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
399
        Now start your local Launchpad with "make run_codehosting" and log
400
        into https://launchpad.dev/ as "%(email)s" with "test" as the
401
        password.
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
402
        Your user name will be %(user_name)s."""
403
        % {
404
            'email': options.email,
405
            'user_name': user_name,
406
            })
407
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
408
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
409
if __name__ == "__main__":
410
    main(sys.argv)