[debhelper-devel] [debhelper] 01/01: Refactor install_dir usage to avoid the "if -d " tests

Niels Thykier nthykier at moszumanska.debian.org
Sun Oct 2 20:13:12 UTC 2016


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

nthykier pushed a commit to branch master
in repository debhelper.

commit dbdad391cc62fc92f54d8f9eab1f4bc68c1073cb
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Oct 2 20:11:34 2016 +0000

    Refactor install_dir usage to avoid the "if -d " tests
    
    They were not needed in the first place (as "install -d" DTRT).
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 15 +++++----------
 dh_bugfiles                |  2 +-
 dh_builddeb                |  4 +---
 dh_gconf                   |  2 +-
 dh_gencontrol              |  8 ++------
 dh_install                 |  6 ++----
 dh_installcatalogs         |  7 +++----
 dh_installchangelogs       |  4 +---
 dh_installcron             |  8 ++------
 dh_installdeb              |  4 +---
 dh_installdebconf          |  4 +---
 dh_installdirs             |  4 +---
 dh_installdocs             |  4 +---
 dh_installemacsen          | 16 ++++------------
 dh_installexamples         |  6 ++----
 dh_installifupdown         |  4 +---
 dh_installinfo             |  4 +---
 dh_installinit             | 24 +++++-------------------
 dh_installlogcheck         |  4 +---
 dh_installlogrotate        |  4 +---
 dh_installman              |  4 +---
 dh_installmanpages         |  4 +---
 dh_installmenu             |  8 ++------
 dh_installmime             |  8 ++------
 dh_installmodules          |  4 +---
 dh_installpam              |  4 +---
 dh_installppp              |  4 +---
 dh_installudev             |  4 +---
 dh_lintian                 |  4 +---
 dh_makeshlibs              |  8 ++------
 dh_md5sums                 |  8 ++------
 dh_movefiles               |  4 +---
 dh_shlibdeps               |  8 ++------
 dh_strip                   |  8 +++-----
 doc/PROGRAMMING            |  1 +
 35 files changed, 59 insertions(+), 156 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 276686b..3ecd6e6 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -321,7 +321,8 @@ sub install_lib {
 	doit('install', '-p', '-m0644', @_);
 }
 sub install_dir {
-	doit('install', '-d', @_);
+	my @to_create = grep { not -d $_ } @_;
+	doit('install', '-d', @to_create) if @to_create;
 }
 
 # Run a command that may have a huge number of arguments, like xargs does.
@@ -702,9 +703,7 @@ sub generated_file {
 	my $dir = "debian/.debhelper/generated/${package}";
 	my $path = "${dir}/${filename}";
 	$mkdirs //= 1;
-	if ($mkdirs and not -d $dir) {
-		install_dir($dir);
-	}
+	install_dir($dir) if $mkdirs;
 	return $path;
 }
 
@@ -1132,9 +1131,7 @@ sub make_symlink{
 
 	# Make sure the directory the link will be in exists.
 	my $basedir=dirname("$tmp/$dest");
-	if (! -e $basedir) {
-		install_dir($basedir);
-	}
+	install_dir($basedir);
 
 	# Policy says that if the link is all within one toplevel
 	# directory, it should be relative. If it's between
@@ -1354,9 +1351,7 @@ sub restore_file_on_clean {
 	my $bucket_index = 'debian/.debhelper/bucket/index';
 	my $bucket_dir = 'debian/.debhelper/bucket/files';
 	my $checksum;
-	if (not -d $bucket_dir) {
-		install_dir($bucket_dir);
-	}
+	install_dir($bucket_dir);
 	if ($file =~ m{^/}) {
 		error("restore_file_on_clean requires a path relative to the package dir");
 	}
diff --git a/dh_bugfiles b/dh_bugfiles
index 2fe9a11..dd694da 100755
--- a/dh_bugfiles
+++ b/dh_bugfiles
@@ -107,7 +107,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			install_dir($dir);
 			doit("mv", "${dir}.tmp", "$dir/script");
 		}
-		elsif (! -d $dir) {
+		else {
 			install_dir($dir);
 		}
 		while (my ($type, $srcfile) = each(%bugfiles)) {
diff --git a/dh_builddeb b/dh_builddeb
index a39a716..36e729d 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -97,9 +97,7 @@ sub build_and_rename_deb {
 	my ($package, $destdir, $cmd, $rename_sub) = @_;
 	my $build_dir = "debian/.debhelper/scratch-space/build-${package}";
 	my ($dpkg_filename, $desired_filename);
-	if ( ! -d $build_dir) {
-		install_dir($build_dir);
-	}
+	install_dir($build_dir);
 	doit(@${cmd}, $build_dir);
 	opendir(my $fd, $build_dir);
 	for my $name (readdir($fd)) {
diff --git a/dh_gconf b/dh_gconf
index 28793b2..caed0fd 100755
--- a/dh_gconf
+++ b/dh_gconf
@@ -81,7 +81,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 	# Migrate schemas from /etc/gconf/schemas to /usr/share/gconf/schemas
 	if (-d $old_schemas_dir) {
-		install_dir($new_schemas_dir) unless -d $new_schemas_dir;
+		install_dir($new_schemas_dir);
 		complex_doit("mv $old_schemas_dir/*.schemas $new_schemas_dir/");
 		doit("rmdir","-p","--ignore-fail-on-non-empty",$old_schemas_dir);
 	}
diff --git a/dh_gencontrol b/dh_gencontrol
index bde389d..887d35c 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -67,9 +67,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		$changelog='debian/changelog';
 	}
 
-	if ( ! -d "$tmp/DEBIAN" ) {
-		install_dir("$tmp/DEBIAN");
-	}
+	install_dir("$tmp/DEBIAN");
 
 	# avoid gratuitous warning
 	if (! -e $substvars || system("grep -q '^misc:Depends=' $substvars") != 0) {
@@ -124,9 +122,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		} else {
 			push(@dbgsym_options, '-UReplaces', '-UBreaks');
 		}
-		if ( ! -d "${dbgsym_tmp}/DEBIAN" ) {
-			install_dir("${dbgsym_tmp}/DEBIAN");
-		}
+		install_dir("${dbgsym_tmp}/DEBIAN");
 		doit("dpkg-gencontrol", "-p${package}", "-l$changelog", "-T$substvars",
 			"-P${dbgsym_tmp}",@{$dh{U_PARAMS}}, @dbgsym_options);
 
diff --git a/dh_install b/dh_install
index 5275056..205d470 100755
--- a/dh_install
+++ b/dh_install
@@ -227,10 +227,8 @@ foreach my $package (getpackages()) {
 			}
 
 			# Make sure the destination directory exists.
-			if (! -e "$tmp/$dest") {
-				install_dir("$tmp/$dest");
-			}
-			
+			install_dir("$tmp/$dest");
+
 			if (-d $src && $exclude) {
 				my $basename = basename($src);
 				my $dir = ($basename eq '.') ? $src : "$src/..";
diff --git a/dh_installcatalogs b/dh_installcatalogs
index 1a863d5..af6129a 100755
--- a/dh_installcatalogs
+++ b/dh_installcatalogs
@@ -82,10 +82,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		foreach my $line (filedoublearray($sgmlcatlistfile)) {
 			my $source = $line->[0];
 			my $dest = $line->[1];
-	                my $fulldest = "$tmpdir/$dest"; 
+			my $fulldest = "$tmpdir/$dest";
 			$fulldest =~ s|//|/|g; # beautification
 	
 			if (! -d dirname($fulldest)) {
+				# Ensure the parent exist
 				install_dir($tmpdir."/".dirname($dest));
 			}
 
@@ -97,9 +98,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	if (@sgmlinstalled) {
 		addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
 
-		if (! -d "$tmpdir/etc/sgml") {
-			install_dir("$tmpdir/etc/sgml");
-		}
+		install_dir("$tmpdir/etc/sgml");
 
 		my $centralcat = "/etc/sgml/$package.cat";
 
diff --git a/dh_installchangelogs b/dh_installchangelogs
index b5e26a7..9f0563e 100755
--- a/dh_installchangelogs
+++ b/dh_installchangelogs
@@ -199,9 +199,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		next unless -d "$tmp/usr/share/doc/$package";
 	}
 
-	if (! -d "$tmp/usr/share/doc/$package") {
-		install_dir("$tmp/usr/share/doc/$package");
-	}
+	install_dir("$tmp/usr/share/doc/$package");
 
 	if (! $dh{NO_ACT}) {
 		if (! install_binNMU_changelog($package, $changelog, $changelog_name)) {
diff --git a/dh_installcron b/dh_installcron
index 8b42775..9217934 100755
--- a/dh_installcron
+++ b/dh_installcron
@@ -61,18 +61,14 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	foreach my $type (qw{hourly daily weekly monthly}) {
 		my $cron=pkgfile($package,"cron.$type");
 		if ($cron) {
-			if (! -d "$tmp/etc/cron.$type") {
-				install_dir("$tmp/etc/cron.$type");
-			}
+			install_dir("$tmp/etc/cron.$type");
 			install_prog($cron,"$tmp/etc/cron.$type/".pkgfilename($package));
 		}
 	}
 	# Separate because this needs to be mode 644.
 	my $cron=pkgfile($package,"cron.d");
 	if ($cron) {
-		if (! -d "$tmp/etc/cron.d") {
-			install_dir("$tmp/etc/cron.d");
-		}
+		install_dir("$tmp/etc/cron.d");
 		install_file($cron,"$tmp/etc/cron.d/".pkgfilename($package));
 	}
 }
diff --git a/dh_installdeb b/dh_installdeb
index c881707..7ba846c 100755
--- a/dh_installdeb
+++ b/dh_installdeb
@@ -95,9 +95,7 @@ my %maintscript_predeps = (
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 
-	if (! -d "$tmp/DEBIAN") {
-		install_dir("$tmp/DEBIAN");
-	}
+	install_dir("$tmp/DEBIAN");
 
 	if (is_udeb($package)) {
 		# For udebs, only do the postinst, and no #DEBHELPER#.
diff --git a/dh_installdebconf b/dh_installdebconf
index bf601eb..1c3d902 100755
--- a/dh_installdebconf
+++ b/dh_installdebconf
@@ -89,9 +89,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $config=pkgfile($package,"config");
 	my $templates=pkgfile($package,"templates");
 
-	if (! -d "$tmp/DEBIAN") {
-		install_dir("$tmp/DEBIAN");
-	}
+	install_dir("$tmp/DEBIAN");
 
 	if (! is_udeb($package)) {
 		debhelper_script_subst($package, "config");
diff --git a/dh_installdirs b/dh_installdirs
index d3bce35..0ea9dd4 100755
--- a/dh_installdirs
+++ b/dh_installdirs
@@ -63,9 +63,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 	my $file=pkgfile($package,"dirs");
 
-	if (! -e $tmp) {
-		install_dir($tmp);
-	}
+	install_dir($tmp);
 
 	my @dirs;
 
diff --git a/dh_installdocs b/dh_installdocs
index 935d724..9c82b5b 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -325,9 +325,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	closedir(DEB);
 	
 	if (%doc_ids) {
-		if (! -d "$tmp/usr/share/doc-base/") {
-			install_dir("$tmp/usr/share/doc-base/");
-		}
+		install_dir("$tmp/usr/share/doc-base/");
 	}
 	# check for duplicate document ids
 	my %used_doc_ids;
diff --git a/dh_installemacsen b/dh_installemacsen
index aac15a1..98f820c 100755
--- a/dh_installemacsen
+++ b/dh_installemacsen
@@ -100,31 +100,23 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $emacsen_startup=pkgfile($package,"emacsen-startup");
 
 	if ($emacsen_compat ne '') {
-		if (! -d "$tmp/usr/lib/emacsen-common/packages/compat") {
-			install_dir("$tmp/usr/lib/emacsen-common/packages/compat");
-		}
+		install_dir("$tmp/usr/lib/emacsen-common/packages/compat");
 		install_file($emacsen_compat,
 					 "$tmp/usr/lib/emacsen-common/packages/compat/$package");
 	}
 
 	if ($emacsen_install ne '') {
-		if (! -d "$tmp/usr/lib/emacsen-common/packages/install") {
-			install_dir("$tmp/usr/lib/emacsen-common/packages/install");
-		}
+		install_dir("$tmp/usr/lib/emacsen-common/packages/install");
 		install_prog($emacsen_install,"$tmp/usr/lib/emacsen-common/packages/install/$package");
 	}
 
 	if ($emacsen_remove ne '') {
-		if (! -d "$tmp/usr/lib/emacsen-common/packages/remove") {
-			install_dir("$tmp/usr/lib/emacsen-common/packages/remove");
-		}
+		install_dir("$tmp/usr/lib/emacsen-common/packages/remove");
 		install_prog("$emacsen_remove","$tmp/usr/lib/emacsen-common/packages/remove/$package");
 	}
 
 	if ($emacsen_startup ne '') {
-		if (! -d "$tmp/etc/$dh{FLAVOR}/site-start.d/") {
-			install_dir("$tmp/etc/$dh{FLAVOR}/site-start.d/");
-		}
+		install_dir("$tmp/etc/$dh{FLAVOR}/site-start.d/");
 		install_file($emacsen_startup,"$tmp/etc/$dh{FLAVOR}/site-start.d/$dh{PRIORITY}$package.el");
 	}
 
diff --git a/dh_installexamples b/dh_installexamples
index cd2fff5..5a695dd 100755
--- a/dh_installexamples
+++ b/dh_installexamples
@@ -82,10 +82,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 	
 	if (@examples) {
-		if (! -d "$tmp/usr/share/doc/$package/examples") {
-			install_dir("$tmp/usr/share/doc/$package/examples");
-		}
-		
+		install_dir("$tmp/usr/share/doc/$package/examples");
+
 		my $exclude = '';
 		if ($dh{EXCLUDE_FIND}) {
 			$exclude .= ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
diff --git a/dh_installifupdown b/dh_installifupdown
index 3fdbaad..d27f464 100755
--- a/dh_installifupdown
+++ b/dh_installifupdown
@@ -61,9 +61,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	foreach my $script (qw(pre-up up down post-down)) {
 		my $file=pkgfile($package, "if-$script");
 		if ($file ne '') {
-			if (! -d "$tmp/etc/network/if-$script.d") {
-				install_dir("$tmp/etc/network/if-$script.d");
-			}
+			install_dir("$tmp/etc/network/if-$script.d");
 			install_prog($file,"$tmp/etc/network/if-$script.d/".pkgfilename($package));
 		}
 	}
diff --git a/dh_installinfo b/dh_installinfo
index d12b0c0..f5e7ad8 100755
--- a/dh_installinfo
+++ b/dh_installinfo
@@ -66,9 +66,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 
 	if (@info) {
-		if ( ! -d "$tmp/usr/share/info") {
-			install_dir("$tmp/usr/share/info");
-		}
+		install_dir("$tmp/usr/share/info");
 		doit("cp", '--reflink=auto', @info, "$tmp/usr/share/info");
 		doit("chmod","-R", "go=rX","$tmp/usr/share/info/");
 		doit("chmod","-R", "u+rw","$tmp/usr/share/info/");
diff --git a/dh_installinit b/dh_installinit
index a79113a..087a3bd 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -219,37 +219,26 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $service=pkgfile($package,"service");
 	if ($service ne '' && ! $dh{ONLYSCRIPTS}) {
 		my $path="$tmp/lib/systemd/system";
-		if (! -d $path) {
-			install_dir($path);
-		}
-
+		install_dir($path);
 		install_file($service, "$path/$script.service");
 	}
 
 	my $tmpfile=pkgfile($package,"tmpfile");
 	if ($tmpfile ne '' && ! $dh{ONLYSCRIPTS}) {
 		my $path="$tmp/usr/lib/tmpfiles.d";
-		if (! -d $path) {
-			install_dir($path);
-		}
-
+		install_dir($path);
 		install_file($tmpfile, "$path/$script.conf");
 	}
 
 	my $job=pkgfile($package,"upstart");
 	if ($job ne '' && ! $dh{ONLYSCRIPTS}) {
-		if (! -d "$tmp/etc/init") {
-			install_dir("$tmp/etc/init");
-		}
-		
+		install_dir("$tmp/etc/init");
 		install_file($job, "$tmp/etc/init/$jobfile.conf");
 	}
 
 	my $default=pkgfile($package,'default');
 	if ($default ne '' && ! $dh{ONLYSCRIPTS}) {
-		if (! -d "$tmp/etc/default") {
-			install_dir("$tmp/etc/default");
-		}
+		install_dir("$tmp/etc/default");
 		install_file($default, "$tmp/etc/default/$script");
 	}
 
@@ -257,10 +246,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		pkgfile($package,"init.d");
 
 	if ($init ne '' && ! $dh{ONLYSCRIPTS}) {
-		if (! -d "$tmp/etc/init.d") {
-			install_dir("$tmp/etc/init.d");
-		}
-		
+		install_dir("$tmp/etc/init.d");
 		install_prog($init,"$tmp/etc/init.d/$script");
 	}
 
diff --git a/dh_installlogcheck b/dh_installlogcheck
index 72c92a3..b243c6e 100755
--- a/dh_installlogcheck
+++ b/dh_installlogcheck
@@ -68,11 +68,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		$typenod=~s/\.d//;
 		my $logcheck=pkgfile($package,"logcheck.$typenod");
 		if ($logcheck) {
-			if (! -d "$tmp/etc/logcheck/$type") {
-				install_dir("$tmp/etc/logcheck/$type");
-			}
 			my $packagenodot=pkgfilename($package); # run-parts..
 			$packagenodot=~s/\./_/g;
+			install_dir("$tmp/etc/logcheck/$type");
 			install_file($logcheck, "$tmp/etc/logcheck/$type/$packagenodot");
 		}
 	}
diff --git a/dh_installlogrotate b/dh_installlogrotate
index 9d7d554..8e43086 100755
--- a/dh_installlogrotate
+++ b/dh_installlogrotate
@@ -43,9 +43,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $file=pkgfile($package,"logrotate");
 
 	if ($file) {
-		if (! -d "$tmp/etc/logrotate.d") {
-			install_dir("$tmp/etc/logrotate.d");
-		}
+		install_dir("$tmp/etc/logrotate.d");
 		install_file($file,"$tmp/etc/logrotate.d/".pkgfilename($package));
 	}
 }
diff --git a/dh_installman b/dh_installman
index af2d136..78faf13 100755
--- a/dh_installman
+++ b/dh_installman
@@ -178,9 +178,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		next if -l $instpage;
 		next if compat(5) && -e $instpage;
 
-		if (! -d $destdir) {
-			install_dir($destdir);
-		}
+		install_dir($destdir);
 		if ($gz) {
 			complex_doit "zcat \Q$page\E > \Q$instpage\E";
 		}
diff --git a/dh_installmanpages b/dh_installmanpages
index 2583002..3f5a949 100755
--- a/dh_installmanpages
+++ b/dh_installmanpages
@@ -173,9 +173,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$destdir=~tr:/:/:s; # just for looks
 
 			if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
-				if (! -d $destdir) {
-					install_dir($destdir);
-				}
+				install_dir($destdir);
 				install_file($page,$destdir.$instname);
 			}
 		}
diff --git a/dh_installmenu b/dh_installmenu
index a2c5910..9499ad3 100755
--- a/dh_installmenu
+++ b/dh_installmenu
@@ -65,9 +65,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	
 	if ($menu ne '') {
 		if (compat(10)) {
-			if (! -d "$tmp/usr/share/menu") {
-				install_dir("$tmp/usr/share/menu");
-			}
+			install_dir("$tmp/usr/share/menu");
 			install_file($menu,"$tmp/usr/share/menu/$package");
 
 			# Add the scripts if a menu-method file doesn't exist.
@@ -83,9 +81,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 
 	if ($menu_method ne '') {
-		if (!-d "$tmp/etc/menu-methods") {
-			install_dir("$tmp/etc/menu-methods");
-		}
+		install_dir("$tmp/etc/menu-methods");
 		install_file($menu_method,"$tmp/etc/menu-methods/$package");
 
 		if (! $dh{NOSCRIPTS}) {
diff --git a/dh_installmime b/dh_installmime
index 0b394ad..25da89e 100755
--- a/dh_installmime
+++ b/dh_installmime
@@ -46,17 +46,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 	my $mime=pkgfile($package,"mime");
 	if ($mime ne '') {
-		if (! -d "$tmp/usr/lib/mime/packages") {
-			install_dir("$tmp/usr/lib/mime/packages");
-		}
+		install_dir("$tmp/usr/lib/mime/packages");
 		install_file($mime, "$tmp/usr/lib/mime/packages/$package");
 	}
 	
 	my $sharedmimeinfo=pkgfile($package,"sharedmimeinfo");
 	if ($sharedmimeinfo ne '') {
-		if (! -d "$tmp/usr/share/mime/packages") {
-			install_dir("$tmp/usr/share/mime/packages");
-		}
+		install_dir("$tmp/usr/share/mime/packages");
 		install_file($sharedmimeinfo,
 					 "$tmp/usr/share/mime/packages/$package.xml");
 	}
diff --git a/dh_installmodules b/dh_installmodules
index 068f56d..6f7630a 100755
--- a/dh_installmodules
+++ b/dh_installmodules
@@ -91,10 +91,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $modprobe_file=pkgfile($package,"modprobe");
 
 	if ($modprobe_file) {
-		if (! -e "$tmp/etc/modprobe.d") {
-			install_dir("$tmp/etc/modprobe.d");
-		}
 		my $path = '/etc/modprobe.d/' . pkgfilename($package) . '.conf';
+		install_dir("$tmp/etc/modprobe.d");
 		install_file($modprobe_file, "$tmp/$path");
 	}
 	
diff --git a/dh_installpam b/dh_installpam
index 2f73241..92c2621 100755
--- a/dh_installpam
+++ b/dh_installpam
@@ -52,9 +52,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $pam=pkgfile($package,"pam");
 
 	if ($pam ne '') {
-		if (! -d "$tmp/etc/pam.d") {
-			install_dir("$tmp/etc/pam.d");
-		}
+		install_dir("$tmp/etc/pam.d");
 		install_file($pam,"$tmp/etc/pam.d/".pkgfilename($package));
 	}
 }
diff --git a/dh_installppp b/dh_installppp
index 342591a..39e41ca 100755
--- a/dh_installppp
+++ b/dh_installppp
@@ -57,9 +57,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	foreach my $script (qw(up down)) {
 		my $file=pkgfile($package, "ppp.ip-$script");
 		if ($file ne '') {
-			if (! -d "$tmp/etc/ppp/ip-$script.d") {
-				install_dir("$tmp/etc/ppp/ip-$script.d");
-			}
+			install_dir("$tmp/etc/ppp/ip-$script.d");
 			install_prog($file,"$tmp/etc/ppp/ip-$script.d/".pkgfilename($package));
 		}
 	}
diff --git a/dh_installudev b/dh_installudev
index 1985676..41870e2 100755
--- a/dh_installudev
+++ b/dh_installudev
@@ -90,10 +90,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 
 	if ($rules_file) {
-		if (! -e "$tmp/lib/udev/rules.d") {
-			install_dir("$tmp/lib/udev/rules.d");
-		}
 		my $rule="/lib/udev/rules.d/$dh{PRIORITY}$filename";
+		install_dir("$tmp/lib/udev/rules.d");
 		install_file($rules_file, "${tmp}${rule}");
 	}
 }
diff --git a/dh_lintian b/dh_lintian
index ffb16f6..4439334 100755
--- a/dh_lintian
+++ b/dh_lintian
@@ -50,9 +50,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $overrides=pkgfile($package,"lintian-overrides");
 
 	if ($overrides ne '') {
-		if (! -d $or_dir) {
-			 install_dir($or_dir);
-		}
+		install_dir($or_dir);
 		install_dh_config_file($overrides, "$or_dir/$package");
 	}
 }
diff --git a/dh_makeshlibs b/dh_makeshlibs
index 4c39387..45f2946 100755
--- a/dh_makeshlibs
+++ b/dh_makeshlibs
@@ -184,9 +184,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$major=$dh{M_PARAMS};
 		}
 		
-		if (! -d "$tmp/DEBIAN") {
-			install_dir("$tmp/DEBIAN");
-		}
+		install_dir("$tmp/DEBIAN");
 		my $deps=$package;
 		if ($dh{V_FLAG_SET}) {
 			if ($shlibs_file) {
@@ -236,9 +234,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 
 	if ($shlibs_file) {
-		if (! -d "$tmp/DEBIAN") {
-			install_dir("$tmp/DEBIAN");
-		}
+		install_dir("$tmp/DEBIAN");
 		install_file($shlibs_file, "$tmp/DEBIAN/shlibs");
 	}
 
diff --git a/dh_md5sums b/dh_md5sums
index 6437003..d4e9ff3 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -55,9 +55,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $dbgsym_tmp = "debian/.debhelper/${package}/dbgsym-root";
 	my $tmp=tmpdir($package);
 
-	if (! -d "$tmp/DEBIAN") {
-		install_dir("$tmp/DEBIAN");
-	}
+	install_dir("$tmp/DEBIAN");
 
 	# Check if we should exclude conffiles.
 	my $exclude="";
@@ -89,9 +87,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("chown", "0:0", "$tmp/DEBIAN/md5sums");
 	}
 	if ( -d $dbgsym_tmp) {
-		if (! -d "${dbgsym_tmp}/DEBIAN") {
-			install_dir("${dbgsym_tmp}/DEBIAN");
-		}
+		install_dir("${dbgsym_tmp}/DEBIAN");
 
 		$find = "find . -type f ! -regex './DEBIAN/.*' -printf '%P\\0'";
 		complex_doit("(cd $dbgsym_tmp >/dev/null ; $find | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums) >/dev/null");
diff --git a/dh_movefiles b/dh_movefiles
index 52a12bb..de9facb 100755
--- a/dh_movefiles
+++ b/dh_movefiles
@@ -118,9 +118,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	push(@tomove, @tomove_expanded);
 
 	if (@tomove) {
-		if (! -d $tmp) {
-			install_dir($tmp);
-		}
+		install_dir($tmp);
 
 		doit("rm","-f","debian/movelist");
 		foreach (@tomove) {
diff --git a/dh_shlibdeps b/dh_shlibdeps
index 19df209..eefcc43 100755
--- a/dh_shlibdeps
+++ b/dh_shlibdeps
@@ -107,14 +107,10 @@ if (defined $dh{V_FLAG}) {
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 	my $ext=pkgext($package);
+	my (@filelist, $ff);
 
 	# dpkg-shlibdeps expects this directory to exist
-	if (! -d "$tmp/DEBIAN") {
-		install_dir("$tmp/DEBIAN");
-	}
-
-	my @filelist;
-	my $ff;
+	install_dir("$tmp/DEBIAN");
 
 	# Generate a list of ELF binaries in the package, ignoring any
 	# we were told to exclude.
diff --git a/dh_strip b/dh_strip
index 7161cc5..7a16750 100755
--- a/dh_strip
+++ b/dh_strip
@@ -272,9 +272,7 @@ sub make_debug {
 		$debug_path=$desttmp."/usr/lib/debug/".$base_file;
 	}
 	my $debug_dir=dirname($debug_path);
-	if (! -d $debug_dir) {
-		install_dir($debug_dir);
-	}
+	install_dir($debug_dir);
 	if (compat(8) && $use_build_id < 2) {
 		doit($objcopy, "--only-keep-debug", $file, $debug_path);
 	}
@@ -369,7 +367,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		my $dbgsym_docdir = "${debugtmp}/usr/share/doc";
 		my $doc_symlink = "${dbgsym_docdir}/${package}-dbgsym";
 		if ( not -l $doc_symlink and not -e $doc_symlink ) {
-			install_dir($dbgsym_docdir) if not -d $dbgsym_docdir;
+			install_dir($dbgsym_docdir);
 			doit('ln', '-s', $package, $doc_symlink);
 		}
 		if ($dh{MIGRATE_DBGSYM}) {
@@ -388,7 +386,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$dir = "debian/.debhelper/${dbg_pkg}";
 		}
 		$path = "${dir}/dbgsym-build-ids";
-		install_dir($dir) if ! -d $dir;
+		install_dir($dir);
 		open(my $fd, '>>', $path) or error("open $path failed: $!");
 		print {$fd} join(q{ }, sort(@build_ids)) . "\n";
 		close($fd) or error("close $path failed: $!");
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index f530b94..4d1e315 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -311,6 +311,7 @@ install_dh_config_file($src, $dest[, $mode])
 install_dir($dir)
 	Create the directory denoted by the path $dir and all parent
 	entries as well (as needed).
+        If the directory already exists, the function does not.
 install_file($src, $dest)
 	Installs $src into $dest with mode 0644.  The parent dir of
 	$dest must exist (can be created with install_dir).

-- 
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