Package: dh-make
Version: 2.201802
Severity: normal
Tags: patch

Dear Maintainer,

Custom templates currently cannot contain directories. This makes it impossible
to use custom templates for certain files, e.g. source/options.

  Unable to open file /tmp/template/source for reading: Is a directory

It would be more useful for custom templates to also be processed recursively,
like the built-in templates are.

Regards,
Robin


-- System Information:
Debian Release: 10.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-6-amd64 (SMP w/12 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dh-make depends on:
ii  debhelper  12.1.1
ii  dpkg-dev   1.19.7
ii  make       4.2.1-1.2
ii  python3    3.7.3-1

dh-make recommends no packages.

Versions of packages dh-make suggests:
ii  build-essential  12.6

-- no debconf information
>From d56bf66a5e5fcb97632430fdc4eabb967c98dc3c Mon Sep 17 00:00:00 2001
From: Robin Gustafsson <ro...@rgson.se>
Date: Mon, 30 Dec 2019 15:56:58 +0100
Subject: [PATCH] Support directories in custom templates

---
 dh_make | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/dh_make b/dh_make
index b8a3a7c..6526a4a 100755
--- a/dh_make
+++ b/dh_make
@@ -73,13 +73,19 @@ def process_dhlib(args, subs_func, subdir, destdir=''):
             process_file(args, subs_func, file, os.path.join(destdir, f))
 
 
-def process_dir(args, subs_func, adir):
+def process_dir(args, subs_func, adir, destdir=''):
     '''
-    Find all templates in custom directory
+    Recursively find all templates in custom directory
     and process them into our debian directory
     '''
     for f in os.listdir(adir):
-        process_file(args, subs_func, os.path.join(adir, f), f)
+        file = os.path.join(adir, f)
+        dest = os.path.join(destdir, f)
+        if os.path.isdir(file):
+            os.mkdir(dest, 0o755)
+            process_dir(args, subs_func, file, dest)
+        else:
+            process_file(args, subs_func, file, dest)
 
 
 def process_copyright(args, subs_func):
-- 
2.20.1

Reply via email to