summaryrefslogtreecommitdiff
path: root/Debian
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-07-12 19:35:11 +0000
committerNiels Thykier <niels@thykier.net>2017-07-12 19:44:06 +0000
commit378dfa200576c1823241f47fff88224a051a0a68 (patch)
treeb8c33d7fcbba160cf0b2378adfd70b5e9089772e /Debian
parent7db95f249b2d71e41d0712136ecf281a328d5993 (diff)
downloaddebhelper-378dfa200576c1823241f47fff88224a051a0a68.tar.gz
reset_perm_and_owner: Use perl functions instead of fork+exec
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'Debian')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm20
1 files changed, 18 insertions, 2 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 56ebeaf2..744c9f15 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -430,8 +430,24 @@ sub rename_path {
sub reset_perm_and_owner {
my ($mode, @paths) = @_;
- doit('chmod', $mode, '--', @paths);
- doit('chown', '0:0', '--', @paths);
+ my $_mode;
+ # Dark goat blood to tell 0755 from "0755"
+ if (length( do { no warnings "numeric"; $mode & "" } ) ) {
+ # 0755, leave it alone.
+ $_mode = $mode;
+ } else {
+ # "0755" -> convert to 0755
+ $_mode = oct($mode);
+ }
+ if ($dh{VERBOSE}) {
+ verbose_print(sprintf('chmod %#o -- %s', $_mode, escape_shell(@paths)));
+ verbose_print(sprintf('chown 0:0 -- %s', escape_shell(@paths)));
+ }
+ return if $dh{NO_ACT};
+ for my $path (@paths) {
+ chmod($_mode, $path) or error(sprintf('chmod(%#o, %s): %s', $mode, $path, $!));
+ chown(0, 0, $path) or error("chown(0, 0, $path): $!");
+ }
}
# Run a command that may have a huge number of arguments, like xargs does.