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=bab74e22a6db2707e442823d6c0b2a1334e76d1b

commit bab74e22a6db2707e442823d6c0b2a1334e76d1b
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Sat Feb 10 14:20:28 2024 +0100

    dpkg-buildpackage: Refactor build target hook execution
    
    This unifies the handling with the other hook execution. It has a slight
    behavior change, where the DPKG_BUILDPACKAGE_HOOK_BUILD_TARGET is now
    set even when the hook has been disabled.
---
 man/dpkg-buildpackage.pod                            |  3 ++-
 scripts/dpkg-buildpackage.pl                         | 20 ++++++++++----------
 .../t/dpkg_buildpackage/test-source_0_source.hook    |  2 +-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/man/dpkg-buildpackage.pod b/man/dpkg-buildpackage.pod
index eb5fd5534..a3dc324de 100644
--- a/man/dpkg-buildpackage.pod
+++ b/man/dpkg-buildpackage.pod
@@ -515,7 +515,8 @@ of options that will passed to the B<dpkg-source> call.
 =item B<build>
 
 Gets B<DPKG_BUILDPACKAGE_HOOK_BUILD_TARGET> with the name of the
-B<debian/rules> build target called, but only if called.
+B<debian/rules> build target called.
+Before dpkg 1.22.7 the variable was only set if the target was called.
 
 =item B<binary>
 
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 5a9152d0e..77b160c34 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -670,19 +670,19 @@ if (build_has_any(BUILD_SOURCE)) {
 
 my $build_types = get_build_options_from_type();
 
+my $need_buildtask = rules_requires_root($binarytarget);
+
+run_hook('build', {
+    enabled => build_has_any(BUILD_BINARY) && $need_buildtask,
+    env => {
+        DPKG_BUILDPACKAGE_HOOK_BUILD_TARGET => $buildtarget,
+    },
+});
+
 # If we are building rootless, there is no need to call the build target
 # independently as non-root.
-if (build_has_any(BUILD_BINARY) && rules_requires_root($binarytarget)) {
-    run_hook('build', {
-        env => {
-            DPKG_BUILDPACKAGE_HOOK_BUILD_TARGET => $buildtarget,
-        },
-    });
+if (build_has_any(BUILD_BINARY) && $need_buildtask) {
     run_cmd(@debian_rules, $buildtarget);
-} else {
-    run_hook('build', {
-        enabled => 0,
-    });
 }
 
 if (build_has_any(BUILD_BINARY)) {
diff --git a/scripts/t/dpkg_buildpackage/test-source_0_source.hook 
b/scripts/t/dpkg_buildpackage/test-source_0_source.hook
index eb7387a57..dde9b7d58 100644
--- a/scripts/t/dpkg_buildpackage/test-source_0_source.hook
+++ b/scripts/t/dpkg_buildpackage/test-source_0_source.hook
@@ -3,7 +3,7 @@ hook: n=init a=1 p=test-source v=0 s=0 u=0
 hook: n=preclean a=1 p=test-source v=0 s=0 u=0
 hook: source-opts=
 hook: n=source a=1 p=test-source v=0 s=0 u=0
-hook: build-target=
+hook: build-target=build
 hook: n=build a=0 p=test-source v=0 s=0 u=0
 hook: buildinfo-opts=--build=source --admindir=<ROOT>/dpkgdb 
-O../test-source_0_source.buildinfo
 hook: n=buildinfo a=1 p=test-source v=0 s=0 u=0

-- 
Dpkg.Org's dpkg

Reply via email to