[debhelper-devel] [debhelper] 01/08: Dh_Lib: Use File::Copy instead of calling install(1)
Niels Thykier
nthykier at moszumanska.debian.org
Tue Jun 13 20:33:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 8b8dc96abb9b1596c3685a9ae69816654489c99f
Author: Niels Thykier <niels at thykier.net>
Date: Mon Jun 5 13:40:37 2017 +0000
Dh_Lib: Use File::Copy instead of calling install(1)
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Dh_Lib.pm | 42 ++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 6e976d6..ec8b49f 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -338,15 +338,41 @@ sub error_exitcode {
# install_prog - installs an executable
# install_lib - installs a shared library (some systems may need x-bit, others don't)
# install_dir - installs a directory
-sub install_file {
- doit('install', '-p', '-m0644', @_);
-}
-sub install_prog {
- doit('install', '-p', '-m0755', @_);
-}
-sub install_lib {
- doit('install', '-p', '-m0644', @_);
+{
+ my $_loaded = 0;
+ sub install_file {
+ unshift(@_, 0644);
+ goto \&_install_file_to_path;
+ }
+
+ sub install_prog {
+ unshift(@_, 0755);
+ goto \&_install_file_to_path;
+ }
+ sub install_lib {
+ unshift(@_, 0644);
+ goto \&_install_file_to_path;
+ }
+
+ sub _install_file_to_path {
+ my ($mode, $source, $dest) = @_;
+ if (not $_loaded) {
+ $_loaded++;
+ require File::Copy;
+ }
+ verbose_print(sprintf('install -p -m%04o %s', $mode, escape_shell($source, $dest)))
+ if $dh{VERBOSE};
+ return 1 if $dh{NO_ACT};
+ 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));
+ return 1;
+ }
}
+
sub install_dir {
my @to_create = grep { not -d $_ } @_;
doit('install', '-d', @to_create) if @to_create;
--
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