summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-06-26 07:35:18 +0000
committerNiels Thykier <niels@thykier.net>2017-06-26 07:39:49 +0000
commitee8fd59af61fa4739cdd536ecbb492cc8520df40 (patch)
tree4e2211bb3a4290bcc0d1bc8ae8bf053257897eaf
parenta157c078b721015c844e27a9f7b5201b6dd206cc (diff)
downloaddebhelper-ee8fd59af61fa4739cdd536ecbb492cc8520df40.tar.gz
Avoid fork+exec for rm -f and ln -s in non-deprecated tools
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--Debian/Debhelper/Dh_Lib.pm4
-rwxr-xr-xdh5
-rwxr-xr-xdh_clean8
-rwxr-xr-xdh_compress6
-rwxr-xr-xdh_installdeb2
-rwxr-xr-xdh_installdocs2
-rwxr-xr-xdh_installman6
-rwxr-xr-xdh_makeshlibs4
-rwxr-xr-xdh_md5sums4
-rwxr-xr-xdh_strip2
10 files changed, 24 insertions, 19 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 8b64e03c..c3f3c4a9 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -1357,8 +1357,8 @@ sub make_symlink{
if (-d "$tmp/$dest" && ! -l "$tmp/$dest") {
error("link destination $tmp/$dest is a directory");
}
- doit("rm", "-f", "$tmp/$dest");
- doit("ln","-sf", $src, "$tmp/$dest");
+ rm_files("$tmp/$dest");
+ make_symlink_raw_target($src, "$tmp/$dest");
}
# _expand_path expands all path "." and ".." components, but doesn't
diff --git a/dh b/dh
index ee8c6cfc..2f63a96e 100755
--- a/dh
+++ b/dh
@@ -851,7 +851,10 @@ sub run_override {
# Discard any override log files before calling the override
# target
- complex_doit("rm","-f","debian/*.debhelper.log") if not compat(9);
+ if (not compat(9)) {
+ my @files = glob('debian/*.debhelper.log');
+ rm_files(@files) if @files;
+ }
# This passes the options through to commands called
# inside the target.
$ENV{DH_INTERNAL_OPTIONS}=join("\x1e", @options);
diff --git a/dh_clean b/dh_clean
index 47f04346..f50be303 100755
--- a/dh_clean
+++ b/dh_clean
@@ -86,7 +86,7 @@ if ($dh{K_FLAG}) {
}
# Remove the debhelper stamp file
-doit('rm', '-f', 'debian/debhelper-build-stamp') if not $dh{D_FLAG};
+rm_files('debian/debhelper-build-stamp') if not $dh{D_FLAG};
my (@clean_files, @clean_dirs);
@@ -120,7 +120,8 @@ if (not $dh{D_FLAG}) {
# Remove all debhelper logs.
if (! $dh{D_FLAG} && ! $dh{K_FLAG}) {
- complex_doit("rm","-f","debian/*.debhelper.log");
+ my @logs = glob('debian/*.debhelper.log');
+ rm_files(@logs) if @logs;
}
if (! $dh{D_FLAG}) {
@@ -171,7 +172,8 @@ doit('rm', '-rf', 'debian/tmp') if -x 'debian/tmp' &&
! excludefile("debian/tmp");
if (!compat(6) && !$dh{K_FLAG}) {
- complex_doit('rm -f *-stamp');
+ my @stamp_files = glob('*-stamp');
+ rm_files(@stamp_files) if @stamp_files;
}
=head1 SEE ALSO
diff --git a/dh_compress b/dh_compress
index c3def868..89c23f8a 100755
--- a/dh_compress
+++ b/dh_compress
@@ -192,7 +192,7 @@ on_pkgs_in_parallel {
# they are again.
foreach (keys %hardlinks) {
# Remove old file.
- doit("rm","-f","$_");
+ rm_files($_);
# Make new hardlink.
doit("ln","$hardlinks{$_}.gz","$_.gz");
}
@@ -212,8 +212,8 @@ on_pkgs_in_parallel {
my ($directory) = $link =~ m:(.*)/:;
my $linkval = readlink($link);
if (! -e "$directory/$linkval" && -e "$directory/$linkval.gz") {
- doit("rm","-f",$link);
- doit("ln","-sf","$linkval.gz","$link.gz");
+ rm_files($link);
+ make_symlink_raw_target("$linkval.gz","$link.gz");
delete $links{$link};
$changed++;
}
diff --git a/dh_installdeb b/dh_installdeb
index 0507617e..09d04263 100755
--- a/dh_installdeb
+++ b/dh_installdeb
@@ -179,7 +179,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
complex_doit("find $tmp/etc -type f -printf '/etc/%P\n' | LC_ALL=C sort >> $tmp/DEBIAN/conffiles");
# Anything found?
if (-z "$tmp/DEBIAN/conffiles") {
- doit("rm","-f","$tmp/DEBIAN/conffiles");
+ rm_files("$tmp/DEBIAN/conffiles");
}
else {
reset_perm_and_owner('0644', "$tmp/DEBIAN/conffiles");
diff --git a/dh_installdocs b/dh_installdocs
index 5d82ea5f..465a74d5 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -207,7 +207,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# necessary.
if (! -d "$tmp/usr/share/doc/$package" &&
! -l "$tmp/usr/share/doc/$package") {
- doit("ln", "-sf", $dh{LINK_DOC}, "$tmp/usr/share/doc/$package");
+ make_symlink_raw_target($dh{LINK_DOC}, "$tmp/usr/share/doc/$package");
# Policy says that if you make your documentation
# directory a symlink, then you have to depend on
# the target.
diff --git a/dh_installman b/dh_installman
index 59514efc..ec55873b 100755
--- a/dh_installman
+++ b/dh_installman
@@ -229,8 +229,8 @@ on_selected_pkgs_in_parallel(\@all_packages, sub {
}
foreach my $sofile (@sofiles) {
my $sodest = shift(@sodests);
- doit "rm", "-f", $sofile;
- doit "ln", "-sf", $sodest, $sofile;
+ rm_files($sofile);
+ make_symlink_raw_target($sodest, $sofile);
}
# Now utf-8 conversion.
@@ -243,7 +243,7 @@ on_selected_pkgs_in_parallel(\@all_packages, sub {
my ($tmp, $orig) = ($_.".new", $_);
complex_doit "man --recode UTF-8 ./\Q$orig\E > \Q$tmp\E";
# recode uncompresses compressed pages
- doit "rm", "-f", $orig if s/\.(gz|Z)$//;
+ rm_files($orig) if s/\.(gz|Z)$//;
doit "mv", "-f", $tmp, $_;
# Schedule a permission reset
push(@files, "${File::Find::dir}/${_}");
diff --git a/dh_makeshlibs b/dh_makeshlibs
index 4f5c8b6a..0dc2027b 100755
--- a/dh_makeshlibs
+++ b/dh_makeshlibs
@@ -149,7 +149,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
my $need_ldconfig = 0;
my $shlibs_file = pkgfile($package, 'shlibs');
- doit("rm", "-f", "$tmp/DEBIAN/shlibs");
+ rm_files("$tmp/DEBIAN/shlibs");
# So, we look for files or links to existing files with names that
# match "*.so.*". And we only look at real files not
@@ -263,7 +263,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
) && $ok;
if (-f "$tmp/DEBIAN/symbols" and -s _ == 0) {
- doit("rm", "-f", "$tmp/DEBIAN/symbols");
+ rm_files("$tmp/DEBIAN/symbols");
} elsif ($unversioned_so) {
# There are a few "special" libraries (e.g. nss/nspr)
# which do not have versioned SONAMES. However the
diff --git a/dh_md5sums b/dh_md5sums
index b91b2d65..344c9adf 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -82,7 +82,7 @@ on_pkgs_in_parallel {
q{perl -pe 'if (s@^\\\\@@) { s/\\\\\\\\/\\\\/g; }' > DEBIAN/md5sums) >/dev/null});
# If the file's empty, no reason to waste inodes on it.
if (-z "$tmp/DEBIAN/md5sums") {
- doit("rm","-f","$tmp/DEBIAN/md5sums");
+ rm_files("$tmp/DEBIAN/md5sums");
}
else {
reset_perm_and_owner('0644', "$tmp/DEBIAN/md5sums");
@@ -95,7 +95,7 @@ on_pkgs_in_parallel {
q{perl -pe 'if (s@^\\\\@@) { s/\\\\\\\\/\\\\/g; }' > DEBIAN/md5sums) >/dev/null});
# If the file's empty, no reason to waste inodes on it.
if (-z "${dbgsym_tmp}/DEBIAN/md5sums") {
- doit('rm', '-f', "${dbgsym_tmp}/DEBIAN/md5sums");
+ rm_files("${dbgsym_tmp}/DEBIAN/md5sums");
}
else {
reset_perm_and_owner('0644', "${dbgsym_tmp}/DEBIAN/md5sums");
diff --git a/dh_strip b/dh_strip
index 738bcc54..a7efc2d0 100755
--- a/dh_strip
+++ b/dh_strip
@@ -368,7 +368,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
my $doc_symlink = "${dbgsym_docdir}/${package}-dbgsym";
if ( not -l $doc_symlink and not -e $doc_symlink ) {
install_dir($dbgsym_docdir);
- doit('ln', '-s', $package, $doc_symlink);
+ make_symlink_raw_target($package, $doc_symlink);
}
if ($dh{MIGRATE_DBGSYM}) {
my $path = "debian/.debhelper/${package}/dbgsym-migration";