X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Finit_db.py;h=e1f1bced854ddcece7528db09d150c0892d759f5;hb=b43ed3ff3738940ce46caa836d88b6937a76582c;hp=58e46ad77badcdf330a151c096ad1d5f8e0f8c86;hpb=41f8dfa67162e2c6d5e213cd5f8398eb4063dee7;p=dak.git diff --git a/dak/init_db.py b/dak/init_db.py index 58e46ad7..e1f1bced 100755 --- a/dak/init_db.py +++ b/dak/init_db.py @@ -21,8 +21,8 @@ import pg, sys import apt_pkg -import daklib.database -import daklib.utils +from daklib import database +from daklib import utils ################################################################################ @@ -101,24 +101,20 @@ def do_location(): projectB.query("DELETE FROM location") for location in Cnf.SubTree("Location").List(): location_config = Cnf.SubTree("Location::%s" % (location)) - archive_id = daklib.database.get_archive_id(location_config["Archive"]) + archive_id = database.get_archive_id(location_config["Archive"]) if archive_id == -1: - daklib.utils.fubar("Archive '%s' for location '%s' not found." + utils.fubar("Archive '%s' for location '%s' not found." % (location_config["Archive"], location)) location_type = location_config.get("type") - if location_type == "legacy-mixed": - projectB.query("INSERT INTO location (path, archive, type) VALUES " - "('%s', %d, '%s')" - % (location, archive_id, location_config["type"])) - elif location_type == "legacy" or location_type == "pool": + if location_type == "pool": for component in Cnf.SubTree("Component").List(): - component_id = daklib.database.get_component_id(component) + component_id = database.get_component_id(component) projectB.query("INSERT INTO location (path, component, " "archive, type) VALUES ('%s', %d, %d, '%s')" % (location, component_id, archive_id, location_type)) else: - daklib.utils.fubar("E: type '%s' not recognised in location %s." + utils.fubar("E: type '%s' not recognised in location %s." % (location_type, location)) projectB.query("COMMIT WORK") @@ -135,10 +131,10 @@ 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)): - architecture_id = daklib.database.get_architecture_id (architecture) + for architecture in database.get_suite_architectures(suite): + architecture_id = database.get_architecture_id (architecture) if architecture_id < 0: - daklib.utils.fubar("architecture '%s' not found in architecture" + utils.fubar("architecture '%s' not found in architecture" " table for suite %s." % (architecture, suite)) projectB.query("INSERT INTO suite_architectures (suite, " @@ -180,7 +176,6 @@ def do_section(): prefix = "" else: prefix = "" - component = component.replace("non-US/", "") if component != "main": suffix = '/' + component else: @@ -191,13 +186,13 @@ def do_section(): projectB.query("COMMIT WORK") ################################################################################ - + def main (): """Sync dak.conf configuartion file and the SQL database""" global Cnf, projectB - Cnf = daklib.utils.get_conf() + Cnf = utils.get_conf() arguments = [('h', "help", "Init-DB::Options::Help")] for i in [ "help" ]: if not Cnf.has_key("Init-DB::Options::%s" % (i)): @@ -209,12 +204,12 @@ def main (): if options["Help"]: usage() elif arguments: - daklib.utils.warn("dak init-db takes no arguments.") + utils.warn("dak init-db takes no arguments.") usage(exit_code=1) projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) - daklib.database.init(Cnf, projectB) + database.init(Cnf, projectB) do_archive() do_architecture()