@@ -239,11 +239,17 @@ if [ -n "$3" ]; then
239239 /usr/bin/find " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /lib" -type f -name " *dylib" -exec /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --preserve-metadata=identifier,entitlements,flags -f {} \;
240240 # Nested Tcl/Tk frameworks (bundled inside Python 3.13+). install_name_tool
241241 # invalidates their python.org signatures during the relocatable rewrite.
242- # Re-sign every Mach-O binary under Frameworks/ before signing the parent
243- # Python binary, so the parent's chain-of-trust over them is valid.
242+ # Sign each nested framework as a bundle (NOT the inner binary alone) so
243+ # codesign regenerates the framework's _CodeSignature/CodeResources file
244+ # to match the re-signed binary. --deep walks the framework's Versions/
245+ # tree and signs the binary at the same time. Without this, signing only
246+ # the inner binary leaves the bundle's CodeResources pointing at the old
247+ # binary hash → "nested code is modified or invalid".
244248 if [ -d " $NESTED_FRAMEWORKS_DIR " ]; then
245- /usr/bin/find " $NESTED_FRAMEWORKS_DIR " -type f -perm -u=x -exec /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --force {} \;
246- /usr/bin/find " $NESTED_FRAMEWORKS_DIR " -type f -name " *dylib" -exec /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --force {} \;
249+ for nested_fw in " $NESTED_FRAMEWORKS_DIR " /* .framework; do
250+ [ -d " $nested_fw " ] || continue
251+ /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --force --deep " $nested_fw "
252+ done
247253 fi
248254 /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --deep --force --preserve-metadata=identifier,entitlements,flags " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /Resources/Python.app"
249255 /usr/bin/codesign --sign " $3 " --timestamp --options=runtime --force --preserve-metadata=identifier,entitlements,flags " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /Python"
@@ -253,8 +259,10 @@ else
253259 /usr/bin/find " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /lib" -type f -perm -u=x -exec /usr/bin/codesign -s - --options=runtime --preserve-metadata=identifier,entitlements,flags -f {} \;
254260 /usr/bin/find " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /lib" -type f -name " *dylib" -exec /usr/bin/codesign -s - --options=runtime --preserve-metadata=identifier,entitlements,flags -f {} \;
255261 if [ -d " $NESTED_FRAMEWORKS_DIR " ]; then
256- /usr/bin/find " $NESTED_FRAMEWORKS_DIR " -type f -perm -u=x -exec /usr/bin/codesign -s - --options=runtime --force {} \;
257- /usr/bin/find " $NESTED_FRAMEWORKS_DIR " -type f -name " *dylib" -exec /usr/bin/codesign -s - --options=runtime --force {} \;
262+ for nested_fw in " $NESTED_FRAMEWORKS_DIR " /* .framework; do
263+ [ -d " $nested_fw " ] || continue
264+ /usr/bin/codesign -s - --options=runtime --force --deep " $nested_fw "
265+ done
258266 fi
259267 /usr/bin/codesign -s - --options=runtime --deep --force --preserve-metadata=identifier,entitlements,flags " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /Resources/Python.app"
260268 /usr/bin/codesign -s - --options=runtime --force --preserve-metadata=identifier,entitlements,flags " $TOOLSDIR /$TYPE /payload${FRAMEWORKDIR} /Python3.framework/Versions/${PYTHON_BIN_VERSION} /Python"
0 commit comments