macOS - Improved source validation on copying of Qt frameworks to app bundle.

This commit is contained in:
Stephan Witt 2023-06-14 08:17:10 +02:00
parent f7e625d7ce
commit 789da12d31

View File

@ -803,41 +803,47 @@ EOF
cp -p "${libname}" "${condir}/PlugIns/${dirname}" cp -p "${libname}" "${condir}/PlugIns/${dirname}"
done done
fi fi
echo Copy frameworks ${QtLibraries} ...
for libnm in ${QtLibraries} ; do for libnm in ${QtLibraries} ; do
fwdir=$(framework_name "$libnm") fwdir=$(framework_name "$libnm")
dirname=$(dirname "${fwdir}") dirname=$(dirname "${fwdir}")
mkdir -p "${condir}/${dirname}" mkdir -p "${condir}/${dirname}"
dirname=$(basename "${fwdir}") dirname=$(basename "${fwdir}")
test -d "${condir}/${fwdir}" || ( libpath="${source}/lib/${dirname}"
echo Copy framework "${source}/lib/"$(basename "${fwdir}") if [ -d "${libpath}" ]; then
cp -pR "${source}/lib/"$(basename "${fwdir}") "${condir}/${fwdir}" test -d "${condir}/${fwdir}" || (
rm -f "${condir}/${fwdir}/${libnm}"_debug "${condir}/${fwdir}/${version}${libnm}"_debug echo Copy framework "${libpath}"
test -f "${condir}/${fwdir}/${libnm}".prl && mv "${condir}/${fwdir}/${libnm}".prl "${condir}/${fwdir}"/Resources cp -pR "${libpath}" "${condir}/${fwdir}"
test -f "${condir}/${fwdir}/${libnm}"_debug.prl && mv "${condir}/${fwdir}/${libnm}"_debug.prl "${condir}/${fwdir}"/Resources rm -f "${condir}/${fwdir}/${libnm}"_debug "${condir}/${fwdir}/${version}${libnm}"_debug
installname -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}" test -f "${condir}/${fwdir}/${libnm}".prl && mv "${condir}/${fwdir}/${libnm}".prl "${condir}/${fwdir}"/Resources
find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do test -f "${condir}/${fwdir}/${libnm}"_debug.prl && mv "${condir}/${fwdir}/${libnm}"_debug.prl "${condir}/${fwdir}"/Resources
if [ "${filename}" != "${target}" ]; then installname -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do find "${condir}/PlugIns" "${condir}/"$(dirname "${fwdir}") -name Headers -prune -o -type f -print | while read filename ; do
# pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2) if [ "${filename}" != "${target}" ]; then
case "${library}" in otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
*@rpath/*"${libnm}"*"("*version*")"*) # pattern match for: /path/to/qt/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
# echo rpath based name for ${libnm} is ok. case "${library}" in
;; *@rpath/*"${libnm}"*"("*version*")"*)
*"${libnm}"*"("*version*")"*) # echo rpath based name for ${libnm} is ok.
installname -change\ ;;
"${source}/lib/${dirname}/${version}${libnm}"\ *"${libnm}"*"("*version*")"*)
"@executable_path/../${fwdir}/${version}${libnm}"\ installname -change\
"${filename}" "${source}/lib/${dirname}/${version}${libnm}"\
;; "@executable_path/../${fwdir}/${version}${libnm}"\
esac "${filename}"
done ;;
fi esac
done done
) fi
installname -change\ done
"${source}/lib/${dirname}/${version}${libnm}"\ )
"@executable_path/../${fwdir}/${version}${libnm}"\ installname -change\
"${target}" "${source}/lib/${dirname}/${version}${libnm}"\
"@executable_path/../${fwdir}/${version}${libnm}"\
"${target}"
else
echo Warning: Cannot copy framework for "$libnm" ... missing source "${libpath}"
fi
done done
if [ -d "${source}"/translations ]; then if [ -d "${source}"/translations ]; then
if [ ! -d "${condir}/translations" ]; then if [ ! -d "${condir}/translations" ]; then