Sanitize awk and find-debuginfo paths in macros

Commit adad2be2e4 moved the detection of
awk outside of makemacros() so that we could require it at build time,
but that isn't ideal.  These are two separate use cases, really, they
just happen to involve awk in both cases.

In the first case (build time), keep using find_program(REQUIRED) as
normal, however for makemacros(), revert back to the custom findutil()
function.

The find-debuginfo script is the same story so fix that too while at it.
In practice, it's not likely for there to be multiple implementations of
this script installed on the build system for this to matter, so this
change is mostly just for the sake of consistency.

Also add a short description of findutil() to make its purpose a bit
clearer to the casual onlooker.

Fixes: #2926
This commit is contained in:
Michal Domonkos 2024-03-12 17:24:57 +01:00 committed by Florian Festi
parent 4cb7aaa6da
commit 78fd1fc05f
3 changed files with 12 additions and 7 deletions

View File

@ -64,6 +64,9 @@ include(CheckSymbolExists)
add_compile_definitions(_GNU_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
# Find a (system) utility in canonical FHS paths, excluding $PATH. Useful for
# when the path is to be used at RPM runtime, such as in the macro files. The
# MYPATH environment variable can be used to augment these paths.
function(findutil UTIL TRY)
list(GET TRY 0 util)
find_program(${UTIL}
@ -140,6 +143,8 @@ function(makemacros)
findutil(__OBJDUMP objdump)
findutil(__STRIP strip)
findutil(__SYSTEMD_SYSUSERS systemd-sysusers)
findutil(__FIND_DEBUGINFO find-debuginfo)
findutil(__AWK awk)
findutil(__AR ar)
findutil(__AS as)
findutil(__CPP cpp)
@ -301,11 +306,11 @@ if (WITH_IMAEVM)
target_include_directories(IMA::IMA INTERFACE "${IMA_INCLUDE_DIR}")
endif()
find_program(__AWK awk REQUIRED)
mark_as_advanced(__AWK)
find_program(AWK awk REQUIRED)
mark_as_advanced(AWK)
find_program(__FIND_DEBUGINFO find-debuginfo)
mark_as_advanced(__FIND_DEBUGINFO)
find_program(FIND_DEBUGINFO find-debuginfo)
mark_as_advanced(FIND_DEBUGINFO)
function(chkdef func req)
string(TOUPPER ${func} FUNC)
@ -343,7 +348,7 @@ foreach(f ${OPTINCS})
endforeach()
function(id0name var file)
execute_process(COMMAND ${__AWK} -F: "$3==0 {print $1;exit}" ${file}
execute_process(COMMAND ${AWK} -F: "$3==0 {print $1;exit}" ${file}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE name)
if ("${name}" STREQUAL "")

View File

@ -70,7 +70,7 @@ if(WITH_CAP)
endif()
add_custom_command(OUTPUT tagtbl.C
COMMAND AWK=${__AWK} ${CMAKE_CURRENT_SOURCE_DIR}/gentagtbl.sh ${CMAKE_SOURCE_DIR}/include/rpm/rpmtag.h > tagtbl.C
COMMAND AWK=${AWK} ${CMAKE_CURRENT_SOURCE_DIR}/gentagtbl.sh ${CMAKE_SOURCE_DIR}/include/rpm/rpmtag.h > tagtbl.C
DEPENDS ${CMAKE_SOURCE_DIR}/include/rpm/rpmtag.h gentagtbl.sh
)

View File

@ -25,7 +25,7 @@ export TZ
unset SOURCE_DATE_EPOCH
RPM_XFAIL=${RPM_XFAIL-1}
if test -x "@__FIND_DEBUGINFO@"; then
if test -x "@FIND_DEBUGINFO@"; then
DEBUGINFO_DISABLED=false;
else
DEBUGINFO_DISABLED=true;