# Look for the plugins/platforms directory to find the plugin root
for candidate in "${_QT_PLUGIN_CANDIDATES[@]}";do
if[ -d "${candidate}/platforms"];then
_QT_PLUGIN_PATH="${candidate}"
echo"Found Qt${_QT_VERSION} plugin directory at ${_QT_PLUGIN_PATH}"
break
fi
done
# If not found using the above method, try finding it by searching for platforms directory
if[ -z "${_QT_PLUGIN_PATH}"];then
_PLATFORMS_DIR=$(find ${_QT_PATH} -type d -regex '.*/plugins/platforms'| head -n 1)
if[ -n "${_PLATFORMS_DIR}"];then
_QT_PLUGIN_PATH=$(dirname ${_PLATFORMS_DIR})
echo"Found Qt plugin directory via platforms subdirectory at ${_QT_PLUGIN_PATH}"
fi
fi
for i in audio bearer imageformats mediaservice platforminputcontexts platformthemes xcbglintegrations platforms wayland-decoration-client wayland-graphics-integration-client wayland-graphics-integration-server wayland-shell-integration;do
echo"WARNING: Could not find Qt${_QT_VERSION} plugin directory. Skipping plugin deployment."
else
# Process Qt plugins
for i in audio bearer imageformats mediaservice platforminputcontexts platformthemes xcbglintegrations platforms wayland-decoration-client wayland-graphics-integration-client wayland-graphics-integration-server wayland-shell-integration;do
if[ -d "${_QT_PLUGIN_PATH}/${i}"];then
mkdir -p ${LIB_DIR}/../plugins/${i}
cp -rnv ${_QT_PLUGIN_PATH}/${i}/*.so ${LIB_DIR}/../plugins/${i}||echo"No Qt plugins found in ${i}"
find ${LIB_DIR}/../plugins/ -type f -regex '.*\.so' -exec patchelf --set-rpath '$ORIGIN/../../lib:$ORIGIN'{}';'
# Find any remaining libraries needed for Qt plugins