~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
300 by Łukasz 'sil2100' Zemczak
groovy -> hirsute
8
SERIES = "hirsute"
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
31
32
# Process the packages
33
for pkg in series.getPackageUploads(status=QUEUE, pocket=POCKET,
34
                                    archive=archive):
35
36
    # Whitelisted packages
37
    if pkg.package_name in PACKAGE_WHITELIST:
38
        if DEBUG:
39
            print("%s: Accepting due to whitelist: %s (%s)" %
40
                  (time.asctime(), pkg.package_name, pkg.package_version))
41
        pkg.acceptFromQueue()
42
43
    # Extract all the packagesets and skip if in any
44
    package_sets = set()
45
    for pkgset in lp.packagesets.setsIncludingSource(
46
            distroseries=series, sourcepackagename=pkg.package_name):
47
        package_sets.add(pkgset.name)
48
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.
49
    package_sets -= PACKAGESET_WHITELIST
192 by Ubuntu Archive
Add auto-accept
50
    if package_sets:
51
        if DEBUG:
52
            print("Skipping '%s' because it's in the following packagesets: %s" %
53
                  (pkg.package_name, ", ".join(package_sets)))
54
        continue
55
56
    # Extract all the seeds and skip if in any
57
    seed = subprocess.Popen([SEEDED_IN_UBUNTU, pkg.package_name],
58
                            universal_newlines=True, stdout=subprocess.PIPE,
59
                            stderr=subprocess.PIPE)
60
    if seed.wait() != 0 or seed.stderr.read():
61
        if DEBUG:
62
            print("Skipping '%s' due to Invalid output from seeded-in-ubuntu: %s" %
63
                  (pkg.package_name, seed.stderr.read().strip()))
64
        continue
65
66
    seeds = set()
67
    for line in seed.stdout:
68
        if not line.startswith("  "):
69
            continue
70
71
        line = line.strip()
72
        seed = line.split(":")[0]
73
        if seed in SEED_WHITELIST:
74
            continue
75
        seeds.add(seed)
76
77
    if seeds:
78
        if DEBUG:
79
            print("Skipping '%s' because it's seeded on: %s" %
80
                  (pkg.package_name, ", ".join(seeds)))
81
        continue
82
83
    print("%s: Accepting: %s (%s)" % (time.asctime(), pkg.package_name,
84
                                 pkg.package_version))
85
    pkg.acceptFromQueue()