Skip to content

MDEV-39258 Make THIRD_PARTY_DOWNLOAD_LOCATION settable#4898

Open
vaintroub wants to merge 1 commit into10.6from
MDEV-39258
Open

MDEV-39258 Make THIRD_PARTY_DOWNLOAD_LOCATION settable#4898
vaintroub wants to merge 1 commit into10.6from
MDEV-39258

Conversation

@vaintroub
Copy link
Copy Markdown
Member

This allows to pre-download HeidiSQL on CI, rsp avoid multiple repeated downloads on every build, or avoid problems
in case HeidiSQL download is slow (like it currently is, see MDBF-1197)

Also, on request of Razvan, increase HeidiSQL download timeout.

Also, on request of Razvan, increase HeidiSQL download timeout
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Windows packaging CMake flow to make the third-party download directory configurable (so CI can reuse cached artifacts) and increases the HeidiSQL download timeout to reduce build flakiness when upstream downloads are slow.

Changes:

  • Make THIRD_PARTY_DOWNLOAD_LOCATION configurable via the CMake cache (instead of always overriding it with $ENV{TEMP}).
  • Increase HeidiSQL download timeout from 60s to 300s.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
win/packaging/CMakeLists.txt Exposes THIRD_PARTY_DOWNLOAD_LOCATION as a cache variable so CI/users can set a persistent download/cache directory.
win/packaging/heidisql.cmake Raises the HeidiSQL FILE(DOWNLOAD ...) timeout to tolerate slow upstream downloads.
Comments suppressed due to low confidence (1)

win/packaging/CMakeLists.txt:145

  • THIRD_PARTY_DOWNLOAD_LOCATION is a directory path, but it’s declared as CACHE STRING. Using CACHE PATH is more appropriate (better UX in CMake GUIs). Also, when $ENV{TEMP} is empty, the cache entry becomes empty even though you later fall back to ${CMAKE_BINARY_DIR} for the non-cache variable; consider initializing the cache default to the fallback value to avoid persisting an empty cache entry.
IF(WITH_THIRD_PARTY)
  SET(THIRD_PARTY_DOWNLOAD_LOCATION "$ENV{TEMP}" CACHE STRING "Download location for third party")
  IF(THIRD_PARTY_DOWNLOAD_LOCATION)
    FILE(TO_CMAKE_PATH "${THIRD_PARTY_DOWNLOAD_LOCATION}" THIRD_PARTY_DOWNLOAD_LOCATION)
  ELSE()
    SET(THIRD_PARTY_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}")
  ENDIF()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 6 to 10
IF(NOT EXISTS ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP})
MAKE_DIRECTORY(${HEIDISQL_DOWNLOAD_DIR})
MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 300)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E chdir ${HEIDISQL_DOWNLOAD_DIR}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FILE(DOWNLOAD ...) arguments are unquoted. Since THIRD_PARTY_DOWNLOAD_LOCATION is now user-settable, it may contain spaces/semicolons and break argument parsing (e.g., producing multiple args / wrong path). Quote the URL and destination path (and related path usages in this block) to make the download/extract robust on Windows paths with spaces.

Copilot uses AI. Check for mistakes.
MAKE_DIRECTORY(${HEIDISQL_DOWNLOAD_DIR})
MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 300)
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The download step ignores FILE(DOWNLOAD ...) result/status, so a network failure can fall through to the extract step and produce a confusing tar error (or extract a partial file). Capture the download status/log and message(FATAL_ERROR ...) on failure so CI fails with a clear cause.

Suggested change
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 300)
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}
TIMEOUT 300
STATUS HEIDISQL_DOWNLOAD_STATUS
LOG HEIDISQL_DOWNLOAD_LOG
)
LIST(GET HEIDISQL_DOWNLOAD_STATUS 0 HEIDISQL_DOWNLOAD_STATUS_CODE)
LIST(GET HEIDISQL_DOWNLOAD_STATUS 1 HEIDISQL_DOWNLOAD_STATUS_MESSAGE)
IF(NOT HEIDISQL_DOWNLOAD_STATUS_CODE EQUAL 0)
MESSAGE(FATAL_ERROR
"Failed to download ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}: "
"${HEIDISQL_DOWNLOAD_STATUS_MESSAGE}\n${HEIDISQL_DOWNLOAD_LOG}"
)
ENDIF()

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 10
MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 300)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E chdir ${HEIDISQL_DOWNLOAD_DIR}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This downloads a third-party ZIP from the public internet without any integrity verification. Since the downloaded content is packaged into the MSI, this is a supply-chain risk if the download is tampered with or the upstream is compromised. Consider pinning an EXPECTED_HASH (or equivalent signature/checksum verification) and failing the build if it doesn’t match.

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 12
IF(NOT EXISTS ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP})
MAKE_DIRECTORY(${HEIDISQL_DOWNLOAD_DIR})
MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 300)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E chdir ${HEIDISQL_DOWNLOAD_DIR}
${CMAKE_COMMAND} -E tar xfz ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}
)
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IF(NOT EXISTS .../${HEIDISQL_ZIP}) guard skips both download and extraction when the ZIP already exists. That means a CI “pre-download” that only places the ZIP in the cache won’t trigger extraction, and packaging will later fail because ${HEIDISQL_DOWNLOAD_DIR}\\heidisql.exe (and other files) aren’t present. Consider separating the conditions: download only if the ZIP is missing, but extract if the extracted payload (e.g., heidisql.exe) is missing.

Copilot uses AI. Check for mistakes.
@RazvanLiviuVarzaru
Copy link
Copy Markdown

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants