~developer-membership-board/+junk/packageset

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/usr/bin/env python

# Sync a suite with a Seed list.
# Copyright (C) 2004, 2005, 2009  Canonical Ltd.
#   James Troup <james.troup@canonical.com>
#   Colin Watson <cjwatson@canonical.com>
# $Id$

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


from __future__ import print_function

import distro_info
import sys
from optparse import OptionParser

seed_source = {}
seed_binary = {}

# Please keep this in the same order as the STRUCTURE files.
seed_sets = {
    'platform/required': ['core'],
    'platform/minimal': ['core'],
    'platform/boot': ['core'],
    'platform/standard': ['core'],
    'platform/desktop-common': ['desktop-core'],
    'platform/d-i-requirements': ['core'],
    'platform/installer': ['core'],
    'platform/installer-gtk': ['ubuntu-desktop'],
    'platform/build-essential': ['core'],
    'platform/language-packs': ['core'],
    'platform/live-common': ['core'],
    'platform/supported-development-common': ['core'],
    'platform/supported-development-desktop': ['ubuntu-desktop'],
    'platform/supported-kernel-common': ['core'],
    'platform/supported-kernel-desktop': ['ubuntu-desktop'],
    'platform/supported-misc-servers': ['ubuntu-server'],
    'platform/supported-hardware-common': ['core'],
    'platform/supported-hardware-desktop': ['ubuntu-desktop'],
    'platform/supported-installer-common': ['core'],
    'platform/supported-installer-desktop': ['desktop-core'],
    'platform/supported-network-common': ['core'],
    'platform/supported-network-client': ['core'],
    'platform/supported-sysadmin-common': ['core'],
    'platform/supported-sysadmin-desktop': ['ubuntu-desktop'],
    'platform/supported-server': ['ubuntu-server'],
    'platform/supported-desktop': ['ubuntu-desktop'],
    'platform/supported-common': [], # aggregation only

    'ubuntu/desktop': ['ubuntu-desktop'],
    'ubuntu/dns-server': ['ubuntu-server'],
    'ubuntu/lamp-server': ['ubuntu-server'],
    'ubuntu/openssh-server': ['ubuntu-server'],
    'ubuntu/print-server': ['ubuntu-server'],
    'ubuntu/samba-server': ['ubuntu-server'],
    'ubuntu/postgresql-server': ['ubuntu-server'],
    'ubuntu/mail-server': ['ubuntu-server'],
    'ubuntu/tomcat-server': ['ubuntu-server'],
    'ubuntu/virt-host': ['ubuntu-server'],
    'ubuntu/server': ['ubuntu-server'],
    'ubuntu/openstack': ['ubuntu-server'],
    'ubuntu/server-ship': ['ubuntu-server'],
    'ubuntu/cloud-image': ['ubuntu-server'],
    'ubuntu/ship': ['ubuntu-desktop'],
    'ubuntu/live': ['ubuntu-desktop'],
    'ubuntu/dvd-live-langsupport': ['ubuntu-desktop'],
    'ubuntu/dvd-live': ['ubuntu-desktop'],
    'ubuntu/ship-live': ['ubuntu-desktop'],
    'ubuntu/development': ['ubuntu-desktop'], # ? depends on desktop
    'ubuntu/education': [], # intentional duplicate of Edubuntu
    'ubuntu/dvd-langsupport': ['ubuntu-desktop'],
    'ubuntu/dvd': ['ubuntu-desktop'],
    'ubuntu/usb-langsupport': ['ubuntu-desktop'],
    'ubuntu/usb': ['ubuntu-desktop'],
    'ubuntu/usb-live': ['ubuntu-desktop'],
    'ubuntu/usb-ship-live': ['ubuntu-desktop'],
    'ubuntu/supported-desktop-extra': ['ubuntu-desktop'],
    'ubuntu/supported': ['ubuntu-desktop'],

    'kubuntu/kubuntu-common': ['kubuntu'],
    'kubuntu/desktop-common': ['kubuntu'],
    'kubuntu/desktop': ['kubuntu'],
    'kubuntu/netbook': ['kubuntu'],
    'kubuntu/mobile': ['kubuntu'],
    'kubuntu/ship': ['kubuntu'],
    'kubuntu/netbook-ship': ['kubuntu'],
    'kubuntu/mobile-ship': ['kubuntu'],
    'kubuntu/live': ['kubuntu'],
    'kubuntu/dvd-live-langsupport': ['kubuntu'],
    'kubuntu/dvd-live': ['kubuntu'],
    'kubuntu/netbook-live': ['kubuntu'],
    'kubuntu/mobile-live': ['kubuntu'],
    'kubuntu/ship-live': ['kubuntu'],
    'kubuntu/ship-netbook-live': ['kubuntu'],
    'kubuntu/ship-mobile-live': ['kubuntu'],
    'kubuntu/development': ['kubuntu'],
    'kubuntu/education': [], # intentional duplicate of Edubuntu
    'kubuntu/dvd-langsupport': ['kubuntu'],
    'kubuntu/dvd': ['kubuntu'],
    'kubuntu/full': ['kubuntu'],
    'kubuntu/supported-desktop-extra': ['kubuntu'],
    'kubuntu/active': ['kubuntu'],
    'kubuntu/active-ship': ['kubuntu'],
    'kubuntu/active-live': ['kubuntu'],
    'kubuntu/active-ship-live': ['kubuntu'],
    'kubuntu/supported': ['kubuntu'],

    'edubuntu/desktop-gnome': ['edubuntu'],
    'edubuntu/desktop-kde': ['edubuntu'],
    'edubuntu/fonts': ['edubuntu'],
    'edubuntu/ubuntu-edu-preschool': ['edubuntu'],
    'edubuntu/ubuntu-edu-primary': ['edubuntu'],
    'edubuntu/ubuntu-edu-secondary': ['edubuntu'],
    'edubuntu/ubuntu-edu-tertiary': ['edubuntu'],
    'edubuntu/server': ['edubuntu'],
    'edubuntu/ship-addon': ['edubuntu'],
    'edubuntu/dvd-live-langsupport': ['edubuntu'],
    'edubuntu/dvd-live': ['edubuntu'],
    'edubuntu/dvd-langsupport': ['edubuntu'],
    # This would cause ubuntu-netbook to be sucked into Edubuntu, which has
    # complicated effects.
    #'edubuntu/dvd': ['edubuntu'],
    #'edubuntu/supported-desktop-extra': ['edubuntu'],
    #'edubuntu/supported': ['edubuntu'],

    'xubuntu/core': ['xubuntu'],
    'xubuntu/desktop': ['xubuntu'],
    # why are these still in the Xubuntu seeds?
    'xubuntu/dns-server': [],
    'xubuntu/lamp-server': [],
    'xubuntu/openssh-server': [],
    'xubuntu/print-server': [],
    'xubuntu/samba-server': [],
    'xubuntu/postgresql-server': [],
    'xubuntu/mail-server': [],
    'xubuntu/server-ship': [],
    'xubuntu/ship': ['xubuntu'],
    'xubuntu/live': ['xubuntu'],
    'xubuntu/ship-live': ['xubuntu'],
    'xubuntu/development': ['xubuntu'],
    'xubuntu/supported-desktop-extra': ['xubuntu'],
    'xubuntu/supported': ['xubuntu'],

    'mythbuntu/desktop': ['mythbuntu'],
    'mythbuntu/backend-master': ['mythbuntu'],
    'mythbuntu/backend-slave': ['mythbuntu'],
    'mythbuntu/frontend': ['mythbuntu'],
    'mythbuntu/ship': ['mythbuntu'],
    'mythbuntu/live': ['mythbuntu'],
    'mythbuntu/ship-live': ['mythbuntu'],
    'mythbuntu/supported': ['mythbuntu'],

    'ubuntustudio/boot': ['ubuntustudio'], # for RT kernel, but careful about core overlap
    'ubuntustudio/desktop-common': ['ubuntustudio'],
    'ubuntustudio/desktop': ['ubuntustudio'],
    'ubuntustudio/desktop-gnome': ['ubuntustudio'],
    'ubuntustudio/ffmpeg-common': ['ubuntustudio'],
    'ubuntustudio/audio': ['ubuntustudio'],
    'ubuntustudio/audio-plugins': ['ubuntustudio'],
    'ubuntustudio/font-meta': ['ubuntustudio'],
    'ubuntustudio/graphics': ['ubuntustudio'],
    'ubuntustudio/photography': ['ubuntustudio'],
    'ubuntustudio/publishing': ['ubuntustudio'],
    'ubuntustudio/video': ['ubuntustudio'],
    'ubuntustudio/ship': ['ubuntustudio'],
    'ubuntustudio/dvd-live': ['ubuntustudio'],
    'ubuntustudio/dvd': ['ubuntustudio'],
    'ubuntustudio/supported': ['ubuntustudio'],

    'lubuntu/core': ['lubuntu'],
    'lubuntu/desktop': ['lubuntu'],
    'lubuntu/live': ['lubuntu'],
    'lubuntu/ship': ['lubuntu'],
    'lubuntu/ship-live': ['lubuntu'],
    'lubuntu/supported': ['lubuntu'],

    'ubuntu-gnome/desktop': ['ubuntugnome'],
    'ubuntu-gnome/live': ['ubuntugnome'],
    'ubuntu-gnome/ship': ['ubuntugnome'],
    'ubuntu-gnome/ship-live': ['ubuntugnome'],
    'ubuntu-gnome/supported': ['ubuntugnome'],

    'ubuntukylin/desktop': ['ubuntukylin'],
    'ubuntukylin/live': ['ubuntukylin'],
    'ubuntukylin/ship': ['ubuntukylin'],
    'ubuntukylin/ship-live': ['ubuntukylin'],
    'ubuntukylin/supported': ['ubuntukylin'],

    'ubuntu-mate/core': ['ubuntu-mate'],
    'ubuntu-mate/cloudtop': ['ubuntu-mate'],
    'ubuntu-mate/desktop': ['ubuntu-mate'],
    'ubuntu-mate/live': ['ubuntu-mate'],
    'ubuntu-mate/ship': ['ubuntu-mate'],
    'ubuntu-mate/ship-live': ['ubuntu-mate'],
    'ubuntu-mate/supported': ['ubuntu-mate'],
}


def read_germinate(options):
    local_germinate = 'germinate-output'
    seen_seedpaths = set()

    # XXX - dehardcode me harder
    for distro in reversed([ "ubuntu", "kubuntu", "edubuntu", "xubuntu", "mythbuntu", "ubuntustudio", "lubuntu", "ubuntu-gnome", "ubuntukylin", "ubuntu-mate" ]):
        # List of seeds
        seeds = ["all"]
        structure = open("%s/structure_%s_%s_i386" %
                         (local_germinate, distro, options.suite))
        for line in structure:
            if not line or line.startswith('#') or ':' not in line:
                continue
            seed = line.split(':')[0]
            seeds.append(seed)
        structure.close()
        # ideally supported+build-depends too, but Launchpad's
        # cron.germinate doesn't save this

        seed_binary.setdefault('langpack', set())
        seed_source.setdefault('langpack', set())

        for arch in [ "i386", "amd64", "armhf", "arm64", "ppc64el", "s390x" ]:
            for seed in seeds:
                if seed == "all":
                    continue
                # special-case ahoy for structural includes
                # TODO should be possible to figure out exceptions from STRUCTURE
                if ('platform/%s' % seed) in seed_sets and (distro == 'ubuntu'):
                    seedpath = 'platform/%s' % seed
                elif distro == 'edubuntu' and ('edubuntu/%s' % seed) not in seed_sets and ('ubuntu/%s' % seed) in seed_sets:
                    seedpath = 'ubuntu/%s' % seed
                else:
                    seedpath = '%s/%s' % (distro, seed)
                if seedpath not in seed_sets:
                    if seedpath not in seen_seedpaths:
                        print("No package set information for %s" % seedpath,
                              file=sys.stderr)
                        seen_seedpaths.add(seedpath)
                    continue
                packagesets = seed_sets[seedpath]
                for ps in packagesets:
                    seed_binary.setdefault(ps, set())
                    seed_source.setdefault(ps, set())
                for file in (seed, '%s.build-depends' % seed):
                    filename = "%s/%s_%s_%s_%s" \
                               % (local_germinate, file, distro,
                                  options.suite, arch)
                    f = open(filename)
                    for line in f:
                        # Skip header and footer
                        if (line[0] == "-" or line.startswith("Package") or
                            line[0] == " "):
                            continue
                        # Skip empty lines
                        line = line.strip()
                        if not line:
                            continue
                        pkg, source, why = [word.strip() for word in line.split('|')][:3]
                        if (why.startswith('Rescued from')):
                            continue
                        if (pkg.startswith('language-pack-') or
                            pkg.startswith('language-support-')):
                            seed_binary['langpack'].add(pkg)
                            seed_source['langpack'].add(source)
                        for ps in packagesets:
                            seed_binary[ps].add(pkg)
                            seed_source[ps].add(source)
                    f.close()

    all_pkgs = set()
    all_srcs = set()
    for ps in seed_source.keys():
        all_pkgs |= seed_binary[ps]
        all_srcs |= seed_source[ps]
    # TODO: make table-driven
    # TODO: handle binaries
    for src in all_srcs:
        if src in seed_source['core']:
            for ps in [key for key in seed_source.keys() if key not in ('core', 'langpack')]:
                seed_source[ps].discard(src)
        # Less-core desktops don't automatically get packages belonging to
        # core desktops
        if ((src in seed_source['ubuntu-desktop'] or src in seed_source['kubuntu'] or src in seed_source['edubuntu']) and
            (src in seed_source['xubuntu'] or src in seed_source['mythbuntu'] or src in seed_source['ubuntustudio'] or src in seed_source['lubuntu'] or src in seed_source['ubuntugnome'] or src in seed_source['ubuntukylin'] or src in seed_source['ubuntu-mate'])):
            for ps in ('xubuntu', 'mythbuntu', 'ubuntustudio', 'lubuntu', 'ubuntukylin'):
                seed_source[ps].discard(src)
            # edubuntu isn't here; it's allowed to share with ubuntugnome
            if (src in seed_source['ubuntu-desktop'] or src in seed_source['kubuntu']):
                seed_source['ubuntugnome'].discard(src)
        if src in seed_source['desktop-core']:
            for ps in ('ubuntu-desktop', 'kubuntu', 'edubuntu', 'xubuntu', 'mythbuntu', 'ubuntustudio', 'lubuntu', 'ubuntugnome', 'ubuntukylin', 'ubuntu-mate'):
                seed_source[ps].discard(src)
        if src in seed_source['ubuntu-desktop']:
            seed_source['edubuntu'].discard(src)
            seed_source['ubuntugnome'].discard(src)
            seed_source['ubuntukylin'].discard(src)
            seed_source['ubuntu-mate'].discard(src)
        if src in seed_source['kubuntu']:
            seed_source['edubuntu'].discard(src)
            seed_source['ubuntugnome'].discard(src)
            seed_source['ubuntukylin'].discard(src)
            seed_source['ubuntu-mate'].discard(src)
        # for now ...
        if src in seed_source['ubuntu-server']:
            for ps in ('xubuntu', 'mythbuntu', 'ubuntustudio', 'lubuntu', 'ubuntugnome', 'ubuntukylin', 'ubuntu-mate'):
                seed_source[ps].discard(src)


def do_intersections(sofar, rest, intersections):
    if not intersections:
        return set()
    if rest:
        # It's important that we process sofar + [rest[0]] before sofar;
        # this means that maximal intersections will be detected first.
        handled = do_intersections(sofar + [rest[0]], rest[1:],
                                   intersections & set(seed_source[rest[0]]))
        return do_intersections(sofar, rest[1:],
                                intersections - handled) | handled
    elif len(sofar) > 1:
        heading = "Intersection: %s" % " & ".join(sofar)
        print(heading)
        print('-' * len(heading))
        print()
        for src in sorted(intersections):
            print(" %s" % src)
        print()
        return intersections
    return set()

def do_output():
    all_srcs = set()
    for ps in sorted(seed_source.keys()):
        all_srcs |= seed_source[ps]
        print(ps)
        print('-' * len(ps))
        print()
        for src in sorted(seed_source[ps]):
            print(" %s" % src)
        print()

    do_intersections([], sorted(seed_source.keys()), all_srcs)


def main():
    parser = OptionParser(description='Generate seed-based package sets.')
    parser.add_option('-s', '--suite', default=distro_info.UbuntuDistroInfo().devel(),
                      help='examine this suite')
    options, args = parser.parse_args()

    read_germinate(options)
    do_output()


if __name__ == '__main__':
    main()