X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fimport_archive.py;h=028239b0d4b3b374107ab52550e40e3ce1a02237;hb=b43ed3ff3738940ce46caa836d88b6937a76582c;hp=53635e2acac63b7f086cb4b5b208f138ef0acd56;hpb=af486e867c2809515c09ae4f854a95355112010e;p=dak.git diff --git a/dak/import_archive.py b/dak/import_archive.py index 53635e2a..028239b0 100755 --- a/dak/import_archive.py +++ b/dak/import_archive.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Populate the DB +""" Populate the DB """ # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup # This program is free software; you can redistribute it and/or modify @@ -36,15 +36,13 @@ ############################################################################### -import commands, os, pg, re, sys, time +import commands, os, pg, sys, time import apt_pkg from daklib import database from daklib import utils from daklib.dak_exceptions import * - -############################################################################### - -re_arch_from_filename = re.compile(r"binary-[^/]+") +from daklib.regexes import re_arch_from_filename, re_taint_free, re_no_epoch, \ + re_extract_src_version ############################################################################### @@ -94,7 +92,7 @@ def reject (str, prefix="Rejected: "): ############################################################################### def check_signature (filename): - if not utils.re_taint_free.match(os.path.basename(filename)): + if not re_taint_free.match(os.path.basename(filename)): reject("!!WARNING!! tainted filename: '%s'." % (filename)) return None @@ -235,13 +233,10 @@ def update_locations (): SubSec = Cnf.SubTree("Location::%s" % (location)) archive_id = database.get_archive_id(SubSec["archive"]) type = SubSec.Find("type") - if type == "legacy-mixed": - projectB.query("INSERT INTO location (path, archive, type) VALUES ('%s', %d, '%s')" % (location, archive_id, SubSec["type"])) - else: - for component in Cnf.SubTree("Component").List(): - 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, SubSec["type"])) + for component in Cnf.SubTree("Component").List(): + 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, SubSec["type"])) def update_architectures (): projectB.query("DELETE FROM architecture") @@ -256,7 +251,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 database.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)) @@ -332,12 +327,12 @@ def process_sources (filename, suite, component, archive): package = Scanner.Section["package"] version = Scanner.Section["version"] directory = Scanner.Section["directory"] - dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version))) + dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version))) # Sometimes the Directory path is a lie; check in the pool if not os.path.exists(dsc_file): if directory.split('/')[0] == "dists": directory = Cnf["Dir::PoolRoot"] + utils.poolify(package, component) - dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version))) + dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version))) if not os.path.exists(dsc_file): utils.fubar("%s not found." % (dsc_file)) install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file))) @@ -355,7 +350,7 @@ def process_sources (filename, suite, component, archive): directory = poolify (directory, location) if directory != "" and not directory.endswith("/"): directory += '/' - no_epoch_version = utils.re_no_epoch.sub('', version) + no_epoch_version = re_no_epoch.sub('', version) # Add all files referenced by the .dsc to the files table ids = [] for line in Scanner.Section["files"].split('\n'): @@ -427,7 +422,7 @@ def process_packages (filename, suite, component, archive): source = Scanner.Section["source"] source_version = "" if source.find("(") != -1: - m = utils.re_extract_src_version.match(source) + m = re_extract_src_version.match(source) source = m.group(1) source_version = m.group(2) if not source_version: @@ -544,11 +539,7 @@ Please read the documentation before running this script. SubSec = Cnf.SubTree("Location::%s" % (location)) server = SubSec["Archive"] type = Cnf.Find("Location::%s::Type" % (location)) - if type == "legacy-mixed": - sources = location + 'Sources.gz' - suite = Cnf.Find("Location::%s::Suite" % (location)) - do_sources(sources, suite, "", server) - elif type == "legacy" or type == "pool": + if type == "pool": for suite in Cnf.ValueList("Location::%s::Suites" % (location)): for component in Cnf.SubTree("Component").List(): sources = Cnf["Dir::Root"] + "dists/" + Cnf["Suite::%s::CodeName" % (suite)] + '/' + component + '/source/' + 'Sources.gz' @@ -562,18 +553,12 @@ Please read the documentation before running this script. SubSec = Cnf.SubTree("Location::%s" % (location)) server = SubSec["Archive"] type = Cnf.Find("Location::%s::Type" % (location)) - if type == "legacy-mixed": - packages = location + 'Packages' - suite = Cnf.Find("Location::%s::Suite" % (location)) - print 'Processing '+location+'...' - process_packages (packages, suite, "", server) - elif type == "legacy" or type == "pool": + if type == "pool": for suite in Cnf.ValueList("Location::%s::Suites" % (location)): 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, database.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+'...'