CMake: Fix DESTDIR handling in SBOM checksum verification

The DESTDIR env var needs to be evaluated at install time, not
configure time, so the $ENV{} needs to be escaped in the generated
script.

Also improve the error message a bit, to say which path exactly it
expected to read.

This fixes SBOM generation for the debian package builds.

Task-number: QTBUG-122899
Change-Id: I6869f0054601dcb35ae7ad7b55f808df4dc12311
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 08d5d9e9da8a4815be7dd2c952cb45a6597cc077)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-10-17 20:40:18 +02:00 committed by Qt Cherry-pick Bot
parent d81f226fd4
commit 8113dc73f0

View File

@ -596,17 +596,18 @@ FileCopyrightText: NOASSERTION"
endif() endif()
set(content " set(content "
if(NOT EXISTS $ENV{DESTDIR}${install_prefix}/${arg_FILENAME} if(NOT EXISTS \$ENV{DESTDIR}${install_prefix}/${arg_FILENAME}
AND NOT QT_SBOM_BUILD_TIME AND NOT QT_SBOM_FAKE_CHECKSUM) AND NOT QT_SBOM_BUILD_TIME AND NOT QT_SBOM_FAKE_CHECKSUM)
if(NOT ${arg_OPTIONAL}) if(NOT ${arg_OPTIONAL})
message(FATAL_ERROR \"Cannot find ${arg_FILENAME}\") message(FATAL_ERROR \"Cannot find '${arg_FILENAME}' to compute its checksum. \"
\"Expected to find it at '\$ENV{DESTDIR}${install_prefix}/${arg_FILENAME}' \")
endif() endif()
else() else()
if(NOT QT_SBOM_BUILD_TIME) if(NOT QT_SBOM_BUILD_TIME)
if(QT_SBOM_FAKE_CHECKSUM) if(QT_SBOM_FAKE_CHECKSUM)
set(sha1 \"158942a783ee1095eafacaffd93de73edeadbeef\") set(sha1 \"158942a783ee1095eafacaffd93de73edeadbeef\")
else() else()
file(SHA1 $ENV{DESTDIR}${install_prefix}/${arg_FILENAME} sha1) file(SHA1 \$ENV{DESTDIR}${install_prefix}/${arg_FILENAME} sha1)
endif() endif()
list(APPEND QT_SBOM_VERIFICATION_CODES \${sha1}) list(APPEND QT_SBOM_VERIFICATION_CODES \${sha1})
endif() endif()