~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
13194.2.1 by Gavin Panella
Change all uses of 'initialise' to 'initialize'.
61
from lp.soyuz.scripts.initialize_distroseries import InitializeDistroSeries
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
13168.13.30 by Raphael Badin
Setup previous_series properly in tests.
231
    new_series.previous_series = parent
13194.2.1 by Gavin Panella
Change all uses of 'initialise' to 'initialize'.
232
    ids = InitializeDistroSeries(new_series, [parent.id])
233
    ids.initialize()
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
234
    return new_series
235
236
237
def create_sample_series(original_series, log):
238
    """Set up sample `DistroSeries`.
239
240
    :param original_series: The parent for the first new series to be
241
        created.  The second new series will have the first as a parent,
242
        and so on.
243
    """
244
    series_descriptions = [
245
        ('Dapper Drake', SeriesStatus.SUPPORTED, '6.06'),
246
        ('Edgy Eft', SeriesStatus.OBSOLETE, '6.10'),
247
        ('Feisty Fawn', SeriesStatus.OBSOLETE, '7.04'),
248
        ('Gutsy Gibbon', SeriesStatus.OBSOLETE, '7.10'),
249
        ('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.
250
        ('Intrepid Ibex', SeriesStatus.OBSOLETE, '8.10'),
251
        ('Jaunty Jackalope', SeriesStatus.OBSOLETE, '9.04'),
11091.5.2 by Aaron Bentley
Update soyuz sample data
252
        ('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.
253
        ('Lucid Lynx', SeriesStatus.SUPPORTED, '10.04'),
254
        ('Maverick Meerkat', SeriesStatus.CURRENT, '10.10'),
255
        ('Natty Narwhal', SeriesStatus.DEVELOPMENT, '11.04'),
256
        ('Onerous Ocelot', SeriesStatus.FUTURE, '11.10'),
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
257
        ]
258
259
    parent = original_series
260
    for full_name, status, version in series_descriptions:
261
        log.info('Creating %s...' % full_name)
262
        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.
263
        # Karmic is the first series in which the 3.0 formats are
264
        # allowed. Subsequent series will inherit them.
265
        if version == '9.10':
266
            spfss = getUtility(ISourcePackageFormatSelectionSet)
267
            spfss.add(parent, SourcePackageFormat.FORMAT_3_0_QUILT)
268
            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.
269
270
12473.2.3 by William Grant
Add a component to grumpy to placate the publisher.
271
def add_series_component(series):
272
    """Permit a component in the given series."""
273
    component = getUtility(IComponentSet)['main']
274
    get_store(MASTER_FLAVOR).add(
275
        ComponentSelection(
276
            distroseries=series, component=component))
277
278
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
279
def clean_up(distribution, log):
280
    # First we eliminate all active publishings in the Ubuntu main archives.
281
    # None of the librarian files exist, so it kills the publisher.
282
283
    # Could use IPublishingSet.requestDeletion() on the published sources to
284
    # get rid of the binaries too, but I don't trust that there aren't
285
    # published binaries without corresponding sources.
286
287
    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.
288
    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.
289
290
    # Disable publishing of all PPAs, as they probably have broken
291
    # publishings too.
292
    log.info("Disabling all PPAs...")
293
    retire_ppas(distribution)
294
295
    retire_series(distribution)
296
12473.2.3 by William Grant
Add a component to grumpy to placate the publisher.
297
    # grumpy has no components, which upsets the publisher.
298
    add_series_component(distribution['grumpy'])
299
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
300
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
301
def set_source_package_format(distroseries):
302
    """Register a series' source package format selection."""
303
    utility = getUtility(ISourcePackageFormatSelectionSet)
304
    format = SourcePackageFormat.FORMAT_1_0
305
    if utility.getBySeriesAndFormat(distroseries, format) is None:
306
        utility.add(distroseries, format)
307
308
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
309
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.
310
    """Set up sample data on `distribution`."""
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
311
    previous_series = distribution.getSeries(previous_series_name)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
312
313
    log.info("Configuring sections...")
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
314
    create_sections(previous_series)
315
    add_architecture(previous_series, 'amd64')
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
316
317
    log.info("Configuring components and permissions...")
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
318
    uploader = get_person_set().getByName(uploader_name)
13045.14.3 by Gavin Panella
Change many more sites from using parent_series to previous_series.
319
    create_components(previous_series, uploader)
320
321
    set_source_package_format(previous_series)
322
323
    create_sample_series(previous_series, log)
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
324
325
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
326
def sign_code_of_conduct(person, log):
327
    """Sign Ubuntu Code of Conduct for `person`, if necessary."""
328
    if person.is_ubuntu_coc_signer:
329
        # Already signed.
330
        return
331
332
    log.info("Signing Ubuntu code of conduct.")
333
    signedcocset = getUtility(ISignedCodeOfConductSet)
334
    person_id = person.id
335
    if signedcocset.searchByUser(person_id).count() == 0:
336
        fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person)
337
        Store.of(person).add(SignedCodeOfConduct(
338
            owner=person, signingkey=fake_gpg_key,
339
            signedcode="Normally a signed CoC would go here.", active=True))
340
341
342
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.
343
    """Create new user, with password "test," and sign code of conduct."""
344
    person = get_person_set().getByName(username)
345
    if person is None:
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
346
        have_email = (options.email != default_email)
347
        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.
348
            'utilities/make-lp-user', username, 'ubuntu-team']
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
349
        if have_email:
350
            command_line += ['--email', options.email]
351
352
        pipe = subprocess.Popen(command_line, stderr=subprocess.PIPE)
353
        stdout, stderr = pipe.communicate()
354
        if stderr != '':
355
            print stderr
356
        if pipe.returncode != 0:
357
            sys.exit(2)
358
359
    transaction.commit()
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
360
10427.4.6 by Jeroen Vermeulen
Final polish. I hope.
361
    person = getUtility(IPersonSet).getByName(username)
10373.3.4 by Jeroen Vermeulen
Make soyuz sampledata script do more of the work.
362
    sign_code_of_conduct(person, log)
10373.3.3 by Jeroen Vermeulen
Make the script take over much more of the manual work.
363
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
364
    return person
365
366
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
367
def create_ppa(distribution, person, name):
368
    """Create a PPA for `person`."""
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
369
    ppa = LaunchpadObjectFactory().makeArchive(
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
370
        distribution=distribution, owner=person, name=name, virtualized=False,
371
        description="Automatically created test PPA.")
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
372
    ppa.external_dependencies = (
12473.2.1 by William Grant
An archive's external dependencies can have a series variable. Use it.
373
        "deb http://archive.ubuntu.com/ubuntu %(series)s "
374
        "main restricted universe multiverse\n")
10373.3.12 by Jeroen Vermeulen
Set external dependencies.
375
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
376
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
377
def main(argv):
378
    options, args, log = parse_args(argv[1:])
379
380
    execute_zcml_for_scripts()
381
    txn = initZopeless(dbuser='launchpad')
382
383
    check_preconditions(options.force)
384
385
    ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
386
    clean_up(ubuntu, log)
387
388
    # 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.
389
    populate(ubuntu, 'hoary', 'ubuntu-team', options, log)
390
391
    admin = get_person_set().getByName('name16')
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
392
    person = create_ppa_user(user_name, options, admin, log)
393
10373.3.10 by Jeroen Vermeulen
Creating PPA as well.
394
    create_ppa(ubuntu, person, 'test-ppa')
10303.1.9 by Gary Poster
merge with devel; it has been awhile!
395
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
396
    txn.commit()
10373.3.8 by Jeroen Vermeulen
Moved instructions to the very end again.
397
    log.info("Done.")
398
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
399
    print dedent("""
10427.4.2 by Jeroen Vermeulen
Moved user/gpg creation into make-lp-user.
400
        Now start your local Launchpad with "make run_codehosting" and log
401
        into https://launchpad.dev/ as "%(email)s" with "test" as the
402
        password.
10373.3.5 by Jeroen Vermeulen
Automating lots of manual steps for getting Soyuz to work.
403
        Your user name will be %(user_name)s."""
404
        % {
405
            'email': options.email,
406
            'user_name': user_name,
407
            })
408
10373.3.2 by Jeroen Vermeulen
Integrate cleanup of playground sample data for Soyuz testing.
409
10373.3.1 by Jeroen Vermeulen
Import make-ubuntu-sane.py into the LP tree, with cleanups.
410
if __name__ == "__main__":
411
    main(sys.argv)