~ubuntu-archive/ubuntu-archive-scripts/trunk

192 by Ubuntu Archive
Add auto-accept
1
#!/usr/bin/python
2
import subprocess
3
import sys
4
import time
5
6
from launchpadlib.launchpad import Launchpad
7
310 by Łukasz 'sil2100' Zemczak
hirsute -> impish
8
SERIES = "impish"
192 by Ubuntu Archive
Add auto-accept
9
POCKET = "Proposed"
10
QUEUE = "Unapproved"
253 by Adam Conrad
auto-accept: Commit production changes.
11
SEED_WHITELIST = ["ubuntu-desktop-next", "ubuntugnome", "edubuntu"]
278.1.1 by Iain Lane
auto-accept: Add i386-whitelist to the seed whitelist
12
PACKAGESET_WHITELIST = {"ubuntugnome", "edubuntu", "i386-excludes", "i386-whitelist"}
192 by Ubuntu Archive
Add auto-accept
13
SEEDED_IN_UBUNTU = "/home/ubuntu-archive/ubuntu-dev-tools/seeded-in-ubuntu"
14
PACKAGE_WHITELIST = ["upstart-app-launch", "click", "click-apparmor",
15
                     "apparmor-easyprof-ubuntu", "ubuntuone-credentials"]
16
17
DEBUG = 0
18
if len(sys.argv) > 1 and sys.argv[1] == "debug":
19
    DEBUG = 1
20
21
# Connect to Launchpad
22
lp = Launchpad.login_with("auto-accept", "production", version="devel")
23
ubuntu = lp.distributions['ubuntu']
24
25
# Get the primary archive
26
archive = ubuntu.getArchive(name="primary")
27
28
# Get the series
29
series = ubuntu.getSeries(name_or_version=SERIES)
30
313 by Steve Langasek
Don't auto-accept packages if this is no longer the development release
31
if series.status != 'Active Development':
32
    print("Series no longer in active development; not accepting packages")
33
    sys.exit(1)
192 by Ubuntu Archive
Add auto-accept
34
35
# Process the packages
36
for pkg in series.getPackageUploads(status=QUEUE, pocket=POCKET,
37
                                    archive=archive):
38
39
    # Whitelisted packages
40
    if pkg.package_name in PACKAGE_WHITELIST:
41
        if DEBUG:
42
            print("%s: Accepting due to whitelist: %s (%s)" %
43
                  (time.asctime(), pkg.package_name, pkg.package_version))
44
        pkg.acceptFromQueue()
45
46
    # Extract all the packagesets and skip if in any
47
    package_sets = set()
48
    for pkgset in lp.packagesets.setsIncludingSource(
49
            distroseries=series, sourcepackagename=pkg.package_name):
50
        package_sets.add(pkgset.name)
51
252 by Steve Langasek
i386-excludes is a packageset, not a seed, so it needs to be in a different list. Land Iain's local modifications to support this.
52
    package_sets -= PACKAGESET_WHITELIST
192 by Ubuntu Archive
Add auto-accept
53
    if package_sets:
54
        if DEBUG:
55
            print("Skipping '%s' because it's in the following packagesets: %s" %
56
                  (pkg.package_name, ", ".join(package_sets)))
57
        continue
58
59
    # Extract all the seeds and skip if in any
60
    seed = subprocess.Popen([SEEDED_IN_UBUNTU, pkg.package_name],
61
                            universal_newlines=True, stdout=subprocess.PIPE,
62
                            stderr=subprocess.PIPE)
63
    if seed.wait() != 0 or seed.stderr.read():
64
        if DEBUG:
65
            print("Skipping '%s' due to Invalid output from seeded-in-ubuntu: %s" %
66
                  (pkg.package_name, seed.stderr.read().strip()))
67
        continue
68
69
    seeds = set()
70
    for line in seed.stdout:
71
        if not line.startswith("  "):
72
            continue
73
74
        line = line.strip()
75
        seed = line.split(":")[0]
76
        if seed in SEED_WHITELIST:
77
            continue
78
        seeds.add(seed)
79
80
    if seeds:
81
        if DEBUG:
82
            print("Skipping '%s' because it's seeded on: %s" %
83
                  (pkg.package_name, ", ".join(seeds)))
84
        continue
85
86
    print("%s: Accepting: %s (%s)" % (time.asctime(), pkg.package_name,
87
                                 pkg.package_version))
88
    pkg.acceptFromQueue()