attachment:make-ubuntu-sane.py of Soyuz/HowToUseSoyuzLocally

Not logged in - Log In / Register

Attachment 'make-ubuntu-sane.py'

Download

   1 #!/usr/bin/python2.4
   2 
   3 import _pythonpath
   4 
   5 import logging
   6 
   7 from storm.store import Store
   8 from zope.component import getUtility
   9 from zope.event import notify
  10 from zope.lifecycleevent import ObjectCreatedEvent
  11 from zope.security.proxy import removeSecurityProxy
  12 
  13 from canonical.database.sqlbase import (
  14     sqlvalues, flush_database_updates, cursor, flush_database_caches)
  15 from canonical.launchpad.scripts import execute_zcml_for_scripts
  16 from canonical.lp import initZopeless
  17 
  18 # Circular imports inhibit import from lp.r.i.p.
  19 from canonical.launchpad.interfaces import IPersonSet
  20 from lp.registry.interfaces.distribution import IDistributionSet
  21 from lp.registry.interfaces.distroseries import DistroSeriesStatus
  22 from lp.soyuz.interfaces.publishing import active_publishing_status
  23 from lp.soyuz.interfaces.component import IComponentSet
  24 from lp.soyuz.interfaces.section import ISectionSet
  25 from lp.soyuz.model.section import SectionSelection
  26 from lp.soyuz.model.component import ComponentSelection
  27 
  28 OBSOLETE = DistroSeriesStatus.OBSOLETE
  29 SUPPORTED = DistroSeriesStatus.SUPPORTED
  30 CURRENT = DistroSeriesStatus.CURRENT
  31 DEVELOPMENT = DistroSeriesStatus.DEVELOPMENT
  32 
  33 if __name__ == "__main__":
  34     logging.basicConfig(level=logging.INFO)
  35 
  36     execute_zcml_for_scripts()
  37     txn = initZopeless(dbuser='launchpad')
  38 
  39     ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
  40     foobar = getUtility(IPersonSet).getByName('name16')
  41 
  42     # First we eliminate all active publishings in the Ubuntu main archives.
  43     # None of the librarian files exist, so it kills the publisher.
  44 
  45     # Could use IPublishingSet.requestDeletion() on the published sources to
  46     # get rid of the binaries too, but I don't trust that there aren't
  47     # published binaries without corresponding sources.
  48 
  49     def kill_them_all(f):
  50         for pph in f(status=active_publishing_status):
  51             pph.requestDeletion(foobar, 'Missing files. Go away.')
  52 
  53     logging.info("Deleting all items in official archives...")
  54     for archive in ubuntu.all_distro_archives:
  55         kill_them_all(archive.getPublishedSources)
  56         kill_them_all(archive.getAllPublishedBinaries)
  57 
  58 
  59     # Next we disable publishing of all PPAs, as they probably have broken
  60     # publishings too.
  61     logging.info("Disabling all PPAs...")
  62     for ppa in ubuntu.getAllPPAs():
  63         removeSecurityProxy(ppa).publish = False
  64 
  65 
  66     # Now we set up lucilleconfig on all Ubuntu distroserieses, as it isn't
  67     # there to start with :(
  68     # We also take this opportunity to mark all of the old serieses as
  69     # obsolete.
  70     logging.info("Setting lucilleconfig...")
  71     for series in ubuntu.series:
  72         removeSecurityProxy(series).lucilleconfig = '''[publishing]
  73 components = main restricted universe multiverse'''
  74         series.status = DistroSeriesStatus.OBSOLETE
  75 
  76 
  77     # We create some more modern distroseries, and initialise them.
  78     # We use Hoary as the root, as Breezy and Grumpy are broken.
  79     parent = ubuntu.getSeries('hoary')
  80 
  81     logging.info("Configuring sections...")
  82     # Before we start creating the rest, let's configure permissions,
  83     # components and sections.
  84     for section in ('admin', 'cli-mono', 'comm', 'database', 'devel', 'debug',
  85                     'doc', 'editors', 'electronics', 'embedded', 'fonts',
  86                     'games', 'gnome', 'graphics', 'gnu-r', 'gnustep',
  87                     'hamradio', 'haskell', 'httpd', 'interpreters', 'java',
  88                     'kde', 'kernel', 'libs', 'libdevel', 'lisp',
  89                     'localization', 'mail', 'math', 'misc', 'net', 'news',
  90                     'ocaml', 'oldlibs', 'otherosfs', 'perl', 'php', 'python',
  91                     'ruby', 'science', 'shells', 'sound', 'tex', 'text',
  92                     'utils', 'vcs', 'video', 'web', 'x11', 'xfce', 'zope'):
  93         section_obj = getUtility(ISectionSet).ensure(section)
  94         if section_obj not in parent.sections:
  95             Store.of(parent).add(
  96                 SectionSelection(distroseries=parent, section=section_obj))
  97 
  98     ubuntu_team = getUtility(IPersonSet).getByName('ubuntu-team')
  99 
 100     logging.info("Configuring components and permissions...")
 101     for component in ('main', 'restricted', 'universe', 'multiverse'):
 102         component_obj = getUtility(IComponentSet).ensure(component)
 103         if component_obj not in parent.components:
 104             Store.of(parent).add(ComponentSelection(
 105                 distroseries=parent, component=component_obj))
 106         ubuntu.main_archive.newComponentUploader(ubuntu_team, component_obj)
 107         ubuntu.main_archive.newQueueAdmin(ubuntu_team, component_obj)
 108 
 109 
 110     for series, status, ver in [('Dapper Drake', SUPPORTED, '6.06'),
 111                                 ('Edgy Eft', OBSOLETE, '6.10'),
 112                                 ('Feisty Fawn', OBSOLETE, '7.04'),
 113                                 ('Gutsy Gibbon', OBSOLETE, '7.10'),
 114                                 ('Hardy Heron', SUPPORTED, '8.04'),
 115                                 ('Intrepid Ibex', SUPPORTED, '8.10'),
 116                                 ('Jaunty Jackalope', SUPPORTED, '9.04'),
 117                                 ('Karmic Koala', CURRENT, '9.10'),
 118                                 ('Lucid Lynx', DEVELOPMENT, '10.04'),
 119                                 ]:
 120         displayname = series.split()[0]
 121         name = displayname.lower()
 122         logging.info('Creating %s...' % displayname)
 123 
 124         distroseries = ubuntu.newSeries(name=name, title=series,
 125             displayname=displayname, summary='Ubuntu %s is good.' % ver,
 126             description='%s is awesome.' % ver, version=ver,
 127             parent_series=parent, owner=foobar)
 128         distroseries.status = status
 129         notify(ObjectCreatedEvent(distroseries))
 130 
 131         # This bit copied from scripts/ftpmaster-tools/initialise-from-parent.py.
 132         assert distroseries.architectures.count() is 0, (
 133             "Can not copy distroarchseries from parent, there are already "
 134             "distroarchseries(s) initialised for this series.")
 135         flush_database_updates()
 136         cur = cursor()
 137         cur.execute("""
 138         INSERT INTO DistroArchSeries
 139               (distroseries, processorfamily, architecturetag, owner, official)
 140         SELECT %s, processorfamily, architecturetag, %s, official
 141         FROM DistroArchSeries WHERE distroseries = %s
 142         """ % sqlvalues(distroseries, distroseries.owner,
 143                         distroseries.parent_series))
 144         flush_database_caches()
 145 
 146         i386 = distroseries.getDistroArchSeries('i386')
 147         i386.supports_virtualized = True
 148         distroseries.nominatedarchindep = i386
 149 
 150         distroseries.initialiseFromParent()
 151 
 152         parent = distroseries
 153 
 154     txn.commit()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-11-11 17:33:50, 6.5 KB) [[attachment:make-ubuntu-sane.py]]
  • [get | view] (2009-11-05 12:34:43, 0.3 KB) [[attachment:start-soyuz.sh]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.