3
3
# python port of the nice maintainace-check script by Nick Barcet
6
6
# https://code.edge.launchpad.net/~mvo/ubuntu-maintenance-check/python-port
7
7
# (where it will vanish once taken here)
9
# this warning filter is only needed on older versions of python-apt,
10
# once the machine runs lucid it can be removed
14
warnings.filterwarnings("ignore", "apt API not stable yet")
16
warnings.resetwarnings()
10
from optparse import OptionParser
25
from optparse import OptionParser
27
19
# This is fun! We have a bunch of cases for 10.04 LTS
85
77
# germinate output base directory
86
78
BASE_URL = os.environ.get(
87
"MAINTENANCE_CHECK_BASE_URL",
79
"MAINTENANCE_CHECK_BASE_URL",
88
80
"http://people.canonical.com/~ubuntu-archive/germinate-output/")
90
82
# hints dir url, hints file is "$distro.hints" by default
91
83
# (e.g. lucid.hints)
92
84
HINTS_DIR_URL = os.environ.get(
93
"MAINTENANCE_CHECK_HINTS_DIR_URL",
94
"http://people.canonical.com/~ubuntu-archive/seeds/platform.%s/SUPPORTED_HINTS")
85
"MAINTENANCE_CHECK_HINTS_DIR_URL",
86
"http://people.canonical.com/"
87
"~ubuntu-archive/seeds/platform.%s/SUPPORTED_HINTS")
96
89
# we need the archive root to parse the Sources file to support
192
185
def expand_seeds(structure, seedname):
193
""" Expand seed by its dependencies using the strucure file.
186
"""Expand seed by its dependencies using the strucure file.
195
188
:param structure: The content of the STRUCTURE file as string list.
196
189
:param seedname: The name of the seed as string that needs to be expanded.
197
:return: a set() for the seed dependencies (excluding the original
190
:return: A set() for the seed dependencies (excluding the original
201
194
for line in structure:
209
202
def get_packages_for_seeds(name, distro, seeds):
211
get packages for the given name (e.g. ubuntu) and distro release
204
Get packages for the given name (e.g. ubuntu) and distro release
212
205
(e.g. lucid) that are in the given list of seeds
213
returns a set() of package names
206
returns a set() of package names.
215
208
pkgs_in_seeds = {}
217
for seed in [bseed]: #, bseed+".build-depends", bseed+".seed"]:
218
pkgs_in_seeds[seed] = set()
219
seedurl = "%s/%s.%s/%s" % (BASE_URL, name, distro, seed)
220
logging.debug("looking for '%s'" % seedurl)
222
f = urllib2.urlopen(seedurl)
224
# ignore lines that are not a package name (headers etc)
225
if line[0] < 'a' or line[0] > 'z':
227
# lines are (package,source,why,maintainer,size,inst-size)
228
if options.source_packages:
229
pkgname = line.split("|")[1]
231
pkgname = line.split("|")[0]
232
pkgs_in_seeds[seed].add(pkgname.strip())
235
logging.error("seed %s failed (%s)" % (seedurl, e))
210
pkgs_in_seeds[seed] = set()
211
seedurl = "%s/%s.%s/%s" % (BASE_URL, name, distro, seed)
212
logging.debug("looking for '%s'", seedurl)
214
f = urllib2.urlopen(seedurl)
216
# Ignore lines that are not package names (headers etc).
217
if line[0] < 'a' or line[0] > 'z':
219
# Each line contains these fields:
220
# (package, source, why, maintainer, size, inst-size)
221
if options.source_packages:
222
pkgname = line.split("|")[1]
224
pkgname = line.split("|")[0]
225
pkgs_in_seeds[seed].add(pkgname.strip())
227
except Exception as e:
228
logging.error("seed %s failed (%s)" % (seedurl, e))
236
229
return pkgs_in_seeds
355
347
# now go over the bits in main that we have not seen (because
356
348
# they are not in any seed and got added manually into "main"
357
349
for arch in PRIMARY_ARCHES:
358
rootdir="./aptroot.%s" % distro
350
rootdir = "./aptroot.%s" % distro
359
351
apt_pkg.Config.Set("APT::Architecture", arch)
360
352
cache = apt.Cache(rootdir=rootdir)