1 import sys, os, textwrap
4 import daklib.utils, daklib.database
7 # This function and its data should move into daklib/extensions.py
11 def replace_dak_function(module,name):
13 replace_funcs["%s:%s" % (module,name)] = f
16 def check_transition():
17 changes = dak_module.changes
18 reject = dak_module.reject
21 sourcepkg = changes["source"]
23 # No sourceful upload -> no need to do anything else, direct return
24 if "source" not in changes["architecture"]:
27 # Also only check if there is a file defined (and existant) with
29 transpath = Cnf.get("Dinstall::Reject::ReleaseTransitions", "")
30 if transpath == "" or not os.path.exists(transpath):
34 sourcefile = file(transpath, 'r')
35 sourcecontent = sourcefile.read()
37 transitions = syck.load(sourcecontent)
38 except syck.error, msg:
39 # This shouldn't happen, there is a wrapper to edit the file which
40 # checks it, but we prefer to be safe than ending up rejecting
42 daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg))
45 # Now look through all defined transitions
46 for trans in transitions:
47 t = transitions[trans]
51 # Will be None if nothing is in testing.
52 current = daklib.database.get_suite_version(source, "testing")
53 if current is not None:
54 compare = apt_pkg.VersionCompare(current, expected)
56 if current is None or compare < 0:
57 # This is still valid, the current version in testing is older than
58 # the new version we wait for, or there is none in testing yet
60 # Check if the source we look at is affected by this.
61 if sourcepkg in t['packages']:
62 # The source is affected, lets reject it.
64 rejectmsg = "%s: part of the %s transition.\n\n" % (
67 if current is not None:
68 currentlymsg = "at version %s" % (current)
70 currentlymsg = "not present in testing"
72 rejectmsg += "Transition description: %s\n\n" % (t["reason"])
74 rejectmsg += "\n".join(textwrap.wrap("""Your package
75 is part of a testing transition designed to get %s migrated (it is
76 currently %s, we need version %s). This transition is managed by the
77 Release Team, and %s is the Release-Team member responsible for it.
78 Please mail debian-release@lists.debian.org or contact %s directly if you
79 need further assistance."""
80 % (source, currentlymsg, expected,t["rm"], t["rm"])))
82 reject(rejectmsg + "\n")
85 @replace_dak_function("process-unchecked", "check_signed_by_key")
86 def check_signed_by_key():
87 changes = dak_module.changes
88 reject = dak_module.reject
90 if changes["source"] == "dpkg":
91 fpr = changes["fingerprint"]
92 (uid, uid_name) = dak_module.lookup_uid_from_fingerprint(fpr)
93 if fpr == "5906F687BD03ACAD0D8E602EFCF37657" or uid == "iwj":
94 reject("Upload blocked due to hijack attempt 2008/03/19")
96 # NB: 1.15.0, 1.15.2 signed by this key targetted at unstable
97 # have been made available in the wild, and should not be
98 # blocked until Debian's dpkg has revved past those version
101 replaced_funcs["check_signed_by_key"]()
106 global replaced_funcs
108 # This bit should be done automatically too
110 for f,newfunc in replace_funcs.iteritems():
112 if len(f) > 0 and m == name:
113 replaced_funcs[f] = dak_module.__dict__[f]
114 dak_module.__dict__[f] = newfunc