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):
15 f(replaced_funcs[name], *a, **kw)
16 myfunc.__name__ = f.__name__
17 myfunc.__doc__ = f.__doc__
18 myfunc.__dict__.update(f.__dict__)
20 replace_funcs["%s:%s" % (module,name)] = myfunc
24 def check_transition():
25 changes = dak_module.changes
26 reject = dak_module.reject
29 sourcepkg = changes["source"]
31 # No sourceful upload -> no need to do anything else, direct return
32 if "source" not in changes["architecture"]:
35 # Also only check if there is a file defined (and existant) with
37 transpath = Cnf.get("Dinstall::Reject::ReleaseTransitions", "")
38 if transpath == "" or not os.path.exists(transpath):
42 sourcefile = file(transpath, 'r')
43 sourcecontent = sourcefile.read()
45 transitions = syck.load(sourcecontent)
46 except syck.error, msg:
47 # This shouldn't happen, there is a wrapper to edit the file which
48 # checks it, but we prefer to be safe than ending up rejecting
50 daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg))
53 # Now look through all defined transitions
54 for trans in transitions:
55 t = transitions[trans]
59 # Will be None if nothing is in testing.
60 current = daklib.database.get_suite_version(source, "testing")
61 if current is not None:
62 compare = apt_pkg.VersionCompare(current, expected)
64 if current is None or compare < 0:
65 # This is still valid, the current version in testing is older than
66 # the new version we wait for, or there is none in testing yet
68 # Check if the source we look at is affected by this.
69 if sourcepkg in t['packages']:
70 # The source is affected, lets reject it.
72 rejectmsg = "%s: part of the %s transition.\n\n" % (
75 if current is not None:
76 currentlymsg = "at version %s" % (current)
78 currentlymsg = "not present in testing"
80 rejectmsg += "Transition description: %s\n\n" % (t["reason"])
82 rejectmsg += "\n".join(textwrap.wrap("""Your package
83 is part of a testing transition designed to get %s migrated (it is
84 currently %s, we need version %s). This transition is managed by the
85 Release Team, and %s is the Release-Team member responsible for it.
86 Please mail debian-release@lists.debian.org or contact %s directly if you
87 need further assistance."""
88 % (source, currentlymsg, expected,t["rm"], t["rm"])))
90 reject(rejectmsg + "\n")
93 @replace_dak_function("process-unchecked", "check_signed_by_key")
94 def check_signed_by_key(oldfn):
95 changes = dak_module.changes
96 reject = dak_module.reject
98 if changes["source"] == "dpkg":
99 fpr = changes["fingerprint"]
100 (uid, uid_name) = dak_module.lookup_uid_from_fingerprint(fpr)
101 if fpr == "5906F687BD03ACAD0D8E602EFCF37657" or uid == "iwj":
102 reject("Upload blocked due to hijack attempt 2008/03/19")
104 # NB: 1.15.0, 1.15.2 signed by this key targetted at unstable
105 # have been made available in the wild, and should remain
106 # blocked until Debian's dpkg has revved past those version
114 global replaced_funcs
116 # This bit should be done automatically too
118 for f,newfunc in replace_funcs.iteritems():
120 if len(f) > 0 and m == name:
121 replaced_funcs[f] = dak_module.__dict__[f]
122 dak_module.__dict__[f] = newfunc