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
110
111
112
113 | #!/usr/bin/python
import optparse
import pymod2pkg
import subprocess
from prettytable import PrettyTable
EXCLUDED_PROJECTS = [
'diskimage-builder',
'os-apply-config',
'os-cloud-config',
'os-collect-config',
'os-net-config',
'os-refresh-config',
'tripleo-common',
'backports.ssl-match-hostname',
'ndg-httpsclient',
'packaging',
'python-editor',
'qpid-python',
'restructuredtext-lint',
'virtualenv',
'xvfbwrapper',
]
UC = 'upper-constraints.txt'
def filter_openstack_projects(project):
return project not in EXCLUDED_PROJECTS \
and not project.startswith('XStatic')
def load_uc(projects_filter):
uc = {}
with open(UC, 'rb') as ucfiles:
for line in ucfiles.readlines():
name, version_spec = line.rstrip().split('===')
if name and projects_filter(name):
version = version_spec.split(';')[0]
if version:
uc[name] = version
return uc
def get_ubuntu_version(pkg, series):
cmd = ['rmadison', '-s', series, pkg]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
output, error_output = process.communicate()
if process.wait() != 0:
if error_output:
return 'n/a'
try:
for line in output.strip().splitlines():
pkg, ver, dist, arches = [x.strip() for x in line.split('|')]
if ver == 'None':
return 'Not Packaged'
return ver
except:
return 'n/a'
def compare_upper_constraints(newer, older):
if older is None:
return '???'
dpkg = subprocess.Popen(['dpkg', '--compare-versions', older, 'ge', newer])
dpkg.communicate()
rc = dpkg.returncode
if rc == 1:
return ''
else:
return 'X'
if __name__ == '__main__':
uc = load_uc(filter_openstack_projects)
parser = optparse.OptionParser(usage="usage: %prog -s <distro release")
parser.add_option('--series', help='Distro series to compare against.')
(opt, args) = parser.parse_args
if opt.series:
series = opt.series
else:
series = 'zesty'
table = PrettyTable(['Source Package', 'Debian Package',
'Upper Constraints', 'Ubuntu Version', 'Version Check'])
for pkg, version in sorted(uc.iteritems()):
p = pymod2pkg.module2package(pkg, 'ubuntu')
if 'python-python-' in p:
p = p.replace('python-python', 'python')
if 'python-libvirt-python' in p:
p = p.replace('python-libvirt-python', 'python-libvirt')
if 'python-pycrypto' in p:
p = p.replace('python-pycrypto', 'python-crypto')
if 'amqp' in p:
p = p.replace('python-amqp', 'python-amqplib')
if 'pykerberos' in p:
p = p.replace('pykerberos', 'pykerberos')
if 'pykerberos' in p:
p = p.replace('pytz', 'python-tz')
u_v = get_ubuntu_version(p)
if u_v is None:
v = 'Not Packaged.'
else:
v = compare_upper_constraints(version, u_v))
table.add_row([pkg,
p,
version,
get_ubuntu_version(p, series),
v])
print table
|