From: Ansgar Burchardt Date: Tue, 31 Jul 2012 17:33:06 +0000 (+0200) Subject: Use archive path instead of Dir::Root X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa4f71d8e30c23e458a8148be258c89bffbd405f;p=dak Use archive path instead of Dir::Root --- diff --git a/dak/cruft_report.py b/dak/cruft_report.py index 6200aa2c..98381bc1 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -680,7 +680,7 @@ def main (): # Checks based on the Sources files components = get_component_names(session) for component in components: - filename = "%s/dists/%s/%s/source/Sources.gz" % (cnf["Dir::Root"], suite_name, component) + filename = "%s/dists/%s/%s/source/Sources.gz" % (suite.archive.path, suite_name, component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) @@ -729,7 +729,7 @@ def main (): for architecture in architectures: if component == 'main/debian-installer' and re.match("kfreebsd", architecture): continue - filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (cnf["Dir::Root"], suite_name, component, architecture) + filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (suite.archive.path, suite_name, component, architecture) # apt_pkg.ParseTagFile needs a real file handle (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) diff --git a/dak/generate_packages_sources2.py b/dak/generate_packages_sources2.py index f0e08654..34c62b09 100755 --- a/dak/generate_packages_sources2.py +++ b/dak/generate_packages_sources2.py @@ -103,7 +103,7 @@ def generate_sources(suite_id, component_id): overridesuite_id = suite.get_overridesuite().suite_id - writer = SourcesFileWriter(suite=suite.suite_name, component=component.component_name) + writer = SourcesFileWriter(archive=suite.archive.path, suite=suite.suite_name, component=component.component_name) output = writer.open() # run query and write Sources @@ -226,7 +226,8 @@ def generate_packages(suite_id, component_id, architecture_id, type_name): if include_long_description: metadata_skip.append("Description-md5") - writer = PackagesFileWriter(suite=suite.suite_name, component=component.component_name, + writer = PackagesFileWriter(archive=suite.archive.path, suite=suite.suite_name, + component=component.component_name, architecture=architecture.arch_string, debtype=type_name) output = writer.open() @@ -287,7 +288,7 @@ def generate_translations(suite_id, component_id): suite = session.query(Suite).get(suite_id) component = session.query(Component).get(component_id) - writer = TranslationFileWriter(suite=suite.suite_name, component=component.component_name, language="en") + writer = TranslationFileWriter(archive=suite.archive.path, suite=suite.suite_name, component=component.component_name, language="en") output = writer.open() r = session.execute(_translations_query, {"suite": suite_id, "component": component_id}) diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 3801132d..a57c5fc2 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -145,9 +145,9 @@ class ReleaseWriter(object): cnf = Config() - suite_suffix = "%s" % (cnf.find("Dinstall::SuiteSuffix")) + suite_suffix = cnf.find("Dinstall::SuiteSuffix", "") - outfile = os.path.join(cnf["Dir::Root"], 'dists', "%s/%s" % (suite.suite_name, suite_suffix), "Release") + outfile = os.path.join(suite.archive.path, 'dists', suite.suite_name, suite_suffix, "Release") out = open(outfile + ".new", "w") for key, dbfield in attribs: @@ -182,7 +182,7 @@ class ReleaseWriter(object): out.write("Description: %s\n" % suite.description) for comp in components: - for dirpath, dirnames, filenames in os.walk("%sdists/%s/%s%s" % (cnf["Dir::Root"], suite.suite_name, suite_suffix, comp), topdown=True): + for dirpath, dirnames, filenames in os.walk(os.path.join(suite.archive.path, "dists", suite.suite_name, suite_suffix, comp), topdown=True): if not re_gensubrelease.match(dirpath): continue @@ -214,7 +214,7 @@ class ReleaseWriter(object): # their checksums to the main Release file oldcwd = os.getcwd() - os.chdir("%sdists/%s/%s" % (cnf["Dir::Root"], suite.suite_name, suite_suffix)) + os.chdir(os.path.join(suite.archive.path, "dists", suite.suite_name, suite_suffix)) hashfuncs = { 'MD5Sum' : apt_pkg.md5sum, 'SHA1' : apt_pkg.sha1sum, diff --git a/dak/init_dirs.py b/dak/init_dirs.py index fd140714..0c63fe3e 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -137,7 +137,7 @@ def create_directories(): # Process dists directories # TODO: Store location of each suite in database for suite in session.query(Suite): - suite_dir = os.path.join( Cnf['Dir::Root'], 'dists', "%s/%s" % (suite.suite_name, suite_suffix) ) + suite_dir = os.path.join(suite.archive.path, 'dists', suite.suite_name, suite_suffix) # TODO: Store valid suite/component mappings in database for component in session.query(Component): diff --git a/dak/override.py b/dak/override.py index a9f28322..44fc16f4 100755 --- a/dak/override.py +++ b/dak/override.py @@ -56,7 +56,7 @@ Make microchanges or microqueries of the binary overrides """ sys.exit(exit_code) -def check_override_compliance(package, priority, suite_name, cnf, session): +def check_override_compliance(package, priority, archive_path, suite_name, cnf, session): print "Checking compliance with related overrides..." depends = set() @@ -66,7 +66,7 @@ def check_override_compliance(package, priority, suite_name, cnf, session): arches -= set(["source", "all"]) for arch in arches: for component in components: - Packages = utils.get_packages_from_ftp(cnf['Dir::Root'], suite_name, component, arch) + Packages = utils.get_packages_from_ftp(archive_path, suite_name, component, arch) while Packages.Step(): package_name = Packages.Section.Find("Package") dep_list = Packages.Section.Find("Depends") @@ -140,6 +140,10 @@ def main (): if arguments and len(arguments) > 2: utils.fubar("Too many arguments") + suite = get_suite(suite_name, session) + if suite is None: + utils.fubar("Unknown suite '{0}'".format(suite_name)) + if arguments and len(arguments) == 1: # Determine if the argument is a priority or a section... arg = arguments.pop() @@ -227,7 +231,7 @@ def main (): utils.fubar("Trying to change priority of a source-only package") if Options["Check"] and newpriority != oldpriority: - check_override_compliance(package, p, suite_name, cnf, session) + check_override_compliance(package, p, suite.archive.path, suite_name, cnf, session) # If we're in no-action mode if Options["No-Action"]: diff --git a/dak/override_disparity.py b/dak/override_disparity.py index e48bd7de..6b0f9da4 100755 --- a/dak/override_disparity.py +++ b/dak/override_disparity.py @@ -82,12 +82,15 @@ def main(): depends = {} session = DBConn().session() suite_name = Options['suite'] + suite = get_suite(suite_name, session) + if suite is None: + utils.fubar("Unknown suite '{0}'".format(suite_name)) components = get_component_names(session) arches = set([x.arch_string for x in get_suite_architectures(suite_name)]) arches -= set(['source', 'all']) for arch in arches: for component in components: - Packages = utils.get_packages_from_ftp(cnf['Dir::Root'], suite_name, component, arch) + Packages = utils.get_packages_from_ftp(suite.archive.path, suite_name, component, arch) while Packages.Step(): package = Packages.Section.Find('Package') dep_list = Packages.Section.Find('Depends') diff --git a/daklib/contents.py b/daklib/contents.py index e9517d63..02abe1f9 100644 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -123,6 +123,7 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package Returns a writer object. ''' values = { + 'archive': self.suite.archive.path, 'suite': self.suite.suite_name, 'component': self.component.component_name, 'debtype': self.overridetype.overridetype, @@ -223,6 +224,7 @@ select sc.file, string_agg(s.source, ',' order by s.source) as pkglist Returns a writer object. ''' values = { + 'archive': self.suite.archive.path, 'suite': self.suite.suite_name, 'component': self.component.component_name } diff --git a/daklib/filewriter.py b/daklib/filewriter.py index c010fb5d..7fa68289 100644 --- a/daklib/filewriter.py +++ b/daklib/filewriter.py @@ -47,9 +47,7 @@ class BaseFileWriter(object): self.uncompressed = 'none' in compression self.gzip = 'gzip' in compression self.bzip2 = 'bzip2' in compression - root_dir = Config()['Dir::Root'] - relative_dir = template % keywords - self.path = os.path.join(root_dir, relative_dir) + self.path = template % keywords def open(self): ''' @@ -98,9 +96,9 @@ class BinaryContentsFileWriter(BaseFileWriter): } flags.update(keywords) if flags['debtype'] == 'deb': - template = "dists/%(suite)s/%(component)s/Contents-%(architecture)s" + template = "%(archive)s/dists/%(suite)s/%(component)s/Contents-%(architecture)s" else: # udeb - template = "dists/%(suite)s/%(component)s/Contents-udeb-%(architecture)s" + template = "%(archive)s/dists/%(suite)s/%(component)s/Contents-udeb-%(architecture)s" BaseFileWriter.__init__(self, template, **flags) class SourceContentsFileWriter(BaseFileWriter): @@ -113,7 +111,7 @@ class SourceContentsFileWriter(BaseFileWriter): 'compression': ['gzip'], } flags.update(keywords) - template = "dists/%(suite)s/%(component)s/Contents-source" + template = "%(archive)s/dists/%(suite)s/%(component)s/Contents-source" BaseFileWriter.__init__(self, template, **flags) class PackagesFileWriter(BaseFileWriter): @@ -127,9 +125,9 @@ class PackagesFileWriter(BaseFileWriter): } flags.update(keywords) if flags['debtype'] == 'deb': - template = "dists/%(suite)s/%(component)s/binary-%(architecture)s/Packages" + template = "%(archive)s/dists/%(suite)s/%(component)s/binary-%(architecture)s/Packages" else: # udeb - template = "dists/%(suite)s/%(component)s/debian-installer/binary-%(architecture)s/Packages" + template = "%(archive)s/dists/%(suite)s/%(component)s/debian-installer/binary-%(architecture)s/Packages" BaseFileWriter.__init__(self, template, **flags) class SourcesFileWriter(BaseFileWriter): @@ -142,7 +140,7 @@ class SourcesFileWriter(BaseFileWriter): 'compression': ['gzip', 'bzip2'], } flags.update(keywords) - template = "dists/%(suite)s/%(component)s/source/Sources" + template = "%(archive)s/dists/%(suite)s/%(component)s/source/Sources" BaseFileWriter.__init__(self, template, **flags) class TranslationFileWriter(BaseFileWriter): @@ -156,5 +154,5 @@ class TranslationFileWriter(BaseFileWriter): 'language': 'en', } flags.update(keywords) - template = "dists/%(suite)s/%(component)s/i18n/Translation-%(language)s" + template = "%(archive)s/dists/%(suite)s/%(component)s/i18n/Translation-%(language)s" super(TranslationFileWriter, self).__init__(template, **flags)