[debhelper-devel] [debhelper] 03/03: dh_missing: Support wildcards in d/not-installed

Niels Thykier nthykier at moszumanska.debian.org
Sat Dec 30 10:19:14 UTC 2017


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

nthykier pushed a commit to branch master
in repository debhelper.

commit e8359d54d79027467285a21c96daff3f8f9838ed
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Dec 30 09:51:08 2017 +0000

    dh_missing: Support wildcards in d/not-installed
    
    Closes: Debian#884556
    Closes: nthykier/debhelper#1
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog                     |  4 ++++
 dh_missing                           | 21 +++++++++++++++-----
 t/dh_missing/04-not-installed-glob.t | 37 ++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d49f271..11eea1d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,10 @@ debhelper (11.1) UNRELEASED; urgency=medium
   [ Hideki Yamane ]
   * Fix typo of unnecessary.  (Closes: #884574)
 
+  [ Niels Thykier ]
+  * dh_missing: Support wildcards in debian/not-installed.  Thanks
+    to Maximiliano Curia for the suggestion.  (Closes: #884556)
+
  -- Niels Thykier <niels at thykier.net>  Sun, 17 Dec 2017 07:59:18 +0000
 
 debhelper (11) unstable; urgency=medium
diff --git a/dh_missing b/dh_missing
index a25cd20..d6eb0dc 100755
--- a/dh_missing
+++ b/dh_missing
@@ -44,8 +44,8 @@ However, it is B<not> a method to exclude files from being installed
 by any of the debhelper tool.  If you want a tool to not install a
 given file, please use its B<--exclude> option (where available).
 
-Please keep in mind that B<dh_missing> will B<not> expand wildcards in
-this file.
+B<dh_missing> will expand wildcards in this file (since debhelper 11.1).
+Wildcards without matches will be ignored.
 
 =back
 
@@ -130,10 +130,21 @@ for my $file (glob('debian/.debhelper/generated/*/installed-by-*')) {
 my @missing;
 if ( -f 'debian/not-installed') {
 	my @not_installed = filearray('debian/not-installed');
-	foreach (@not_installed) {
-		s:^\s*:debian/tmp/: unless m:^\s*debian/tmp/:;
+	for my $pattern (@not_installed) {
+		my @matches;
+		# Add an explicit d/tmp if absent as there is no point in
+		# looking outside the debian staging directory
+		$pattern =~ s:^\s*:debian/tmp/: unless $pattern =~ m:^\s*debian/tmp/:;
+		@matches = glob_expand(['.'], \&glob_expand_error_handler_silently_ignore, $pattern);
+		if (@matches) {
+			# Assume classify them as installed
+			push(@installed, @matches);
+		} else {
+			# Assume it is not a pattern and classify it as installed
+			push(@installed, $pattern);
+		}
 	}
-	# Pretend that these are also installed.
+
 	push(@installed, @not_installed);
 }
 my $installed=join("|", map {
diff --git a/t/dh_missing/04-not-installed-glob.t b/t/dh_missing/04-not-installed-glob.t
new file mode 100755
index 0000000..b46eca3
--- /dev/null
+++ b/t/dh_missing/04-not-installed-glob.t
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More;
+
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+our $TEST_DH_FIXTURE_DIR = 'template';
+our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw(
+    debian/changelog
+    debian/control
+    debian/foo.install
+    file-for-foo
+    Makefile
+));
+
+plan(tests => 1);
+
+each_compat_subtest {
+	rm_files('debian/not-installed');
+	open(my $fd, '>', 'debian/not-installed') or error("open(d/not-installed): $!");
+	# Non-glob match
+	print {$fd} "usr/bin/file-for-foo\n";
+	# Glob match (note that it must not match the above)
+	print {$fd} "usr/bin/file-for-foo-*\n";
+	# Non-matches (silently ignored)
+	print {$fd} "usr/bin/does-not-exist\n";
+	print {$fd} "usr/bin/does-not-exist-*\n";
+	close($fd) or error("close(d/not-installed: $!");
+	ok(run_dh_tool('dh_clean'));
+	is(system('make', 'installmore'), 0);
+	ok(run_dh_tool('dh_missing', '--fail-missing'));
+};
+

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




More information about the debhelper-devel mailing list