This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=b6ebaf630f812b3ed9d7ee8ba0fcb958e098b8aa

commit b6ebaf630f812b3ed9d7ee8ba0fcb958e098b8aa
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Aug 9 18:28:42 2025 +0200

    Dpkg::BuildDriver::DebianRules: Unify debian/rules fixer with source extract
    
    Apply the same logic as the debian/rules executable permissions fixed
    from the Dpkg::Source::Package->extract() method, which is more complete
    and strict.
    
    The new strictness should not be an issue, because if we cannot execute
    the script then the build will fail anyway.
---
 scripts/Dpkg/BuildDriver/DebianRules.pm | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/scripts/Dpkg/BuildDriver/DebianRules.pm 
b/scripts/Dpkg/BuildDriver/DebianRules.pm
index 8a7033694..7070dfa2f 100644
--- a/scripts/Dpkg/BuildDriver/DebianRules.pm
+++ b/scripts/Dpkg/BuildDriver/DebianRules.pm
@@ -32,6 +32,8 @@ package Dpkg::BuildDriver::DebianRules 0.01;
 
 use v5.36;
 
+use Errno qw(ENOENT);
+
 use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
@@ -220,11 +222,23 @@ and if not then make it so.
 sub pre_check {
     my $self = shift;
 
-    if (@{$self->{debian_rules}} == 1 && ! -x $self->{debian_rules}[0]) {
-        warning(g_('%s is not executable; fixing that'),
-                $self->{debian_rules}[0]);
-        # No checks of failures, non fatal.
-        chmod 0o755, $self->{debian_rules}[0];
+    if (@{$self->{debian_rules}} == 1) {
+        my $rules = $self->{debian_rules}[0];
+
+        my @sb = lstat $rules;
+        if (@sb == 0) {
+            syserr(g_('cannot stat %s'), $rules) if $! != ENOENT;
+            warning(g_('%s does not exist'), $rules);
+        } elsif (-f _) {
+            if (! -x _) {
+                warning(g_('%s is not executable; fixing that'), $rules);
+
+                chmod($sb[2] | 0o111, $rules)
+                    or syserr(g_('cannot make %s executable'), $rules);
+            }
+        } else {
+            warning(g_('%s is not a plain file'), $rules);
+        }
     }
 }
 

-- 
Dpkg.Org's dpkg

Reply via email to