summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2016-10-02 20:41:26 +0000
committerNiels Thykier <niels@thykier.net>2016-10-02 20:41:26 +0000
commit580bc09d41ddc8542515f50d40ff8c8477711d3d (patch)
tree7d7a119f256da70068de3280e3657e5b2f616c96
parentf1757dd5d915e567d2cd1f09e3811c2673ad1867 (diff)
downloaddebhelper-580bc09d41ddc8542515f50d40ff8c8477711d3d.tar.gz
Dh_Lib: Add a reset_perm_and_owner function
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--Debian/Debhelper/Dh_Lib.pm13
-rwxr-xr-xdh_bugfiles4
-rwxr-xr-xdh_fixperms4
-rwxr-xr-xdh_gencontrol7
-rwxr-xr-xdh_installchangelogs3
-rwxr-xr-xdh_installdeb2
-rwxr-xr-xdh_installman2
-rwxr-xr-xdh_makeshlibs3
-rwxr-xr-xdh_md5sums6
-rwxr-xr-xdh_strip2
-rw-r--r--doc/PROGRAMMING10
11 files changed, 31 insertions, 25 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 3ecd6e6c..121dc04b 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -49,7 +49,7 @@ use vars qw(@EXPORT %dh);
&get_source_date_epoch &is_cross_compiling
&generated_file &autotrigger &package_section
&restore_file_on_clean &restore_all_files
- &open_gz
+ &open_gz &reset_perm_and_owner
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -324,6 +324,11 @@ sub install_dir {
my @to_create = grep { not -d $_ } @_;
doit('install', '-d', @to_create) if @to_create;
}
+sub reset_perm_and_owner {
+ my ($mode, @paths) = @_;
+ doit('chmod', $mode, '--', @paths);
+ doit('chown', '0:0', '--', @paths);
+}
# Run a command that may have a huge number of arguments, like xargs does.
# Pass in a reference to an array containing the arguments, and then other
@@ -1101,14 +1106,12 @@ sub debhelper_script_subst {
# Just get rid of any #DEBHELPER# in the script.
complex_doit("sed s/#DEBHELPER#// < $file > $tmp/DEBIAN/$script");
}
- doit("chown","0:0","$tmp/DEBIAN/$script");
- doit("chmod","0755","$tmp/DEBIAN/$script");
+ reset_perm_and_owner('0755', "$tmp/DEBIAN/$script");
}
elsif ( -f "debian/$ext$script.debhelper" ) {
complex_doit("printf '#!/bin/sh\nset -e\n' > $tmp/DEBIAN/$script");
complex_doit("cat debian/$ext$script.debhelper >> $tmp/DEBIAN/$script");
- doit("chown","0:0","$tmp/DEBIAN/$script");
- doit("chmod","0755","$tmp/DEBIAN/$script");
+ reset_perm_and_owner('0755', "$tmp/DEBIAN/$script");
}
}
diff --git a/dh_bugfiles b/dh_bugfiles
index dd694daf..51fe1ff3 100755
--- a/dh_bugfiles
+++ b/dh_bugfiles
@@ -121,10 +121,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# Ensure that the bug script is executable
if (-f $dir) {
- chmod 0755, $dir;
+ reset_perm_and_owner('0755', $dir);
}
elsif (-f "$dir/script") {
- chmod 0755, "$dir/script";
+ reset_perm_and_owner('0755', "$dir/script");
}
}
diff --git a/dh_fixperms b/dh_fixperms
index 79c2b189..fafe4510 100755
--- a/dh_fixperms
+++ b/dh_fixperms
@@ -124,10 +124,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
"! -name 'script' $find_options -print0",
"2>/dev/null | xargs -0r chmod 644");
if ( -f "$tmp/usr/share/bug/$package/script" ) {
- doit('chmod', '0755', "$tmp/usr/share/bug/$package/script");
+ reset_perm_and_owner('0755', "$tmp/usr/share/bug/$package/script");
}
} elsif ( -f "$tmp/usr/share/bug/$package" ) {
- doit('chmod', '0755', "$tmp/usr/share/bug/$package");
+ reset_perm_and_owner('0755', "$tmp/usr/share/bug/$package");
}
# Lintian overrides should never be executable, too.
diff --git a/dh_gencontrol b/dh_gencontrol
index 887d35c2..4edb065f 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -126,8 +126,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
doit("dpkg-gencontrol", "-p${package}", "-l$changelog", "-T$substvars",
"-P${dbgsym_tmp}",@{$dh{U_PARAMS}}, @dbgsym_options);
- doit("chmod","0644","${dbgsym_tmp}/DEBIAN/control");
- doit("chown","0:0","${dbgsym_tmp}/DEBIAN/control");
+ reset_perm_and_owner('0644', "${dbgsym_tmp}/DEBIAN/control");
} elsif ($build_ids) {
# Only include the build-id if there is no dbgsym package (if
# there is a dbgsym package, the build-ids into the control
@@ -141,9 +140,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
# This chmod is only necessary if the user sets the umask to
# something odd.
- doit("chmod","0644","$tmp/DEBIAN/control");
-
- doit("chown","0:0","$tmp/DEBIAN/control");
+ reset_perm_and_owner('0644', "${tmp}/DEBIAN/control");
}
sub read_dbgsym_file {
diff --git a/dh_installchangelogs b/dh_installchangelogs
index 9f0563ea..4aaef0b1 100755
--- a/dh_installchangelogs
+++ b/dh_installchangelogs
@@ -224,8 +224,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
$link_to='changelog.html';
if (! defined $upstream_text) {
complex_doit("echo 'See changelog.html.gz' > $base/changelog");
- doit("chmod","644","$base/changelog");
- doit("chown","0:0","$base/changelog");
+ reset_perm_and_owner('0644',"$base/changelog");
}
}
if ($dh{K_FLAG}) {
diff --git a/dh_installdeb b/dh_installdeb
index 7ba846c2..0507617e 100755
--- a/dh_installdeb
+++ b/dh_installdeb
@@ -182,7 +182,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
doit("rm","-f","$tmp/DEBIAN/conffiles");
}
else {
- doit("chmod","0644","$tmp/DEBIAN/conffiles");
+ reset_perm_and_owner('0644', "$tmp/DEBIAN/conffiles");
}
}
}
diff --git a/dh_installman b/dh_installman
index 78faf13e..bbea82e8 100755
--- a/dh_installman
+++ b/dh_installman
@@ -210,7 +210,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
complex_doit "man --recode UTF-8 ./\Q$orig\E > \Q$tmp\E";
# recode uncompresses compressed pages
doit "rm", "-f", $orig if s/\.(gz|Z)$//;
- doit "chmod", 644, $tmp;
+ reset_perm_and_owner('0755' $tmp);
doit "mv", "-f", $tmp, $_;
}, "$tmp/$dir");
}
diff --git a/dh_makeshlibs b/dh_makeshlibs
index 45f29462..7fb5ac12 100755
--- a/dh_makeshlibs
+++ b/dh_makeshlibs
@@ -239,8 +239,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
if (-e "$tmp/DEBIAN/shlibs") {
- doit("chmod","0644","$tmp/DEBIAN/shlibs");
- doit("chown","0:0","$tmp/DEBIAN/shlibs");
+ reset_perm_and_owner('0644', "$tmp/DEBIAN/shlibs");
}
# dpkg-gensymbols files
diff --git a/dh_md5sums b/dh_md5sums
index d4e9ff35..b4b3c925 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -83,8 +83,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
doit("rm","-f","$tmp/DEBIAN/md5sums");
}
else {
- doit("chmod", "0644", "$tmp/DEBIAN/md5sums");
- doit("chown", "0:0", "$tmp/DEBIAN/md5sums");
+ reset_perm_and_owner('0644', "$tmp/DEBIAN/md5sums");
}
if ( -d $dbgsym_tmp) {
install_dir("${dbgsym_tmp}/DEBIAN");
@@ -96,8 +95,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
doit('rm', '-f', "${dbgsym_tmp}/DEBIAN/md5sums");
}
else {
- doit('chmod', '0644', "${dbgsym_tmp}/DEBIAN/md5sums");
- doit('chown', '0:0', "${dbgsym_tmp}/DEBIAN/md5sums");
+ reset_perm_and_owner('0644', "${dbgsym_tmp}/DEBIAN/md5sums");
}
}
}
diff --git a/dh_strip b/dh_strip
index 7a16750a..9ecfa415 100755
--- a/dh_strip
+++ b/dh_strip
@@ -283,7 +283,7 @@ sub make_debug {
}
# No reason for this to be executable.
- doit("chmod", "0644", $debug_path);
+ reset_perm_and_owner('0644', $debug_path);
return $debug_path;
}
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 4d1e315b..eb063724 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -324,6 +324,16 @@ install_lib($src, $dest)
Installs a library at the path $src into $dest. The parent
dir of $dest must exist (can be created with install_dir).
This is intended for installing libraries.
+reset_perm_and_owner($mode, $path...)
+ Resets the ownership and mode (POSIX permissions) of $path
+ This is useful for files created directly by the script, but
+ it not necessary for files installed via the install_*
+ functions.
+ The file owner and group is set to "root:root". The change
+ is only done on the exact paths listed (i.e. it is *not*
+ recursive).
+ To avoid issue, please pass mode as a string (i.e. '0755'
+ rather than 0755).
open_gz($file)
Open $file, read from it as a gzip-compressed file and return
the file handle.