diff options
author | Niels Thykier <niels@thykier.net> | 2022-12-14 19:27:46 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2022-12-14 20:27:36 +0000 |
commit | ca66cf4bc74fe31b3d5c8131788effff7fdd8731 (patch) | |
tree | 633a382c15bc4c90e604adb353258d87e4667f21 | |
parent | 729b0688babcb7b0964892b7b4f6e7f86ebbcb7d (diff) |
Dh_Lib.pm: Revert change where `install_{file,prog,lib}` would use chown
The problem that prompted this change was not caused by debhelper but
by fakeroot (#1024544) and the change in debhelper would not even
function as a work around in this case. Accordingly, the extra
complexity is not worth it and has been reverted.
Gbp-Dch: Full
-rw-r--r-- | lib/Debian/Debhelper/Dh_Lib.pm | 26 | ||||
-rw-r--r-- | t/Test/DH.pm | 2 |
2 files changed, 11 insertions, 17 deletions
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm index f519bbb3..afd183ea 100644 --- a/lib/Debian/Debhelper/Dh_Lib.pm +++ b/lib/Debian/Debhelper/Dh_Lib.pm @@ -631,46 +631,40 @@ sub error_exitcode { { my $_loaded = 0; sub install_file { - unshift(@_, 1, 0644); + unshift(@_, 0644); goto \&_install_file_to_path; } sub install_prog { - unshift(@_, 1, 0755); + unshift(@_, 0755); goto \&_install_file_to_path; } sub install_lib { - unshift(@_, 1, 0644); + unshift(@_, 0644); goto \&_install_file_to_path; } sub _install_file_to_path { - my ($consider_using_root, $mode, $source, $dest) = @_; + my ($mode, $source, $dest) = @_; if (not $_loaded) { $_loaded++; require File::Copy; } - my $use_root = !$consider_using_root && should_use_root(); - if ($dh{VERBOSE}) { - my $install_opts = $use_root ? '-o 0 -g 0 ' : ''; - verbose_print(sprintf('install -p %s-m%04o %s', $install_opts, $mode, escape_shell($source, $dest))) - } + verbose_print(sprintf('install -p -m%04o %s', $mode, escape_shell($source, $dest))) + if $dh{VERBOSE}; return 1 if $dh{NO_ACT}; # "install -p -mXXXX foo bar" silently discards broken # symlinks to install the file in place. File::Copy does not, # so emulate it manually. (#868204) if ( -l $dest and not -e $dest and not unlink($dest) and $! != ENOENT) { - error("unlink(\"$dest\") failed: $!"); - } - File::Copy::copy($source, $dest) or error("copy(\"$source\", \"$dest\"): $!"); - chmod($mode, $dest) or error("chmod($mode, \"$dest\"): $!"); - if ($use_root) { - chown(0, 0, $dest) or error("chown(0, 0, \"$dest\") failed: $!"); + error("unlink $dest failed: $!"); } + File::Copy::copy($source, $dest) or error("copy($source, $dest): $!"); + chmod($mode, $dest) or error("chmod($mode, $dest): $!"); my (@stat) = stat($source); error("stat($source): $!") if not @stat; utime($stat[8], $stat[9], $dest) - or error(sprintf("utime(%d, %d, \"%s\"): $!", $stat[8] , $stat[9], $dest)); + or error(sprintf("utime(%d, %d, %s): $!", $stat[8] , $stat[9], $dest)); return 1; } } diff --git a/t/Test/DH.pm b/t/Test/DH.pm index 7d85353d..8d9e71fe 100644 --- a/t/Test/DH.pm +++ b/t/Test/DH.pm @@ -58,7 +58,7 @@ my $TEST_DIR; sub copy_file { my ($src, $dest, $mode) = @_; $mode //= 0644; - return Debian::Debhelper::Dh_Lib::_install_file_to_path(0, $mode, $src, $dest); + return Debian::Debhelper::Dh_Lib::_install_file_to_path($mode, $src, $dest); } sub run_dh_tool { |