]> git.decadent.org.uk Git - dak.git/blob - config/debian/extensions.py
Merge branch 'master' into bugfixes
[dak.git] / config / debian / extensions.py
1 import sys, os, textwrap
2
3 import apt_pkg
4 import daklib.utils, daklib.database
5 import yaml
6
7 import daklib.extensions
8 from daklib.extensions import replace_dak_function
9
10 def check_transition():
11     changes = dak_module.changes
12     reject = dak_module.reject
13     Cnf = dak_module.Cnf
14
15     sourcepkg = changes["source"]
16
17     # No sourceful upload -> no need to do anything else, direct return
18     # We also work with unstable uploads, not experimental or those going to some
19     # proposed-updates queue
20     if "source" not in changes["architecture"] or "unstable" not in changes["distribution"]:
21         return
22
23     # Also only check if there is a file defined (and existant) with
24     # checks.
25     transpath = Cnf.get("Dinstall::Reject::ReleaseTransitions", "")
26     if transpath == "" or not os.path.exists(transpath):
27         return
28
29     # Parse the yaml file
30     sourcefile = file(transpath, 'r')
31     sourcecontent = sourcefile.read()
32     try:
33         transitions = yaml.load(sourcecontent)
34     except yaml.YAMLError, msg:
35         # This shouldn't happen, there is a wrapper to edit the file which
36         # checks it, but we prefer to be safe than ending up rejecting
37         # everything.
38         daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg))
39         return
40
41     # Now look through all defined transitions
42     for trans in transitions:
43         t = transitions[trans]
44         source = t["source"]
45         expected = t["new"]
46
47         # Will be None if nothing is in testing.
48         current = daklib.database.get_suite_version(source, "testing")
49         if current is not None:
50             compare = apt_pkg.VersionCompare(current, expected)
51
52         if current is None or compare < 0:
53             # This is still valid, the current version in testing is older than
54             # the new version we wait for, or there is none in testing yet
55
56             # Check if the source we look at is affected by this.
57             if sourcepkg in t['packages']:
58                 # The source is affected, lets reject it.
59
60                 rejectmsg = "%s: part of the %s transition.\n\n" % (
61                     sourcepkg, trans)
62
63                 if current is not None:
64                     currentlymsg = "at version %s" % (current)
65                 else:
66                     currentlymsg = "not present in testing"
67
68                 rejectmsg += "Transition description: %s\n\n" % (t["reason"])
69
70                 rejectmsg += "\n".join(textwrap.wrap("""Your package
71 is part of a testing transition designed to get %s migrated (it is
72 currently %s, we need version %s).  This transition is managed by the
73 Release Team, and %s is the Release-Team member responsible for it.
74 Please mail debian-release@lists.debian.org or contact %s directly if you
75 need further assistance.  You might want to upload to experimental until this
76 transition is done."""
77                         % (source, currentlymsg, expected,t["rm"], t["rm"])))
78
79                 reject(rejectmsg + "\n")
80                 return
81
82 @replace_dak_function("process-unchecked", "check_signed_by_key")
83 def check_signed_by_key(oldfn):
84     changes = dak_module.changes
85     reject = dak_module.reject
86
87     if changes["source"] == "dpkg":
88         fpr = changes["fingerprint"]
89         (uid, uid_name, is_dm) = dak_module.lookup_uid_from_fingerprint(fpr)
90         if fpr == "5906F687BD03ACAD0D8E602EFCF37657" or uid == "iwj":
91             reject("Upload blocked due to hijack attempt 2008/03/19")
92
93             # NB: 1.15.0, 1.15.2 signed by this key targetted at unstable
94             #     have been made available in the wild, and should remain
95             #     blocked until Debian's dpkg has revved past those version
96             #     numbers
97
98     oldfn()
99
100     check_transition()