X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fgenerate_packages_sources2.py;h=e746019d0c970fc8723fc674403172496fc457c6;hb=dd80b169287a128cd9e3b833852fbf68106385b5;hp=42aa7abb5af615cfd6924a0b5a73fe2cc78ee901;hpb=721447422c79c1150399824fa74dc0bcadd4d420;p=dak.git diff --git a/dak/generate_packages_sources2.py b/dak/generate_packages_sources2.py index 42aa7abb..e746019d 100755 --- a/dak/generate_packages_sources2.py +++ b/dak/generate_packages_sources2.py @@ -151,13 +151,20 @@ WITH SELECT (SELECT - STRING_AGG(key || '\: ' || value, E'\n' ORDER BY mk.ordering, mk.key) + STRING_AGG(key || '\: ' || value, E'\n' ORDER BY ordering, key) FROM - binaries_metadata bm - JOIN metadata_keys mk ON mk.key_id = bm.key_id - WHERE - bm.bin_id = tmp.binary_id - AND key != ALL (:metadata_skip) + (SELECT key, ordering, + CASE WHEN :include_long_description = 'false' AND key = 'Description' + THEN SUBSTRING(value FROM E'\\A[^\n]*') + ELSE value + END AS value + FROM + binaries_metadata bm + JOIN metadata_keys mk ON mk.key_id = bm.key_id + WHERE + bm.bin_id = tmp.binary_id + AND key != ALL (:metadata_skip) + ) AS metadata ) || COALESCE(E'\n' || (SELECT STRING_AGG(key || '\: ' || value, E'\n' ORDER BY key) @@ -209,16 +216,15 @@ def generate_packages(suite_id, component_id, architecture_id, type_name): architecture = session.query(Architecture).get(architecture_id) overridesuite_id = suite.get_overridesuite().suite_id + include_long_description = suite.include_long_description # We currently filter out the "Tag" line. They are set by external # overrides and NOT by the maintainer. And actually having it set by # maintainer means we output it twice at the moment -> which breaks # dselect. metadata_skip = ["Section", "Priority", "Tag"] - if suite.include_long_description: + if include_long_description: metadata_skip.append("Description-md5") - else: - metadata_skip.append("Description") writer = PackagesFileWriter(suite=suite.suite_name, component=component.component_name, architecture=architecture.arch_string, debtype=type_name) @@ -226,7 +232,8 @@ def generate_packages(suite_id, component_id, architecture_id, type_name): r = session.execute(_packages_query, {"suite": suite_id, "component": component_id, "arch": architecture_id, "type_id": type_id, "type_name": type_name, "arch_all": arch_all_id, - "overridesuite": overridesuite_id, "metadata_skip": metadata_skip}) + "overridesuite": overridesuite_id, "metadata_skip": metadata_skip, + "include_long_description": 'true' if include_long_description else 'false'}) for (stanza,) in r: print >>output, stanza print >>output, "" @@ -240,6 +247,13 @@ def generate_packages(suite_id, component_id, architecture_id, type_name): ############################################################################# _translations_query = """ +WITH + override_suite AS + (SELECT + s.id AS id, + COALESCE(os.id, s.id) AS overridesuite_id + FROM suite AS s LEFT JOIN suite AS os ON s.overridesuite = os.suite_name) + SELECT 'Package\: ' || b.package || E'\nDescription-md5\: ' || bm_description_md5.value @@ -248,7 +262,8 @@ SELECT FROM binaries b -- join tables for suite and component JOIN bin_associations ba ON b.id = ba.bin - JOIN override o ON b.package = o.package AND o.suite = :suite AND o.type = (SELECT id FROM override_type WHERE type = 'deb') + JOIN override_suite os ON os.id = ba.suite + JOIN override o ON b.package = o.package AND o.suite = os.overridesuite_id AND o.type = (SELECT id FROM override_type WHERE type = 'deb') -- join tables for Description and Description-md5 JOIN binaries_metadata bm_description ON b.id = bm_description.bin_id AND bm_description.key_id = (SELECT key_id FROM metadata_keys WHERE key = 'Description') @@ -288,10 +303,6 @@ def generate_translations(suite_id, component_id): ############################################################################# def main(): - from daklib.dakmultiprocessing import DakProcessPool, PROC_STATUS_SUCCESS, PROC_STATUS_SIGNALRAISED - pool = DakProcessPool() - - from daklib.dbconn import Component, DBConn, get_suite, Suite from daklib.config import Config from daklib import daklog @@ -299,7 +310,8 @@ def main(): Arguments = [('h',"help","Generate-Packages-Sources::Options::Help"), ('s',"suite","Generate-Packages-Sources::Options::Suite"), - ('f',"force","Generate-Packages-Sources::Options::Force")] + ('f',"force","Generate-Packages-Sources::Options::Force"), + ('o','option','','ArbItem')] suite_names = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv) try: @@ -310,8 +322,12 @@ def main(): if Options.has_key("Help"): usage() + from daklib.dakmultiprocessing import DakProcessPool, PROC_STATUS_SUCCESS, PROC_STATUS_SIGNALRAISED + pool = DakProcessPool() + logger = daklog.Logger('generate-packages-sources2') + from daklib.dbconn import Component, DBConn, get_suite, Suite session = DBConn().session() session.execute("SELECT add_missing_description_md5()") session.commit() @@ -344,10 +360,12 @@ def main(): for s in suites: if s.untouchable and not force: + import utils utils.fubar("Refusing to touch %s (untouchable and not forced)" % s.suite_name) for c in component_ids: pool.apply_async(generate_sources, [s.suite_id, c], callback=parse_results) - pool.apply_async(generate_translations, [s.suite_id, c], callback=parse_results) + if not s.include_long_description: + pool.apply_async(generate_translations, [s.suite_id, c], callback=parse_results) for a in s.architectures: if a == 'source': continue