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