[diffoscope] 02/02: Tidy/clarify generation of debian/diffoscope.substvars

Chris Lamb chris at chris-lamb.co.uk
Wed Mar 29 14:41:06 CEST 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch experimental
in repository diffoscope.

commit 93b02cb2f89f35268f2156d52d074e2c40213471
Author: Chris Lamb <lamby at debian.org>
Date:   Wed Mar 29 13:40:57 2017 +0100

    Tidy/clarify generation of debian/diffoscope.substvars
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 debian/rules       |  5 +----
 diffoscope/main.py | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/debian/rules b/debian/rules
index 6a4a414..d0012c3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -38,10 +38,7 @@ override_dh_python3:
 		--recommends=progressbar
 
 override_dh_gencontrol:
-	TOOLS="$$(bin/diffoscope --list-tools=debian | awk -F': ' '/Available-in-Debian-packages/ { print $$2 }' | \
-		sed -e 's/\(^\| \)\(coreutils\|diffutils\|e2fsprogs\|findutils\|gzip\|tar\)\(,\|$$\)//g')"; \
-		[ -n "$$TOOLS" ] || { echo '--list-tools failed' >&2; exit 1; }; \
-		echo "diffoscope:Recommends=$$TOOLS" >> debian/diffoscope.substvars
+	bin/diffoscope --list-debian-substvars >> debian/diffoscope.substvars
 	dh_gencontrol -O--buildsystem=pybuild
 
 debian/%.1: debian/%.1.rst
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 3b82a7a..11cb0e6 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -188,6 +188,8 @@ def create_parser():
                         'DISTRO can be one of {%(choices)s}. '
                         'If specified, the output will list packages in that '
                         'distribution that satisfy these dependencies.')
+    group4.add_argument('--list-debian-substvars', action=ListDebianSubstvarsAction,
+                        help="List packages needed for Debian in 'substvar' format.")
 
     if not tlsh:
         parser.epilog = 'File renaming detection based on fuzzy-matching is currently disabled. It can be enabled by installing the "tlsh" module available at https://github.com/trendmicro/tlsh'
@@ -231,6 +233,32 @@ class ListToolsAction(argparse.Action):
             print(', '.join(sorted(tools)))
         sys.exit(0)
 
+class ListDebianSubstvarsAction(argparse._StoreTrueAction):
+    def __call__(self, *args, **kwargs):
+        # Ensure all comparators are imported so tool_required.all is
+        # populated.
+        ComparatorManager().reload()
+
+        tools = set()
+        for x in tool_required.all:
+            try:
+                tools.add(EXTERNAL_TOOLS[x]['debian'])
+            except KeyError:
+                pass
+
+        # Exclude "Required" packages
+        for x in (
+            'gzip',
+            'tar',
+            'coreutils',
+            'diffutils',
+            'e2fsprogs',
+            'findutils',
+        ):
+            tools.discard(x)
+
+        print(', '.join(sorted(tools)))
+        sys.exit(0)
 
 def maybe_set_limit(config, parsed_args, key):
     v = getattr(parsed_args, key)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list