qt/qtbase: make cook-time source mutations idempotent (stop vendored-source corruption)
Root cause of the recurring line-duplication corruption (duplicate #include <sys/ioctl.h>, nested #if QT_CONFIG(opengl), duplicate assert.h): several of the recipe's in-place source-munging steps were NOT guarded, so on a committed (vendored) source/ they re-applied every cook and accumulated. Guard the four unguarded ones (qwaylandclientbufferintegration opengl-wrap, qnet_unix ioctl include, corelib CMakeLists REDOX storageinfo block) with grep/marker checks so re-running on an already-patched tree is a no-op. The rest were already guarded or naturally idempotent (text.replace consuming its needle).
This commit is contained in:
@@ -285,6 +285,10 @@ done
|
||||
|
||||
# Patch CMakeLists.txt: Redox uses POSIX statvfs, not Linux statfs.
|
||||
# Exclude qstorageinfo_linux.cpp, include qstorageinfo_unix.cpp instead.
|
||||
# Idempotency guard: the found_linux block appends a new "CONDITION REDOX" target
|
||||
# every cook (qstorageinfo_linux.cpp is never removed, so found_linux re-triggers)
|
||||
# -> duplicate blocks on a vendored source/. Skip if already applied.
|
||||
if ! grep -q 'qt_internal_extend_target(Core CONDITION REDOX' "${COOKBOOK_SOURCE}/src/corelib/CMakeLists.txt" 2>/dev/null; then
|
||||
awk '
|
||||
/^qt_internal_extend_target\\(Core CONDITION LINUX AND NOT ANDROID AND NOT VXWORKS/ {
|
||||
sub(/LINUX AND NOT ANDROID AND NOT VXWORKS/, "LINUX AND NOT REDOX AND NOT ANDROID AND NOT VXWORKS")
|
||||
@@ -303,6 +307,7 @@ found_linux && /^)$/ {
|
||||
{ print }
|
||||
' "${COOKBOOK_SOURCE}/src/corelib/CMakeLists.txt" > "${COOKBOOK_SOURCE}/src/corelib/CMakeLists.txt.tmp"
|
||||
mv "${COOKBOOK_SOURCE}/src/corelib/CMakeLists.txt.tmp" "${COOKBOOK_SOURCE}/src/corelib/CMakeLists.txt"
|
||||
fi
|
||||
|
||||
# Enable QtNetwork — relibc DNS resolver hardened (2026-04-29: use-after-free fix, FD leak fix,
|
||||
# transaction ID validation, RCODE/TC handling, typed error mapping).
|
||||
@@ -318,14 +323,17 @@ from pathlib import Path
|
||||
|
||||
path = Path(os.environ["COOKBOOK_SOURCE"]) / "src/network/socket/qnet_unix_p.h"
|
||||
text = path.read_text()
|
||||
text = text.replace(
|
||||
'''#include <sys/socket.h>
|
||||
# Idempotency: only add the ioctl include if it is not already present (else a
|
||||
# vendored source/ accumulates a duplicate "#include <sys/ioctl.h>" every cook).
|
||||
if "#include <sys/ioctl.h>" not in text:
|
||||
text = text.replace(
|
||||
'''#include <sys/socket.h>
|
||||
''',
|
||||
'''#include <sys/socket.h>
|
||||
'''#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
''',
|
||||
1,
|
||||
)
|
||||
1,
|
||||
)
|
||||
old = '''#if defined(Q_OS_VXWORKS)
|
||||
# include <hostLib.h>
|
||||
#else
|
||||
@@ -338,7 +346,7 @@ new = '''#if defined(Q_OS_VXWORKS)
|
||||
# include <resolv.h>
|
||||
#endif
|
||||
'''
|
||||
text = text.replace(old, new)
|
||||
text = text.replace(old, new) # replace() is a no-op once already applied
|
||||
path.write_text(text)
|
||||
PY
|
||||
python - <<'PY'
|
||||
@@ -470,6 +478,11 @@ fi
|
||||
# with QT_CONFIG(opengl). Without OpenGL, QPlatformOpenGLContext is not defined.
|
||||
# This allows Wayland client to build with software rendering (shared memory).
|
||||
BUFI="${COOKBOOK_SOURCE}/src/plugins/platforms/wayland/hardwareintegration/qwaylandclientbufferintegration_p.h"
|
||||
# Idempotency guard: this rewrite is NOT self-limiting across cooks (the done1/2
|
||||
# awk flags only prevent repeats within one run), so on a vendored source/ it
|
||||
# re-wraps every cook -> nested "#if QT_CONFIG(opengl)" corruption. Skip if the
|
||||
# guard is already present.
|
||||
if ! grep -q 'QT_CONFIG(opengl)' "${BUFI}" 2>/dev/null; then
|
||||
awk '
|
||||
/createPlatformOpenGLContext.*QPlatformOpenGLContext/ && !done1 {
|
||||
print "#if QT_CONFIG(opengl)"; print; print "#endif /* QT_CONFIG(opengl) */"; done1=1; next
|
||||
@@ -480,6 +493,7 @@ awk '
|
||||
{ print }
|
||||
' "${BUFI}" > "${BUFI}.tmp"
|
||||
mv "${BUFI}.tmp" "${BUFI}"
|
||||
fi
|
||||
|
||||
# qtypes.h uses static_assert in C mode. relibc's assert.h does not currently expose the
|
||||
# expected macro there, so inject both the include and a bounded fallback macro for C only.
|
||||
|
||||
Reference in New Issue
Block a user