diff options
author | Niels Thykier <niels@thykier.net> | 2017-06-26 07:35:18 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-06-26 07:39:49 +0000 |
commit | ee8fd59af61fa4739cdd536ecbb492cc8520df40 (patch) | |
tree | 4e2211bb3a4290bcc0d1bc8ae8bf053257897eaf | |
parent | a157c078b721015c844e27a9f7b5201b6dd206cc (diff) | |
download | debhelper-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.pm | 4 | ||||
-rwxr-xr-x | dh | 5 | ||||
-rwxr-xr-x | dh_clean | 8 | ||||
-rwxr-xr-x | dh_compress | 6 | ||||
-rwxr-xr-x | dh_installdeb | 2 | ||||
-rwxr-xr-x | dh_installdocs | 2 | ||||
-rwxr-xr-x | dh_installman | 6 | ||||
-rwxr-xr-x | dh_makeshlibs | 4 | ||||
-rwxr-xr-x | dh_md5sums | 4 | ||||
-rwxr-xr-x | dh_strip | 2 |
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 @@ -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); @@ -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 @@ -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"); @@ -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"; |