7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
1 |
#!/usr/bin/python
|
2 |
#
|
|
3 |
# python port of the nice maintainace-check script by Nick Barcet
|
|
4 |
#
|
|
5 |
# taken from:
|
|
6 |
# https://code.edge.launchpad.net/~mvo/ubuntu-maintenance-check/python-port
|
|
7 |
# (where it will vanish once taken here)
|
|
8 |
||
7675.633.8
by Michael Vogt
cronscripts/publishing/maintenance-check.py: create required dirs/files in rootdir (for older python-apt versions) |
9 |
# this warning filter is only needed on older versions of python-apt,
|
10 |
# once the machine runs lucid it can be removed
|
|
11 |
import warnings |
|
12 |
warnings.filterwarnings("ignore","apt API not stable yet") |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
13 |
import apt |
7675.633.8
by Michael Vogt
cronscripts/publishing/maintenance-check.py: create required dirs/files in rootdir (for older python-apt versions) |
14 |
warnings.resetwarnings() |
15 |
||
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
16 |
import apt_pkg |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
17 |
import logging |
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
18 |
import os |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
19 |
import sys |
20 |
import urllib2 |
|
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
21 |
import urlparse |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
22 |
|
23 |
from optparse import OptionParser |
|
24 |
||
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
25 |
# This is fun! We have a bunch of cases for 10.04 LTS
|
26 |
#
|
|
27 |
# - distro "ubuntu" follows SUPPORT_TIMEFRAME_LTS but only for
|
|
28 |
# amd64/i386
|
|
29 |
# - distros "kubuntu", "edubuntu" and "netbook" need to be
|
|
30 |
# considered *but* only follow SUPPORT_TIMEFRAME
|
|
31 |
# - anything that is in armel follows SUPPORT_TIMEFRAME
|
|
32 |
#
|
|
7675.481.3
by Michael Vogt
cronscripts/publishing/maintenance-check.py: only add Supported tag for the suported architectures |
33 |
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
34 |
# codename of the lts releases
|
35 |
LTS_RELEASES = [ "dapper", "hardy", "lucid" ] |
|
36 |
||
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
37 |
# architectures that are full supported (including LTS time)
|
38 |
PRIMARY_ARCHES = ["i386", "amd64"] |
|
39 |
||
40 |
# architectures we support (but not for LTS time)
|
|
41 |
SUPPORTED_ARCHES = PRIMARY_ARCHES + ["armel"] |
|
42 |
||
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
43 |
# what defines the seeds is documented in wiki.ubuntu.com/SeedManagement
|
7675.633.6
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add "server-ship" to the SERVER_SEEDS |
44 |
SERVER_SEEDS = [ "supported-server", "server-ship"] |
7675.642.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add supported-desktop-extra seed to ensure we can fine tune 3y support per desktop (supported-desktop is not flexible enough for this as it lives in plattform.lucid and not in (k)ubuntu.lucid) |
45 |
DESKTOP_SEEDS = ["ship", "supported-desktop", "supported-desktop-extra"] |
7675.481.6
by Michael Vogt
cronscripts/publishing/maintenance-check.py: use "all" as the supported seed |
46 |
SUPPORTED_SEEDS = [ "all" ] |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
47 |
|
48 |
# normal support timeframe
|
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
49 |
# time, seeds, arches
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
50 |
SUPPORT_TIMEFRAME = [ |
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
51 |
("18m", SUPPORTED_SEEDS), |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
52 |
]
|
53 |
||
54 |
# lts support timeframe
|
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
55 |
# time, seeds, arches
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
56 |
SUPPORT_TIMEFRAME_LTS = [ |
57 |
("5y", SERVER_SEEDS), |
|
58 |
("3y", DESKTOP_SEEDS), |
|
59 |
("18m", SUPPORTED_SEEDS), |
|
60 |
]
|
|
61 |
||
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
62 |
# distro names and if they get LTS support (order is important)
|
63 |
DISTRO_NAMES_AND_LTS_SUPPORT = [ ("ubuntu", True), |
|
7675.630.1
by Michael Vogt
kubuntu is supported for 3y according to https://wiki.ubuntu.com/LucidLynx/ReleaseManifest |
64 |
("kubuntu", True), |
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
65 |
("netbook", False), |
66 |
]
|
|
67 |
||
68 |
# germinate output base directory
|
|
69 |
BASE_URL = "http://people.canonical.com/~ubuntu-archive/germinate-output/" |
|
70 |
||
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
71 |
# hints dir url, hints file is "$distro.hints" by default
|
72 |
# (e.g. lucid.hints)
|
|
7675.633.5
by Michael Vogt
cronscripts/publishing/maintenance-check.py: updated for final hints filename/destination, add debug outout if hints_file is not found |
73 |
HINTS_DIR_URL = "http://people.canonical.com/~ubuntu-archive/seeds/platform.%s/SUPPORTED_HINTS" |
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
74 |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
75 |
# we need the archive root to parse the Sources file to support
|
76 |
# by-source hints
|
|
77 |
ARCHIVE_ROOT = "http://archive.ubuntu.com/ubuntu" |
|
78 |
||
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
79 |
# support timeframe tag used in the Packages file
|
80 |
SUPPORT_TAG = "Supported" |
|
81 |
||
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
82 |
def get_binaries_for_source_pkg(srcname): |
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
83 |
""" Return all binary package names for the given source package name.
|
84 |
||
85 |
:param srcname: The source package name.
|
|
86 |
:return: A list of binary package names.
|
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
87 |
"""
|
88 |
pkgnames = set() |
|
89 |
recs = apt_pkg.GetPkgSrcRecords() |
|
90 |
while recs.Lookup(srcname): |
|
7675.633.4
by Michael Vogt
cronscripts/publishing/maintenance-check.py: fix for old 0.7.x python-apt API |
91 |
for binary in recs.Binaries: |
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
92 |
pkgnames.add(binary) |
93 |
return pkgnames |
|
94 |
||
95 |
def expand_src_pkgname(pkgname): |
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
96 |
""" Expand a package name if it is prefixed with src.
|
97 |
||
98 |
If the package name is prefixed with src it will be expanded
|
|
99 |
to a list of binary package names. Otherwise the original
|
|
100 |
package name will be returned.
|
|
101 |
|
|
102 |
:param pkgname: The package name (that may include src:prefix).
|
|
103 |
:return: A list of binary package names (the list may be one element long).
|
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
104 |
"""
|
105 |
if not pkgname.startswith("src:"): |
|
106 |
return [pkgname] |
|
107 |
return get_binaries_for_source_pkg(pkgname.split("src:")[1]) |
|
108 |
||
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
109 |
def create_and_update_deb_src_source_list(distroseries): |
110 |
""" Create sources.list and update cache.
|
|
111 |
||
112 |
This creates a sources.list file with deb-src entries for a given
|
|
113 |
distroseries and apt.Cache.update() to make sure the data is up-to-date.
|
|
114 |
:param distro: The code name of the distribution series (e.g. lucid).
|
|
115 |
:return: None
|
|
116 |
:raises: IOError: When cache update fails.
|
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
117 |
"""
|
118 |
# apt root dir
|
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
119 |
rootdir="./aptroot.%s" % distroseries |
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
120 |
sources_list_dir = os.path.join(rootdir, "etc","apt") |
121 |
if not os.path.exists(sources_list_dir): |
|
122 |
os.makedirs(sources_list_dir) |
|
123 |
sources_list = open(os.path.join(sources_list_dir, "sources.list"),"w") |
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
124 |
for pocket in [ |
125 |
"%s" % distroseries, |
|
126 |
"%s-updates" % distroseries, |
|
127 |
"%s-security" % distroseries]: |
|
128 |
sources_list.write( |
|
129 |
"deb-src %s %s main restricted\n" % ( |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
130 |
ARCHIVE_ROOT, pocket)) |
7675.642.4
by Michael Vogt
cronscripts/publishing/maintenance-check.py: collect leftover packages in main that are not in a seed. there shouldn't be any, but there are some |
131 |
sources_list.write( |
132 |
"deb %s %s main restricted\n" % ( |
|
133 |
ARCHIVE_ROOT, pocket)) |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
134 |
sources_list.close() |
7675.633.8
by Michael Vogt
cronscripts/publishing/maintenance-check.py: create required dirs/files in rootdir (for older python-apt versions) |
135 |
# create required dirs/files for apt.Cache(rootdir) to work on older
|
136 |
# versions of python-apt. once lucid is used it can be removed
|
|
137 |
for d in ["var/lib/dpkg", |
|
138 |
"var/cache/apt/archives/partial", |
|
139 |
"var/lib/apt/lists/partial"]: |
|
140 |
if not os.path.exists(os.path.join(rootdir,d)): |
|
141 |
os.makedirs(os.path.join(rootdir,d)) |
|
142 |
if not os.path.exists(os.path.join(rootdir,"var/lib/dpkg/status")): |
|
143 |
open(os.path.join(rootdir,"var/lib/dpkg/status"),"w") |
|
144 |
# open cache with our just prepared rootdir
|
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
145 |
cache = apt.Cache(rootdir=rootdir) |
7675.642.8
by Michael Vogt
cronscripts/publishing/maintenance-check.py: log update() errors (caused e.g. by proxies) but continue, its ok to have slightly outdated data) |
146 |
try: |
147 |
cache.update(apt.progress.FetchProgress()) |
|
148 |
except SystemError: |
|
149 |
logging.exception("cache.update() failed") |
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
150 |
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
151 |
def get_structure(distroname, version): |
152 |
""" Get structure file conent for named distro and distro version.
|
|
153 |
|
|
154 |
:param name: Name of the distribution (e.g. kubuntu, ubuntu, xubuntu).
|
|
155 |
:param version: Code name of the distribution version (e.g. lucid).
|
|
156 |
:return: List of strings with the structure file content
|
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
157 |
"""
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
158 |
f = urllib2.urlopen("%s/%s.%s/structure" % (BASE_URL, distroname, version)) |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
159 |
structure = f.readlines() |
160 |
f.close() |
|
161 |
return structure |
|
162 |
||
163 |
def expand_seeds(structure, seedname): |
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
164 |
""" Expand seed by its dependencies using the strucure file.
|
165 |
||
166 |
:param structure: The content of the STRUCTURE file as string list.
|
|
167 |
:param seedname: The name of the seed as string that needs to be expanded.
|
|
168 |
:return: a set() for the seed dependencies (excluding the original seedname)
|
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
169 |
"""
|
170 |
seeds = [] |
|
171 |
for line in structure: |
|
172 |
if line.startswith("%s:" % seedname): |
|
173 |
seeds += line.split(":")[1].split() |
|
174 |
for seed in seeds: |
|
175 |
seeds += expand_seeds(structure, seed) |
|
176 |
return set(seeds) |
|
177 |
||
178 |
def get_packages_for_seeds(name, distro, seeds): |
|
179 |
"""
|
|
180 |
get packages for the given name (e.g. ubuntu) and distro release
|
|
181 |
(e.g. lucid) that are in the given list of seeds
|
|
182 |
returns a set() of package names
|
|
183 |
"""
|
|
184 |
pkgs_in_seeds = {} |
|
185 |
for bseed in seeds: |
|
186 |
for seed in [bseed]: #, bseed+".build-depends", bseed+".seed"]: |
|
187 |
pkgs_in_seeds[seed] = set() |
|
188 |
seedurl = "%s/%s.%s/%s" % (BASE_URL,name, distro, seed) |
|
189 |
logging.debug("looking for '%s'" % seedurl) |
|
190 |
try: |
|
191 |
f = urllib2.urlopen(seedurl) |
|
192 |
for line in f: |
|
193 |
# ignore lines that are not a package name (headers etc)
|
|
194 |
if line[0] < 'a' or line[0] > 'z': |
|
195 |
continue
|
|
196 |
# lines are (package,source,why,maintainer,size,inst-size)
|
|
197 |
if options.source_packages: |
|
198 |
pkgname = line.split("|")[1] |
|
199 |
else: |
|
200 |
pkgname = line.split("|")[0] |
|
201 |
pkgs_in_seeds[seed].add(pkgname.strip()) |
|
202 |
f.close() |
|
203 |
except Exception, e: |
|
204 |
logging.error("seed %s failed (%s)" % (seedurl, e)) |
|
205 |
return pkgs_in_seeds |
|
206 |
||
207 |
def what_seeds(pkgname, seeds): |
|
208 |
in_seeds = set() |
|
209 |
for s in seeds: |
|
210 |
if pkgname in seeds[s]: |
|
211 |
in_seeds.add(s) |
|
212 |
return in_seeds |
|
213 |
||
7675.642.2
by Michael Vogt
cronscripts/publishing/maintenance-check.py: deal properly with packages in multiple seeds that have different support levels (pick the highest support level than) |
214 |
def compare_support_level(x, y): |
215 |
"""
|
|
216 |
compare two support level strings of the form 18m, 3y etc
|
|
217 |
:parm x: the first support level
|
|
218 |
:parm y: the second support level
|
|
219 |
:return: negative if x < y, zero if x==y, positive if x > y
|
|
220 |
"""
|
|
221 |
def support_to_int(support_time): |
|
222 |
"""
|
|
223 |
helper that takes a support time string and converts it to
|
|
224 |
a integer for cmp()
|
|
225 |
"""
|
|
226 |
# allow strings like "5y (kubuntu-common)
|
|
227 |
x = support_time.split()[0] |
|
228 |
if x.endswith("y"): |
|
229 |
return 12 * int(x[0:-1]) |
|
230 |
elif x.endswith("m"): |
|
231 |
return int(x[0:-1]) |
|
232 |
else: |
|
233 |
raise ValueError("support time '%s' has to end with y or m" % x) |
|
234 |
return cmp(support_to_int(x), support_to_int(y)) |
|
235 |
||
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
236 |
def get_packages_support_time(structure, name, pkg_support_time, support_timeframe_list): |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
237 |
"""
|
238 |
input a structure file and a list of pair<timeframe, seedlist>
|
|
239 |
return a dict of pkgnames -> support timeframe string
|
|
240 |
"""
|
|
241 |
for (timeframe, seedlist) in support_timeframe_list: |
|
242 |
expanded = set() |
|
243 |
for s in seedlist: |
|
244 |
expanded.add(s) |
|
245 |
expanded |= expand_seeds(structure, s) |
|
246 |
pkgs_in_seeds = get_packages_for_seeds(name, distro, expanded) |
|
247 |
for seed in pkgs_in_seeds: |
|
248 |
for pkg in pkgs_in_seeds[seed]: |
|
249 |
if not pkg in pkg_support_time: |
|
250 |
pkg_support_time[pkg] = timeframe |
|
7675.642.2
by Michael Vogt
cronscripts/publishing/maintenance-check.py: deal properly with packages in multiple seeds that have different support levels (pick the highest support level than) |
251 |
else: |
252 |
old_timeframe = pkg_support_time[pkg] |
|
253 |
if compare_support_level(old_timeframe, timeframe) < 0: |
|
254 |
logging.debug("overwriting %s from %s to %s" % ( |
|
255 |
pkg, old_timeframe, timeframe)) |
|
256 |
pkg_support_time[pkg] = timeframe |
|
257 |
if options.with_seeds: |
|
258 |
pkg_support_time[pkg] += " (%s)" % ", ".join(what_seeds(pkg, pkgs_in_seeds)) |
|
259 |
||
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
260 |
|
261 |
return pkg_support_time |
|
262 |
||
263 |
if __name__ == "__main__": |
|
264 |
parser = OptionParser() |
|
265 |
parser.add_option("--with-seeds", "", default=False, |
|
266 |
action="store_true", |
|
267 |
help="add seed(s) of the package that are responsible for the maintaince time") |
|
268 |
parser.add_option("--source-packages", "", default=False, |
|
269 |
action="store_true", |
|
270 |
help="show as source pkgs") |
|
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
271 |
parser.add_option("--hints-file", "", default=None, |
272 |
help="use diffenrt use hints file location") |
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
273 |
(options, args) = parser.parse_args() |
274 |
||
275 |
# init
|
|
276 |
if len(args) > 0: |
|
277 |
distro = args[0] |
|
278 |
if distro[0] < 'h': |
|
279 |
print "ERROR: only hardy or later is supported" |
|
280 |
sys.exit(1) |
|
281 |
else: |
|
282 |
distro = "lucid" |
|
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
283 |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
284 |
# make sure our deb-src information is up-to-date
|
285 |
create_and_update_deb_src_source_list(distro) |
|
286 |
||
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
287 |
if options.hints_file: |
288 |
hints_file = options.hints_file |
|
289 |
(schema, netloc, path, query, fragment) = urlparse.urlsplit(hints_file) |
|
290 |
if not schema: |
|
291 |
hints_file = "file:%s" % path |
|
292 |
else: |
|
7675.633.3
by Michael Vogt
update hints file location, add hints overwrite information to maintenance-check.stderr output |
293 |
hints_file = HINTS_DIR_URL % distro |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
294 |
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
295 |
# go over the distros we need to check
|
296 |
pkg_support_time = {} |
|
297 |
for (name, lts_supported) in DISTRO_NAMES_AND_LTS_SUPPORT: |
|
298 |
||
299 |
# get basic structure file
|
|
300 |
structure = get_structure(name, distro) |
|
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
301 |
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
302 |
# get dicts of pkgname -> support timeframe string
|
303 |
support_timeframe = SUPPORT_TIMEFRAME |
|
304 |
if lts_supported and distro in LTS_RELEASES: |
|
305 |
support_timeframe = SUPPORT_TIMEFRAME_LTS |
|
306 |
else: |
|
307 |
support_timeframe = SUPPORT_TIMEFRAME |
|
308 |
get_packages_support_time(structure, name, pkg_support_time, support_timeframe) |
|
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
309 |
|
7675.642.4
by Michael Vogt
cronscripts/publishing/maintenance-check.py: collect leftover packages in main that are not in a seed. there shouldn't be any, but there are some |
310 |
# now go over the bits in main that we have not seen (because
|
311 |
# they are not in any seed and got added manually into "main"
|
|
7675.642.5
by Michael Vogt
cronscripts/publishing/maintenance-check.py: update/reopen the cache with the new arch |
312 |
for arch in PRIMARY_ARCHES: |
7675.642.4
by Michael Vogt
cronscripts/publishing/maintenance-check.py: collect leftover packages in main that are not in a seed. there shouldn't be any, but there are some |
313 |
rootdir="./aptroot.%s" % distro |
314 |
apt_pkg.Config.Set("APT::Architecture", arch) |
|
315 |
cache = apt.Cache(rootdir=rootdir) |
|
7675.642.8
by Michael Vogt
cronscripts/publishing/maintenance-check.py: log update() errors (caused e.g. by proxies) but continue, its ok to have slightly outdated data) |
316 |
try: |
317 |
cache.update(apt.progress.FetchProgress()) |
|
318 |
except SystemError: |
|
319 |
logging.exception("cache.update() failed") |
|
7675.642.6
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add compatibility with hardy python-apt |
320 |
cache.open(apt.progress.OpProgress()) |
7675.642.4
by Michael Vogt
cronscripts/publishing/maintenance-check.py: collect leftover packages in main that are not in a seed. there shouldn't be any, but there are some |
321 |
for pkg in cache: |
322 |
if not pkg.name in pkg_support_time: |
|
323 |
pkg_support_time[pkg.name] = support_timeframe[-1][0] |
|
324 |
logging.warn("add package in main but not in seeds %s with %s" % |
|
325 |
(pkg.name, pkg_support_time[pkg.name])) |
|
326 |
||
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
327 |
# now check the hints file that is used to overwrite
|
328 |
# the default seeds
|
|
329 |
try: |
|
330 |
for line in urllib2.urlopen(hints_file): |
|
331 |
line = line.strip() |
|
332 |
if not line or line.startswith("#"): |
|
333 |
continue
|
|
334 |
try: |
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
335 |
(raw_pkgname, support_time) = line.split() |
336 |
for pkgname in expand_src_pkgname(raw_pkgname): |
|
337 |
if support_time == 'unsupported': |
|
7675.633.3
by Michael Vogt
update hints file location, add hints overwrite information to maintenance-check.stderr output |
338 |
try: |
339 |
del pkg_support_time[pkgname] |
|
340 |
sys.stderr.write("hints-file: marking %s unsupported\n" % pkgname) |
|
341 |
except KeyError: |
|
342 |
pass
|
|
7675.633.2
by Michael Vogt
support src: prefix for src package hints |
343 |
else: |
7675.633.3
by Michael Vogt
update hints file location, add hints overwrite information to maintenance-check.stderr output |
344 |
if pkg_support_time.get(pkgname) != support_time: |
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
345 |
sys.stderr.write( |
346 |
"hints-file: changing %s from %s to %s\n" % ( |
|
347 |
pkgname, pkg_support_time.get(pkgname), |
|
348 |
support_time)) |
|
7675.633.3
by Michael Vogt
update hints file location, add hints overwrite information to maintenance-check.stderr output |
349 |
pkg_support_time[pkgname] = support_time |
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
350 |
except: |
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
351 |
logging.exception("can not parse line '%s'" % line) |
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
352 |
except urllib2.HTTPError, e: |
7675.720.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: urllib2.HTTPError has a code attribute, getcode() is only available for the old urllib |
353 |
if e.code != 404: |
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
354 |
raise
|
7675.633.5
by Michael Vogt
cronscripts/publishing/maintenance-check.py: updated for final hints filename/destination, add debug outout if hints_file is not found |
355 |
sys.stderr.write("hints-file: %s gave 404 error\n" % hints_file) |
7675.481.1
by Michael Vogt
* lib/lp/soyuz/scripts/maintenance-check.py: |
356 |
|
357 |
# output suitable for the extra-override file
|
|
358 |
for pkgname in sorted(pkg_support_time.keys()): |
|
7675.633.7
by Michael Vogt
address points raised in review (many thanks) |
359 |
# special case, the hints file may contain overrides that
|
7675.633.1
by Michael Vogt
cronscripts/publishing/maintenance-check.py: add support for a ".binary-hints" file that can be used to overwrite the seed support timeframe |
360 |
# are arch-specific (like zsh-doc/armel)
|
361 |
if "/" in pkgname: |
|
362 |
print "%s %s %s" % ( |
|
363 |
pkgname, SUPPORT_TAG, pkg_support_time[pkgname]) |
|
364 |
else: |
|
365 |
# go over the supported arches, they are divided in
|
|
366 |
# first-class (PRIMARY) and second-class with different
|
|
367 |
# support levels
|
|
368 |
for arch in SUPPORTED_ARCHES: |
|
369 |
# ensure we do not overwrite arch-specific overwrites
|
|
370 |
pkgname_and_arch = "%s/%s" % (pkgname, arch) |
|
371 |
if pkgname_and_arch in pkg_support_time: |
|
372 |
break
|
|
373 |
if arch in PRIMARY_ARCHES: |
|
374 |
# arch with full LTS support
|
|
375 |
print "%s %s %s" % ( |
|
376 |
pkgname_and_arch, SUPPORT_TAG, pkg_support_time[pkgname]) |
|
377 |
else: |
|
378 |
# not a LTS supported architecture, gets only regular
|
|
379 |
# support_timeframe
|
|
380 |
print "%s %s %s" % ( |
|
381 |
pkgname_and_arch, SUPPORT_TAG, SUPPORT_TIMEFRAME[0][0]) |
|
7675.481.5
by Michael Vogt
add armel case and proper checking for all of main |
382 |