+ message = ["generate-packages", suite.suite_name, component.component_name, architecture.arch_string]
+ session.rollback()
+ return (PROC_STATUS_SUCCESS, message)
+
+#############################################################################
+
+_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
+ E'Package\: ' || b.package
+ || E'\nDescription-md5\: ' || bm_description_md5.value
+ || E'\nDescription-en\: ' || bm_description.value
+ || E'\n'
+FROM binaries b
+ -- join tables for suite and component
+ JOIN bin_associations ba ON b.id = ba.bin
+ 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')
+ JOIN binaries_metadata bm_description_md5 ON b.id = bm_description_md5.bin_id AND bm_description_md5.key_id = (SELECT key_id FROM metadata_keys WHERE key = 'Description-md5')
+
+ -- we want to sort by source name
+ JOIN source s ON b.source = s.id
+
+WHERE ba.suite = :suite AND o.component = :component
+GROUP BY b.package, bm_description_md5.value, bm_description.value
+ORDER BY MIN(s.source), b.package, bm_description_md5.value
+"""
+
+def generate_translations(suite_id, component_id):
+ global _translations_query
+ from daklib.filewriter import TranslationFileWriter
+ from daklib.dbconn import DBConn, Suite, Component
+ from daklib.dakmultiprocessing import PROC_STATUS_SUCCESS
+
+ session = DBConn().session()
+ suite = session.query(Suite).get(suite_id)
+ component = session.query(Component).get(component_id)
+
+ 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})
+ for (stanza,) in r:
+ print >>output, stanza
+
+ writer.close()
+
+ message = ["generate-translations", suite.suite_name, component.component_name]
+ session.rollback()
+ return (PROC_STATUS_SUCCESS, message)