From 7c06b533fa59a3de8fd9d379790a893835f812e4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 13 Mar 2016 14:48:51 +0100 Subject: [PATCH] Only generate fields in Sources for requested checksums We make use of the fact that STRING_AGG ignores NULL values when joining the values, so we do not get empty lines in there. --- dak/generate_packages_sources2.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dak/generate_packages_sources2.py b/dak/generate_packages_sources2.py index ed12e9f1..e44d9cee 100755 --- a/dak/generate_packages_sources2.py +++ b/dak/generate_packages_sources2.py @@ -56,9 +56,12 @@ SELECT STRING_AGG( CASE WHEN key = 'Source' THEN E'Package\: ' - WHEN key = 'Files' THEN E'Files\:\n ' || f.md5sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') - WHEN key = 'Checksums-Sha1' THEN E'Checksums-Sha1\:\n ' || f.sha1sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') - WHEN key = 'Checksums-Sha256' THEN E'Checksums-Sha256\:\n ' || f.sha256sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') + WHEN key = 'Files' AND sui.checksums && array['md5sum'] THEN E'Files\:\n ' || f.md5sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') + WHEN key = 'Files' THEN NULL + WHEN key = 'Checksums-Sha1' AND sui.checksums && array['sha1'] THEN E'Checksums-Sha1\:\n ' || f.sha1sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') + WHEN key = 'Checksums-Sha1' THEN NULL + WHEN key = 'Checksums-Sha256' AND sui.checksums && array['sha256'] THEN E'Checksums-Sha256\:\n ' || f.sha256sum || ' ' || f.size || ' ' || SUBSTRING(f.filename FROM E'/([^/]*)\\Z') + WHEN key = 'Checksums-Sha256' THEN NULL ELSE key || E'\: ' END || value, E'\n' ORDER BY mk.ordering, mk.key) FROM @@ -93,6 +96,7 @@ LEFT JOIN override o ON o.package = s.source AND o.type = :dsc_type LEFT JOIN section sec ON o.section = sec.id LEFT JOIN priority pri ON o.priority = pri.id +LEFT JOIN suite sui on sui.id = :suite ORDER BY s.source, s.version -- 2.39.5