From da9a8a3fbeccc06ffec88dda3d151fcf5a2390d2 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Thu, 30 Jul 2026 18:07:06 +0400 Subject: [PATCH] CPack/DEB: Fix regression when package architecture is explicitly specified Since commit 302a645d73 (CPack/DEB: use `triggers` instead of legacy postXXX scripts for `ldconfig`, 2026-03-05, v4.4.0-rc1~583^2) the `triggers` feature refers to `DPKG_EXECUTABLE` if the latter is defined. Unfortunately, it is defined only if one particular execution branch has executed. Move the `find_program(dpkg)` to the function scope to make it available in all execution branches. --- Modules/Internal/CPack/CPackDeb.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index c4d7155b10..499331c1e8 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -608,13 +608,14 @@ function(cpack_deb_prepare_package_vars) "${CPACK_DEBIAN_PACKAGE_EPOCH}:${CPACK_DEBIAN_PACKAGE_VERSION}") endif() + find_program(DPKG_EXECUTABLE dpkg) + # Architecture: (mandatory) if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}") elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # There is no such thing as i686 architecture on debian, you should use i386 instead # $ dpkg --print-architecture - find_program(DPKG_EXECUTABLE dpkg) if(NOT DPKG_EXECUTABLE) message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)