Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#This script is fairly hacky, but it allows you to create a working bundle.
#You should run the regular deploy.sh script that uses macdeployqt before using this one.
#Use it to convert occurences of @rpath and @loader_path to the final @executable_path.
#It might be best if there's some way to make macdeployqt or cmake add the correct paths.
#Essentially, you need to check the dependencies in Frameworks .dylibs, Qt libraries that are included
#and all the .so plugins in PlugIns/krita.
#Please note that if you are using MacDependency to view the .so plugins, they will always appear red,
#even if they are correctly linked. Use export QT_DEBUG_PLUGINS=1 while running krita if you suspect one of these plugins or any other
#framework library is not being linked correctly within some dependency.
#I have only ever gotten .so plugins to work correctly if their dependencies are linked with @rpath or @executable_path
#(but for bundles, @executable_path is of course preferred)
#Check Qt frameworks and their dependencies
cd /Applications/KF5/krita.app/Contents/Frameworks
for qtclass in Qt*/Versions/5/Qt*
do
#echo $qtclass
install_name_tool -id @executable_path/../Frameworks/$qtclass $qtclass
#echo "install_name_tool -id @executable_path/../Frameworks/"$qtclass" "$qtclass
install_name_tool -change @rpath/$qtclass @executable_path/../Frameworks/$qtclass ../MacOS/krita
#echo "install_name_tool -change @rpath/"$qtclass" @executable_path/../Frameworks/"$qtclass" ../MacOS/krita"
dependencies=$(otool -L $qtclass)
#echo $dependencies
for dependency in Qt*/Versions/5/Qt*
do
containsDependency=false
if grep -q $dependency <<<$dependencies
then
containsDependency=true
fi
if $containsDependency && [ $dependency != $qtclass ]
then
install_name_tool -change @rpath/$dependency @executable_path/../Frameworks/$dependency $qtclass
#echo "install_name_tool -change @rpath/"$dependency" @executable_path/../Frameworks/"$dependency" "$qtclass
fi
done
done
#Check framework libs and their dependencies
for dylib in *.dylib
do
install_name_tool -id @executable_path/../Frameworks/$dylib $dylib
install_name_tool -change @loader_path/../Frameworks/$dylib @executable_path/../Frameworks/$dylib ../MacOS/krita
dependencies=$(otool -L $dylib)
for dependency in Qt*/Versions/5/Qt*
do
containsDependency=false
if grep -q $dependency <<<$dependencies
then
containsDependency=true
fi
if $containsDependency && [ $dependency != $dylib ]
then
install_name_tool -change @rpath/$dependency @executable_path/../Frameworks/$dependency $dylib
install_name_tool -change @loader_path/$dependency @executable_path/../Frameworks/$dependency $dylib
fi
done
for dependency in *.dylib
do
containsDependency=false
if grep -q $dependency <<<$dependencies
then
containsDependency=true
fi
if $containsDependency && [ $dependency != $dylib ]
then
install_name_tool -change @loader_path/$dependency @executable_path/../Frameworks/$dependency $dylib
fi
done
done
#Check krita plugins and their dependencies
for plugin in ../PlugIns/krita/*.so
do
dependencies=$(otool -L $plugin)
for dependency in Qt*/Versions/5/Qt*
do
containsDependency=false
if grep -q $dependency <<<$dependencies
then
containsDependency=true
fi
if $containsDependency
then
install_name_tool -change @rpath/$dependency @executable_path/../Frameworks/$dependency $plugin
install_name_tool -change @loader_path/../Frameworks/$dependency @executable_path/../Frameworks/$dependency $plugin
fi
done
for dependency in *.dylib
do
containsDependency=false
if grep -q $dependency <<<$dependencies
then
containsDependency=true
fi
if $containsDependency
then
install_name_tool -change @loader_path/../Frameworks/$dependency @executable_path/../Frameworks/$dependency $plugin
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment