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
|
#!/usr/bin/python
import apt_pkg
import argparse
from distro_info import UbuntuDistroInfo
from launchpadlib.launchpad import Launchpad
import re
import sys
parser = argparse.ArgumentParser(description="Retry builds whoes build-deps are built now.")
parser.add_argument("-d", "--dist", default=UbuntuDistroInfo().devel(), help="Distribution name (default: current development release)")
parser.add_argument("--ppa", action="store_true", help="Check the PPA instead of the main archive.")
parser.add_argument("--proposed", action="store_true", help="Check the proposed pocket instead of release.")
args = parser.parse_args()
release = args.dist
ppa = args.ppa
if args.proposed:
pocket = "Proposed"
else:
pocket = "Release"
apt_pkg.init()
lp = Launchpad.login_with("kubuntu-retry-builds", "production")
ubuntu = lp.distributions["ubuntu"]
lpseries = ubuntu.getSeries(name_or_version=release)
if ppa:
archive = lp.people["kubuntu-ninjas"].getPPAByName(name="ppa")
else:
archive = ubuntu.main_archive
def get_log(url):
# hack to get build log for private PPAs
url = url.replace("https://launchpad.net/", "https://api.launchpad.net/devel/")
return lp._browser.get(url)
def get_binary_version(binaryName, arch):
archSeries = lpseries.getDistroArchSeries(archtag=arch)
binaries = archive.getPublishedBinaries(distro_arch_series=archSeries, status="Published", binary_name=binaryName, exact_match=True)
if not binaries:
return False
else:
return binaries[0].binary_package_version
def can_retry(log, arch):
matches = re.findall(r'Breaks: ([^ ]+) \(< ([^\)]+)\)', log)
if not matches:
return False
for match in matches:
currentVersion = get_binary_version(match[0], arch)
if not currentVersion:
return False
if apt_pkg.version_compare(currentVersion, match[1]) < 0:
return False
return True
f = open("kdesc-packages-"+release+".txt", "r")
kdesc = f.readlines()
f.close()
kdesc = map(lambda line: line.strip("\r\n\t "), kdesc)
kdesc = filter(lambda line: line and not line.startswith("#"), kdesc)
# move libraries to the front
kdesc.sort(key=lambda package: package.find("lib") != -1 and "_" + package or package)
for package in kdesc:
sources = archive.getPublishedSources(distro_series=lpseries, exact_match=True, status="Published", pocket=pocket, source_name=package)
try:
source = sources[0]
except IndexError:
print >> sys.stderr, "Package not found: " + package
continue
for build in source.getBuilds():
if build.buildstate != "Failed to build":
continue
arch = build.arch_tag
log = get_log(build.build_log_url)
if can_retry(log, arch):
print "Retrying %s (%s)" % (source.source_package_name, arch)
build.retry()
else:
print "Can't retry: %s (%s)" % (source.source_package_name, arch)
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space on;
|