1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/bin/python
# (C) 2011 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@canonical.com>
# License: GPL-2+
#
# Process two reports of component-mismatches, and email new source
# universe->main promotions to the release team.
#from launchpadlib.launchpad import Launchpad
import difflib
import sys
import smtplib
from email.mime.text import MIMEText
def release_team_emails():
'''Return a list of email addresses of the release team.'''
# this only works authenticated:
#lp = Launchpad.login_anonymously('process-component-mismatches-diff', 'production')
#addresses = []
#for member in lp.people['ubuntu-release'].members_details:
# addresses.append(member.member.preferred_email_address_link.split('/')[-1])
#return addresses
return ['martin.pitt@ubuntu.com',
'cjwatson@canonical.com',
'iain@orangesquash.org.uk',
'ubuntu@kitterman.com',
'steve.langasek@canonical.com',
'stefan.potyra@informatik.uni-erlangen.de']
def read_file(filename):
'''Read the output of component-mismatches.
Filter out the "source/binary promotion to main" part, as this is the only
part for which timely email notifications are helpful and appropriate.
Return a list of lines.
'''
f = open(filename)
result = []
# first, read until the first section starts
line = ''
while '----------' not in line:
line = f.readline()
if line == '':
return result
# slurp in the section
while True:
line = f.readline()
if line == '' or line.startswith('========='):
break
result.append(line)
f.close()
return result
def report(old_cm, new_cm):
'''Generate a report for the difference between two c-m results.'''
old = read_file(old_cm)
new = read_file(new_cm)
report = ''
for i in difflib.Differ().compare(old, new):
if i.startswith('+'):
report += i[1:]
return report
#
# main
#
if len(sys.argv) != 3:
sys.stderr.write('Usage: %s <old report> <new report>\n' % sys.argv[0])
sys.exit(0)
r = report(sys.argv[1], sys.argv[2])
if not r:
sys.exit()
r = '''The following universe packages have new reverse dependencies
in main or got seeded. They need to get a MainInclusionReport and be
promoted, or the reverse dependencies in main need to be dropped:
%s
Please see http://people.canonical.com/~ubuntu-archive/component-mismatches.txt
for the full report.
Please contact https://launchpad.net/~ubuntu-archive for problems with this
notification.
''' % r
# send mail
#addrs = release_team_emails()
addrs = ['ubuntu-release@lists.ubuntu.com']
msg = MIMEText(r)
msg['Subject'] = 'New component-mismatches for source universe -> main'
msg['From'] = 'process-component-mismatches-diff <martin.pitt@ubuntu.com>'
msg['To'] = ', '.join(addrs)
msgstr = msg.as_string()
for addr in addrs:
s = smtplib.SMTP()
s.connect()
s.sendmail('archive@ubuntu.com', addr, msgstr)
s.quit()
|