-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathack-report
executable file
·133 lines (96 loc) · 3.98 KB
/
ack-report
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import glob
import time
from pisi.package import Package
# Generates detailed statistics about pisi files
test_path = "/var/cache/pisi/packages-test"
stable_path = "/var/cache/pisi/packages-stable"
template = """\
* Ver.: %s, Rel.: %s, Type: %s
* %s [%s]
%s
"""
def get_package_name(filename):
return filename.rstrip(".pisi").rsplit("-", 3)[0]
def get_package_build(filename):
return int(filename.rstrip(".pisi").rsplit("-", 3)[3])
def get_package_release(filename):
if filename:
return int(filename.rstrip(".pisi").rsplit("-", 3)[2])
else:
return 0
def get_latest_package(package):
""" Returns the file name corresponding to the
latest release of the package 'package_name' found in 'path'."""
file_list = glob.glob1(stable_path, "%s-[0-9]*-[0-9]*-[0-9]*.pisi" % get_package_name(package))
file_list.sort(cmp=lambda x,y:get_package_build(x)-get_package_build(y), reverse=True)
try:
name = file_list[0]
return name
except IndexError:
return ""
def main(file_list):
files = [_f.rstrip() for _f in open(file_list, "rb").read().strip().split("\n")]
d = {}
for f in files:
if os.path.exists(os.path.join(test_path, f)):
name = get_package_name(f)
latest_package = get_latest_package(f)
current_release = get_package_release(f)
stable_release = get_package_release(latest_package)
if f != latest_package:
metadata = Package(os.path.join(test_path, f)).get_metadata()
packager = "%s <%s>" % (metadata.source.packager.name, metadata.source.packager.email.replace('@', '_at_'))
changes = ""
if not latest_package and metadata.source.name != metadata.package.name:
h = metadata.package.history[0]
changes += template % (h.version, h.release, h.type,
("%s <%s>" % (h.name, h.email.replace('@', '_at_'))), h.date,
"Splitted from %s" % metadata.source.name)
else:
for h in metadata.package.history[0:current_release-stable_release]:
changes += template % (h.version, h.release, h.type,
("%s <%s>" % (h.name, h.email.replace('@', '_at_'))), h.date,
"\n ".join([l.strip() for l in h.comment.split('\n')]))
d[name] = [current_release, stable_release, packager, changes]
# Generate statistics file
stats = open("stats-%s" % "-".join([str(i) for i in time.localtime()[:3]]), "wb")
stats.write("Testing->Stable merge reports for %s\n%s\n\n" % (time.asctime(), '-'*60))
new_packages = []
security_updates = []
for package in d.keys():
if d[package][1] == 0:
new_packages.append(package)
if "Type: security" in d[package][3]:
security_updates.append(package)
stats.write("** Total new packages: %d\n" % len(new_packages))
for p in new_packages:
stats.write(" * %s\n" % p)
stats.write("\n** Total security updates: %d\n" % len(security_updates))
for p in security_updates:
stats.write(" * %s\n" % p)
stats.close()
keys = d.keys()
keys.sort()
for p in keys:
print "= Package : %s [%s]" % (p, d[p][2])
print "="*70
print d[p][3],
if __name__ == "__main__":
if len(sys.argv) != 2:
print "Generates ACK/NACK list by looking difference of these directories:"
print " %s" % test_path
print " %s" % stable_path
print
print "Usage:"
print " %s <file_list>" % sys.argv[0]
sys.exit(1)
else:
file_list = sys.argv[1]
if not os.path.exists(file_list):
print "%s doesn't exist!" % file_list
sys.exit(1)
sys.exit(main(file_list))