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

« back to all changes in this revision

Viewing changes to auto-accept

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2022-04-19 17:02:10 UTC
  • Revision ID: lukasz.zemczak@canonical.com-20220419170210-3nmi5ryi84lf3zm8
...run ben as ubuntu using sudo, as the previous approach doesn't work

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
import subprocess
 
3
import sys
 
4
import time
 
5
 
 
6
from launchpadlib.launchpad import Launchpad
 
7
 
 
8
SERIES = "jammy"
 
9
POCKET = "Proposed"
 
10
QUEUE = "Unapproved"
 
11
SEED_WHITELIST = ["ubuntu-desktop-next", "ubuntugnome", "edubuntu"]
 
12
PACKAGESET_WHITELIST = {"ubuntugnome", "edubuntu", "i386-excludes", "i386-whitelist"}
 
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
if series.status not in ('Active Development', 'Pre-release Freeze'):
 
32
    print("Series no longer in active development; not accepting packages")
 
33
    sys.exit(1)
 
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
 
 
52
    package_sets -= PACKAGESET_WHITELIST
 
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()