X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=242400a9ed0e012ae85da33680e327ccd2e74788;hb=7634c6b12df2eaf14e4b07e27222c87cb740268d;hp=6fecfb877a5eb9743643a671da8f81c4e3a7ffe3;hpb=012d6535656c6b6001e87b419e60180f4d205d91;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 6fecfb87..242400a9 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1387,7 +1387,7 @@ def gpg_get_key_addresses(fingerprint): addresses = key_uid_email_cache.get(fingerprint) if addresses != None: return addresses - addresses = set() + addresses = list() cmd = "gpg --no-default-keyring %s --fingerprint %s" \ % (gpg_keyring_args(), fingerprint) (result, output) = commands.getstatusoutput(cmd) @@ -1395,7 +1395,7 @@ def gpg_get_key_addresses(fingerprint): for l in output.split('\n'): m = re_gpg_uid.match(l) if m: - addresses.add(m.group(1)) + addresses.append(m.group(1)) key_uid_email_cache[fingerprint] = addresses return addresses @@ -1562,3 +1562,27 @@ def get_packages_from_ftp(root, suite, component, architecture): def deb_extract_control(fh): """extract DEBIAN/control from a binary package""" return apt_inst.DebFile(fh).control.extractdata("control") + +################################################################################ + +def mail_addresses_for_upload(maintainer, changed_by, fingerprint): + """Mail addresses to contact for an upload + + Args: + maintainer (str): Maintainer field of the changes file + changed_by (str): Changed-By field of the changes file + fingerprint (str): Fingerprint of the PGP key used to sign the upload + + Returns: + List of RFC 2047-encoded mail addresses to contact regarding this upload + """ + addresses = [maintainer] + if changed_by != maintainer: + addresses.append(changed_by) + + fpr_addresses = gpg_get_key_addresses(fingerprint) + if fix_maintainer(changed_by)[3] not in fpr_addresses and fix_maintainer(maintainer)[3] not in fpr_addresses: + addresses.append(fpr_addresses[0]) + + encoded_addresses = [ fix_maintainer(e)[1] for e in addresses ] + return encoded_addresses