mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
[Build] Keep Windows installs free of build-tree artifacts (#7316)
* [Build] Keep Windows installs free of build-tree artifacts
Several Windows packaging gaps could leak Visual Studio CMake build
output into the installed application or the NSIS installer:
- The per-app DLL sweep used
${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}, which is
empty on multi-config generators, collapsing the recursive
DIRECTORY install into the whole build tree (containing *.dir,
*_autogen, .qt, .qsb, x64, ...). Point it at the real per-config
output with $<TARGET_FILE_DIR:...> and exclude build artifacts.
- install(FILES ${OPENSSL_INCLUDE_DIRS} ...) tried to install OpenSSL
include directories as files. CMake refuses this
("install FILES given directory"); it only slipped through CI
because the vcpkg OpenSSL config leaves the variable empty. Remove it;
fixup_bundle already ships the OpenSSL runtime DLLs.
- The NSIS uninstaller only deleted *.exe/*.dll and a few known files,
so build-tree leftovers survived an uninstall/reinstall cycle. Wipe
the whole directory tree instead.
- Add a Windows CI gate that lists the packaged installer with 7-Zip
and fails the build if any build-tree artifact path is found.
* Update .ci/compile.sh
Co-authored-by: tooomm <tooomm@users.noreply.github.com>
* [Build] Rework Windows installer artifact exclusions per review
---------
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: tooomm <tooomm@users.noreply.github.com>
This commit is contained in:
parent
b3c426cd43
commit
a5e94d8a4f
5 changed files with 74 additions and 20 deletions
|
|
@ -327,4 +327,32 @@ if [[ $MAKE_PACKAGE ]]; then
|
||||||
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"
|
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $RUNNER_OS == Windows ]]; then
|
||||||
|
echo "::group::Check installer for build-tree artifacts"
|
||||||
|
cd "$BUILD_DIR"
|
||||||
|
package="$(find . -maxdepth 1 -type f -name 'Cockatrice-*.exe' -print -quit)"
|
||||||
|
if [[ ! $package ]]; then
|
||||||
|
echo "::error file=$0::Could not find installer to inspect"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
seven_zip="$(command -v 7z || true)"
|
||||||
|
if [[ ! $seven_zip ]]; then
|
||||||
|
seven_zip="/c/Program Files/7-Zip/7z.exe"
|
||||||
|
fi
|
||||||
|
if [[ ! -f $seven_zip ]]; then
|
||||||
|
echo "::warning file=$0::7-Zip not found, skipping installer content check"
|
||||||
|
else
|
||||||
|
echo "Inspecting $package"
|
||||||
|
# Fail the build if the installer contains any path left behind by the MSBuild or
|
||||||
|
# Qt AUTOMOC tooling (build-tree artifacts must live in the build dir, not the install)
|
||||||
|
if "$seven_zip" l "$package" |
|
||||||
|
grep -E "_autogen|\.dir[\\/]|\.tlog|(^|[\\/])x64[\\/]|(^|[\\/])\.qt[\\/]|(^|[\\/])\.qsb[\\/]|(^|[\\/])\.lupdate[\\/]|CMakeFiles"; then
|
||||||
|
echo "::error file=$0::Installer contains build-tree artifacts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Installer content is clean"
|
||||||
|
fi
|
||||||
|
echo "::endgroup::"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -387,19 +387,14 @@ SectionEnd
|
||||||
|
|
||||||
Section "un.Application" UnSecApplication
|
Section "un.Application" UnSecApplication
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
RMDir /r "$INSTDIR\plugins"
|
|
||||||
RMDir /r "$INSTDIR\sounds"
|
|
||||||
RMDir /r "$INSTDIR\themes"
|
|
||||||
RMDir /r "$INSTDIR\translations"
|
|
||||||
Delete "$INSTDIR\*.exe"
|
|
||||||
Delete "$INSTDIR\*.dll"
|
|
||||||
Delete "$INSTDIR\qt.conf"
|
|
||||||
Delete "$INSTDIR\qdebug.txt"
|
|
||||||
Delete "$INSTDIR\servatrice.sql"
|
|
||||||
Delete "$INSTDIR\servatrice.ini.example"
|
|
||||||
RMDir "$INSTDIR"
|
|
||||||
|
|
||||||
RMDir "$SMPROGRAMS\Cockatrice"
|
; Remove the entire application directory so any file that is not part of
|
||||||
|
; the installed payload (e.g. build-tree artifacts such as *.dir folders,
|
||||||
|
; *_autogen and *.tlog files from a build) cannot survive between an
|
||||||
|
; uninstall and a fresh reinstall.
|
||||||
|
RMDir /r "$INSTDIR"
|
||||||
|
|
||||||
|
RMDir /r "$SMPROGRAMS\Cockatrice"
|
||||||
|
|
||||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
|
||||||
|
|
@ -656,18 +656,35 @@ if(WIN32)
|
||||||
set(qtconf_dest_dir .)
|
set(qtconf_dest_dir .)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
|
DIRECTORY "$<TARGET_FILE_DIR:cockatrice>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
PATTERN "*.dll"
|
PATTERN "*.dll"
|
||||||
|
PATTERN "*.pdb" EXCLUDE
|
||||||
|
PATTERN "*.dir*" EXCLUDE
|
||||||
|
PATTERN "*_autogen*" EXCLUDE
|
||||||
|
PATTERN "*.tlog*" EXCLUDE
|
||||||
|
PATTERN "CMakeFiles*" EXCLUDE
|
||||||
|
PATTERN "x64*" EXCLUDE
|
||||||
|
PATTERN ".qt*" EXCLUDE
|
||||||
|
PATTERN ".qsb*" EXCLUDE
|
||||||
|
PATTERN ".lupdate*" EXCLUDE
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "${CMAKE_BINARY_DIR}/cockatrice/"
|
DIRECTORY "${CMAKE_BINARY_DIR}/cockatrice/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
PATTERN "CMakeFiles" EXCLUDE
|
|
||||||
PATTERN "*.ini"
|
PATTERN "*.ini"
|
||||||
|
PATTERN "CMakeFiles*" EXCLUDE
|
||||||
|
PATTERN "*.dir*" EXCLUDE
|
||||||
|
PATTERN "*_autogen*" EXCLUDE
|
||||||
|
PATTERN "*.tlog*" EXCLUDE
|
||||||
|
PATTERN "*.pdb" EXCLUDE
|
||||||
|
PATTERN "x64*" EXCLUDE
|
||||||
|
PATTERN ".qt*" EXCLUDE
|
||||||
|
PATTERN ".qsb*" EXCLUDE
|
||||||
|
PATTERN ".lupdate*" EXCLUDE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qt plugins: audio, iconengines, imageformats, multimedia, platforms, printsupport, styles, tls
|
# Qt plugins: audio, iconengines, imageformats, multimedia, platforms, printsupport, styles, tls
|
||||||
|
|
@ -720,10 +737,6 @@ Data = Resources\")
|
||||||
"
|
"
|
||||||
COMPONENT Runtime
|
COMPONENT Runtime
|
||||||
)
|
)
|
||||||
|
|
||||||
if(OPENSSL_FOUND)
|
|
||||||
install(FILES ${OPENSSL_INCLUDE_DIRS} DESTINATION ./)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Qt6LinguistTools_FOUND)
|
if(Qt6LinguistTools_FOUND)
|
||||||
|
|
|
||||||
|
|
@ -213,10 +213,19 @@ if(WIN32)
|
||||||
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
|
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
|
DIRECTORY "$<TARGET_FILE_DIR:oracle>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
PATTERN "*.dll"
|
PATTERN "*.dll"
|
||||||
|
PATTERN "*.pdb" EXCLUDE
|
||||||
|
PATTERN "*.dir*" EXCLUDE
|
||||||
|
PATTERN "*_autogen*" EXCLUDE
|
||||||
|
PATTERN "*.tlog*" EXCLUDE
|
||||||
|
PATTERN "CMakeFiles*" EXCLUDE
|
||||||
|
PATTERN "x64*" EXCLUDE
|
||||||
|
PATTERN ".qt*" EXCLUDE
|
||||||
|
PATTERN ".qsb*" EXCLUDE
|
||||||
|
PATTERN ".lupdate*" EXCLUDE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qt plugins: iconengines, platforms, styles, tls (Qt6)
|
# Qt plugins: iconengines, platforms, styles, tls (Qt6)
|
||||||
|
|
|
||||||
|
|
@ -184,10 +184,19 @@ if(WIN32)
|
||||||
set(qtconf_dest_dir .)
|
set(qtconf_dest_dir .)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"
|
DIRECTORY "$<TARGET_FILE_DIR:servatrice>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
PATTERN "*.dll"
|
PATTERN "*.dll"
|
||||||
|
PATTERN "*.pdb" EXCLUDE
|
||||||
|
PATTERN "*.dir*" EXCLUDE
|
||||||
|
PATTERN "*_autogen*" EXCLUDE
|
||||||
|
PATTERN "*.tlog*" EXCLUDE
|
||||||
|
PATTERN "CMakeFiles*" EXCLUDE
|
||||||
|
PATTERN "x64*" EXCLUDE
|
||||||
|
PATTERN ".qt*" EXCLUDE
|
||||||
|
PATTERN ".qsb*" EXCLUDE
|
||||||
|
PATTERN ".lupdate*" EXCLUDE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qt plugins: platforms, sqldrivers, tls (Qt6)
|
# Qt plugins: platforms, sqldrivers, tls (Qt6)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue