X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fimport_archive.py;h=d87d6ca9e3fd98e638620807aed50be1929cbdb3;hb=be43b7027584f24eb1faa6275553d96f91e4e6c7;hp=b8884ab242191b5f69a8673c06f65aaa64c3b14b;hpb=9678ddd39550f29a651ca1065dc0b4444e16d636;p=dak.git diff --git a/dak/import_archive.py b/dak/import_archive.py index b8884ab2..d87d6ca9 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,14 +36,13 @@ ############################################################################### -import commands, os, pg, re, sys, time +import commands, os, pg, sys, time import apt_pkg -import daklib.database as database -import daklib.utils as utils - -############################################################################### - -re_arch_from_filename = re.compile(r"binary-[^/]+") +from daklib import database +from daklib import utils +from daklib.dak_exceptions import * +from daklib.regexes import re_arch_from_filename, re_taint_free, re_no_epoch, \ + re_extract_src_version ############################################################################### @@ -93,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 @@ -323,7 +322,7 @@ def process_sources (filename, suite, component, archive): suite_id = database.get_suite_id(suite) try: file = utils.open_file (filename) - except utils.cant_open_exc: + except CantOpenError: utils.warn("can't open '%s'" % (filename)) return Scanner = apt_pkg.ParseTagFile(file) @@ -331,12 +330,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))) @@ -354,7 +353,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'): @@ -406,7 +405,7 @@ def process_packages (filename, suite, component, archive): suite_id = database.get_suite_id(suite) try: file = utils.open_file (filename) - except utils.cant_open_exc: + except CantOpenError: utils.warn("can't open '%s'" % (filename)) return Scanner = apt_pkg.ParseTagFile(file) @@ -426,14 +425,18 @@ 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: source_version = version filename = Scanner.Section["filename"] + if filename.endswith(".deb"): + type = "deb" + else: + type = "udeb" location = get_location_path(filename.split('/')[0]) - location_id = database.get_location_id (location, component, archive) + location_id = database.get_location_id (location, component.replace("/debian-installer", ""), archive) filename = poolify (filename, location) if architecture == "all": filename = re_arch_from_filename.sub("binary-all", filename) @@ -442,7 +445,6 @@ def process_packages (filename, suite, component, archive): size = Scanner.Section["size"] md5sum = Scanner.Section["md5sum"] files_id = get_or_set_files_id (filename, size, md5sum, location_id) - type = "deb"; # FIXME cache_key = "%s_%s_%s_%d_%d_%d_%d" % (package, version, repr(source_id), architecture_id, location_id, files_id, suite_id) if not arch_all_cache.has_key(cache_key): arch_all_cache[cache_key] = 1 @@ -473,7 +475,7 @@ def process_packages (filename, suite, component, archive): ############################################################################### def do_sources(sources, suite, component, server): - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename)) if (result != 0): utils.fubar("Gunzip invocation failed!\n%s" % (output), result) @@ -565,7 +567,9 @@ Please read the documentation before running this script. process_packages (packages, suite, "", server) elif type == "legacy" or type == "pool": for suite in Cnf.ValueList("Location::%s::Suites" % (location)): - for component in Cnf.SubTree("Component").List(): + 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))) for architecture in architectures: