From: Joerg Jaspert Date: Thu, 19 Feb 2009 21:36:34 +0000 (+0100) Subject: suite_architectures X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e47619471d54d20613d18bb8ac928650513ab404;p=dak.git suite_architectures new function, daklib.database.get_suite_architectures. Use that instead of Cnf.ValueList("Suites::%s::Architectures") everywhere to find out which suite supports which architectures Signed-off-by: Joerg Jaspert --- diff --git a/dak/check_archive.py b/dak/check_archive.py index 65b5cae4..01876120 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -412,7 +412,7 @@ def check_indices_files_exist(): """ for suite in [ "stable", "testing", "unstable" ]: for component in Cnf.ValueList("Suite::%s::Components" % (suite)): - architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite)) + architectures = get_suite_architectures(suite) for arch in [ i.lower() for i in architectures ]: if arch == "source": validate_sources(suite, component) diff --git a/dak/check_proposed_updates.py b/dak/check_proposed_updates.py index 5b9283f7..57d068a3 100755 --- a/dak/check_proposed_updates.py +++ b/dak/check_proposed_updates.py @@ -242,7 +242,7 @@ def parse_packages(): suite = "stable" stable = {} components = Cnf.ValueList("Suite::%s::Components" % (suite)) - architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(utils.real_arch, get_suite_architectures(suite)) for component in components: for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages" % (Cnf["Dir::Root"], suite, component, architecture) diff --git a/dak/compare_suites.py b/dak/compare_suites.py index ab0ab3c0..22b00101 100755 --- a/dak/compare_suites.py +++ b/dak/compare_suites.py @@ -67,7 +67,7 @@ def main (): arch_all_id = database.get_architecture_id("all") dsc_type_id = database.get_override_type_id("dsc") - for arch in Cnf.ValueList("Suite::%s::Architectures" % (src_suite)): + for arch in get_suite_architectures(src_suite_id): if arch == "source": continue diff --git a/dak/cruft_report.py b/dak/cruft_report.py index d88c799b..19b02172 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -426,7 +426,7 @@ def main (): if suite != "experimental": check_components.append('main/debian-installer'); for component in check_components: - architectures = filter(utils.real_arch, Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(utils.real_arch, get_suite_architectures(suite)) for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suite, component, architecture) # apt_pkg.ParseTagFile needs a real file handle diff --git a/dak/import_archive.py b/dak/import_archive.py index d87d6ca9..d61a1a19 100755 --- a/dak/import_archive.py +++ b/dak/import_archive.py @@ -254,7 +254,7 @@ def update_suites (): for i in ("Version", "Origin", "Description"): if SubSec.has_key(i): projectB.query("UPDATE suite SET %s = '%s' WHERE suite_name = '%s'" % (i.lower(), SubSec[i], suite.lower())) - for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)): + for architecture in get_suite_architectures(suite): architecture_id = database.get_architecture_id (architecture) projectB.query("INSERT INTO suite_architectures (suite, architecture) VALUES (currval('suite_id_seq'), %d)" % (architecture_id)) @@ -570,8 +570,7 @@ Please read the documentation before running this script. udeb_components = map(lambda x: x+"/debian-installer", Cnf.ValueList("Suite::%s::UdebComponents" % suite)) for component in Cnf.SubTree("Component").List() + udeb_components: - architectures = filter(utils.real_arch, - Cnf.ValueList("Suite::%s::Architectures" % (suite))) + architectures = filter(utils.real_arch, get_suite_architectures(suite)) for architecture in architectures: packages = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/binary-' + architecture + '/Packages' print 'Processing '+packages+'...' diff --git a/dak/init_db.py b/dak/init_db.py index d40ad0c0..8f757a36 100755 --- a/dak/init_db.py +++ b/dak/init_db.py @@ -135,7 +135,7 @@ def do_suite(): projectB.query("INSERT INTO suite (suite_name, version, origin, " "description) VALUES ('%s', %s, %s, %s)" % (suite.lower(), version, origin, description)) - for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)): + for architecture in get_suite_architectures(suite): architecture_id = database.get_architecture_id (architecture) if architecture_id < 0: utils.fubar("architecture '%s' not found in architecture" diff --git a/dak/make_suite_file_list.py b/dak/make_suite_file_list.py index e754e77d..3f05de3a 100755 --- a/dak/make_suite_file_list.py +++ b/dak/make_suite_file_list.py @@ -296,7 +296,7 @@ def write_filelists(packages, dislocated_files): else: binary_types = [ "deb" ] if not Options["Architecture"]: - architectures = Cnf.ValueList("Suite::%s::Architectures" % (suite)) + architectures = get_suite_architectures(suite) else: architectures = utils.split_args(Options["Architectures"]) for arch in [ i.lower() for i in architectures ]: diff --git a/dak/new_security_install.py b/dak/new_security_install.py index c72641a2..7858fd0e 100755 --- a/dak/new_security_install.py +++ b/dak/new_security_install.py @@ -386,7 +386,7 @@ def generate_advisory(template): ver, suite) adv += "%s\n%s\n\n" % (suite_header, "-"*len(suite_header)) - arches = Cnf.ValueList("Suite::%s::Architectures" % suite) + arches = get_suite_architectures(suite) if "source" in arches: arches.remove("source") if "all" in arches: diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 1ec04563..4c87a17a 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -289,7 +289,7 @@ def check_distributions(): (source, dest) = args[1:3] if changes["distribution"].has_key(source): for arch in changes["architecture"].keys(): - if arch not in Cnf.ValueList("Suite::%s::Architectures" % (source)): + if arch not in get_suite_architectures(source): reject("Mapping %s to %s for unreleased architecture %s." % (source, dest, arch),"") del changes["distribution"][source] changes["distribution"][dest] = 1 @@ -451,7 +451,7 @@ def check_files(): default_suite = Cnf.get("Dinstall::DefaultSuite", "Unstable") architecture = control.Find("Architecture") upload_suite = changes["distribution"].keys()[0] - if architecture not in Cnf.ValueList("Suite::%s::Architectures" % (default_suite)) and architecture not in Cnf.ValueList("Suite::%s::Architectures" % (upload_suite)): + if architecture not in get_suite_architectures(default_suite) and architecture not in get_suite_architectures(upload_suite): reject("Unknown architecture '%s'." % (architecture)) # Ensure the architecture of the .deb is one of the ones diff --git a/dak/rm.py b/dak/rm.py index 005653e5..6a76eb78 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -100,7 +100,7 @@ def reverse_depends_check(removals, suites, arches=None): if arches: all_arches = set(arches) else: - all_arches = set(Cnf.ValueList("Suite::%s::Architectures" % suites[0])) + all_arches = set(get_suite_architectures(suites[0])) all_arches -= set(["source", "all"]) for architecture in all_arches: deps = {} diff --git a/dak/stats.py b/dak/stats.py index 105bf6c9..d8bf457f 100755 --- a/dak/stats.py +++ b/dak/stats.py @@ -179,7 +179,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""") for suite in suite_list: suite_id = suite_ids[suite] suite_arches[suite_id] = {} - for arch in Cnf.ValueList("Suite::%s::Architectures" % (suite)): + for arch in get_suite_architectures(suite): suite_arches[suite_id][arch] = "" suite_id_list.append(suite_id) output_list = [ output_format(i) for i in suite_list ] diff --git a/daklib/database.py b/daklib/database.py index 1882ad8b..3fbd2a50 100755 --- a/daklib/database.py +++ b/daklib/database.py @@ -3,7 +3,8 @@ """ DB access functions @group readonly: get_suite_id, get_section_id, get_priority_id, get_override_type_id, get_architecture_id, get_archive_id, get_component_id, get_location_id, - get_source_id, get_suite_version, get_files_id, get_maintainer, get_suites + get_source_id, get_suite_version, get_files_id, get_maintainer, get_suites, + get_suite_architectures @group read/write: get_or_set*, set_files_id @contact: Debian FTP Master @@ -409,6 +410,33 @@ def get_suite_version(source, suite): return version +def get_suite_architectures(suite): + """ + Returns list of architectures for C{suite}. + + @type suite: string, int + @param suite: the suite name or the suite_id + + @rtype: list + @return: the list of architectures for I{suite} + """ + + suite_id = None + if type(suite) == str: + suite_id = get_suite_id(suite) + elif type(suite) == int: + suite_id = suite + else: + return None + + sql = """ SELECT a.arch_string FROM suite_architectures sa + JOIN architecture a ON (a.id = sa.architecture) + WHERE suite='%s' """ % (suite_id) + + q = projectB.query(sql) + return map(lambda x: x[0], q.getresult()) + + ################################################################################ def get_or_set_maintainer_id (maintainer):